value based on gain
This commit is contained in:
@@ -23,6 +23,7 @@ type DeviceState struct {
|
||||
|
||||
sensorValue int // Default 2067 (ideal rest value)
|
||||
jitterRange int // Default 10 (means ±10)
|
||||
gain int // Default 50 (TUI gain slider, 1-100)
|
||||
|
||||
connectedClients int // Track number of connected BLE clients
|
||||
}
|
||||
@@ -46,6 +47,7 @@ func NewDeviceState() *DeviceState {
|
||||
ncParam: true, // Default NO mode (1)
|
||||
sensorValue: 2067,
|
||||
jitterRange: 10,
|
||||
gain: 50,
|
||||
connectedClients: 0,
|
||||
}
|
||||
}
|
||||
@@ -135,6 +137,7 @@ func (s *DeviceState) ResetToDefaults() {
|
||||
s.ncParam = true // Default NO mode (1)
|
||||
s.sensorValue = 2067
|
||||
s.jitterRange = 10
|
||||
s.gain = 50
|
||||
}
|
||||
|
||||
// SetSensorValue sets the current sensor value
|
||||
@@ -158,6 +161,20 @@ func (s *DeviceState) SetJitterRange(jitter int) {
|
||||
s.jitterRange = jitter
|
||||
}
|
||||
|
||||
// GetGain returns the current gain value
|
||||
func (s *DeviceState) GetGain() int {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
return s.gain
|
||||
}
|
||||
|
||||
// SetGain sets the gain value
|
||||
func (s *DeviceState) SetGain(gain int) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.gain = gain
|
||||
}
|
||||
|
||||
// TriggerAlarm triggers an alarm with the given type ("TRIGGERED" or "TAMPER")
|
||||
func (s *DeviceState) TriggerAlarm(alarmType string) {
|
||||
s.mu.Lock()
|
||||
|
||||
@@ -127,6 +127,15 @@ func NewModel(state *device.DeviceState, logBuffer *LogBuffer, notifyCh chan str
|
||||
Max: 100,
|
||||
Step: 5,
|
||||
},
|
||||
{
|
||||
Name: "Gain",
|
||||
Type: ControlSlider,
|
||||
GetValue: state.GetGain,
|
||||
SetValue: state.SetGain,
|
||||
Min: 1,
|
||||
Max: 100,
|
||||
Step: 1,
|
||||
},
|
||||
}
|
||||
|
||||
return m
|
||||
|
||||
Reference in New Issue
Block a user