display aqi working

This commit is contained in:
Siwat Sirichai 2024-03-23 17:31:04 +07:00
parent 5887862992
commit 1fd1ab1119
2 changed files with 11 additions and 9 deletions

View File

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

View File

@ -150,6 +150,7 @@ void CUDDisplay::begin(cud_display_cards_t cards)
this->ac_temp_upper_bound.setIntValue(DEFAULT_TEMP_UPPER_BOUND); this->ac_temp_upper_bound.setIntValue(DEFAULT_TEMP_UPPER_BOUND);
} }
// Initialize the display // Initialize the display
ESP_LOGV("CUD Display", "Initializing display"); ESP_LOGV("CUD Display", "Initializing display");
this->display_init(); this->display_init();
@ -507,40 +508,41 @@ void CUDDisplay::handle_bound_change(char *value)
void CUDDisplay::handle_aqi_change(char *value) void CUDDisplay::handle_aqi_change(char *value)
{ {
ESP_LOGV("CUD Display", "AQI Changed: %s", value);
// Update the AQI value on the display // Update the AQI value on the display
float aqi = atof(value); uint8_t aqi = atoi(value);
this->takeSerialMutex(); this->takeSerialMutex();
this->displayAdapter->printf("%s.txt=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_TEXT, (int)aqi); this->displayAdapter->printf("%s.txt=\"%03d\"", LCD_DASHBOARD_ELEMENT_NAME_AQI_TEXT, (int)aqi);
this->sendStopBytes(); this->sendStopBytes();
// Update the AQI picture on the display // Update the AQI picture on the display
if (aqi <= 50) if (aqi <= 50)
{ {
this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_TEXT, LCD_DASHBOARD_PIC_AQI_GOOD); this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_PICTURE, LCD_DASHBOARD_PIC_AQI_GOOD);
this->sendStopBytes(); this->sendStopBytes();
} }
else if (aqi <= 100) else if (aqi <= 100)
{ {
this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_TEXT, LCD_DASHBOARD_PIC_AQI_MODERATE); this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_PICTURE, LCD_DASHBOARD_PIC_AQI_MODERATE);
this->sendStopBytes(); this->sendStopBytes();
} }
else if (aqi <= 150) else if (aqi <= 150)
{ {
this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_TEXT, LCD_DASHBOARD_PIC_AQI_UNHEALTHY_FOR_SENSITIVE_GROUPS); this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_PICTURE, LCD_DASHBOARD_PIC_AQI_UNHEALTHY_FOR_SENSITIVE_GROUPS);
this->sendStopBytes(); this->sendStopBytes();
} }
else if (aqi <= 200) else if (aqi <= 200)
{ {
this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_TEXT, LCD_DASHBOARD_PIC_AQI_UNHEALTHY); this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_PICTURE, LCD_DASHBOARD_PIC_AQI_UNHEALTHY);
this->sendStopBytes(); this->sendStopBytes();
} }
else if (aqi <= 300) else if (aqi <= 300)
{ {
this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_TEXT, LCD_DASHBOARD_PIC_AQI_VERY_UNHEALTHY); this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_PICTURE, LCD_DASHBOARD_PIC_AQI_VERY_UNHEALTHY);
this->sendStopBytes(); this->sendStopBytes();
} }
else else
{ {
this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_TEXT, LCD_DASHBOARD_PIC_AQI_HAZARDOUS); this->displayAdapter->printf("%s.pic=%d", LCD_DASHBOARD_ELEMENT_NAME_AQI_PICTURE, LCD_DASHBOARD_PIC_AQI_HAZARDOUS);
this->sendStopBytes(); this->sendStopBytes();
} }
this->giveSerialMutex(); this->giveSerialMutex();