change single shot task, gets stability and memory
This commit is contained in:
@@ -15,13 +15,12 @@ framework = arduino
|
|||||||
board_build.f_flash = 80000000L
|
board_build.f_flash = 80000000L
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
build_flags =
|
build_flags =
|
||||||
-DSPI_FREQUENCY=80000000L
|
; -DLOG_LOCAL_LEVEL=ESP_LOG_INFO
|
||||||
|
; -DSPI_FREQUENCY=80000000L
|
||||||
-DBOARD_HAS_PSRAM
|
-DBOARD_HAS_PSRAM
|
||||||
-mfix-esp32-psram-cache-issue
|
-mfix-esp32-psram-cache-issue
|
||||||
src_filter =
|
src_filter =
|
||||||
+<*>
|
+<*>
|
||||||
+<../src/font>
|
|
||||||
+<../src/images>
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
TTGO TWatch Library@>=1.2.0
|
TTGO TWatch Library@>=1.2.0
|
||||||
ESP Async WebServer@>=1.2.0
|
ESP Async WebServer@>=1.2.0
|
||||||
|
|||||||
@@ -113,14 +113,6 @@ void weather_app_setup( void ) {
|
|||||||
|
|
||||||
weather_widget_event_handle = xEventGroupCreate();
|
weather_widget_event_handle = xEventGroupCreate();
|
||||||
xEventGroupClearBits( weather_widget_event_handle, WEATHER_WIDGET_SYNC_REQUEST );
|
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 ) {
|
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 {
|
else {
|
||||||
xEventGroupSetBits( weather_widget_event_handle, WEATHER_WIDGET_SYNC_REQUEST );
|
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 ) {
|
void weather_widget_sync_Task( void * pvParameters ) {
|
||||||
while( true ) {
|
log_i("start weather widget task");
|
||||||
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 ) );
|
|
||||||
|
|
||||||
if ( weather_config.showWind )
|
if ( xEventGroupGetBits( weather_widget_event_handle ) & WEATHER_WIDGET_SYNC_REQUEST ) {
|
||||||
{
|
if ( weather_config.autosync ) {
|
||||||
lv_label_set_text( weather_widget_wind_label, weather_today.wind );
|
uint32_t retval = weather_fetch_today( &weather_config, &weather_today );
|
||||||
lv_obj_align( weather_widget_temperature_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, -22);
|
if ( retval == 200 ) {
|
||||||
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
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 ) );
|
||||||
else
|
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_label_set_text( weather_widget_wind_label, "" );
|
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_today.icon ) );
|
||||||
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 ( 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -141,14 +141,6 @@ void weather_forecast_tile_setup( uint32_t tile_num ) {
|
|||||||
weather_forecast_event_handle = xEventGroupCreate();
|
weather_forecast_event_handle = xEventGroupCreate();
|
||||||
xEventGroupClearBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST );
|
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 ) {
|
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 {
|
else {
|
||||||
xEventGroupSetBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST );
|
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();
|
weather_config_t *weather_config = weather_get_config();
|
||||||
uint32_t retval = -1;
|
uint32_t retval = -1;
|
||||||
|
|
||||||
while( true ) {
|
log_i("start weather forecast task");
|
||||||
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];
|
|
||||||
|
|
||||||
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_label_set_text( weather_forecast_location_label, weather_forecast[ 0 ].name );
|
||||||
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_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_label_set_text( weather_forecast_temperature_label[ i ], weather_forecast[ i * 2 ].temp );
|
||||||
{
|
|
||||||
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], "");
|
|
||||||
}
|
|
||||||
|
|
||||||
localtime_r( &weather_forecast[ i * 2 ].timestamp, &info );
|
if(weather_config->showWind)
|
||||||
strftime( buf, sizeof(buf), "%H:%M", &info );
|
{
|
||||||
lv_label_set_text( weather_forecast_time_label[ i ], buf );
|
lv_obj_align(weather_forecast_temperature_label[i], weather_forecast_icon_imgbtn[i], LV_ALIGN_OUT_BOTTOM_MID, 0, -22);
|
||||||
lv_obj_align( weather_forecast_time_label[ i ], weather_forecast_icon_imgbtn[ i ], LV_ALIGN_OUT_TOP_MID, 0, 0);
|
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( &weather_forecast[ i * 2 ].timestamp, &info );
|
||||||
localtime_r( &now, &info );
|
strftime( buf, sizeof(buf), "%H:%M", &info );
|
||||||
strftime( buf, sizeof(buf), "updated: %d.%b %H:%M", &info );
|
lv_label_set_text( weather_forecast_time_label[ i ], buf );
|
||||||
lv_label_set_text( weather_forecast_update_label, buf );
|
lv_obj_align( weather_forecast_time_label[ i ], weather_forecast_icon_imgbtn[ i ], LV_ALIGN_OUT_TOP_MID, 0, 0);
|
||||||
}
|
|
||||||
else {
|
|
||||||
char buf[64];
|
|
||||||
snprintf( buf, sizeof(buf), "Error: %d", retval );
|
|
||||||
lv_label_set_text( weather_forecast_update_label, buf );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,6 @@
|
|||||||
/*
|
/*
|
||||||
* firmeware version string
|
* firmeware version string
|
||||||
*/
|
*/
|
||||||
#define __FIRMWARE__ "2020073003"
|
#define __FIRMWARE__ "2020073007"
|
||||||
|
|
||||||
#endif // _CONFIG_H
|
#endif // _CONFIG_H
|
||||||
|
|||||||
@@ -120,17 +120,18 @@ lv_obj_t *mainbar_get_tile_obj( uint32_t tile_number ) {
|
|||||||
return( tile[ tile_number ].tile );
|
return( tile[ tile_number ].tile );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_e("tile number %d do not exist", tile_number );
|
log_e( "tile number %d do not exist", tile_number );
|
||||||
}
|
}
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainbar_jump_to_maintile( lv_anim_enable_t anim ) {
|
void mainbar_jump_to_maintile( lv_anim_enable_t anim ) {
|
||||||
lv_tileview_set_tile_act( mainbar, 0, 0, anim );
|
if ( tile_entrys != 0 ) {
|
||||||
}
|
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 ) {
|
else {
|
||||||
lv_tileview_set_tile_act( mainbar, x, y, anim );
|
log_e( "main tile do not exist" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainbar_jump_to_tilenumber( uint32_t tile_number, lv_anim_enable_t anim ) {
|
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 );
|
lv_tileview_set_tile_act( mainbar, tile_pos_table[ tile_number ].x, tile_pos_table[ tile_number ].y, anim );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_e("tile number %d do not exist", tile_number );
|
log_e( "tile number %d do not exist", tile_number );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,50 +24,6 @@
|
|||||||
|
|
||||||
#include <TTGO.h>
|
#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 {
|
typedef struct {
|
||||||
lv_obj_t *tile;
|
lv_obj_t *tile;
|
||||||
} lv_tile_t;
|
} lv_tile_t;
|
||||||
@@ -80,12 +36,6 @@
|
|||||||
* @param none
|
* @param none
|
||||||
*/
|
*/
|
||||||
void mainbar_setup( void );
|
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
|
* @brief jump to the given tile
|
||||||
* @param tile tile number
|
* @param tile tile number
|
||||||
@@ -97,15 +47,41 @@
|
|||||||
* @param anim LV_ANIM_ON or LV_ANIM_OFF for animated switch
|
* @param anim LV_ANIM_ON or LV_ANIM_OFF for animated switch
|
||||||
*/
|
*/
|
||||||
void mainbar_jump_to_maintile( lv_anim_enable_t anim );
|
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 );
|
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 );
|
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 );
|
* @brief get the lv_obj_t for a specific tile number
|
||||||
void mainbar_set_tile_setup_cb( lv_tile_number tile_number, TILE_CALLBACK_FUNC callback );
|
* @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
|
#endif // _MAINBAR_H
|
||||||
@@ -50,8 +50,9 @@ void battery_update_task( lv_task_t *task );
|
|||||||
|
|
||||||
void battery_settings_tile_setup( void ) {
|
void battery_settings_tile_setup( void ) {
|
||||||
// get an app tile and copy mainstyle
|
// 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 );
|
battery_settings_tile = mainbar_get_tile_obj( battery_tile_num );
|
||||||
|
|
||||||
lv_style_copy( &battery_settings_style, mainbar_get_style() );
|
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_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);
|
lv_style_set_bg_opa( &battery_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);
|
||||||
|
|||||||
@@ -117,14 +117,6 @@ void update_tile_setup( void ) {
|
|||||||
|
|
||||||
update_event_handle = xEventGroupCreate();
|
update_event_handle = xEventGroupCreate();
|
||||||
xEventGroupClearBits( update_event_handle, UPDATE_REQUEST );
|
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 ) {
|
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) {
|
static void update_event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||||
if(event == LV_EVENT_CLICKED) {
|
if(event == LV_EVENT_CLICKED) {
|
||||||
motor_vibe( 1 );
|
motor_vibe( 1 );
|
||||||
if ( xEventGroupGetBits( update_event_handle) & UPDATE_REQUEST ) {
|
if ( xEventGroupGetBits( update_event_handle) & ( UPDATE_GET_VERSION_REQUEST | UPDATE_REQUEST ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xEventGroupSetBits( update_event_handle, UPDATE_REQUEST );
|
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 ) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xEventGroupSetBits( update_event_handle, UPDATE_GET_VERSION_REQUEST );
|
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 ) {
|
void update_Task( void * pvParameters ) {
|
||||||
while( true ) {
|
log_i("start update task");
|
||||||
vTaskDelay( 500 );
|
|
||||||
if ( xEventGroupGetBits( update_event_handle) & UPDATE_GET_VERSION_REQUEST ) {
|
if ( xEventGroupGetBits( update_event_handle) & UPDATE_GET_VERSION_REQUEST ) {
|
||||||
if ( update_check_new_version() > atol( __FIRMWARE__ ) ) {
|
if ( update_check_new_version() > atol( __FIRMWARE__ ) ) {
|
||||||
lv_label_set_text( update_status_label, "new version available" );
|
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 );
|
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
|
||||||
}
|
|
||||||
xEventGroupClearBits( update_event_handle, UPDATE_GET_VERSION_REQUEST );
|
|
||||||
}
|
}
|
||||||
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 );
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ void wlan_settings_tile_setup( void ) {
|
|||||||
|
|
||||||
wifi_settings_tile = mainbar_get_tile_obj( wifi_settings_tile_num );
|
wifi_settings_tile = mainbar_get_tile_obj( wifi_settings_tile_num );
|
||||||
lv_style_copy( &wifi_settings_style, mainbar_get_style() );
|
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_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_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 );
|
lv_obj_add_style( wifi_settings_tile, LV_OBJ_PART_MAIN, &wifi_settings_style );
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ static lv_obj_t *statusbar = NULL;
|
|||||||
static lv_obj_t *statusbar_wifi = NULL;
|
static lv_obj_t *statusbar_wifi = NULL;
|
||||||
static lv_obj_t *statusbar_wifilabel = NULL;
|
static lv_obj_t *statusbar_wifilabel = NULL;
|
||||||
static lv_obj_t *statusbar_bluetooth = NULL;
|
static lv_obj_t *statusbar_bluetooth = NULL;
|
||||||
static lv_obj_t *statusbar_bluetoothlabel = NULL;
|
|
||||||
static lv_obj_t *statusbar_stepcounterlabel = NULL;
|
static lv_obj_t *statusbar_stepcounterlabel = NULL;
|
||||||
static lv_style_t statusbarstyle[ STATUSBAR_STYLE_NUM ];
|
static lv_style_t statusbarstyle[ STATUSBAR_STYLE_NUM ];
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,7 @@ void timesync_Task( void * pvParameters );
|
|||||||
timesync_config_t timesync_config;
|
timesync_config_t timesync_config;
|
||||||
|
|
||||||
void timesync_setup( TTGOClass *ttgo ) {
|
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();
|
timesync_read_config();
|
||||||
|
|
||||||
WiFi.onEvent( [](WiFiEvent_t event, WiFiEventInfo_t info) {
|
WiFi.onEvent( [](WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
@@ -46,22 +41,18 @@ void timesync_setup( TTGOClass *ttgo ) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xEventGroupSetBits( time_event_handle, TIME_SYNC_REQUEST );
|
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 );
|
}, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP );
|
||||||
|
|
||||||
time_event_handle = xEventGroupCreate();
|
time_event_handle = xEventGroupCreate();
|
||||||
xEventGroupClearBits( time_event_handle, TIME_SYNC_REQUEST );
|
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 ) {
|
void timesync_save_config( void ) {
|
||||||
@@ -132,25 +123,23 @@ void timesyncToRTC( void ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void timesync_Task( void * pvParameters ) {
|
void timesync_Task( void * pvParameters ) {
|
||||||
|
log_i("start time sync task");
|
||||||
|
|
||||||
while( true ) {
|
if ( xEventGroupGetBits( time_event_handle ) & TIME_SYNC_REQUEST ) {
|
||||||
vTaskDelay( 500 );
|
struct tm info;
|
||||||
if ( xEventGroupGetBits( time_event_handle ) & TIME_SYNC_REQUEST ) {
|
|
||||||
struct tm info;
|
|
||||||
|
|
||||||
long gmtOffset_sec = timesync_config.timezone * 3600;
|
long gmtOffset_sec = timesync_config.timezone * 3600;
|
||||||
int daylightOffset_sec = 0;
|
int daylightOffset_sec = 0;
|
||||||
|
|
||||||
|
if ( timesync_config.daylightsave )
|
||||||
|
daylightOffset_sec = 3600;
|
||||||
|
|
||||||
if ( timesync_config.daylightsave )
|
configTime( gmtOffset_sec, daylightOffset_sec, "pool.ntp.org" );
|
||||||
daylightOffset_sec = 3600;
|
|
||||||
|
|
||||||
configTime( gmtOffset_sec, daylightOffset_sec, "pool.ntp.org" );
|
|
||||||
|
|
||||||
if( !getLocalTime( &info ) ) {
|
if( !getLocalTime( &info ) ) {
|
||||||
log_e("Failed to obtain time" );
|
log_e("Failed to obtain time" );
|
||||||
}
|
|
||||||
xEventGroupClearBits( time_event_handle, TIME_SYNC_REQUEST );
|
|
||||||
}
|
|
||||||
vTaskSuspend( _timesync_Task );
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
xEventGroupClearBits( time_event_handle, TIME_SYNC_REQUEST );
|
||||||
|
vTaskDelete( NULL );
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -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"}
|
||||||
|
|||||||
Reference in New Issue
Block a user