diff --git a/src/config.h b/src/config.h index fa73b26..bb883e9 100644 --- a/src/config.h +++ b/src/config.h @@ -31,6 +31,6 @@ /* * firmeware version string */ - #define __FIRMWARE__ "2020072403" + #define __FIRMWARE__ "2020072408" #endif // _CONFIG_H diff --git a/src/gui/mainbar/setup_tile/battery_settings/battery_settings.cpp b/src/gui/mainbar/setup_tile/battery_settings/battery_settings.cpp index 4849656..856150b 100644 --- a/src/gui/mainbar/setup_tile/battery_settings/battery_settings.cpp +++ b/src/gui/mainbar/setup_tile/battery_settings/battery_settings.cpp @@ -81,7 +81,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t lv_obj_align( battery_design_cap_label, battery_design_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 ); battery_design_cap = lv_label_create( battery_design_cont, NULL); lv_obj_add_style( battery_design_cap, LV_OBJ_PART_MAIN, style ); - lv_label_set_text( battery_design_cap, "350mAh"); + lv_label_set_text( battery_design_cap, "300mAh"); lv_obj_align( battery_design_cap, battery_design_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 ); lv_obj_t *battery_current_cont = lv_obj_create( battery_settings_tile, NULL ); @@ -94,7 +94,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t lv_obj_align( battery_current_cap_label, battery_current_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 ); battery_current_cap = lv_label_create( battery_current_cont, NULL); lv_obj_add_style( battery_current_cap, LV_OBJ_PART_MAIN, style ); - lv_label_set_text( battery_current_cap, "380mAh"); + lv_label_set_text( battery_current_cap, "300mAh"); lv_obj_align( battery_current_cap, battery_current_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 ); lv_obj_t *battery_voltage_cont = lv_obj_create( battery_settings_tile, NULL ); diff --git a/src/gui/widget/weather/weather.cpp b/src/gui/widget/weather/weather.cpp index 93b3c75..73e3d65 100644 --- a/src/gui/widget/weather/weather.cpp +++ b/src/gui/widget/weather/weather.cpp @@ -31,6 +31,8 @@ #include "gui/keyboard.h" #include "images/resolve_owm_icon.h" +#include "hardware/motor.h" + EventGroupHandle_t weather_widget_event_handle = NULL; TaskHandle_t _weather_widget_sync_Task; void weather_widget_sync_Task( void * pvParameters ); @@ -97,7 +99,8 @@ void weather_widget_setup( void ) { static void enter_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) { switch( event ) { - case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( weather_widget_tile_num, LV_ANIM_OFF ); + case( LV_EVENT_CLICKED ): motor_vibe( 1 ); + mainbar_jump_to_tilenumber( weather_widget_tile_num, LV_ANIM_OFF ); break; } } diff --git a/src/gui/widget/weather/weather_fetch.cpp b/src/gui/widget/weather/weather_fetch.cpp index 5e5d63a..ac69f78 100644 --- a/src/gui/widget/weather/weather_fetch.cpp +++ b/src/gui/widget/weather/weather_fetch.cpp @@ -50,6 +50,7 @@ void weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *w uint64_t startMillis = millis(); while ( today_client.available() == 0 ) { + yield(); if ( millis() - startMillis > 5000 ) { today_client.stop(); return; @@ -61,6 +62,7 @@ void weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *w bool data_begin = false; while( today_client.available() ) { + yield(); if ( data_begin ) { *ptr = today_client.read(); ptr++; @@ -76,6 +78,7 @@ void weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *w return; } + yield(); today_client.stop(); DynamicJsonDocument doc(20000); @@ -89,6 +92,7 @@ void weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *w return; } + yield(); weather_today->valide = true; snprintf( weather_today->temp, sizeof( weather_today->temp ),"%0.1f°C", doc["main"]["temp"].as() - 273.15 ); snprintf( weather_today->humidity, sizeof( weather_today->humidity ),"%f%%", doc["main"]["humidity"].as() ); @@ -121,6 +125,7 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t uint64_t startMillis = millis(); while ( forecast_client.available() == 0 ) { + yield(); if ( millis() - startMillis > 5000 ) { forecast_client.stop(); return; @@ -132,6 +137,7 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t bool data_begin = false; while( forecast_client.available() ) { + yield(); if ( data_begin ) { ptr[ forecast_client.readBytes( ptr, 40000 ) ] = '\0'; } @@ -149,6 +155,7 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t free( json ); return; } + yield(); DynamicJsonDocument doc(20000); DeserializationError error = deserializeJson( doc, json ); @@ -160,6 +167,7 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t return; } + yield(); 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°C", doc["list"][i]["main"]["temp"].as() - 273.15 ); diff --git a/src/gui/widget/weather/weather_forecast.cpp b/src/gui/widget/weather/weather_forecast.cpp index 8c8f737..31760ac 100644 --- a/src/gui/widget/weather/weather_forecast.cpp +++ b/src/gui/widget/weather/weather_forecast.cpp @@ -32,12 +32,15 @@ #include "gui/statusbar.h" #include "gui/keyboard.h" +#include "hardware/motor.h" + EventGroupHandle_t weather_forecast_event_handle = NULL; 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_update_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; @@ -86,10 +89,15 @@ void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hr 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 ); + weather_forecast_update_label = lv_label_create( tile , NULL); + lv_label_set_text( weather_forecast_update_label, ""); + lv_obj_reset_style_list( weather_forecast_update_label, LV_OBJ_PART_MAIN ); + lv_obj_align( weather_forecast_update_label, weather_forecast_location_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0 ); + 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 ); + lv_obj_align( weater_forecast_cont, tile, LV_ALIGN_CENTER, 0, 10 ); for ( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) { weather_forecast_icon_imgbtn[ i ] = lv_imgbtn_create( weater_forecast_cont, NULL); @@ -127,28 +135,36 @@ void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hr static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) { switch( event ) { - case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( MAIN_TILE, LV_ANIM_OFF ); + case( LV_EVENT_CLICKED ): motor_vibe( 1 ); + mainbar_jump_to_tilenumber( MAIN_TILE, LV_ANIM_OFF ); break; } } static void setup_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) { switch( event ) { - case( LV_EVENT_CLICKED ): weather_jump_to_setup(); + case( LV_EVENT_CLICKED ): motor_vibe( 1 ); + weather_jump_to_setup(); break; } } static void refresh_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) { switch( event ) { - case( LV_EVENT_CLICKED ): weather_forecast_sync_request(); + case( LV_EVENT_CLICKED ): motor_vibe( 1 ); + weather_forecast_sync_request(); weather_widget_sync_request(); break; } } void weather_forecast_sync_request( void ) { - xEventGroupSetBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST ); + if ( xEventGroupGetBits( weather_forecast_event_handle ) & WEATHER_FORECAST_SYNC_REQUEST ) { + return; + } + else { + xEventGroupSetBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST ); + } vTaskResume( _weather_forecast_sync_Task ); } @@ -163,7 +179,6 @@ void weather_forecast_sync_Task( void * pvParameters ) { 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 / 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 ); @@ -172,6 +187,14 @@ void weather_forecast_sync_Task( void * pvParameters ) { 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 ) ); + + time_t now; + struct tm info; + char buf[64]; + time( &now ); + localtime_r( &now, &info ); + strftime( buf, sizeof(buf), "updated: %d.%b %H:%M", &info ); + lv_label_set_text( weather_forecast_update_label, buf ); } } } diff --git a/src/hardware/pmu.h b/src/hardware/pmu.h index f1fedb1..15f6e33 100644 --- a/src/hardware/pmu.h +++ b/src/hardware/pmu.h @@ -24,7 +24,7 @@ #define PMU_EVENT_AXP_INT _BV(0) - #define PMU_BATTERY_CAP 350 + #define PMU_BATTERY_CAP 300 /* * @brief setup pmu: axp202 diff --git a/src/hardware/touch.cpp b/src/hardware/touch.cpp index 89bc9d0..9b8166e 100644 --- a/src/hardware/touch.cpp +++ b/src/hardware/touch.cpp @@ -39,7 +39,8 @@ static bool touch_getXY( int16_t &x, int16_t &y ) { if ( !ttgo->touch->touched() ) { return false; - } + } + p = ttgo->touch->getPoint(); uint8_t rotation = ttgo->tft->getRotation(); diff --git a/src/hardware/wifictl.cpp b/src/hardware/wifictl.cpp index 8947020..46a76f3 100644 --- a/src/hardware/wifictl.cpp +++ b/src/hardware/wifictl.cpp @@ -247,7 +247,7 @@ void wifictl_Task( void * pvParameters ) { return; while( true ) { - vTaskDelay( 500 ); + vTaskDelay( 125 ); 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 91d64cd..58ce060 100644 Binary files a/ttgo-t-watch2020_v1.ino.bin and b/ttgo-t-watch2020_v1.ino.bin differ