volatile char old_mode = mode_heat;
/* Water temperature */
-int water_centi_degrees = 0;
+volatile int water_centi_degrees = 0;
+#define T_HYST 200 /* 2°C */
+#define T_HYST_DELAY 1800 /* 1800 * DEC_PERIOD : 180 seconds : 3 minutes */
+volatile int temp_OK_hysteresys = 0;
+
/* Internal temperatures */
int deci_degrees_power = 0; /* Power board sensor */
int deci_degrees_disp = 0; /* Display board sensor */
-/* Set to ABSOLUTE_MAX_WATER_TEMP - 1.5°C when enabling max temp hysteresis */
-int max_temp_hysteresys = 0;
/* Value in mA computed upon startup from config ext_source_power_limit */
int32_t max_intensity = 0;
overvoltage--;
}
}
+ /* Decrease temp hysteresys only when getting bellow max configuration temperature by T_HYST */
+ if (temp_OK_hysteresys > 0) {
+ if (water_centi_degrees < (sc_conf.conf_max_temp - T_HYST)) {
+ temp_OK_hysteresys--;
+ }
+ }
}
force_fan = 1;
}
break;
+ case mode_water_critical:
+ /* Water over-temperature limit reached */
+ cmd = 0;
+ break;
case mode_manual:
case mode_forced:
/* Forced heating mode */
}
/* Mosfet temperature limit reached or internal temperature above max internal temp */
if ((mosfet_temp_shutdown != 0) || (internal_temp_error_shutdown < 0)) {
- old_mode = mode;
- mode = mode_overtemp;
+ if (mode != mode_overtemp) {
+ old_mode = mode;
+ mode = mode_overtemp;
+ }
+ return;
+ }
+ /* Water temperature above absolute maximum limit ? */
+ if (water_centi_degrees >= ABSOLUTE_MAX_WATER_TEMP) {
+ if (mode != mode_water_critical) {
+ old_mode = mode;
+ mode = mode_water_critical;
+ }
return;
}
/* Water temperature reached config limit ? */
if (water_centi_degrees >= sc_conf.conf_max_temp) {
mode = mode_temp_OK; /* Max temperature reached */
+ temp_OK_hysteresys = T_HYST_DELAY;
+ return;
+ }
+ if (temp_OK_hysteresys > 0) {
+ mode = mode_temp_OK; /* Max temperature reached */
+ /* Do not decrease temp hysteresys here to get more precise duration */
return;
}