fix ranges

This commit is contained in:
2026-02-23 01:12:49 +01:00
parent dd18f74e65
commit e115106b2b
3 changed files with 22 additions and 22 deletions

View File

@@ -164,13 +164,13 @@ func isReadableParamID(id int) bool {
// validateParamRange checks if value is within acceptable range for parameter
func validateParamRange(id, value int) bool {
ranges := map[int][2]int{
1: {0, 2000}, // W1 - Min Threshold
2: {0, 4095}, // W2 - Max Threshold
3: {1, 50}, // W3 - Pulse Count
4: {10, 1000}, // W4 - Time Window
11: {0, 1000}, // W11 - Min Pulse Duration
12: {0, 1000}, // W12 - Max Pulse Duration
20: {0, 255}, // W20 - Gain (Wiper)
1: {0, 255}, // W1 - Min Threshold
2: {0, 4095}, // W2 - Max Threshold
3: {1, 50}, // W3 - Pulse Count
4: {1000, 60000},// W4 - Time Window
11: {5, 300}, // W11 - Min Pulse Duration
12: {5, 300}, // W12 - Max Pulse Duration
20: {0, 255}, // W20 - Gain (Wiper)
}
r, ok := ranges[id]

View File

@@ -35,13 +35,13 @@ func NewDeviceState() *DeviceState {
alarmActive: false,
alarmType: "",
params: map[int]int{
1: 1000, // W1 - Min Threshold (middle of 0-2000)
2: 2047, // W2 - Max Threshold (middle of 0-4095)
3: 25, // W3 - Pulse Count (middle of 1-50)
4: 505, // W4 - Time Window (middle of 10-1000)
11: 0, // W11 - Min Pulse Duration (min)
12: 1000, // W12 - Max Pulse Duration (max)
20: 127, // W20 - Gain (middle of 0-255)
1: 127, // W1 - Min Threshold (middle of 0-255)
2: 2047, // W2 - Max Threshold (middle of 0-4095)
3: 25, // W3 - Pulse Count (middle of 1-50)
4: 30500, // W4 - Time Window (middle of 1000-60000)
11: 152, // W11 - Min Pulse Duration (middle of 5-300)
12: 152, // W12 - Max Pulse Duration (middle of 5-300)
20: 127, // W20 - Gain (middle of 0-255)
},
ncParam: true, // Default NO mode (1)
sensorValue: 2067,
@@ -124,12 +124,12 @@ func (s *DeviceState) ResetToDefaults() {
s.alarmActive = false
s.alarmType = ""
s.params = map[int]int{
1: 1000,
1: 127,
2: 2047,
3: 25,
4: 505,
11: 0,
12: 1000,
4: 30500,
11: 152,
12: 152,
20: 127,
}
s.ncParam = true // Default NO mode (1)

View File

@@ -155,12 +155,12 @@ func (m Model) renderControlsPanel(width int) string {
20: "W20 (Gain)",
}
paramRanges := map[int][2]int{
1: {0, 2000},
1: {0, 255},
2: {0, 4095},
3: {1, 50},
4: {10, 1000},
11: {0, 1000},
12: {0, 1000},
4: {1000, 60000},
11: {5, 300},
12: {5, 300},
20: {0, 255},
}