@@ -141,6 +141,7 @@ void InitializeFanCurves() {
141
141
fan_doc[" temp_th" ] = m_SensorSettings[fan_id].temperature_alarm_threshold ;
142
142
fan_doc[" duty_th" ] = m_SensorSettings[fan_id].rpm_alarm_threshold ;
143
143
fan_doc[" sud_dur" ] = m_SensorSettings[fan_id].step_duration_seconds ;
144
+ fan_doc[" halt_on" ] = m_SensorSettings[fan_id].halt_on ;
144
145
145
146
String settings_json;
146
147
serializeJson (fan_doc, settings_json);
@@ -150,6 +151,7 @@ void InitializeFanCurves() {
150
151
m_SensorSettings[fan_id].temperature_alarm_threshold = fan_doc[" temp_th" ].as <int >();
151
152
m_SensorSettings[fan_id].rpm_alarm_threshold = fan_doc[" duty_th" ].as <int >();
152
153
m_SensorSettings[fan_id].step_duration_seconds = fan_doc[" sud_dur" ].as <uint8_t >();
154
+ m_SensorSettings[fan_id].halt_on = fan_doc[" halt_on" ].as <uint8_t >();
153
155
m_SensorSettings[fan_id].fan_speed_curve .clear ();
154
156
for (auto const & setting : fan_doc[" curves" ].as <JsonArray>()) {
155
157
m_SensorSettings[fan_id].fan_speed_curve .push_back ({setting[" temp" ].as <float >(), setting[" fan" ].as <int >()});
@@ -293,12 +295,20 @@ void MonitorStatesTask(void *pvParameters) {
293
295
294
296
// Temperature Alarm
295
297
if (temp > 0 && settings.temperature_alarm_threshold > 0 && temp >= settings.temperature_alarm_threshold ) {
298
+ if (settings.halt_on == HALT_ON_ALARM_TEMP || settings.halt_on == HALT_ON_ALARM_BOTH) {
299
+ Serial.println (" Halting system due to alarm condition." );
300
+ digitalWrite (PIN_PWR, HIGH); // Cut power
301
+ }
296
302
temp_alarm_active = true ;
297
303
if (!b_TempAlarmFiring) Serial.printf (" ALARM: Temp high on %s (%.1fC)\n " , settings.sensor_name .c_str (), temp);
298
304
}
299
305
300
306
// RPM Alarm (only if threshold is set, > 0)
301
307
if (settings.rpm_alarm_threshold >= 0 && current_rpm < (unsigned long )settings.rpm_alarm_threshold ) {
308
+ if (settings.halt_on == HALT_ON_ALARM_FAN || settings.halt_on == HALT_ON_ALARM_BOTH) {
309
+ Serial.println (" Halting system due to alarm condition." );
310
+ digitalWrite (PIN_PWR, HIGH); // Cut power
311
+ }
302
312
rpm_alarm_active = true ;
303
313
if (!b_RpmAlarmFiring) Serial.printf (" ALARM: RPM low on FAN_%d (%lu RPM)\n " , fan_id, current_rpm);
304
314
}
@@ -319,6 +329,7 @@ void PlayAlarmsTask(void *pvParameters) {
319
329
vTaskDelay (pdMS_TO_TICKS (1000 ));
320
330
} else {
321
331
noTone (PIN_BUZZER);
332
+ digitalWrite (PIN_PWR, LOW); // Stop cutting power, alarm turned off.
322
333
vTaskDelay (pdMS_TO_TICKS (250 ));
323
334
}
324
335
}
@@ -726,6 +737,7 @@ void InitializeHttpServer() {
726
737
doc[fkey][" temp_th" ] = value.temperature_alarm_threshold ;
727
738
doc[fkey][" duty_th" ] = value.rpm_alarm_threshold ;
728
739
doc[fkey][" sud_dur" ] = value.step_duration_seconds ;
740
+ doc[fkey][" halt_on" ] = value.halt_on ;
729
741
doc[fkey][" units" ] = systemSettings.units ;
730
742
JsonArray curves = doc[fkey][" curves" ].to <JsonArray>();
731
743
for (const auto & setting : value.fan_speed_curve ) {
@@ -758,6 +770,7 @@ void InitializeHttpServer() {
758
770
m_SensorSettings[fan_id].temperature_alarm_threshold = fan_doc[" temp_th" ].as <int >();
759
771
m_SensorSettings[fan_id].rpm_alarm_threshold = fan_doc[" duty_th" ].as <int >();
760
772
m_SensorSettings[fan_id].step_duration_seconds = fan_doc[" sud_dur" ].as <uint8_t >();
773
+ m_SensorSettings[fan_id].halt_on = fan_doc[" halt_on" ].as <uint8_t >();
761
774
m_SensorSettings[fan_id].fan_speed_curve .clear ();
762
775
for (const auto & setting : fan_doc[" curves" ].as <JsonArray>()) {
763
776
m_SensorSettings[fan_id].fan_speed_curve .push_back ({setting[" temp" ].as <float >(), setting[" fan" ].as <int >()});
0 commit comments