change single shot task, gets stability and memory

This commit is contained in:
sharandac
2020-07-30 10:46:32 +02:00
parent d945b1f5c8
commit 9b94b63574
13 changed files with 204 additions and 251 deletions

View File

@@ -15,13 +15,12 @@ framework = arduino
board_build.f_flash = 80000000L
monitor_speed = 115200
build_flags =
-DSPI_FREQUENCY=80000000L
; -DLOG_LOCAL_LEVEL=ESP_LOG_INFO
; -DSPI_FREQUENCY=80000000L
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
src_filter =
+<*>
+<../src/font>
+<../src/images>
lib_deps =
TTGO TWatch Library@>=1.2.0
ESP Async WebServer@>=1.2.0

View File

@@ -113,14 +113,6 @@ void weather_app_setup( void ) {
weather_widget_event_handle = xEventGroupCreate();
xEventGroupClearBits( weather_widget_event_handle, WEATHER_WIDGET_SYNC_REQUEST );
xTaskCreate(
weather_widget_sync_Task, /* Function to implement the task */
"weather widget sync Task", /* Name of the task */
5000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_weather_widget_sync_Task ); /* Task handle. */
}
static void enter_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
@@ -145,7 +137,12 @@ void weather_widget_sync_request( void ) {
}
else {
xEventGroupSetBits( weather_widget_event_handle, WEATHER_WIDGET_SYNC_REQUEST );
vTaskResume( _weather_widget_sync_Task );
xTaskCreate( weather_widget_sync_Task, /* Function to implement the task */
"weather widget sync Task", /* Name of the task */
5000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_weather_widget_sync_Task ); /* Task handle. */
}
}
@@ -154,37 +151,33 @@ weather_config_t *weather_get_config( void ) {
}
void weather_widget_sync_Task( void * pvParameters ) {
while( true ) {
vTaskDelay( 500 );
esp_task_wdt_delete( _weather_widget_sync_Task );
if ( xEventGroupGetBits( weather_widget_event_handle ) & WEATHER_WIDGET_SYNC_REQUEST ) {
if ( weather_config.autosync ) {
uint32_t retval = weather_fetch_today( &weather_config, &weather_today );
if ( retval == 200 ) {
lv_label_set_text( weather_widget_temperature_label, weather_today.temp );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_RELEASED, resolve_owm_icon( weather_today.icon ) );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_PRESSED, resolve_owm_icon( weather_today.icon ) );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_CHECKED_RELEASED, resolve_owm_icon( weather_today.icon ) );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_today.icon ) );
log_i("start weather widget task");
if ( weather_config.showWind )
{
lv_label_set_text( weather_widget_wind_label, weather_today.wind );
lv_obj_align( weather_widget_temperature_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, -22);
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
}
else
{
lv_label_set_text( weather_widget_wind_label, "" );
lv_obj_align( weather_widget_temperature_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
}
if ( xEventGroupGetBits( weather_widget_event_handle ) & WEATHER_WIDGET_SYNC_REQUEST ) {
if ( weather_config.autosync ) {
uint32_t retval = weather_fetch_today( &weather_config, &weather_today );
if ( retval == 200 ) {
lv_label_set_text( weather_widget_temperature_label, weather_today.temp );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_RELEASED, resolve_owm_icon( weather_today.icon ) );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_PRESSED, resolve_owm_icon( weather_today.icon ) );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_CHECKED_RELEASED, resolve_owm_icon( weather_today.icon ) );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_today.icon ) );
if ( weather_config.showWind ) {
lv_label_set_text( weather_widget_wind_label, weather_today.wind );
lv_obj_align( weather_widget_temperature_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, -22);
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
}
else {
lv_label_set_text( weather_widget_wind_label, "" );
lv_obj_align( weather_widget_temperature_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
}
}
xEventGroupClearBits( weather_widget_event_handle, WEATHER_WIDGET_SYNC_REQUEST );
}
vTaskSuspend( _weather_widget_sync_Task );
}
xEventGroupClearBits( weather_widget_event_handle, WEATHER_WIDGET_SYNC_REQUEST );
vTaskDelete( NULL );
}
/*

View File

@@ -141,14 +141,6 @@ void weather_forecast_tile_setup( uint32_t tile_num ) {
weather_forecast_event_handle = xEventGroupCreate();
xEventGroupClearBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST );
xTaskCreate(
weather_forecast_sync_Task, /* Function to implement the task */
"weather forecast sync Task", /* Name of the task */
5000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_weather_forecast_sync_Task ); /* Task handle. */
}
static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
@@ -182,7 +174,12 @@ void weather_forecast_sync_request( void ) {
}
else {
xEventGroupSetBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST );
vTaskResume( _weather_forecast_sync_Task );
xTaskCreate( weather_forecast_sync_Task, /* Function to implement the task */
"weather forecast sync Task", /* Name of the task */
5000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_weather_forecast_sync_Task ); /* Task handle. */
}
}
@@ -190,58 +187,56 @@ void weather_forecast_sync_Task( void * pvParameters ) {
weather_config_t *weather_config = weather_get_config();
uint32_t retval = -1;
while( true ) {
vTaskDelay( 500 );
esp_task_wdt_delete( _weather_forecast_sync_Task );
if ( xEventGroupGetBits( weather_forecast_event_handle ) & WEATHER_FORECAST_SYNC_REQUEST ) {
if ( weather_config->autosync ) {
retval = weather_fetch_forecast( weather_get_config() , &weather_forecast[ 0 ] );
if ( retval == 200 ) {
time_t now;
struct tm info;
char buf[64];
log_i("start weather forecast task");
lv_label_set_text( weather_forecast_location_label, weather_forecast[ 0 ].name );
if ( xEventGroupGetBits( weather_forecast_event_handle ) & WEATHER_FORECAST_SYNC_REQUEST ) {
if ( weather_config->autosync ) {
retval = weather_fetch_forecast( weather_get_config() , &weather_forecast[ 0 ] );
if ( retval == 200 ) {
time_t now;
struct tm info;
char buf[64];
for( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) {
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_RELEASED, resolve_owm_icon( weather_forecast[ i * 2 ].icon ) );
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_PRESSED, resolve_owm_icon( weather_forecast[ i * 2 ].icon ) );
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_RELEASED, resolve_owm_icon( weather_forecast[ i * 2 ].icon ) );
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_forecast[ i * 2 ].icon ) );
lv_label_set_text( weather_forecast_location_label, weather_forecast[ 0 ].name );
lv_label_set_text( weather_forecast_temperature_label[ i ], weather_forecast[ i * 2 ].temp );
for( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) {
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_RELEASED, resolve_owm_icon( weather_forecast[ i * 2 ].icon ) );
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_PRESSED, resolve_owm_icon( weather_forecast[ i * 2 ].icon ) );
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_RELEASED, resolve_owm_icon( weather_forecast[ i * 2 ].icon ) );
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_forecast[ i * 2 ].icon ) );
if(weather_config->showWind)
{
lv_obj_align(weather_forecast_temperature_label[i], weather_forecast_icon_imgbtn[i], LV_ALIGN_OUT_BOTTOM_MID, 0, -22);
lv_label_set_text(weather_forecast_wind_label[i], weather_forecast[i * 2].wind);
lv_obj_align(weather_forecast_wind_label[i], weather_forecast_icon_imgbtn[i], LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
}
else
{
lv_obj_align(weather_forecast_temperature_label[i], weather_forecast_icon_imgbtn[i], LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
lv_label_set_text(weather_forecast_wind_label[i], "");
}
lv_label_set_text( weather_forecast_temperature_label[ i ], weather_forecast[ i * 2 ].temp );
localtime_r( &weather_forecast[ i * 2 ].timestamp, &info );
strftime( buf, sizeof(buf), "%H:%M", &info );
lv_label_set_text( weather_forecast_time_label[ i ], buf );
lv_obj_align( weather_forecast_time_label[ i ], weather_forecast_icon_imgbtn[ i ], LV_ALIGN_OUT_TOP_MID, 0, 0);
if(weather_config->showWind)
{
lv_obj_align(weather_forecast_temperature_label[i], weather_forecast_icon_imgbtn[i], LV_ALIGN_OUT_BOTTOM_MID, 0, -22);
lv_label_set_text(weather_forecast_wind_label[i], weather_forecast[i * 2].wind);
lv_obj_align(weather_forecast_wind_label[i], weather_forecast_icon_imgbtn[i], LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
}
else
{
lv_obj_align(weather_forecast_temperature_label[i], weather_forecast_icon_imgbtn[i], LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
lv_label_set_text(weather_forecast_wind_label[i], "");
}
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 );
}
else {
char buf[64];
snprintf( buf, sizeof(buf), "Error: %d", retval );
lv_label_set_text( weather_forecast_update_label, buf );
localtime_r( &weather_forecast[ i * 2 ].timestamp, &info );
strftime( buf, sizeof(buf), "%H:%M", &info );
lv_label_set_text( weather_forecast_time_label[ i ], buf );
lv_obj_align( weather_forecast_time_label[ i ], weather_forecast_icon_imgbtn[ i ], LV_ALIGN_OUT_TOP_MID, 0, 0);
}
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 );
}
else {
char buf[64];
snprintf( buf, sizeof(buf), "Error: %d", retval );
lv_label_set_text( weather_forecast_update_label, buf );
}
xEventGroupClearBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST );
}
vTaskSuspend( _weather_forecast_sync_Task );
}
xEventGroupClearBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST );
vTaskDelete( NULL );
}

View File

@@ -31,6 +31,6 @@
/*
* firmeware version string
*/
#define __FIRMWARE__ "2020073003"
#define __FIRMWARE__ "2020073007"
#endif // _CONFIG_H

View File

@@ -120,17 +120,18 @@ lv_obj_t *mainbar_get_tile_obj( uint32_t tile_number ) {
return( tile[ tile_number ].tile );
}
else {
log_e("tile number %d do not exist", tile_number );
log_e( "tile number %d do not exist", tile_number );
}
return( NULL );
}
void mainbar_jump_to_maintile( lv_anim_enable_t anim ) {
lv_tileview_set_tile_act( mainbar, 0, 0, anim );
}
void mainbar_jump_to_tile( lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim ) {
lv_tileview_set_tile_act( mainbar, x, y, anim );
if ( tile_entrys != 0 ) {
lv_tileview_set_tile_act( mainbar, 0, 0, anim );
}
else {
log_e( "main tile do not exist" );
}
}
void mainbar_jump_to_tilenumber( uint32_t tile_number, lv_anim_enable_t anim ) {
@@ -138,6 +139,6 @@ void mainbar_jump_to_tilenumber( uint32_t tile_number, lv_anim_enable_t anim ) {
lv_tileview_set_tile_act( mainbar, tile_pos_table[ tile_number ].x, tile_pos_table[ tile_number ].y, anim );
}
else {
log_e("tile number %d do not exist", tile_number );
log_e( "tile number %d do not exist", tile_number );
}
}

View File

@@ -24,50 +24,6 @@
#include <TTGO.h>
typedef void ( * TILE_CALLBACK_FUNC ) ( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
typedef enum {
TILE_TYPE_MAIN_TILE,
TILE_TYPE_APP_TILE,
TILE_TYPE_NOTE_TILE,
TILE_TYPE_KEYBOARD_TILE,
TILE_TYPE_SETUP_TILE,
TILE_TYPE_SETUP,
TILE_TYPE_WIDGET_TILE,
TILE_TYPE_WIDGET_SETUP,
TILE_TYPE_NUM
} lv_tile_type;
typedef enum {
NO_TILE = -1,
MAIN_TILE,
SETUP_TILE,
NOTE_TILE,
APP_TILE,
KEYBOARD_TILE,
WLAN_SETTINGS_TILE,
WLAN_PASSWORD_TILE,
MOVE_SETTINGS_TILE,
DISPLAY_SETTINGS_TILE,
BATTERY_OVERVIEW_TILE,
BATTERY_SETTINGS_TILE,
TIME_SETTINGS_TILE,
UPDATE_SETTINGS_TILE,
WIDGET1_1_TILE,
WIDGET1_2_TILE,
WIDGET2_1_TILE,
WIDGET2_2_TILE,
TILE_NUM
} lv_tile_number;
typedef struct {
lv_obj_t *tile;
lv_tile_type tile_type;
lv_tile_number tile_number;
TILE_CALLBACK_FUNC tilecallback;
lv_point_t pos;
} lv_tile_entry_t;
typedef struct {
lv_obj_t *tile;
} lv_tile_t;
@@ -80,12 +36,6 @@
* @param none
*/
void mainbar_setup( void );
/*
* @brief jump to the given tile
* @param x x coordinate
* @param y y coordinate
*/
void mainbar_jump_to_tile( lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim );
/*
* @brief jump to the given tile
* @param tile tile number
@@ -97,15 +47,41 @@
* @param anim LV_ANIM_ON or LV_ANIM_OFF for animated switch
*/
void mainbar_jump_to_maintile( lv_anim_enable_t anim );
lv_obj_t * mainbar_get_tile_obj( uint32_t tile_number );
/*
* @brief add a tile at a specific position
* @param x x position
* @param y y position
*
* @return tile number
*/
uint32_t mainbar_add_tile( uint16_t x, uint16_t y );
lv_style_t *mainbar_get_style( void );
void mainbar_print_cont( void );
/*
* @brief add a independent app tile formation
*
* +---+---+ +---+ +---+---+
* | n |n+1| | n | | n |n+1|
* +---+---+ +---+ +---+---+
* |n+2|n+3| |n+1|
* +---+---+ +---+
*
* @param x x size in tiles
* @param y y size in tiles
*
* @return tile number, if get more than 1 tile it is the first tile number
*/
uint32_t mainbar_add_app_tile( uint16_t x, uint16_t y );
lv_tile_number mainbar_get_next_free_tile( lv_tile_type tile_type );
void mainbar_set_tile_setup_cb( lv_tile_number tile_number, TILE_CALLBACK_FUNC callback );
/*
* @brief get the lv_obj_t for a specific tile number
* @param tile_number tile number
*
* @return lv_obj_t
*/
lv_obj_t * mainbar_get_tile_obj( uint32_t tile_number );
/*
* @brief get main tile style
*
* @return lv_style_t
*/
lv_style_t *mainbar_get_style( void );
#endif // _MAINBAR_H

View File

@@ -50,8 +50,9 @@ void battery_update_task( lv_task_t *task );
void battery_settings_tile_setup( void ) {
// get an app tile and copy mainstyle
battery_tile_num = mainbar_add_app_tile( 1, 1 );
battery_tile_num = mainbar_add_app_tile( 1, 2 );
battery_settings_tile = mainbar_get_tile_obj( battery_tile_num );
lv_style_copy( &battery_settings_style, mainbar_get_style() );
lv_style_set_bg_color( &battery_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &battery_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);

View File

@@ -117,14 +117,6 @@ void update_tile_setup( void ) {
update_event_handle = xEventGroupCreate();
xEventGroupClearBits( update_event_handle, UPDATE_REQUEST );
xTaskCreate(
update_Task, /* Function to implement the task */
"update Task", /* Name of the task */
5000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_update_Task ); /* Task handle. */
}
static void enter_update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
@@ -145,74 +137,82 @@ static void exit_update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void update_event_handler(lv_obj_t * obj, lv_event_t event) {
if(event == LV_EVENT_CLICKED) {
motor_vibe( 1 );
if ( xEventGroupGetBits( update_event_handle) & UPDATE_REQUEST ) {
if ( xEventGroupGetBits( update_event_handle) & ( UPDATE_GET_VERSION_REQUEST | UPDATE_REQUEST ) ) {
return;
}
else {
xEventGroupSetBits( update_event_handle, UPDATE_REQUEST );
vTaskResume( _update_Task );
xTaskCreate( update_Task, /* Function to implement the task */
"update Task", /* Name of the task */
10000, /* Stack size in words */
NULL, /* Task input parameter */
0, /* Priority of the task */
&_update_Task ); /* Task handle. */
}
}
}
void update_check_version( void ) {
if ( xEventGroupGetBits( update_event_handle ) & UPDATE_GET_VERSION_REQUEST ) {
if ( xEventGroupGetBits( update_event_handle ) & ( UPDATE_GET_VERSION_REQUEST | UPDATE_REQUEST ) ) {
return;
}
else {
xEventGroupSetBits( update_event_handle, UPDATE_GET_VERSION_REQUEST );
vTaskResume( _update_Task );
xTaskCreate( update_Task, /* Function to implement the task */
"update Task", /* Name of the task */
2000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_update_Task ); /* Task handle. */
}
}
void update_Task( void * pvParameters ) {
while( true ) {
vTaskDelay( 500 );
if ( xEventGroupGetBits( update_event_handle) & UPDATE_GET_VERSION_REQUEST ) {
if ( update_check_new_version() > atol( __FIRMWARE__ ) ) {
lv_label_set_text( update_status_label, "new version available" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
}
xEventGroupClearBits( update_event_handle, UPDATE_GET_VERSION_REQUEST );
log_i("start update task");
if ( xEventGroupGetBits( update_event_handle) & UPDATE_GET_VERSION_REQUEST ) {
if ( update_check_new_version() > atol( __FIRMWARE__ ) ) {
lv_label_set_text( update_status_label, "new version available" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
}
if ( xEventGroupGetBits( update_event_handle) & UPDATE_REQUEST ) {
if( WiFi.status() == WL_CONNECTED ) {
uint32_t display_timeout = display_get_timeout();
display_set_timeout( DISPLAY_MAX_TIMEOUT );
WiFiClient client;
lv_label_set_text( update_status_label, "start update ..." );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
t_httpUpdate_return ret = httpUpdate.update( client, "http://www.neo-guerillaz.de/ttgo-t-watch2020_v1.ino.bin" );
switch(ret) {
case HTTP_UPDATE_FAILED:
lv_label_set_text( update_status_label, "update failed" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
break;
case HTTP_UPDATE_NO_UPDATES:
lv_label_set_text( update_status_label, "no update" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
break;
case HTTP_UPDATE_OK:
lv_label_set_text( update_status_label, "update ok" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
break;
}
display_set_timeout( display_timeout );
}
else {
lv_label_set_text( update_status_label, "turn wifi on!" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
}
xEventGroupClearBits( update_event_handle, UPDATE_REQUEST );
}
lv_disp_trig_activity(NULL);
vTaskSuspend( _update_Task );
}
if ( xEventGroupGetBits( update_event_handle) & UPDATE_REQUEST ) {
if( WiFi.status() == WL_CONNECTED ) {
uint32_t display_timeout = display_get_timeout();
display_set_timeout( DISPLAY_MAX_TIMEOUT );
WiFiClient client;
lv_label_set_text( update_status_label, "start update ..." );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
t_httpUpdate_return ret = httpUpdate.update( client, "http://www.neo-guerillaz.de/ttgo-t-watch2020_v1.ino.bin" );
switch(ret) {
case HTTP_UPDATE_FAILED:
lv_label_set_text( update_status_label, "update failed" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
break;
case HTTP_UPDATE_NO_UPDATES:
lv_label_set_text( update_status_label, "no update" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
break;
case HTTP_UPDATE_OK:
lv_label_set_text( update_status_label, "update ok" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
break;
}
display_set_timeout( display_timeout );
}
else {
lv_label_set_text( update_status_label, "turn wifi on!" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
}
}
xEventGroupClearBits( update_event_handle, UPDATE_REQUEST | UPDATE_GET_VERSION_REQUEST );
lv_disp_trig_activity(NULL);
vTaskDelete( NULL );
}

View File

@@ -68,7 +68,7 @@ void wlan_settings_tile_setup( void ) {
wifi_settings_tile = mainbar_get_tile_obj( wifi_settings_tile_num );
lv_style_copy( &wifi_settings_style, mainbar_get_style() );
lv_style_set_bg_color( &wifi_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_color( &wifi_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY );
lv_style_set_bg_opa( &wifi_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &wifi_settings_style, LV_OBJ_PART_MAIN, 0);
lv_obj_add_style( wifi_settings_tile, LV_OBJ_PART_MAIN, &wifi_settings_style );

View File

@@ -42,7 +42,6 @@ static lv_obj_t *statusbar = NULL;
static lv_obj_t *statusbar_wifi = NULL;
static lv_obj_t *statusbar_wifilabel = NULL;
static lv_obj_t *statusbar_bluetooth = NULL;
static lv_obj_t *statusbar_bluetoothlabel = NULL;
static lv_obj_t *statusbar_stepcounterlabel = NULL;
static lv_style_t statusbarstyle[ STATUSBAR_STYLE_NUM ];

View File

@@ -31,12 +31,7 @@ void timesync_Task( void * pvParameters );
timesync_config_t timesync_config;
void timesync_setup( TTGOClass *ttgo ) {
/*
char buff[16]="";
snprintf( buff, sizeof(buff),"UTC%d", timesync_config.timezone);
setenv("TZ", buff, 1);
tzset();
*/
timesync_read_config();
WiFi.onEvent( [](WiFiEvent_t event, WiFiEventInfo_t info) {
@@ -46,22 +41,18 @@ void timesync_setup( TTGOClass *ttgo ) {
}
else {
xEventGroupSetBits( time_event_handle, TIME_SYNC_REQUEST );
vTaskResume( _timesync_Task );
xTaskCreate( timesync_Task, /* Function to implement the task */
"timesync Task", /* Name of the task */
2000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_timesync_Task ); /* Task handle. */
}
}
}, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP );
time_event_handle = xEventGroupCreate();
xEventGroupClearBits( time_event_handle, TIME_SYNC_REQUEST );
xTaskCreate(
timesync_Task, /* Function to implement the task */
"timesync Task", /* Name of the task */
2000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_timesync_Task ); /* Task handle. */
}
void timesync_save_config( void ) {
@@ -132,25 +123,23 @@ void timesyncToRTC( void ) {
}
void timesync_Task( void * pvParameters ) {
log_i("start time sync task");
while( true ) {
vTaskDelay( 500 );
if ( xEventGroupGetBits( time_event_handle ) & TIME_SYNC_REQUEST ) {
struct tm info;
if ( xEventGroupGetBits( time_event_handle ) & TIME_SYNC_REQUEST ) {
struct tm info;
long gmtOffset_sec = timesync_config.timezone * 3600;
int daylightOffset_sec = 0;
long gmtOffset_sec = timesync_config.timezone * 3600;
int daylightOffset_sec = 0;
if ( timesync_config.daylightsave )
daylightOffset_sec = 3600;
if ( timesync_config.daylightsave )
daylightOffset_sec = 3600;
configTime( gmtOffset_sec, daylightOffset_sec, "pool.ntp.org" );
configTime( gmtOffset_sec, daylightOffset_sec, "pool.ntp.org" );
if( !getLocalTime( &info ) ) {
log_e("Failed to obtain time" );
}
xEventGroupClearBits( time_event_handle, TIME_SYNC_REQUEST );
}
vTaskSuspend( _timesync_Task );
if( !getLocalTime( &info ) ) {
log_e("Failed to obtain time" );
}
}
xEventGroupClearBits( time_event_handle, TIME_SYNC_REQUEST );
vTaskDelete( NULL );
}

Binary file not shown.

View File

@@ -1 +1 @@
{"version":"2020073003","url":"http://www.neo-guerillaz.de/ttgo-t-watch2020_v1.ino.bin"}
{"version":"2020073007","url":"http://www.neo-guerillaz.de/ttgo-t-watch2020_v1.ino.bin"}