fix bound check recursion bug

This commit is contained in:
Siwat Sirichai 2024-03-30 22:58:25 +07:00
parent dfcc27420a
commit b5b0c866f8
2 changed files with 10 additions and 5 deletions

View File

@ -12,8 +12,6 @@
platform = espressif32
board = wt32-eth01
framework = arduino
lib_deps = siwats/ESPMegaPROR3@^2.4.3
lib_deps = siwats/ESPMegaPROR3@^2.5.5
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=0
monitor_port = COM36
upload_port = COM36
build_flags = -DCORE_DEBUG_LEVEL=5

View File

@ -149,6 +149,7 @@ void CUDDisplay::begin(cud_display_cards_t cards)
// If any of the bound is invalid, set all to default
if (this->ac_temp_lower_bound.getIntValue() < AC_MIN_TEMP || this->ac_temp_upper_bound.getIntValue() > AC_MAX_TEMP || this->ac_temp_lower_bound.getIntValue() >= this->ac_temp_upper_bound.getIntValue())
{
ESP_LOGW("CUD Display", "Temperature Bounds are invalid, setting to default");
this->ac_temp_lower_bound.setIntValue(DEFAULT_TEMP_LOWER_BOUND);
this->ac_temp_upper_bound.setIntValue(DEFAULT_TEMP_UPPER_BOUND);
}
@ -539,9 +540,15 @@ void CUDDisplay::handle_bound_change(char *value)
// Lower Bound can't be less than AC_MIN_TEMP
// Upper Bound can't be more than AC_MAX_TEMP
// If any of the bound is invalid, set all to default
if (this->ac_temp_lower_bound.getIntValue() < AC_MIN_TEMP || this->ac_temp_upper_bound.getIntValue() > AC_MAX_TEMP || this->ac_temp_lower_bound.getIntValue() >= this->ac_temp_upper_bound.getIntValue())
if (this->ac_temp_lower_bound.getIntValue() < AC_MIN_TEMP || this->ac_temp_lower_bound.getIntValue() >= this->ac_temp_upper_bound.getIntValue())
{
ESP_LOGV("CUD Display", "Invalid Lower Bound, Setting to Default");
this->ac_temp_lower_bound.setIntValue(DEFAULT_TEMP_LOWER_BOUND);
}
if (this->ac_temp_upper_bound.getIntValue() > AC_MAX_TEMP || this->ac_temp_lower_bound.getIntValue() >= this->ac_temp_upper_bound.getIntValue())
{
ESP_LOGV("CUD Display", "Invalid Upper Bound, Setting to Default");
this->ac_temp_upper_bound.setIntValue(DEFAULT_TEMP_UPPER_BOUND);
}
// Does the current temperature exceed the new upper bound?, if it does, bound it