change single shot task, gets stability and memory
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 ];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user