Skip to content

Commit 2df1017

Browse files
Copilotdorkmo
andcommitted
Address code review feedback: use named constants, clarify comments, fix grammar
Co-authored-by: dorkmo <[email protected]>
1 parent 2ae8d22 commit 2df1017

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

TankAlarm-112025-Client-BluesOpta/TankAlarm-112025-Client-BluesOpta.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,10 +1574,10 @@ static void evaluateAlarms(uint8_t idx) {
15741574
} else {
15751575
// Legacy behavior: use highAlarm/lowAlarm thresholds
15761576
// Only one of these should be configured for a digital sensor
1577-
// highAlarm = 1 means trigger when activated
1578-
// lowAlarm = 0 means trigger when not activated
1579-
bool hasHighAlarm = (cfg.highAlarmThreshold >= DIGITAL_SWITCH_THRESHOLD);
1580-
bool hasLowAlarm = (cfg.lowAlarmThreshold <= DIGITAL_SWITCH_THRESHOLD && cfg.lowAlarmThreshold >= 0);
1577+
// highAlarm = 1 means trigger when reading is 1.0 (switch activated)
1578+
// lowAlarm = 0 means trigger when reading is 0.0 (switch not activated)
1579+
bool hasHighAlarm = (cfg.highAlarmThreshold >= DIGITAL_SENSOR_ACTIVATED_VALUE);
1580+
bool hasLowAlarm = (cfg.lowAlarmThreshold == DIGITAL_SENSOR_NOT_ACTIVATED_VALUE);
15811581

15821582
if (hasHighAlarm && !hasLowAlarm) {
15831583
shouldAlarm = isActivated;

TankAlarm-112025-Server-BluesOpta/TankAlarm-112025-Server-BluesOpta.ino

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ static const char CONFIG_GENERATOR_HTML[] PROGMEM = R"HTML(
736736
737737
<!-- Digital sensor info box (shown only for float switches) -->
738738
<div class="digital-sensor-info" style="display: none; background: var(--chip); border: 1px solid var(--card-border); border-radius: 8px; padding: 12px; margin-top: 8px; font-size: 0.9rem; color: var(--muted);">
739-
<strong>Float Switch Mode:</strong> This sensor only detects if fluid has reached the switch position. It does not measure actual fluid level. The alarm will trigger when the switch is activated (fluid present) or not activated (no fluid).
739+
<strong>Float Switch Mode:</strong> This sensor only detects whether fluid has reached the switch position. It does not measure actual fluid level. The alarm will trigger when the switch is activated (fluid present) or not activated (fluid absent).
740740
</div>
741741
742742
<button type="button" class="add-section-btn add-alarm-btn" onclick="toggleAlarmSection(${id})">+ Add Alarm</button>
@@ -827,6 +827,7 @@ static const char CONFIG_GENERATOR_HTML[] PROGMEM = R"HTML(
827827
const div = document.createElement('div');
828828
div.innerHTML = createSensorHtml(sensorCount);
829829
container.appendChild(div.firstElementChild);
830+
updateSensorTypeFields(sensorCount); // Initialize fields for default sensor type
830831
sensorCount++;
831832
}
832833
@@ -1115,12 +1116,12 @@ static const char CONFIG_GENERATOR_HTML[] PROGMEM = R"HTML(
11151116
// Digital/float switch sensors use trigger state instead of thresholds
11161117
const digitalTriggerState = card.querySelector('.digital-trigger-state').value;
11171118
tank.digitalTrigger = digitalTriggerState; // 'activated' or 'not_activated'
1118-
// For digital sensors, highAlarm = 1 means "alarm when switch is activated (HIGH)"
1119-
// lowAlarm = 0 means "alarm when switch is NOT activated (LOW)"
1119+
// For digital sensors, highAlarm = 1 means "alarm when reading is 1.0 (switch activated)"
1120+
// lowAlarm = 0 means "alarm when reading is 0.0 (switch not activated)"
11201121
if (digitalTriggerState === 'activated') {
1121-
tank.highAlarm = 1; // Trigger alarm when reading is HIGH (switch activated)
1122+
tank.highAlarm = 1; // Trigger alarm when reading is 1.0 (switch activated)
11221123
} else {
1123-
tank.lowAlarm = 0; // Trigger alarm when reading is LOW (switch not activated)
1124+
tank.lowAlarm = 0; // Trigger alarm when reading is 0.0 (switch not activated)
11241125
}
11251126
tank.alarmSms = true;
11261127
} else if (highAlarmEnabled || lowAlarmEnabled) {

0 commit comments

Comments
 (0)