diff --git a/images/screen1.png b/images/screen1.png index d434312..9d61b90 100644 Binary files a/images/screen1.png and b/images/screen1.png differ diff --git a/images/screen10.png b/images/screen10.png index e5843e6..d36b6be 100644 Binary files a/images/screen10.png and b/images/screen10.png differ diff --git a/src/config.h b/src/config.h index 02da125..fa73b26 100644 --- a/src/config.h +++ b/src/config.h @@ -31,6 +31,6 @@ /* * firmeware version string */ - #define __FIRMWARE__ "2020072308" + #define __FIRMWARE__ "2020072403" #endif // _CONFIG_H diff --git a/src/gui/mainbar/setup_tile/update/update.cpp b/src/gui/mainbar/setup_tile/update/update.cpp index 3f2dbb1..e0e4264 100644 --- a/src/gui/mainbar/setup_tile/update/update.cpp +++ b/src/gui/mainbar/setup_tile/update/update.cpp @@ -125,7 +125,7 @@ static void update_event_handler(lv_obj_t * obj, lv_event_t event) { void update_Task( void * pvParameters ) { while( true ) { - vTaskDelay( 250 ); + vTaskDelay( 500 ); if ( xEventGroupGetBits( update_event_handle) & UPDATE_REQUEST ) { if( WiFi.status() == WL_CONNECTED ) { diff --git a/src/gui/widget/weather/weather.cpp b/src/gui/widget/weather/weather.cpp index bbcdf12..93b3c75 100644 --- a/src/gui/widget/weather/weather.cpp +++ b/src/gui/widget/weather/weather.cpp @@ -122,7 +122,7 @@ weather_config_t *weather_get_config( void ) { void weather_widget_sync_Task( void * pvParameters ) { while( true ) { - vTaskDelay( 250 ); + vTaskDelay( 500 ); if ( xEventGroupGetBits( weather_widget_event_handle ) & WEATHER_WIDGET_SYNC_REQUEST ) { if ( weather_config.autosync ) { weather_fetch_today( &weather_config, &weather_today ); diff --git a/src/gui/widget/weather/weather_fetch.cpp b/src/gui/widget/weather/weather_fetch.cpp index 61ea00e..5e5d63a 100644 --- a/src/gui/widget/weather/weather_fetch.cpp +++ b/src/gui/widget/weather/weather_fetch.cpp @@ -162,9 +162,9 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t weather_forecast[0].valide = true; for ( int i = 0 ; i < WEATHER_MAX_FORECAST ; i++ ) { - snprintf( weather_forecast[ i ].temp, sizeof( weather_forecast[ i ].temp ),"%0.1f", doc["list"][i]["main"]["temp"].as() - 273.15 ); - snprintf( weather_forecast[ i ].humidity, sizeof( weather_forecast[ i ].humidity ),"%f", doc["list"][i]["main"]["humidity"].as() ); - snprintf( weather_forecast[ i ].pressure, sizeof( weather_forecast[ i ].pressure ),"%f", doc["list"][i]["main"]["pressure"].as() ); + snprintf( weather_forecast[ i ].temp, sizeof( weather_forecast[ i ].temp ),"%0.1f°C", doc["list"][i]["main"]["temp"].as() - 273.15 ); + snprintf( weather_forecast[ i ].humidity, sizeof( weather_forecast[ i ].humidity ),"%f%%", doc["list"][i]["main"]["humidity"].as() ); + snprintf( weather_forecast[ i ].pressure, sizeof( weather_forecast[ i ].pressure ),"%fpha", doc["list"][i]["main"]["pressure"].as() ); strcpy( weather_forecast[ i ].icon, doc["list"][i]["weather"][0]["icon"] ); strcpy( weather_forecast[ i ].name, doc["city"]["name"] ); } diff --git a/src/gui/widget/weather/weather_forecast.cpp b/src/gui/widget/weather/weather_forecast.cpp index 60b3ac0..8c8f737 100644 --- a/src/gui/widget/weather/weather_forecast.cpp +++ b/src/gui/widget/weather/weather_forecast.cpp @@ -25,6 +25,7 @@ #include "weather.h" #include "weather_fetch.h" #include "weather_forecast.h" +#include "images/resolve_owm_icon.h" #include "gui/mainbar/mainbar.h" #include "gui/mainbar/main_tile/main_tile.h" @@ -36,6 +37,9 @@ TaskHandle_t _weather_forecast_sync_Task; void weather_forecast_sync_Task( void * pvParameters ); lv_obj_t *weather_widget_tile = NULL; +lv_obj_t *weather_forecast_location_label = NULL; +lv_obj_t *weather_forecast_icon_imgbtn[ WEATHER_MAX_FORECAST ]; +lv_obj_t *weather_forecast_temperature_label[ WEATHER_MAX_FORECAST ]; lv_style_t weather_widget_style; weather_forcast_t weather_forecast[ WEATHER_MAX_FORECAST ]; @@ -43,6 +47,7 @@ weather_forcast_t weather_forecast[ WEATHER_MAX_FORECAST ]; LV_IMG_DECLARE(exit_32px); LV_IMG_DECLARE(setup_32px); LV_IMG_DECLARE(refresh_32px); +LV_IMG_DECLARE(owm_01d_64px); static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ); static void setup_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ); @@ -76,14 +81,39 @@ void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hr lv_obj_align(reload_btn, tile, LV_ALIGN_IN_TOP_RIGHT, -10 , STATUSBAR_HEIGHT + 10 ); lv_obj_set_event_cb( reload_btn, refresh_weather_widget_event_cb ); + weather_forecast_location_label = lv_label_create( tile , NULL); + lv_label_set_text( weather_forecast_location_label, "n/a"); + lv_obj_reset_style_list( weather_forecast_location_label, LV_OBJ_PART_MAIN ); + lv_obj_align( weather_forecast_location_label, tile, LV_ALIGN_IN_TOP_LEFT, 15, STATUSBAR_HEIGHT + 15 ); + + lv_obj_t * weater_forecast_cont = lv_obj_create( tile, NULL ); + lv_obj_set_size( weater_forecast_cont, hres , 80 ); + lv_obj_add_style( weater_forecast_cont, LV_OBJ_PART_MAIN, style ); + lv_obj_align( weater_forecast_cont, tile, LV_ALIGN_CENTER, 0, 0 ); + + for ( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) { + weather_forecast_icon_imgbtn[ i ] = lv_imgbtn_create( weater_forecast_cont, NULL); + lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_RELEASED, &owm_01d_64px); + lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_PRESSED, &owm_01d_64px); + lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_RELEASED, &owm_01d_64px); + lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_PRESSED, &owm_01d_64px); + lv_obj_add_style( weather_forecast_icon_imgbtn[ i ], LV_IMGBTN_PART_MAIN, style); + lv_obj_align( weather_forecast_icon_imgbtn[ i ], weater_forecast_cont, LV_ALIGN_IN_TOP_LEFT, i*60, 0 ); + + weather_forecast_temperature_label[ i ] = lv_label_create( weater_forecast_cont , NULL); + lv_label_set_text( weather_forecast_temperature_label[ i ], "n/a"); + lv_obj_reset_style_list( weather_forecast_temperature_label[ i ], LV_OBJ_PART_MAIN ); + lv_obj_align( weather_forecast_temperature_label[ i ], weather_forecast_icon_imgbtn[ i ], LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + } + // regster callback for wifi sync WiFi.onEvent( [](WiFiEvent_t event, WiFiEventInfo_t info) { - xEventGroupSetBits( weather_forecast_event_handle, WEATHER_WIDGET_SYNC_REQUEST ); + xEventGroupSetBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST ); vTaskResume( _weather_forecast_sync_Task ); }, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP ); weather_forecast_event_handle = xEventGroupCreate(); - xEventGroupClearBits( weather_forecast_event_handle, WEATHER_WIDGET_SYNC_REQUEST ); + xEventGroupClearBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST ); xTaskCreate( weather_forecast_sync_Task, /* Function to implement the task */ @@ -118,7 +148,7 @@ static void refresh_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) } void weather_forecast_sync_request( void ) { - xEventGroupSetBits( weather_forecast_event_handle, WEATHER_WIDGET_SYNC_REQUEST ); + xEventGroupSetBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST ); vTaskResume( _weather_forecast_sync_Task ); } @@ -126,20 +156,26 @@ void weather_forecast_sync_Task( void * pvParameters ) { weather_config_t *weather_config = weather_get_config(); while( true ) { - vTaskDelay( 250 ); - if ( xEventGroupGetBits( weather_forecast_event_handle ) & WEATHER_WIDGET_SYNC_REQUEST ) { + vTaskDelay( 500 ); + if ( xEventGroupGetBits( weather_forecast_event_handle ) & WEATHER_FORECAST_SYNC_REQUEST ) { if ( weather_config->autosync ) { weather_fetch_forecast( weather_get_config() , &weather_forecast[ 0 ] ); if ( !weather_forecast[ 0 ].valide ) weather_fetch_forecast( weather_get_config() , &weather_forecast[ 0 ] ); if ( weather_forecast[ 0 ].valide ) { Serial.printf("weather forecast fetch ok\r\n"); - for( int i = 0 ; i < WEATHER_MAX_FORECAST ; i++ ) { - Serial.printf("Temp %02d: %s\r\n", i, weather_forecast[ i ].temp ); + for( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) { + lv_label_set_text( weather_forecast_location_label, weather_forecast[ i * 4 ].name ); + lv_label_set_text( weather_forecast_temperature_label[ i ], weather_forecast[ i * 4 ].temp ); + lv_obj_align( weather_forecast_temperature_label[ i ], weather_forecast_icon_imgbtn[ i ], LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_RELEASED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) ); + lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_PRESSED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) ); + lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_RELEASED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) ); + lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) ); } } } - xEventGroupClearBits( weather_forecast_event_handle, WEATHER_WIDGET_SYNC_REQUEST ); + xEventGroupClearBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST ); } vTaskSuspend( _weather_forecast_sync_Task ); } diff --git a/src/gui/widget/weather/weather_forecast.h b/src/gui/widget/weather/weather_forecast.h index faf9f42..71fff04 100644 --- a/src/gui/widget/weather/weather_forecast.h +++ b/src/gui/widget/weather/weather_forecast.h @@ -3,8 +3,8 @@ #include - #define WEATHER_WIDGET_SYNC_REQUEST _BV(0) - #define WEATHER_MAX_FORECAST 18 + #define WEATHER_FORECAST_SYNC_REQUEST _BV(0) + #define WEATHER_MAX_FORECAST 16 void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ); void weather_forecast_sync_request( void ); diff --git a/src/hardware/timesync.cpp b/src/hardware/timesync.cpp index 44e36ca..056ce01 100644 --- a/src/hardware/timesync.cpp +++ b/src/hardware/timesync.cpp @@ -113,7 +113,7 @@ void timesync_set_timezone( int32_t timezone ) { void timesync_Task( void * pvParameters ) { while( true ) { - vTaskDelay( 250 ); + vTaskDelay( 500 ); if ( xEventGroupGetBits( time_event_handle ) & TIME_SYNC_REQUEST ) { struct tm info; TTGOClass *ttgo = TTGOClass::getWatch(); diff --git a/src/hardware/wifictl.cpp b/src/hardware/wifictl.cpp index 3ff885b..8947020 100644 --- a/src/hardware/wifictl.cpp +++ b/src/hardware/wifictl.cpp @@ -247,7 +247,7 @@ void wifictl_Task( void * pvParameters ) { return; while( true ) { - vTaskDelay( 50 ); + vTaskDelay( 500 ); if ( powermgm_get_event( POWERMGM_WIFI_ON_REQUEST ) ) { statusbar_wifi_set_state( true, "activate" ); WiFi.mode( WIFI_STA ); diff --git a/ttgo-t-watch2020_v1.ino.bin b/ttgo-t-watch2020_v1.ino.bin index e0188d2..91d64cd 100644 Binary files a/ttgo-t-watch2020_v1.ino.bin and b/ttgo-t-watch2020_v1.ino.bin differ diff --git a/ttgo-t-watch2020_v1.version.txt b/ttgo-t-watch2020_v1.version.txt index e2bd125..e1fc041 100644 --- a/ttgo-t-watch2020_v1.version.txt +++ b/ttgo-t-watch2020_v1.version.txt @@ -1 +1 @@ -2020072308 +2020072403