migration to a dynamic tile management

This commit is contained in:
sharandac
2020-07-29 17:36:05 +02:00
parent 47e2fb0376
commit 8e088ba4e6
33 changed files with 717 additions and 593 deletions

View File

@@ -23,17 +23,19 @@
#include <TTGO.h>
#include <WiFi.h>
#include "weather.h"
#include "weather_fetch.h"
#include "weather_forecast.h"
#include "weather_setup.h"
#include "images/resolve_owm_icon.h"
#include "gui/mainbar/app_tile/app_tile.h"
#include "gui/mainbar/mainbar.h"
#include "gui/mainbar/main_tile/main_tile.h"
#include "gui/statusbar.h"
#include "gui/keyboard.h"
#include "images/resolve_owm_icon.h"
#include "hardware/motor.h"
#include "weather.h"
#include "weather_fetch.h"
#include "weather_setup.h"
EventGroupHandle_t weather_widget_event_handle = NULL;
TaskHandle_t _weather_widget_sync_Task;
void weather_widget_sync_Task( void * pvParameters );
@@ -41,8 +43,10 @@ void weather_widget_sync_Task( void * pvParameters );
weather_config_t weather_config;
weather_forcast_t weather_today;
lv_tile_number weather_widget_tile_num = NO_TILE;
lv_tile_number weather_widget_setup_tile_num = NO_TILE;
uint32_t weather_app_tile_num;
uint32_t weather_app_setup_tile_num;
lv_obj_t *weather_app_cont = NULL;
lv_obj_t *weather_widget_cont = NULL;
lv_obj_t *weather_widget_condition_img = NULL;
lv_obj_t *weather_widget_temperature_label = NULL;
@@ -56,17 +60,26 @@ void weather_app_setup( void ) {
weather_load_config();
// get a free widget tile and a widget setup tile
weather_widget_tile_num = mainbar_get_next_free_tile( TILE_TYPE_WIDGET_TILE );
weather_widget_setup_tile_num = mainbar_get_next_free_tile( TILE_TYPE_WIDGET_SETUP );
// register the widget setup function
mainbar_set_tile_setup_cb( weather_widget_tile_num, weather_tile_setup );
mainbar_set_tile_setup_cb( weather_widget_setup_tile_num, weather_setup_tile_setup );
// get an app tile and copy mainstyle
weather_app_tile_num = mainbar_add_app_tile( 1, 2 );
weather_app_setup_tile_num = weather_app_tile_num + 1;
weather_forecast_tile_setup( weather_app_tile_num );
weather_setup_tile_setup( weather_app_setup_tile_num );
weather_app_cont = app_tile_register_app( "weather");
lv_obj_t *weather_app_icon = lv_imgbtn_create( weather_app_cont, NULL );
lv_imgbtn_set_src( weather_app_icon, LV_BTN_STATE_RELEASED, &owm_01d_64px);
lv_imgbtn_set_src( weather_app_icon, LV_BTN_STATE_PRESSED, &owm_01d_64px);
lv_imgbtn_set_src( weather_app_icon, LV_BTN_STATE_CHECKED_RELEASED, &owm_01d_64px);
lv_imgbtn_set_src( weather_app_icon, LV_BTN_STATE_CHECKED_PRESSED, &owm_01d_64px);
lv_obj_reset_style_list( weather_app_icon, LV_OBJ_PART_MAIN );
lv_obj_align( weather_app_icon , weather_widget_cont, LV_ALIGN_IN_TOP_LEFT, 0, 0 );
lv_obj_set_event_cb( weather_app_icon, enter_weather_widget_event_cb );
// get an widget container from main_tile
weather_widget_cont = main_tile_register_widget();
// create widget weather condition icon and temperature label
weather_widget_cont = main_tile_register_widget();
weather_widget_condition_img = lv_imgbtn_create( weather_widget_cont, NULL );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_RELEASED, &owm_01d_64px);
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_PRESSED, &owm_01d_64px);
@@ -112,17 +125,17 @@ void weather_app_setup( void ) {
static void enter_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( weather_widget_tile_num, LV_ANIM_OFF );
mainbar_jump_to_tilenumber( weather_app_tile_num, LV_ANIM_OFF );
break;
}
}
void weather_jump_to_forecast( void ) {
mainbar_jump_to_tilenumber( weather_widget_tile_num, LV_ANIM_ON );
mainbar_jump_to_tilenumber( weather_app_tile_num, LV_ANIM_ON );
}
void weather_jump_to_setup( void ) {
mainbar_jump_to_tilenumber( weather_widget_setup_tile_num, LV_ANIM_ON );
mainbar_jump_to_tilenumber( weather_app_setup_tile_num, LV_ANIM_ON );
}
void weather_widget_sync_request( void ) {

View File

@@ -38,14 +38,16 @@ 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_tile = NULL;
lv_style_t weather_forecast_style;
uint32_t weather_forecast_tile_num;
lv_obj_t *weather_forecast_location_label = NULL;
lv_obj_t *weather_forecast_update_label = NULL;
lv_obj_t *weather_forecast_time_label[ WEATHER_MAX_FORECAST ];
lv_obj_t *weather_forecast_icon_imgbtn[ WEATHER_MAX_FORECAST ];
lv_obj_t *weather_forecast_temperature_label[ WEATHER_MAX_FORECAST ];
lv_obj_t *weather_forecast_wind_label[ WEATHER_MAX_FORECAST ];
lv_style_t weather_widget_style;
weather_forcast_t weather_forecast[ WEATHER_MAX_FORECAST ];
@@ -58,48 +60,52 @@ 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 );
static void refresh_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event );
void weather_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_obj_t * exit_btn = lv_imgbtn_create(tile, NULL);
void weather_forecast_tile_setup( uint32_t tile_num ) {
weather_forecast_tile_num = tile_num;
weather_forecast_tile = mainbar_get_tile_obj( weather_forecast_tile_num );
lv_style_copy( &weather_forecast_style, mainbar_get_style() );
lv_obj_t * exit_btn = lv_imgbtn_create( weather_forecast_tile, NULL);
lv_imgbtn_set_src(exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src(exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src(exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src(exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style(exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align(exit_btn, tile, LV_ALIGN_IN_BOTTOM_LEFT, 10, -10 );
lv_obj_add_style(exit_btn, LV_IMGBTN_PART_MAIN, &weather_forecast_style );
lv_obj_align(exit_btn, weather_forecast_tile, LV_ALIGN_IN_BOTTOM_LEFT, 10, -10 );
lv_obj_set_event_cb( exit_btn, exit_weather_widget_event_cb );
lv_obj_t * setup_btn = lv_imgbtn_create(tile, NULL);
lv_obj_t * setup_btn = lv_imgbtn_create( weather_forecast_tile, NULL);
lv_imgbtn_set_src(setup_btn, LV_BTN_STATE_RELEASED, &setup_32px);
lv_imgbtn_set_src(setup_btn, LV_BTN_STATE_PRESSED, &setup_32px);
lv_imgbtn_set_src(setup_btn, LV_BTN_STATE_CHECKED_RELEASED, &setup_32px);
lv_imgbtn_set_src(setup_btn, LV_BTN_STATE_CHECKED_PRESSED, &setup_32px);
lv_obj_add_style(setup_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align(setup_btn, tile, LV_ALIGN_IN_BOTTOM_RIGHT, -10, -10 );
lv_obj_add_style(setup_btn, LV_IMGBTN_PART_MAIN, &weather_forecast_style );
lv_obj_align(setup_btn, weather_forecast_tile, LV_ALIGN_IN_BOTTOM_RIGHT, -10, -10 );
lv_obj_set_event_cb( setup_btn, setup_weather_widget_event_cb );
lv_obj_t * reload_btn = lv_imgbtn_create(tile, NULL);
lv_obj_t * reload_btn = lv_imgbtn_create( weather_forecast_tile, NULL);
lv_imgbtn_set_src(reload_btn, LV_BTN_STATE_RELEASED, &refresh_32px);
lv_imgbtn_set_src(reload_btn, LV_BTN_STATE_PRESSED, &refresh_32px);
lv_imgbtn_set_src(reload_btn, LV_BTN_STATE_CHECKED_RELEASED, &refresh_32px);
lv_imgbtn_set_src(reload_btn, LV_BTN_STATE_CHECKED_PRESSED, &refresh_32px);
lv_obj_add_style(reload_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align(reload_btn, tile, LV_ALIGN_IN_TOP_RIGHT, -10 , STATUSBAR_HEIGHT + 10 );
lv_obj_add_style(reload_btn, LV_IMGBTN_PART_MAIN, &weather_forecast_style );
lv_obj_align(reload_btn, weather_forecast_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);
weather_forecast_location_label = lv_label_create( weather_forecast_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, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_align( weather_forecast_location_label, weather_forecast_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
weather_forecast_update_label = lv_label_create( tile , NULL);
weather_forecast_update_label = lv_label_create( weather_forecast_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 , 96 );
lv_obj_add_style( weater_forecast_cont, LV_OBJ_PART_MAIN, style );
lv_obj_align( weater_forecast_cont, tile, LV_ALIGN_CENTER, 0, 10 );
lv_obj_t * weater_forecast_cont = lv_obj_create( weather_forecast_tile, NULL );
lv_obj_set_size( weater_forecast_cont, LV_HOR_RES_MAX , 96 );
lv_obj_add_style( weater_forecast_cont, LV_OBJ_PART_MAIN, &weather_forecast_style );
lv_obj_align( weater_forecast_cont, weather_forecast_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);
@@ -107,7 +113,7 @@ void weather_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_
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_add_style( weather_forecast_icon_imgbtn[ i ], LV_IMGBTN_PART_MAIN, &weather_forecast_style );
lv_obj_align( weather_forecast_icon_imgbtn[ i ], weater_forecast_cont, LV_ALIGN_IN_LEFT_MID, i*58, 0 );
weather_forecast_temperature_label[ i ] = lv_label_create( weater_forecast_cont , NULL);
@@ -147,7 +153,7 @@ void weather_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_
static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( MAIN_TILE, LV_ANIM_OFF );
mainbar_jump_to_maintile( LV_ANIM_OFF );
break;
}
}

View File

@@ -6,7 +6,7 @@
#define WEATHER_FORECAST_SYNC_REQUEST _BV(0)
#define WEATHER_MAX_FORECAST 16
void weather_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void weather_forecast_tile_setup( uint32_t tile_num );
void weather_forecast_sync_request( void );
#endif // _WEATHER_FORECAST_H

View File

@@ -30,7 +30,10 @@
#include "gui/statusbar.h"
#include "gui/keyboard.h"
lv_obj_t *weather_widget_setup_tile = NULL;
lv_obj_t *weather_setup_tile = NULL;
lv_style_t weather_setup_style;
uint32_t weather_setup_tile_num;
lv_obj_t *weather_apikey_textfield = NULL;
lv_obj_t *weather_lat_textfield = NULL;
lv_obj_t *weather_lon_textfield = NULL;
@@ -45,43 +48,39 @@ static void exit_weather_widget_setup_event_cb( lv_obj_t * obj, lv_event_t event
static void weather_autosync_onoff_event_handler( lv_obj_t * obj, lv_event_t event );
static void weather_wind_onoff_event_handler( lv_obj_t *obj, lv_event_t event );
void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
void weather_setup_tile_setup( uint32_t tile_num ) {
weather_config_t *weather_config = weather_get_config();
lv_style_init( &weather_widget_setup_style );
lv_style_set_radius( &weather_widget_setup_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_bg_color( &weather_widget_setup_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &weather_widget_setup_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &weather_widget_setup_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color( &weather_widget_setup_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_style_set_image_recolor( &weather_widget_setup_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
weather_setup_tile_num = tile_num;
weather_setup_tile = mainbar_get_tile_obj( weather_setup_tile_num );
weather_widget_setup_tile = lv_obj_create( tile, NULL);
lv_obj_set_size( weather_widget_setup_tile, hres , vres);
lv_obj_align( weather_widget_setup_tile, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style( weather_widget_setup_tile, LV_OBJ_PART_MAIN, &weather_widget_setup_style );
lv_style_copy( &weather_setup_style, mainbar_get_style() );
lv_style_set_bg_color( &weather_setup_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &weather_setup_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &weather_setup_style, LV_OBJ_PART_MAIN, 0);
lv_obj_add_style( weather_setup_tile, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_obj_t *exit_btn = lv_imgbtn_create( weather_widget_setup_tile, NULL);
lv_obj_t *exit_btn = lv_imgbtn_create( weather_setup_tile, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( exit_btn, weather_widget_setup_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &weather_setup_style );
lv_obj_align( exit_btn, weather_setup_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_weather_widget_setup_event_cb );
lv_obj_t *exit_label = lv_label_create( weather_widget_setup_tile, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, style );
lv_obj_t *exit_label = lv_label_create( weather_setup_tile, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_label_set_text( exit_label, "open weather setup");
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
lv_obj_t *weather_apikey_cont = lv_obj_create( weather_widget_setup_tile, NULL );
lv_obj_set_size(weather_apikey_cont, hres , 40);
lv_obj_add_style( weather_apikey_cont, LV_OBJ_PART_MAIN, style );
lv_obj_align( weather_apikey_cont, weather_widget_setup_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
lv_obj_t *weather_apikey_cont = lv_obj_create( weather_setup_tile, NULL );
lv_obj_set_size(weather_apikey_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( weather_apikey_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_obj_align( weather_apikey_cont, weather_setup_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
lv_obj_t *weather_apikey_label = lv_label_create( weather_apikey_cont, NULL);
lv_obj_add_style( weather_apikey_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( weather_apikey_label, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_label_set_text( weather_apikey_label, "appid");
lv_obj_align( weather_apikey_label, weather_apikey_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
weather_apikey_textfield = lv_textarea_create( weather_apikey_cont, NULL);
@@ -93,12 +92,12 @@ void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
lv_obj_align( weather_apikey_textfield, weather_apikey_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( weather_apikey_textfield, weather_textarea_event_cb );
lv_obj_t *weather_lat_cont = lv_obj_create( weather_widget_setup_tile, NULL );
lv_obj_set_size(weather_lat_cont, hres / 2 , 40 );
lv_obj_add_style( weather_lat_cont, LV_OBJ_PART_MAIN, style );
lv_obj_t *weather_lat_cont = lv_obj_create( weather_setup_tile, NULL );
lv_obj_set_size(weather_lat_cont, LV_HOR_RES_MAX / 2 , 40 );
lv_obj_add_style( weather_lat_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_obj_align( weather_lat_cont, weather_apikey_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0 );
lv_obj_t *weather_lat_label = lv_label_create( weather_lat_cont, NULL);
lv_obj_add_style( weather_lat_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( weather_lat_label, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_label_set_text( weather_lat_label, "lat");
lv_obj_align( weather_lat_label, weather_lat_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
weather_lat_textfield = lv_textarea_create( weather_lat_cont, NULL);
@@ -110,12 +109,12 @@ void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
lv_obj_align( weather_lat_textfield, weather_lat_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( weather_lat_textfield, weather_textarea_event_cb );
lv_obj_t *weather_lon_cont = lv_obj_create( weather_widget_setup_tile, NULL );
lv_obj_set_size(weather_lon_cont, hres / 2 , 40 );
lv_obj_add_style( weather_lon_cont, LV_OBJ_PART_MAIN, style );
lv_obj_t *weather_lon_cont = lv_obj_create( weather_setup_tile, NULL );
lv_obj_set_size(weather_lon_cont, LV_HOR_RES_MAX / 2 , 40 );
lv_obj_add_style( weather_lon_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_obj_align( weather_lon_cont, weather_apikey_cont, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0 );
lv_obj_t *weather_lon_label = lv_label_create( weather_lon_cont, NULL);
lv_obj_add_style( weather_lon_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( weather_lon_label, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_label_set_text( weather_lon_label, "lon");
lv_obj_align( weather_lon_label, weather_lon_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
weather_lon_textfield = lv_textarea_create( weather_lon_cont, NULL);
@@ -127,29 +126,29 @@ void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
lv_obj_align( weather_lon_textfield, weather_lon_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( weather_lon_textfield, weather_textarea_event_cb );
lv_obj_t *weather_autosync_cont = lv_obj_create( weather_widget_setup_tile, NULL );
lv_obj_set_size( weather_autosync_cont, hres , 40);
lv_obj_add_style( weather_autosync_cont, LV_OBJ_PART_MAIN, style );
lv_obj_t *weather_autosync_cont = lv_obj_create( weather_setup_tile, NULL );
lv_obj_set_size( weather_autosync_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( weather_autosync_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_obj_align( weather_autosync_cont, weather_lat_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5 );
weather_autosync_onoff = lv_switch_create( weather_autosync_cont, NULL );
lv_switch_off( weather_autosync_onoff, LV_ANIM_ON );
lv_obj_align( weather_autosync_onoff, weather_autosync_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( weather_autosync_onoff, weather_autosync_onoff_event_handler );
lv_obj_t *weather_autosync_label = lv_label_create( weather_autosync_cont, NULL);
lv_obj_add_style( weather_autosync_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( weather_autosync_label, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_label_set_text( weather_autosync_label, "Sync if wifi connected");
lv_obj_align( weather_autosync_label, weather_autosync_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_obj_t *weather_wind_cont = lv_obj_create( weather_widget_setup_tile, NULL);
lv_obj_set_size( weather_wind_cont, hres, 40);
lv_obj_add_style( weather_wind_cont, LV_OBJ_PART_MAIN, style);
lv_obj_t *weather_wind_cont = lv_obj_create( weather_setup_tile, NULL);
lv_obj_set_size( weather_wind_cont, LV_HOR_RES_MAX, 40);
lv_obj_add_style( weather_wind_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_obj_align( weather_wind_cont, weather_autosync_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
weather_wind_onoff = lv_switch_create( weather_wind_cont, NULL);
lv_switch_off( weather_wind_onoff, LV_ANIM_ON);
lv_obj_align( weather_wind_onoff, weather_wind_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0);
lv_obj_set_event_cb( weather_wind_onoff, weather_wind_onoff_event_handler);
lv_obj_t *weather_wind_label = lv_label_create(weather_wind_cont, NULL);
lv_obj_add_style( weather_wind_label, LV_OBJ_PART_MAIN, style);
lv_obj_add_style( weather_wind_label, LV_OBJ_PART_MAIN, &weather_setup_style );
lv_label_set_text( weather_wind_label, "Display wind");
lv_obj_align( weather_wind_label, weather_wind_cont, LV_ALIGN_IN_LEFT_MID, 5, 0);

View File

@@ -3,6 +3,6 @@
#include <TTGO.h>
void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void weather_setup_tile_setup( uint32_t tile_num );
#endif // _WEATHER_SETUP_H

View File

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

View File

@@ -27,7 +27,19 @@
#include "statusbar.h"
#include "screenshot.h"
#include "keyboard.h"
#include "mainbar/mainbar.h"
#include "mainbar/main_tile/main_tile.h"
#include "mainbar/app_tile/app_tile.h"
#include "mainbar/note_tile/note_tile.h"
#include "mainbar/setup_tile/setup.h"
#include "mainbar/setup_tile/battery_settings/battery_settings.h"
#include "mainbar/setup_tile/display_settings/display_settings.h"
#include "mainbar/setup_tile/move_settings/move_settings.h"
#include "mainbar/setup_tile/time_settings/time_settings.h"
#include "mainbar/setup_tile/update/update.h"
#include "mainbar/setup_tile/wlan_settings/wlan_settings.h"
#include "hardware/powermgm.h"
#include "hardware/display.h"
@@ -50,10 +62,25 @@ void gui_setup(void)
lv_obj_align(img_bin, NULL, LV_ALIGN_CENTER, 0, 0);
mainbar_setup();
/* add the four mainbar screens */
main_tile_setup();
app_tile_setup();
note_tile_setup();
setup_tile_setup();
/* add setup */
battery_settings_tile_setup();
display_settings_tile_setup();
move_settings_tile_setup();
time_settings_tile_setup();
wlan_settings_tile_setup();
update_tile_setup();
statusbar_setup();
keyboard_setup();
lv_disp_trig_activity(NULL);
keyboard_setup();
return;
}

View File

@@ -20,35 +20,31 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "../mainbar.h"
#include "gui/mainbar/mainbar.h"
#include "app_tile.h"
lv_app_entry_t app_entry[ MAX_APPS_ICON ];
static lv_obj_t *app_cont = NULL;
static lv_obj_t *applabel = NULL;
static lv_style_t *style;
static lv_style_t appstyle;
LV_FONT_DECLARE(Ubuntu_72px);
LV_FONT_DECLARE(Ubuntu_16px);
void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
void app_tile_setup( void ) {
app_cont = tile;
app_cont = mainbar_get_tile_obj( mainbar_add_tile( 1, 0 ) );
style = mainbar_get_style();
lv_style_copy( &appstyle, style);
lv_style_set_text_font( &appstyle, LV_STATE_DEFAULT, &Ubuntu_72px);
applabel = lv_label_create(tile, NULL);
lv_label_set_text(applabel, "app");
lv_obj_reset_style_list( applabel, LV_OBJ_PART_MAIN );
lv_obj_add_style( applabel, LV_OBJ_PART_MAIN, &appstyle );
lv_obj_align(applabel, NULL, LV_ALIGN_CENTER, 0, 0);
for ( int app = 0 ; app < MAX_APPS_ICON ; app++ ) {
// set x, y and mark it as inactive
app_entry[ app ].x = APP_FIRST_X_POS + ( ( app % MAX_APPS_ICON_HORZ ) * ( APP_ICON_X_SIZE + APP_ICON_X_CLEARENCE ) );
app_entry[ app ].y = APP_FIRST_Y_POS + ( ( app % MAX_APPS_ICON_VERT ) * ( APP_ICON_Y_SIZE + APP_ICON_Y_CLEARENCE ) );
app_entry[ app ].y = APP_FIRST_Y_POS + ( ( app / MAX_APPS_ICON_HORZ ) * ( APP_ICON_Y_SIZE + APP_ICON_Y_CLEARENCE ) );
app_entry[ app ].active = false;
// create app icon container
app_entry[ app ].app = lv_obj_create( app_cont, NULL );
@@ -61,8 +57,7 @@ void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coor
lv_obj_reset_style_list( app_entry[ app ].label, LV_OBJ_PART_MAIN );
lv_obj_add_style( app_entry[ app ].label, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( app_entry[ app ].label, APP_LABEL_X_SIZE, APP_LABEL_Y_SIZE );
lv_obj_align( app_entry[ app ].app , app_entry[ app ].app, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_align( app_entry[ app ].label , app_entry[ app ].app, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_set_hidden( app_entry[ app ].app, true );
lv_obj_set_hidden( app_entry[ app ].label, true );
}
@@ -72,11 +67,13 @@ lv_obj_t *app_tile_register_app( const char* appname ) {
for( int app = 0 ; app < MAX_APPS_ICON ; app++ ) {
if ( app_entry[ app ].active == false ) {
app_entry[ app ].active = true;
lv_label_set_text( app_entry[ app ].label, appname );
lv_obj_align( app_entry[ app ].label , app_entry[ app ].app, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_set_hidden( app_entry[ app ].app, false );
lv_obj_set_hidden( app_entry[ app ].label, false );
return( app_entry[ app ].app );
}
}
log_e("no space for an app icon");
return( NULL );
}

View File

@@ -28,10 +28,10 @@
#define MAX_APPS_ICON_VERT 2
#define MAX_APPS_ICON ( MAX_APPS_ICON_HORZ * MAX_APPS_ICON_VERT )
#define APP_ICON_X_SIZE 48
#define APP_ICON_Y_SIZE 48
#define APP_ICON_X_CLEARENCE 32
#define APP_ICON_Y_CLEARENCE 32
#define APP_ICON_X_SIZE 64
#define APP_ICON_Y_SIZE 64
#define APP_ICON_X_CLEARENCE 8
#define APP_ICON_Y_CLEARENCE 20
#define APP_LABEL_X_SIZE APP_ICON_X_SIZE + APP_ICON_X_CLEARENCE
#define APP_LABEL_Y_SIZE APP_ICON_Y_CLEARENCE / 2
@@ -46,6 +46,7 @@
bool active;
} lv_app_entry_t;
void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void app_tile_setup( void );
lv_obj_t *app_tile_register_app( const char* appname );
#endif // _APP_TILE_H

View File

@@ -23,7 +23,7 @@
#include <time.h>
#include "config.h"
#include "../mainbar.h"
#include "gui/mainbar/mainbar.h"
#include "main_tile.h"
static lv_obj_t *main_cont = NULL;
@@ -31,6 +31,7 @@ static lv_obj_t *clock_cont = NULL;
static lv_obj_t *timelabel = NULL;
static lv_obj_t *datelabel = NULL;
static lv_style_t *style;
static lv_style_t timestyle;
static lv_style_t datestyle;
@@ -41,9 +42,10 @@ lv_task_t * task;
LV_FONT_DECLARE(Ubuntu_72px);
LV_FONT_DECLARE(Ubuntu_16px);
void main_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
void main_tile_setup( void ) {
main_cont = tile;
main_cont = mainbar_get_tile_obj( mainbar_add_tile( 0, 0 ) );
style = mainbar_get_style();
lv_style_copy( &timestyle, style);
lv_style_set_text_font( &timestyle, LV_STATE_DEFAULT, &Ubuntu_72px);
@@ -51,10 +53,10 @@ void main_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coo
lv_style_copy( &datestyle, style);
lv_style_set_text_font( &datestyle, LV_STATE_DEFAULT, &Ubuntu_16px);
clock_cont = lv_obj_create( tile, NULL );
lv_obj_set_size( clock_cont, hres , hres/2 );
clock_cont = lv_obj_create( main_cont, NULL );
lv_obj_set_size( clock_cont, LV_HOR_RES , LV_VER_RES / 2 );
lv_obj_add_style( clock_cont, LV_OBJ_PART_MAIN, style );
lv_obj_align( clock_cont, tile, LV_ALIGN_CENTER, 0, 0 );
lv_obj_align( clock_cont, main_cont, LV_ALIGN_CENTER, 0, 0 );
timelabel = lv_label_create( clock_cont , NULL);
lv_label_set_text(timelabel, "00:00");

View File

@@ -33,7 +33,7 @@
bool active;
} lv_widget_entry_t;
void main_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void main_tile_setup( void );
void main_tile_task( lv_task_t * task );
lv_obj_t *main_tile_register_widget( void );

View File

@@ -39,30 +39,12 @@
static lv_style_t mainbarstyle;
static lv_obj_t *mainbar = NULL;
static lv_point_t valid_pos[ TILE_NUM ];
lv_tile_entry_t tile_entry[ TILE_NUM ] {
{ NULL, TILE_TYPE_MAIN_TILE, MAIN_TILE, main_tile_setup, { 0 , 0 } },
{ NULL, TILE_TYPE_APP_TILE, APP_TILE, app_tile_setup, { 1 , 0 } },
{ NULL, TILE_TYPE_NOTE_TILE, NOTE_TILE, note_tile_setup, { 0 , 1 } },
{ NULL, TILE_TYPE_KEYBOARD_TILE, KEYBOARD_TILE, NULL, { 0 , 6 } },
{ NULL, TILE_TYPE_SETUP_TILE, SETUP_TILE, setup_tile_setup, { 1 , 1 } },
{ NULL, TILE_TYPE_SETUP, WLAN_SETTINGS_TILE, wlan_settings_tile_setup, { 0,3 } },
{ NULL, TILE_TYPE_SETUP, WLAN_PASSWORD_TILE, wlan_password_tile_setup, { 0,4 } },
{ NULL, TILE_TYPE_SETUP, MOVE_SETTINGS_TILE, move_settings_tile_setup, { 2,3 } },
{ NULL, TILE_TYPE_SETUP, DISPLAY_SETTINGS_TILE, display_settings_tile_setup, { 4,3 } },
{ NULL, TILE_TYPE_SETUP, BATTERY_SETTINGS_TILE, battery_settings_tile_setup, { 6,3 } },
{ NULL, TILE_TYPE_SETUP, BATTERY_OVERVIEW_TILE, NULL, { 6,4 } },
{ NULL, TILE_TYPE_SETUP, TIME_SETTINGS_TILE, time_settings_tile_setup, { 8,3 } },
{ NULL, TILE_TYPE_SETUP, UPDATE_SETTINGS_TILE, update_tile_setup, { 10,3 } },
{ NULL, TILE_TYPE_WIDGET_TILE, WIDGET1_1_TILE, NULL, { 12,3 } },
{ NULL, TILE_TYPE_WIDGET_SETUP, WIDGET1_2_TILE, NULL, { 12,4 } },
{ NULL, TILE_TYPE_WIDGET_TILE, WIDGET2_1_TILE, NULL, { 14,3 } },
{ NULL, TILE_TYPE_WIDGET_SETUP, WIDGET2_2_TILE, NULL, { 14,4 } }
};
static lv_tile_t *tile = NULL;
static lv_point_t *tile_pos_table = NULL;
static uint32_t tile_entrys = 0;
static uint32_t app_tile_pos = MAINBAR_APP_TILE_X_START;
void mainbar_setup( void ) {
lv_style_init( &mainbarstyle );
lv_style_set_radius(&mainbarstyle, LV_OBJ_PART_MAIN, 0);
lv_style_set_bg_color(&mainbarstyle, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
@@ -70,74 +52,92 @@ void mainbar_setup( void ) {
lv_style_set_border_width(&mainbarstyle, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color(&mainbarstyle, LV_OBJ_PART_MAIN, LV_COLOR_WHITE);
lv_style_set_image_recolor(&mainbarstyle, LV_OBJ_PART_MAIN, LV_COLOR_WHITE);
mainbar = lv_tileview_create( lv_scr_act(), NULL);
lv_tileview_set_valid_positions(mainbar, valid_pos, TILE_NUM );
lv_tileview_set_edge_flash(mainbar, false);
lv_tileview_set_valid_positions(mainbar, tile_pos_table, tile_entrys );
lv_tileview_set_edge_flash( mainbar, false);
lv_obj_add_style( mainbar, LV_OBJ_PART_MAIN, &mainbarstyle );
lv_page_set_scrlbar_mode(mainbar, LV_SCRLBAR_MODE_OFF);
for( int tile = 0 ; tile < TILE_NUM ; tile++ ) {
tile_entry[ tile ].tile = lv_obj_create( mainbar, NULL);
lv_obj_set_size( tile_entry[ tile ].tile, LV_HOR_RES, LV_VER_RES);
lv_obj_reset_style_list( tile_entry[ tile ].tile, LV_OBJ_PART_MAIN );
lv_obj_add_style( tile_entry[ tile ].tile, LV_OBJ_PART_MAIN, &mainbarstyle );
lv_obj_set_pos( tile_entry[ tile ].tile, tile_entry[ tile ].pos.x * LV_HOR_RES , tile_entry[ tile ].pos.y * LV_VER_RES );
lv_tileview_add_element( mainbar, tile_entry[ tile ].tile);
if ( tile_entry[ tile ].tilecallback != NULL )
tile_entry[ tile ].tilecallback( tile_entry[ tile ].tile, &mainbarstyle, LV_HOR_RES , LV_VER_RES );
valid_pos[ tile ].x = tile_entry[ tile ].pos.x;
valid_pos[ tile ].y = tile_entry[ tile ].pos.y;
}
mainbar_jump_to_maintile( LV_ANIM_OFF );
}
lv_obj_t * mainbar_get_tile_obj( lv_tile_number tile_number ) {
if ( tile_number < TILE_NUM ) {
for ( int tile = 0 ; tile < TILE_NUM; tile++ ) {
if ( tile_entry[ tile ].tile_number == tile_number ) {
return( tile_entry[ tile ].tile );
uint32_t mainbar_add_tile( uint16_t x, uint16_t y ) {
tile_entrys++;
if ( tile_pos_table == NULL ) {
tile_pos_table = ( lv_point_t * )malloc( sizeof( lv_point_t ) * tile_entrys );
tile = ( lv_tile_t * )malloc( sizeof( lv_tile_t ) * tile_entrys );
}
else {
tile_pos_table = ( lv_point_t * )realloc( tile_pos_table, sizeof( lv_point_t ) * tile_entrys );
tile = ( lv_tile_t * )realloc( tile, sizeof( lv_tile_t ) * tile_entrys );
}
if ( tile_pos_table == NULL || tile == NULL ) {
log_e("memory alloc faild");
while(true);
}
tile_pos_table[ tile_entrys - 1 ].x = x;
tile_pos_table[ tile_entrys - 1 ].y = y;
lv_obj_t *my_tile = lv_obj_create( mainbar, NULL);
tile[ tile_entrys - 1 ].tile = my_tile;
lv_obj_set_size( tile[ tile_entrys - 1 ].tile, LV_HOR_RES, LV_VER_RES);
lv_obj_reset_style_list( tile[ tile_entrys - 1 ].tile, LV_OBJ_PART_MAIN );
lv_obj_add_style( tile[ tile_entrys - 1 ].tile, LV_OBJ_PART_MAIN, &mainbarstyle );
lv_obj_set_pos( tile[ tile_entrys - 1 ].tile, tile_pos_table[ tile_entrys - 1 ].x * LV_HOR_RES , tile_pos_table[ tile_entrys - 1 ].y * LV_VER_RES );
lv_tileview_add_element( mainbar, tile[ tile_entrys - 1 ].tile );
lv_tileview_set_valid_positions( mainbar, tile_pos_table, tile_entrys );
log_d("add tile: x=%d, y=%d", tile_pos_table[ tile_entrys - 1 ].x, tile_pos_table[ tile_entrys - 1 ].y );
return( tile_entrys - 1 );
}
lv_style_t *mainbar_get_style( void ) {
return( &mainbarstyle );
}
uint32_t mainbar_add_app_tile( uint16_t x, uint16_t y ) {
uint32_t retval = -1;
for ( int hor = 0 ; hor < x ; hor++ ) {
for ( int ver = 0 ; ver < y ; ver++ ) {
if ( retval == -1 ) {
retval = mainbar_add_tile( hor + app_tile_pos, ver + MAINBAR_APP_TILE_Y_START );
}
else {
mainbar_add_tile( hor + app_tile_pos, ver + MAINBAR_APP_TILE_Y_START );
}
}
}
app_tile_pos = app_tile_pos + x + 1;
return( retval );
}
lv_obj_t *mainbar_get_tile_obj( uint32_t tile_number ) {
if ( tile_number < tile_entrys ) {
return( tile[ tile_number ].tile );
}
else {
log_e("tile number %d do not exist", tile_number );
}
return( NULL );
}
lv_tile_number mainbar_get_next_free_tile( lv_tile_type tile_type ) {
for ( int tile = 0 ; tile < TILE_NUM; tile++ ) {
if ( tile_entry[ tile ].tile_type == tile_type && tile_entry[ tile ].tilecallback == NULL ) {
return( tile_entry[ tile ].tile_number );
}
}
return( NO_TILE );
void mainbar_jump_to_maintile( lv_anim_enable_t anim ) {
lv_tileview_set_tile_act( mainbar, 0, 0, anim );
}
void mainbar_set_tile_setup_cb( lv_tile_number tile_number, TILE_CALLBACK_FUNC callback ) {
if ( tile_number < TILE_NUM ) {
tile_entry[ tile_number ].tilecallback = callback;
tile_entry[ tile_number ].tilecallback( tile_entry[ tile_number ].tile, &mainbarstyle, LV_HOR_RES , LV_VER_RES );
}
}
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 );
}
void mainbar_jump_to_tilenumber( lv_tile_number tile_number, lv_anim_enable_t anim ) {
for ( int tile = 0 ; tile < TILE_NUM; tile++ ) {
if ( tile_entry[ tile ].tile_number == tile_number ) {
lv_tileview_set_tile_act( mainbar, tile_entry[ tile ].pos.x, tile_entry[ tile ].pos.y, anim );
break;
}
void mainbar_jump_to_tilenumber( uint32_t tile_number, lv_anim_enable_t anim ) {
if ( tile_number < tile_entrys ) {
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 );
}
}
void mainbar_jump_to_maintile( lv_anim_enable_t anim ) {
for ( int tile = 0 ; tile < TILE_NUM; tile++ ) {
if ( tile_entry[ tile ].tile_number == MAIN_TILE ) {
lv_tileview_set_tile_act(mainbar, tile_entry[ tile ].pos.x, tile_entry[ tile ].pos.y, anim );
break;
}
}
}

View File

@@ -68,6 +68,13 @@
lv_point_t pos;
} lv_tile_entry_t;
typedef struct {
lv_obj_t *tile;
} lv_tile_t;
#define MAINBAR_APP_TILE_X_START 0
#define MAINBAR_APP_TILE_Y_START 4
/*
* @brief mainbar setup funktion
* @param none
@@ -84,14 +91,19 @@
* @param tile tile number
* @param anim LV_ANIM_ON or LV_ANIM_OFF for animated switch
*/
void mainbar_jump_to_tilenumber( lv_tile_number tile_number, lv_anim_enable_t anim );
void mainbar_jump_to_tilenumber( uint32_t tile_number, lv_anim_enable_t anim );
/*
* @brief jump direct to main tile
* @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( lv_tile_number tile_number );
lv_obj_t * mainbar_get_tile_obj( uint32_t 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 );
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 );

View File

@@ -20,25 +20,30 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "../mainbar.h"
#include "gui/mainbar/mainbar.h"
#include "note_tile.h"
static lv_obj_t *note_cont = NULL;
static lv_obj_t *notelabel = NULL;
static lv_style_t *style;
static lv_style_t notestyle;
LV_FONT_DECLARE(Ubuntu_72px);
LV_FONT_DECLARE(Ubuntu_16px);
void note_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
void note_tile_setup( void ) {
note_cont = mainbar_get_tile_obj( mainbar_add_tile( 0, 1 ) );
style = mainbar_get_style();
lv_style_copy( &notestyle, style);
lv_style_set_text_font( &notestyle, LV_STATE_DEFAULT, &Ubuntu_72px);
notelabel = lv_label_create(tile, NULL);
notelabel = lv_label_create( note_cont, NULL);
lv_label_set_text( notelabel, "note");
lv_obj_reset_style_list( notelabel, LV_OBJ_PART_MAIN );
lv_obj_add_style( notelabel, LV_OBJ_PART_MAIN, &notestyle );
lv_obj_align( notelabel, NULL, LV_ALIGN_CENTER, 0, 0);
}

View File

@@ -24,6 +24,6 @@
#include <TTGO.h>
void note_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void note_tile_setup( void );
#endif // _NOTE_TILE_H

View File

@@ -24,12 +24,14 @@
#include "battery_settings.h"
#include "gui/mainbar/mainbar.h"
#include "gui/mainbar/setup_tile/setup.h"
#include "gui/statusbar.h"
#include "hardware/pmu.h"
#include "hardware/motor.h"
lv_obj_t *battery_settings_tile=NULL;
lv_style_t battery_settings_style;
uint32_t battery_tile_num;
lv_obj_t *battery_design_cap;
lv_obj_t *battery_current_cap;
@@ -40,124 +42,141 @@ lv_obj_t *vbus_voltage;
lv_task_t *battery_task;
LV_IMG_DECLARE(exit_32px);
LV_IMG_DECLARE(battery_icon_64px);
static void enter_battery_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void exit_battery_setup_event_cb( lv_obj_t * obj, lv_event_t event );
void battery_update_task( lv_task_t *task );
void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_style_init( &battery_settings_style );
lv_style_set_radius( &battery_settings_style, LV_OBJ_PART_MAIN, 0);
void battery_settings_tile_setup( void ) {
// get an app tile and copy mainstyle
battery_tile_num = mainbar_add_app_tile( 1, 1 );
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);
lv_style_set_border_width( &battery_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color( &battery_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_style_set_image_recolor( &battery_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
battery_settings_tile = lv_obj_create( tile, NULL);
lv_obj_set_size(battery_settings_tile, hres , vres);
lv_obj_align(battery_settings_tile, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style( battery_settings_tile, LV_OBJ_PART_MAIN, &battery_settings_style );
// register an setup icon an set an callback
lv_obj_t *battery_setup = lv_imgbtn_create ( setup_tile_register_setup(), NULL);
lv_imgbtn_set_src( battery_setup, LV_BTN_STATE_RELEASED, &battery_icon_64px);
lv_imgbtn_set_src( battery_setup, LV_BTN_STATE_PRESSED, &battery_icon_64px);
lv_imgbtn_set_src( battery_setup, LV_BTN_STATE_CHECKED_RELEASED, &battery_icon_64px);
lv_imgbtn_set_src( battery_setup, LV_BTN_STATE_CHECKED_PRESSED, &battery_icon_64px);
lv_obj_add_style( battery_setup, LV_IMGBTN_PART_MAIN, mainbar_get_style() );
lv_obj_align( battery_setup, NULL, LV_ALIGN_CENTER, 0, 0 );
lv_obj_set_event_cb( battery_setup, enter_battery_setup_event_cb );
// create the battery settings */
lv_obj_t *exit_btn = lv_imgbtn_create( battery_settings_tile, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &battery_settings_style );
lv_obj_align( exit_btn, battery_settings_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_battery_setup_event_cb );
lv_obj_t *exit_label = lv_label_create( battery_settings_tile, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( exit_label, "battery");
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
lv_obj_t *battery_design_cont = lv_obj_create( battery_settings_tile, NULL );
lv_obj_set_size( battery_design_cont, hres , 25 );
lv_obj_add_style( battery_design_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( battery_design_cont, LV_HOR_RES_MAX , 25 );
lv_obj_add_style( battery_design_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_obj_align( battery_design_cont, battery_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
lv_obj_t *battery_design_cap_label = lv_label_create( battery_design_cont, NULL);
lv_obj_add_style( battery_design_cap_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( battery_design_cap_label, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( battery_design_cap_label, "designed cap");
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_obj_add_style( battery_design_cap, LV_OBJ_PART_MAIN, &battery_settings_style );
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 );
lv_obj_set_size( battery_current_cont, hres , 25 );
lv_obj_add_style( battery_current_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( battery_current_cont, LV_HOR_RES_MAX , 25 );
lv_obj_add_style( battery_current_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_obj_align( battery_current_cont, battery_design_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_t *battery_current_cap_label = lv_label_create( battery_current_cont, NULL);
lv_obj_add_style( battery_current_cap_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( battery_current_cap_label, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( battery_current_cap_label, "charged capacity");
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_obj_add_style( battery_current_cap, LV_OBJ_PART_MAIN, &battery_settings_style );
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 );
lv_obj_set_size( battery_voltage_cont, hres , 25 );
lv_obj_add_style( battery_voltage_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( battery_voltage_cont, LV_HOR_RES_MAX , 25 );
lv_obj_add_style( battery_voltage_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_obj_align( battery_voltage_cont, battery_current_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_t *battery_voltage_label = lv_label_create( battery_voltage_cont, NULL);
lv_obj_add_style( battery_voltage_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( battery_voltage_label, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( battery_voltage_label, "battery voltage");
lv_obj_align( battery_voltage_label, battery_voltage_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
battery_voltage = lv_label_create( battery_voltage_cont, NULL);
lv_obj_add_style( battery_voltage, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( battery_voltage, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( battery_voltage, "2.4mV");
lv_obj_align( battery_voltage, battery_voltage_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_t *battery_charge_cont = lv_obj_create( battery_settings_tile, NULL );
lv_obj_set_size( battery_charge_cont, hres , 25 );
lv_obj_add_style( battery_charge_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( battery_charge_cont, LV_HOR_RES_MAX , 25 );
lv_obj_add_style( battery_charge_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_obj_align( battery_charge_cont, battery_voltage_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 5 );
lv_obj_t *battery_charge_label = lv_label_create( battery_charge_cont, NULL);
lv_obj_add_style( battery_charge_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( battery_charge_label, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( battery_charge_label, "charge current");
lv_obj_align( battery_charge_label, battery_charge_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
charge_current = lv_label_create( battery_charge_cont, NULL);
lv_obj_add_style( charge_current, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( charge_current, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( charge_current, "100mA");
lv_obj_align( charge_current, battery_charge_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_t *battery_discharge_cont = lv_obj_create( battery_settings_tile, NULL );
lv_obj_set_size( battery_discharge_cont, hres , 25 );
lv_obj_add_style( battery_discharge_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( battery_discharge_cont, LV_HOR_RES_MAX , 25 );
lv_obj_add_style( battery_discharge_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_obj_align( battery_discharge_cont, battery_charge_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_t *battery_discharge_label = lv_label_create( battery_discharge_cont, NULL);
lv_obj_add_style( battery_discharge_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( battery_discharge_label, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( battery_discharge_label, "discharge current");
lv_obj_align( battery_discharge_label, battery_discharge_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
discharge_current = lv_label_create( battery_discharge_cont, NULL);
lv_obj_add_style( discharge_current, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( discharge_current, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( discharge_current, "100mA");
lv_obj_align( discharge_current, battery_discharge_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_t *vbus_voltage_cont = lv_obj_create( battery_settings_tile, NULL );
lv_obj_set_size( vbus_voltage_cont, hres , 25 );
lv_obj_add_style( vbus_voltage_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( vbus_voltage_cont, LV_HOR_RES_MAX , 25 );
lv_obj_add_style( vbus_voltage_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_obj_align( vbus_voltage_cont, battery_discharge_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_t *vbus_voltage_label = lv_label_create( vbus_voltage_cont, NULL);
lv_obj_add_style( vbus_voltage_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( vbus_voltage_label, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( vbus_voltage_label, "VBUS voltage");
lv_obj_align( vbus_voltage_label, vbus_voltage_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
vbus_voltage = lv_label_create( vbus_voltage_cont, NULL);
lv_obj_add_style( vbus_voltage, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( vbus_voltage, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( vbus_voltage, "2.4mV");
lv_obj_align( vbus_voltage, vbus_voltage_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
battery_task = lv_task_create(battery_update_task, 1000, LV_TASK_PRIO_LOWEST, NULL );
}
static void enter_battery_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( battery_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_battery_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( SETUP_TILE, LV_ANIM_OFF );
mainbar_jump_to_tilenumber( setup_get_tile_num() , LV_ANIM_OFF );
break;
}
}

View File

@@ -32,6 +32,6 @@
* @param hres horizonal resolution
* @param vres vertical resolution
*/
void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void battery_settings_tile_setup( void );
#endif // _BATTERY_SETTINGS_H

View File

@@ -23,90 +23,102 @@
#include "display_settings.h"
#include "gui/mainbar/mainbar.h"
#include "gui/mainbar/setup_tile/setup.h"
#include "gui/statusbar.h"
#include "hardware/display.h"
#include "hardware/motor.h"
lv_obj_t *display_settings_tile1 = NULL;
lv_obj_t *display_settings_tile=NULL;
lv_style_t display_settings_style;
uint32_t display_tile_num;
lv_obj_t *display_brightness_slider = NULL;
lv_obj_t *display_timeout_slider = NULL;
lv_obj_t *display_timeout_slider_label = NULL;
lv_obj_t *display_rotation_list = NULL;
lv_style_t display_settings_style;
LV_IMG_DECLARE(brightness_64px);
LV_IMG_DECLARE(exit_32px);
LV_IMG_DECLARE(brightness_32px);
LV_IMG_DECLARE(time_32px);
static void enter_display_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void exit_display_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void display_brightness_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void display_timeout_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void display_rotation_event_handler(lv_obj_t * obj, lv_event_t event);
void display_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_style_init( &display_settings_style );
lv_style_set_radius( &display_settings_style, LV_OBJ_PART_MAIN, 0);
void display_settings_tile_setup( void ) {
// get an app tile and copy mainstyle
display_tile_num = mainbar_add_app_tile( 1, 1 );
display_settings_tile = mainbar_get_tile_obj( display_tile_num );
lv_style_copy( &display_settings_style, mainbar_get_style() );
lv_style_set_bg_color( &display_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &display_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &display_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color( &display_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_style_set_image_recolor( &display_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_obj_add_style( display_settings_tile, LV_OBJ_PART_MAIN, &display_settings_style );
display_settings_tile1 = lv_obj_create( tile, NULL);
lv_obj_set_size(display_settings_tile1, hres , vres);
lv_obj_align(display_settings_tile1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style( display_settings_tile1, LV_OBJ_PART_MAIN, &display_settings_style );
// register an setup icon an set an callback
lv_obj_t *display_setup = lv_imgbtn_create ( setup_tile_register_setup(), NULL);
lv_imgbtn_set_src( display_setup, LV_BTN_STATE_RELEASED, &brightness_64px);
lv_imgbtn_set_src( display_setup, LV_BTN_STATE_PRESSED, &brightness_64px);
lv_imgbtn_set_src( display_setup, LV_BTN_STATE_CHECKED_RELEASED, &brightness_64px);
lv_imgbtn_set_src( display_setup, LV_BTN_STATE_CHECKED_PRESSED, &brightness_64px);
lv_obj_add_style( display_setup, LV_IMGBTN_PART_MAIN, mainbar_get_style() );
lv_obj_align( display_setup, NULL, LV_ALIGN_CENTER, 0, 0 );
lv_obj_set_event_cb( display_setup, enter_display_setup_event_cb );
lv_obj_t *exit_btn = lv_imgbtn_create( display_settings_tile1, NULL);
lv_obj_t *exit_btn = lv_imgbtn_create( display_settings_tile, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( exit_btn, display_settings_tile1, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &display_settings_style );
lv_obj_align( exit_btn, display_settings_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_display_setup_event_cb );
lv_obj_t *exit_label = lv_label_create( display_settings_tile1, NULL );
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, style );
lv_obj_t *exit_label = lv_label_create( display_settings_tile, NULL );
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &display_settings_style );
lv_label_set_text( exit_label, "display settings");
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
lv_obj_t *brightness_cont = lv_obj_create( display_settings_tile1, NULL );
lv_obj_set_size( brightness_cont, hres , 48 );
lv_obj_add_style( brightness_cont, LV_OBJ_PART_MAIN, style );
lv_obj_align( brightness_cont, display_settings_tile1, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
lv_obj_t *brightness_cont = lv_obj_create( display_settings_tile, NULL );
lv_obj_set_size( brightness_cont, LV_HOR_RES_MAX , 48 );
lv_obj_add_style( brightness_cont, LV_OBJ_PART_MAIN, &display_settings_style );
lv_obj_align( brightness_cont, display_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
display_brightness_slider = lv_slider_create( brightness_cont, NULL );
lv_slider_set_range( display_brightness_slider, DISPLAY_MIN_BRIGHTNESS, DISPLAY_MAX_BRIGHTNESS );
lv_obj_set_size( display_brightness_slider, hres - 100 , 10 );
lv_obj_set_size( display_brightness_slider, LV_HOR_RES_MAX - 100 , 10 );
lv_obj_align( display_brightness_slider, brightness_cont, LV_ALIGN_IN_RIGHT_MID, -30, 0 );
lv_obj_set_event_cb( display_brightness_slider, display_brightness_setup_event_cb );
lv_obj_t *brightness_icon = lv_img_create( brightness_cont, NULL );
lv_img_set_src( brightness_icon, &brightness_32px );
lv_obj_align( brightness_icon, brightness_cont, LV_ALIGN_IN_LEFT_MID, 15, 0 );
lv_obj_t *timeout_cont = lv_obj_create( display_settings_tile1, NULL );
lv_obj_set_size( timeout_cont, hres , 58 );
lv_obj_add_style( timeout_cont, LV_OBJ_PART_MAIN, style );
lv_obj_t *timeout_cont = lv_obj_create( display_settings_tile, NULL );
lv_obj_set_size( timeout_cont, LV_HOR_RES_MAX , 58 );
lv_obj_add_style( timeout_cont, LV_OBJ_PART_MAIN, &display_settings_style );
lv_obj_align( timeout_cont, brightness_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
display_timeout_slider = lv_slider_create( timeout_cont, NULL );
lv_slider_set_range( display_timeout_slider, DISPLAY_MIN_TIMEOUT, DISPLAY_MAX_TIMEOUT );
lv_obj_set_size(display_timeout_slider, hres - 100 , 10 );
lv_obj_set_size(display_timeout_slider, LV_HOR_RES_MAX - 100 , 10 );
lv_obj_align( display_timeout_slider, timeout_cont, LV_ALIGN_IN_TOP_RIGHT, -30, 10 );
lv_obj_set_event_cb( display_timeout_slider, display_timeout_setup_event_cb );
display_timeout_slider_label = lv_label_create( timeout_cont, NULL );
lv_obj_add_style( display_timeout_slider_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( display_timeout_slider_label, LV_OBJ_PART_MAIN, &display_settings_style );
lv_label_set_text( display_timeout_slider_label, "");
lv_obj_align( display_timeout_slider_label, display_timeout_slider, LV_ALIGN_OUT_BOTTOM_MID, 0, -5 );
lv_obj_t *timeout_icon = lv_img_create( timeout_cont, NULL );
lv_img_set_src( timeout_icon, &time_32px );
lv_obj_align( timeout_icon, timeout_cont, LV_ALIGN_IN_LEFT_MID, 15, 0 );
lv_obj_t *rotation_cont = lv_obj_create( display_settings_tile1, NULL );
lv_obj_set_size(rotation_cont, hres , 40 );
lv_obj_add_style( rotation_cont, LV_OBJ_PART_MAIN, style );
lv_obj_t *rotation_cont = lv_obj_create( display_settings_tile, NULL );
lv_obj_set_size(rotation_cont, LV_HOR_RES_MAX , 40 );
lv_obj_add_style( rotation_cont, LV_OBJ_PART_MAIN, &display_settings_style );
lv_obj_align( rotation_cont, timeout_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_t *display_rotation_label = lv_label_create( rotation_cont, NULL );
lv_obj_add_style( display_rotation_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( display_rotation_label, LV_OBJ_PART_MAIN, &display_settings_style );
lv_label_set_text( display_rotation_label, "rotation in degree" );
lv_obj_align( display_rotation_label, rotation_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
display_rotation_list = lv_dropdown_create( rotation_cont, NULL );
@@ -129,11 +141,19 @@ void display_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
lv_dropdown_set_selected( display_rotation_list, display_get_rotation() / 90 );
}
static void enter_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( display_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( SETUP_TILE, LV_ANIM_OFF );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
display_save_config();
break;
}

View File

@@ -32,6 +32,6 @@
* @param hres horizonal resolution
* @param vres vertical resolution
*/
void display_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void display_settings_tile_setup( void );
#endif // _DISPLAY_SETTINGS_H

View File

@@ -23,73 +23,83 @@
#include "move_settings.h"
#include "gui/mainbar/mainbar.h"
#include "gui/mainbar/setup_tile/setup.h"
#include "gui/statusbar.h"
#include "hardware/bma.h"
#include "hardware/motor.h"
lv_obj_t *move_settings_tile1=NULL;
lv_obj_t *move_settings_tile=NULL;
lv_style_t move_settings_style;
uint32_t move_tile_num;
lv_obj_t *stepcounter_onoff=NULL;
lv_obj_t *doubleclick_onoff=NULL;
lv_style_t move_settings_style;
LV_IMG_DECLARE(exit_32px);
LV_IMG_DECLARE(move_32px);
LV_IMG_DECLARE(move_64px);
static void enter_move_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void exit_move_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void stepcounter_onoff_event_handler(lv_obj_t * obj, lv_event_t event);
static void doubleclick_onoff_event_handler(lv_obj_t * obj, lv_event_t event);
void move_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_style_init( &move_settings_style );
lv_style_set_radius( &move_settings_style, LV_OBJ_PART_MAIN, 0);
void move_settings_tile_setup( void ) {
// get an app tile and copy mainstyle
move_tile_num = mainbar_add_app_tile( 1, 1 );
move_settings_tile = mainbar_get_tile_obj( move_tile_num );
lv_style_copy( &move_settings_style, mainbar_get_style() );
lv_style_set_bg_color( &move_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &move_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &move_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color( &move_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_style_set_image_recolor( &move_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_obj_add_style( move_settings_tile, LV_OBJ_PART_MAIN, &move_settings_style );
move_settings_tile1 = lv_obj_create( tile, NULL);
lv_obj_set_size(move_settings_tile1, hres , vres);
lv_obj_align(move_settings_tile1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style( move_settings_tile1, LV_OBJ_PART_MAIN, &move_settings_style );
// register an setup icon an set an callback
lv_obj_t *move_setup = lv_imgbtn_create ( setup_tile_register_setup(), NULL);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_RELEASED, &move_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_PRESSED, &move_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_CHECKED_RELEASED, &move_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_CHECKED_PRESSED, &move_64px);
lv_obj_add_style( move_setup, LV_IMGBTN_PART_MAIN, mainbar_get_style() );
lv_obj_align( move_setup, NULL, LV_ALIGN_CENTER, 0, 0 );
lv_obj_set_event_cb( move_setup, enter_move_setup_event_cb );
lv_obj_t *exit_btn = lv_imgbtn_create( move_settings_tile1, NULL);
lv_obj_t *exit_btn = lv_imgbtn_create( move_settings_tile, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( exit_btn, move_settings_tile1, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &move_settings_style );
lv_obj_align( exit_btn, move_settings_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_move_setup_event_cb );
lv_obj_t *exit_label = lv_label_create( move_settings_tile1, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, style );
lv_obj_t *exit_label = lv_label_create( move_settings_tile, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &move_settings_style );
lv_label_set_text( exit_label, "movement settings");
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
lv_obj_t *stepcounter_cont = lv_obj_create( move_settings_tile1, NULL );
lv_obj_set_size(stepcounter_cont, hres , 40);
lv_obj_add_style( stepcounter_cont, LV_OBJ_PART_MAIN, style );
lv_obj_align( stepcounter_cont, move_settings_tile1, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
lv_obj_t *stepcounter_cont = lv_obj_create( move_settings_tile, NULL );
lv_obj_set_size(stepcounter_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( stepcounter_cont, LV_OBJ_PART_MAIN, &move_settings_style );
lv_obj_align( stepcounter_cont, move_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
stepcounter_onoff = lv_switch_create( stepcounter_cont, NULL );
lv_switch_off( stepcounter_onoff, LV_ANIM_ON );
lv_obj_align( stepcounter_onoff, stepcounter_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( stepcounter_onoff, stepcounter_onoff_event_handler );
lv_obj_t *stepcounter_label = lv_label_create( stepcounter_cont, NULL);
lv_obj_add_style( stepcounter_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( stepcounter_label, LV_OBJ_PART_MAIN, &move_settings_style );
lv_label_set_text( stepcounter_label, "step counter");
lv_obj_align( stepcounter_label, stepcounter_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_obj_t *doubleclick_cont = lv_obj_create( move_settings_tile1, NULL );
lv_obj_set_size(doubleclick_cont, hres , 40);
lv_obj_add_style( doubleclick_cont, LV_OBJ_PART_MAIN, style );
lv_obj_t *doubleclick_cont = lv_obj_create( move_settings_tile, NULL );
lv_obj_set_size(doubleclick_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( doubleclick_cont, LV_OBJ_PART_MAIN, &move_settings_style );
lv_obj_align( doubleclick_cont, stepcounter_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
doubleclick_onoff = lv_switch_create( doubleclick_cont, NULL );
lv_switch_off( doubleclick_onoff, LV_ANIM_ON );
lv_obj_align( doubleclick_onoff, doubleclick_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( doubleclick_onoff, doubleclick_onoff_event_handler );
lv_obj_t *doubleclick_label = lv_label_create( doubleclick_cont, NULL);
lv_obj_add_style( doubleclick_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( doubleclick_label, LV_OBJ_PART_MAIN, &move_settings_style );
lv_label_set_text( doubleclick_label, "double click");
lv_obj_align( doubleclick_label, doubleclick_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
@@ -105,10 +115,18 @@ void move_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
}
static void enter_move_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( move_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_move_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( SETUP_TILE, LV_ANIM_OFF );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
break;
}
}

View File

@@ -24,6 +24,6 @@
#include <TTGO.h>
void move_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void move_settings_tile_setup( void );
#endif // _MOVE_SETTINGS_TILE_H

View File

@@ -25,121 +25,47 @@
#include "gui/mainbar/mainbar.h"
#include "hardware/motor.h"
static void wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void battery_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void move_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void display_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void time_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void update_setup_event_cb( lv_obj_t * obj, lv_event_t event );
lv_setup_entry_t setup_entry[ MAX_SETUP_ICON ];
LV_IMG_DECLARE(wifi_64px);
LV_IMG_DECLARE(battery_icon_64px);
LV_IMG_DECLARE(move_64px);
LV_IMG_DECLARE(brightness_64px);
LV_IMG_DECLARE(time_64px);
LV_IMG_DECLARE(update_64px);
lv_obj_t *setup_cont = NULL;
lv_style_t setup_style;
uint32_t setup_tile_num;
void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
void setup_tile_setup( void ) {
setup_tile_num = mainbar_add_tile( 1, 1 );
setup_cont = mainbar_get_tile_obj( setup_tile_num );
lv_style_copy( &setup_style, mainbar_get_style() );
lv_obj_t * wifi_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src(wifi_setup, LV_BTN_STATE_RELEASED, &wifi_64px);
lv_imgbtn_set_src(wifi_setup, LV_BTN_STATE_PRESSED, &wifi_64px);
lv_imgbtn_set_src(wifi_setup, LV_BTN_STATE_CHECKED_RELEASED, &wifi_64px);
lv_imgbtn_set_src(wifi_setup, LV_BTN_STATE_CHECKED_PRESSED, &wifi_64px);
lv_obj_add_style(wifi_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align(wifi_setup, tile, LV_ALIGN_IN_TOP_LEFT, 16, 48 );
lv_obj_set_event_cb( wifi_setup, wifi_setup_event_cb );
for ( int setup = 0 ; setup < MAX_SETUP_ICON ; setup++ ) {
// set x, y and mark it as inactive
setup_entry[ setup ].x = SETUP_FIRST_X_POS + ( ( setup % MAX_SETUP_ICON_HORZ ) * ( SETUP_ICON_X_SIZE + SETUP_ICON_X_CLEARENCE ) );
setup_entry[ setup ].y = SETUP_FIRST_Y_POS + ( ( setup / MAX_SETUP_ICON_HORZ ) * ( SETUP_ICON_Y_SIZE + SETUP_ICON_Y_CLEARENCE ) );
setup_entry[ setup ].active = false;
// create app icon container
setup_entry[ setup ].setup = lv_obj_create( setup_cont, NULL );
lv_obj_reset_style_list( setup_entry[ setup ].setup, LV_OBJ_PART_MAIN );
lv_obj_add_style( setup_entry[ setup ].setup, LV_OBJ_PART_MAIN, &setup_style );
lv_obj_set_size( setup_entry[ setup ].setup, SETUP_ICON_X_SIZE, SETUP_ICON_Y_SIZE );
lv_obj_align( setup_entry[ setup ].setup , setup_cont, LV_ALIGN_IN_TOP_LEFT, setup_entry[ setup ].x, setup_entry[ setup ].y );
lv_obj_t * battery_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src( battery_setup, LV_BTN_STATE_RELEASED, &battery_icon_64px);
lv_imgbtn_set_src( battery_setup, LV_BTN_STATE_PRESSED, &battery_icon_64px);
lv_imgbtn_set_src( battery_setup, LV_BTN_STATE_CHECKED_RELEASED, &battery_icon_64px);
lv_imgbtn_set_src( battery_setup, LV_BTN_STATE_CHECKED_PRESSED, &battery_icon_64px);
lv_obj_add_style( battery_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( battery_setup, tile, LV_ALIGN_IN_TOP_LEFT, 16+70, 48 );
lv_obj_set_event_cb( battery_setup, battery_setup_event_cb );
lv_obj_set_hidden( setup_entry[ setup ].setup, true );
lv_obj_t * move_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_RELEASED, &move_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_PRESSED, &move_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_CHECKED_RELEASED, &move_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_CHECKED_PRESSED, &move_64px);
lv_obj_add_style( move_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( move_setup, tile, LV_ALIGN_IN_TOP_LEFT, 16, 48+86 );
lv_obj_set_event_cb( move_setup, move_setup_event_cb );
lv_obj_t * brightness_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src( brightness_setup, LV_BTN_STATE_RELEASED, &brightness_64px);
lv_imgbtn_set_src( brightness_setup, LV_BTN_STATE_PRESSED, &brightness_64px);
lv_imgbtn_set_src( brightness_setup, LV_BTN_STATE_CHECKED_RELEASED, &brightness_64px);
lv_imgbtn_set_src( brightness_setup, LV_BTN_STATE_CHECKED_PRESSED, &brightness_64px);
lv_obj_add_style( brightness_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( brightness_setup, tile, LV_ALIGN_IN_TOP_LEFT, 16+70, 48+86 );
lv_obj_set_event_cb( brightness_setup, display_setup_event_cb );
lv_obj_t * time_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src( time_setup, LV_BTN_STATE_RELEASED, &time_64px);
lv_imgbtn_set_src( time_setup, LV_BTN_STATE_PRESSED, &time_64px);
lv_imgbtn_set_src( time_setup, LV_BTN_STATE_CHECKED_RELEASED, &time_64px);
lv_imgbtn_set_src( time_setup, LV_BTN_STATE_CHECKED_PRESSED, &time_64px);
lv_obj_add_style( time_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( time_setup, tile, LV_ALIGN_IN_TOP_LEFT, 16+70+70, 48 );
lv_obj_set_event_cb( time_setup, time_setup_event_cb );
lv_obj_t * update_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src( update_setup, LV_BTN_STATE_RELEASED, &update_64px);
lv_imgbtn_set_src( update_setup, LV_BTN_STATE_PRESSED, &update_64px);
lv_imgbtn_set_src( update_setup, LV_BTN_STATE_CHECKED_RELEASED, &update_64px);
lv_imgbtn_set_src( update_setup, LV_BTN_STATE_CHECKED_PRESSED, &update_64px);
lv_obj_add_style( update_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( update_setup, tile, LV_ALIGN_IN_TOP_LEFT, 16+70+70, 48+86 );
lv_obj_set_event_cb( update_setup, update_setup_event_cb );
}
static void wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( WLAN_SETTINGS_TILE, LV_ANIM_OFF );
break;
log_d("icon x/y: %d/%d", setup_entry[ setup ].x, setup_entry[ setup ].y );
}
}
static void battery_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( BATTERY_SETTINGS_TILE, LV_ANIM_OFF );
break;
lv_obj_t *setup_tile_register_setup( void ) {
for( int setup = 0 ; setup < MAX_SETUP_ICON ; setup++ ) {
if ( setup_entry[ setup ].active == false ) {
setup_entry[ setup ].active = true;
lv_obj_set_hidden( setup_entry[ setup ].setup, false );
return( setup_entry[ setup ].setup );
}
}
log_e("no space for an setup icon");
return( NULL );
}
static void move_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( MOVE_SETTINGS_TILE, LV_ANIM_OFF );
break;
}
uint32_t setup_get_tile_num( void ) {
return( setup_tile_num );
}
static void display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( DISPLAY_SETTINGS_TILE, LV_ANIM_OFF );
break;
}
}
static void time_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( TIME_SETTINGS_TILE, LV_ANIM_OFF );
break;
}
}
static void update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( UPDATE_SETTINGS_TILE, LV_ANIM_OFF );
break;
}
}

View File

@@ -24,6 +24,28 @@
#include <TTGO.h>
#define MAX_SETUP_ICON_HORZ 3
#define MAX_SETUP_ICON_VERT 2
#define MAX_SETUP_ICON ( MAX_SETUP_ICON_HORZ * MAX_SETUP_ICON_VERT )
#define SETUP_ICON_X_SIZE 64
#define SETUP_ICON_Y_SIZE 64
#define SETUP_ICON_X_CLEARENCE 8
#define SETUP_ICON_Y_CLEARENCE 16
#define SETUP_LABEL_X_SIZE SETUP_ICON_X_SIZE + SETUP_ICON_X_CLEARENCE
#define SETUP_LABEL_Y_SIZE SETUP_ICON_Y_CLEARENCE / 2
#define SETUP_FIRST_X_POS ( 240 - ( SETUP_ICON_X_SIZE * MAX_SETUP_ICON_HORZ + SETUP_ICON_X_CLEARENCE * ( MAX_SETUP_ICON_HORZ - 1 ) ) ) / 2
#define SETUP_FIRST_Y_POS ( 240 - ( SETUP_ICON_Y_SIZE * MAX_SETUP_ICON_VERT + SETUP_ICON_Y_CLEARENCE * ( MAX_SETUP_ICON_VERT - 1 ) ) ) / 2
typedef struct {
lv_obj_t *setup;
lv_obj_t *label;
lv_coord_t x;
lv_coord_t y;
bool active;
} lv_setup_entry_t;
/*
* @brief setup the setup tile
*
@@ -32,6 +54,8 @@
* @param hres horizonal resolution
* @param vres vertical resolution
*/
void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void setup_tile_setup( void );
lv_obj_t *setup_tile_register_setup( void );
uint32_t setup_get_tile_num( void );
#endif // _SETUP_H

View File

@@ -24,84 +24,95 @@
#include <WiFi.h>
#include "gui/mainbar/mainbar.h"
#include "gui/mainbar/setup_tile/setup.h"
#include "gui/statusbar.h"
#include "hardware/timesync.h"
#include "hardware/motor.h"
lv_obj_t *time_settings_tile=NULL;
lv_style_t time_settings_style;
uint32_t time_tile_num;
lv_obj_t *utczone_list = NULL;
lv_obj_t *wifisync_onoff = NULL;
lv_obj_t *daylight_onoff = NULL;
LV_IMG_DECLARE(exit_32px);
LV_IMG_DECLARE(time_32px);
LV_IMG_DECLARE(time_64px);
static void enter_time_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void exit_time_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void wifisync_onoff_event_handler(lv_obj_t * obj, lv_event_t event);
static void daylight_onoff_event_handler(lv_obj_t * obj, lv_event_t event);
static void utczone_event_handler(lv_obj_t * obj, lv_event_t event);
void time_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_style_init( &time_settings_style );
lv_style_set_radius( &time_settings_style, LV_OBJ_PART_MAIN, 0);
void time_settings_tile_setup( void ) {
// get an app tile and copy mainstyle
time_tile_num = mainbar_add_app_tile( 1, 1 );
time_settings_tile = mainbar_get_tile_obj( time_tile_num );
lv_style_copy( &time_settings_style, mainbar_get_style() );
lv_style_set_bg_color( &time_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &time_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &time_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color( &time_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_style_set_image_recolor( &time_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
time_settings_tile = lv_obj_create( tile, NULL);
lv_obj_set_size(time_settings_tile, hres , vres);
lv_obj_align(time_settings_tile, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style( time_settings_tile, LV_OBJ_PART_MAIN, &time_settings_style );
// register an setup icon an set an callback
lv_obj_t *move_setup = lv_imgbtn_create ( setup_tile_register_setup(), NULL);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_RELEASED, &time_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_PRESSED, &time_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_CHECKED_RELEASED, &time_64px);
lv_imgbtn_set_src( move_setup, LV_BTN_STATE_CHECKED_PRESSED, &time_64px);
lv_obj_add_style( move_setup, LV_IMGBTN_PART_MAIN, mainbar_get_style() );
lv_obj_align( move_setup, NULL, LV_ALIGN_CENTER, 0, 0 );
lv_obj_set_event_cb( move_setup, enter_time_setup_event_cb );
lv_obj_t *exit_btn = lv_imgbtn_create( time_settings_tile, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &time_settings_style );
lv_obj_align( exit_btn, time_settings_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_time_setup_event_cb );
lv_obj_t *exit_label = lv_label_create( time_settings_tile, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &time_settings_style );
lv_label_set_text( exit_label, "time settings");
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
lv_obj_t *wifisync_cont = lv_obj_create( time_settings_tile, NULL );
lv_obj_set_size(wifisync_cont, hres , 40);
lv_obj_add_style( wifisync_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size(wifisync_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( wifisync_cont, LV_OBJ_PART_MAIN, &time_settings_style );
lv_obj_align( wifisync_cont, time_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
wifisync_onoff = lv_switch_create( wifisync_cont, NULL );
lv_switch_off( wifisync_onoff, LV_ANIM_ON );
lv_obj_align( wifisync_onoff, wifisync_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( wifisync_onoff, wifisync_onoff_event_handler );
lv_obj_t *wifisync_label = lv_label_create( wifisync_cont, NULL);
lv_obj_add_style( wifisync_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( wifisync_label, LV_OBJ_PART_MAIN, &time_settings_style );
lv_label_set_text( wifisync_label, "sync when connect");
lv_obj_align( wifisync_label, wifisync_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_obj_t *daylight_cont = lv_obj_create( time_settings_tile, NULL );
lv_obj_set_size(daylight_cont, hres , 40);
lv_obj_add_style( daylight_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size(daylight_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( daylight_cont, LV_OBJ_PART_MAIN, &time_settings_style );
lv_obj_align( daylight_cont, wifisync_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
daylight_onoff = lv_switch_create( daylight_cont, NULL );
lv_switch_off( daylight_onoff, LV_ANIM_ON );
lv_obj_align( daylight_onoff, daylight_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( daylight_onoff, daylight_onoff_event_handler );
lv_obj_t *daylight_label = lv_label_create( daylight_cont, NULL);
lv_obj_add_style( daylight_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( daylight_label, LV_OBJ_PART_MAIN, &time_settings_style );
lv_label_set_text( daylight_label, "daylight saving");
lv_obj_align( daylight_label, daylight_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_obj_t *utczone_cont = lv_obj_create( time_settings_tile, NULL );
lv_obj_set_size(utczone_cont, hres , 40);
lv_obj_add_style( utczone_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size(utczone_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( utczone_cont, LV_OBJ_PART_MAIN, &time_settings_style );
lv_obj_align( utczone_cont, daylight_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_t *utczone_label = lv_label_create( utczone_cont, NULL);
lv_obj_add_style( utczone_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( utczone_label, LV_OBJ_PART_MAIN, &time_settings_style );
lv_label_set_text( utczone_label, "utc timezone");
lv_obj_align( utczone_label, utczone_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
utczone_list = lv_dropdown_create( utczone_cont, NULL);
@@ -123,10 +134,18 @@ void time_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
lv_dropdown_set_selected( utczone_list, timesync_get_timezone() + 12 );
}
static void enter_time_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( time_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_time_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( SETUP_TILE, LV_ANIM_OFF );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
break;
}
}

View File

@@ -32,6 +32,6 @@
* @param hres horizonal resolution
* @param vres vertical resolution
*/
void time_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void time_settings_tile_setup( void );
#endif // _TIME_SETTINGS_H

View File

@@ -29,6 +29,7 @@
#include "update_check_version.h"
#include "gui/mainbar/mainbar.h"
#include "gui/mainbar/setup_tile/setup.h"
#include "gui/statusbar.h"
#include "hardware/display.h"
#include "hardware/motor.h"
@@ -37,55 +38,64 @@ EventGroupHandle_t update_event_handle = NULL;
TaskHandle_t _update_Task;
void update_Task( void * pvParameters );
lv_obj_t *update_settings_tile = NULL;
lv_obj_t *update_settings_tile=NULL;
lv_style_t update_settings_style;
uint32_t update_tile_num;
lv_obj_t *update_btn = NULL;
lv_obj_t *update_status_label = NULL;
lv_style_t update_settings_style;
static void enter_update_setup_event_cb( lv_obj_t * obj, lv_event_t event );
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 );
LV_IMG_DECLARE(exit_32px);
LV_IMG_DECLARE(time_32px);
LV_IMG_DECLARE(update_64px);
void update_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_style_init( &update_settings_style );
lv_style_set_radius( &update_settings_style, LV_OBJ_PART_MAIN, 0);
void update_tile_setup( void ) {
// get an app tile and copy mainstyle
update_tile_num = mainbar_add_app_tile( 1, 1 );
update_settings_tile = mainbar_get_tile_obj( update_tile_num );
lv_style_copy( &update_settings_style, mainbar_get_style() );
lv_style_set_bg_color( &update_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &update_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &update_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color( &update_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_style_set_image_recolor( &update_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
update_settings_tile = lv_obj_create( tile, NULL);
lv_obj_set_size( update_settings_tile, hres , vres);
lv_obj_align( update_settings_tile, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style( update_settings_tile, LV_OBJ_PART_MAIN, &update_settings_style );
// register an setup icon an set an callback
lv_obj_t *update_setup = lv_imgbtn_create ( setup_tile_register_setup(), NULL);
lv_imgbtn_set_src( update_setup, LV_BTN_STATE_RELEASED, &update_64px);
lv_imgbtn_set_src( update_setup, LV_BTN_STATE_PRESSED, &update_64px);
lv_imgbtn_set_src( update_setup, LV_BTN_STATE_CHECKED_RELEASED, &update_64px);
lv_imgbtn_set_src( update_setup, LV_BTN_STATE_CHECKED_PRESSED, &update_64px);
lv_obj_add_style( update_setup, LV_IMGBTN_PART_MAIN, mainbar_get_style() );
lv_obj_align( update_setup, NULL, LV_ALIGN_CENTER, 0, 0 );
lv_obj_set_event_cb( update_setup, enter_update_setup_event_cb );
lv_obj_t *exit_btn = lv_imgbtn_create( update_settings_tile, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &update_settings_style );
lv_obj_align( exit_btn, update_settings_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_update_setup_event_cb );
lv_obj_t *exit_label = lv_label_create( update_settings_tile, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &update_settings_style );
lv_label_set_text( exit_label, "update");
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
lv_obj_t *update_version_cont = lv_obj_create( update_settings_tile, NULL );
lv_obj_set_size(update_version_cont, hres , 40);
lv_obj_add_style( update_version_cont, LV_OBJ_PART_MAIN, style );
lv_obj_set_size(update_version_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( update_version_cont, LV_OBJ_PART_MAIN, &update_settings_style );
lv_obj_align( update_version_cont, update_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
lv_obj_t *update_version_label = lv_label_create( update_version_cont, NULL);
lv_obj_add_style( update_version_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( update_version_label, LV_OBJ_PART_MAIN, &update_settings_style );
lv_label_set_text( update_version_label, "firmware version" );
lv_obj_align( update_version_label, update_version_cont, LV_ALIGN_IN_TOP_MID, 0, 0 );
lv_obj_t *update_firmware_version_label = lv_label_create( update_version_cont, NULL);
lv_obj_add_style( update_firmware_version_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( update_firmware_version_label, LV_OBJ_PART_MAIN, &update_settings_style );
lv_label_set_text( update_firmware_version_label, __FIRMWARE__ );
lv_obj_align( update_firmware_version_label, update_version_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0 );
@@ -96,7 +106,7 @@ void update_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_c
lv_label_set_text( update_btn_label, "update");
update_status_label = lv_label_create( update_settings_tile, NULL);
lv_obj_add_style( update_status_label, LV_OBJ_PART_MAIN, style );
lv_obj_add_style( update_status_label, LV_OBJ_PART_MAIN, &update_settings_style );
lv_label_set_text( update_status_label, "" );
lv_obj_align( update_status_label, update_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 5 );
@@ -117,10 +127,17 @@ void update_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_c
&_update_Task ); /* Task handle. */
}
static void enter_update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( update_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( SETUP_TILE, LV_ANIM_OFF );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
break;
}
}

View File

@@ -29,7 +29,7 @@
#define FIRMWARE_LOCATION "https://github.com/sharandac/My-TTGO-Watch/blob/master/ttgo-t-watch2020_v1.ino.bin"
void update_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void update_tile_setup( void );
void update_check_version( void );
void update_update_firmware( void );

View File

@@ -23,6 +23,7 @@
#include "wlan_settings.h"
#include "gui/mainbar/mainbar.h"
#include "gui/mainbar/setup_tile/setup.h"
#include "gui/statusbar.h"
#include "gui/keyboard.h"
@@ -33,14 +34,22 @@
LV_IMG_DECLARE(exit_32px);
lv_obj_t *wlan_settings_tile1=NULL;
lv_obj_t *wifi_settings_tile=NULL;
lv_style_t wifi_settings_style;
lv_style_t wifi_password_style;
lv_style_t wifi_list_style;
uint32_t wifi_settings_tile_num;
lv_obj_t *wifi_password_tile=NULL;
lv_obj_t *wifi_password_name_label=NULL;
lv_obj_t *wifi_password_pass_textfield=NULL;
uint32_t wifi_password_tile_num;
lv_obj_t *wifi_onoff=NULL;
lv_obj_t *wifiname_list=NULL;
lv_style_t wlan_settings_style;
lv_style_t wlan_list_style;
static void enter_wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void exit_wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void exit_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event );
static void wifi_onoff_event_handler(lv_obj_t * obj, lv_event_t event);
void wifi_settings_enter_pass_event_cb( lv_obj_t * obj, lv_event_t event );
void WiFiScanDone(WiFiEvent_t event, WiFiEventInfo_t info);
@@ -50,48 +59,57 @@ LV_IMG_DECLARE(unlock_16px);
LV_IMG_DECLARE(check_32px);
LV_IMG_DECLARE(exit_32px);
LV_IMG_DECLARE(trash_32px);
LV_IMG_DECLARE(wifi_64px);
void wlan_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_style_init( &wlan_settings_style );
lv_style_set_radius( &wlan_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_bg_color( &wlan_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &wlan_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &wlan_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color( &wlan_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_style_set_image_recolor( &wlan_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
void wlan_settings_tile_setup( void ) {
// get an app tile and copy mainstyle
wifi_settings_tile_num = mainbar_add_app_tile( 2, 1 );
wifi_password_tile_num = wifi_settings_tile_num + 1;
wlan_settings_tile1 = lv_obj_create( tile, NULL);
lv_obj_set_size(wlan_settings_tile1, hres , vres);
lv_obj_align(wlan_settings_tile1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style( wlan_settings_tile1, LV_OBJ_PART_MAIN, &wlan_settings_style );
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_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 );
lv_obj_t *exit_btn = lv_imgbtn_create( wlan_settings_tile1, NULL);
// register an setup icon an set an callback
lv_obj_t *wifi_setup = lv_imgbtn_create ( setup_tile_register_setup(), NULL);
lv_imgbtn_set_src( wifi_setup, LV_BTN_STATE_RELEASED, &wifi_64px);
lv_imgbtn_set_src( wifi_setup, LV_BTN_STATE_PRESSED, &wifi_64px);
lv_imgbtn_set_src( wifi_setup, LV_BTN_STATE_CHECKED_RELEASED, &wifi_64px);
lv_imgbtn_set_src( wifi_setup, LV_BTN_STATE_CHECKED_PRESSED, &wifi_64px);
lv_obj_add_style( wifi_setup, LV_IMGBTN_PART_MAIN, mainbar_get_style() );
lv_obj_align( wifi_setup, NULL, LV_ALIGN_CENTER, 0, 0 );
lv_obj_set_event_cb( wifi_setup, enter_wifi_setup_event_cb );
lv_obj_t *exit_btn = lv_imgbtn_create( wifi_settings_tile, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( exit_btn, wlan_settings_tile1, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &wifi_settings_style );
lv_obj_align( exit_btn, wifi_settings_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_wifi_setup_event_cb );
lv_obj_t *exit_label = lv_label_create( wlan_settings_tile1, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, style );
lv_obj_t *exit_label = lv_label_create( wifi_settings_tile, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &wifi_settings_style );
lv_label_set_text( exit_label, "wlan settings");
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
/*Copy the first switch and turn it ON*/
wifi_onoff = lv_switch_create( wlan_settings_tile1, NULL );
wifi_onoff = lv_switch_create( wifi_settings_tile, NULL );
lv_switch_off( wifi_onoff, LV_ANIM_ON );
lv_obj_align( wifi_onoff, exit_label, LV_ALIGN_OUT_RIGHT_MID, 30, 0 );
lv_obj_set_event_cb( wifi_onoff, wifi_onoff_event_handler);
wifiname_list = lv_list_create( wlan_settings_tile1, NULL);
lv_obj_set_size( wifiname_list, hres, 160);
lv_style_init( &wlan_list_style );
lv_style_set_border_width( &wlan_list_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_radius( &wlan_list_style, LV_OBJ_PART_MAIN, 0);
lv_obj_add_style( wifiname_list, LV_OBJ_PART_MAIN, &wlan_list_style );
lv_obj_align( wifiname_list, wlan_settings_tile1, LV_ALIGN_IN_TOP_MID, 0, 80);
wifiname_list = lv_list_create( wifi_settings_tile, NULL);
lv_obj_set_size( wifiname_list, LV_HOR_RES_MAX, 160);
lv_style_init( &wifi_list_style );
lv_style_set_border_width( &wifi_list_style , LV_OBJ_PART_MAIN, 0);
lv_style_set_radius( &wifi_list_style , LV_OBJ_PART_MAIN, 0);
lv_obj_add_style( wifiname_list, LV_OBJ_PART_MAIN, &wifi_list_style );
lv_obj_align( wifiname_list, wifi_settings_tile, LV_ALIGN_IN_TOP_MID, 0, 80);
WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info) {
lv_switch_on( wifi_onoff, LV_ANIM_OFF );
@@ -103,123 +121,40 @@ void wlan_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
}, WiFiEvent_t::SYSTEM_EVENT_STA_STOP );
WiFi.onEvent( WiFiScanDone, WiFiEvent_t::SYSTEM_EVENT_SCAN_DONE );
wlan_password_tile_setup( wifi_password_tile_num );
}
lv_obj_t *wlan_password_tile1=NULL;
lv_obj_t *wlan_password_name_label=NULL;
lv_obj_t *wlan_password_pass_textfield=NULL;
static void wlan_password_event_cb(lv_obj_t * obj, lv_event_t event);
static void apply_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event );
static void delete_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event );
void wlan_password_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_style_init( &wlan_settings_style );
lv_style_set_radius( &wlan_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_bg_color( &wlan_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &wlan_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &wlan_settings_style, LV_OBJ_PART_MAIN, 0);
lv_style_set_text_color( &wlan_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
lv_style_set_image_recolor( &wlan_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
wlan_password_tile1 = lv_obj_create( tile, NULL);
lv_obj_set_size (wlan_password_tile1, hres , vres);
lv_obj_align( wlan_password_tile1, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_style( wlan_password_tile1, LV_OBJ_PART_MAIN, &wlan_settings_style );
lv_obj_t *exit_btn = lv_imgbtn_create( wlan_password_tile1, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( exit_btn, wlan_password_tile1, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_wifi_password_event_cb );
wlan_password_name_label = lv_label_create( wlan_password_tile1, NULL);
lv_obj_add_style( wlan_password_name_label, LV_OBJ_PART_MAIN, style );
lv_label_set_text( wlan_password_name_label, "wlan setting");
lv_obj_align( wlan_password_name_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
wlan_password_pass_textfield = lv_textarea_create( wlan_password_tile1, NULL);
lv_textarea_set_text( wlan_password_pass_textfield, "");
lv_textarea_set_pwd_mode( wlan_password_pass_textfield, false);
lv_textarea_set_one_line( wlan_password_pass_textfield, true);
lv_textarea_set_cursor_hidden( wlan_password_pass_textfield, true);
lv_obj_set_width( wlan_password_pass_textfield, LV_HOR_RES );
lv_obj_align( wlan_password_pass_textfield, wlan_password_tile1, LV_ALIGN_IN_TOP_LEFT, 0, 75);
lv_obj_set_event_cb( wlan_password_pass_textfield, wlan_password_event_cb );
lv_obj_t *mac_label = lv_label_create( wlan_password_tile1, NULL);
lv_obj_add_style( mac_label, LV_IMGBTN_PART_MAIN, style);
lv_obj_set_width( mac_label, LV_HOR_RES);
lv_obj_align( mac_label, wlan_password_tile1, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text_fmt( mac_label, "MAC: %s", WiFi.macAddress().c_str());
lv_obj_t *apply_btn = lv_imgbtn_create( wlan_password_tile1, NULL);
lv_imgbtn_set_src( apply_btn, LV_BTN_STATE_RELEASED, &check_32px);
lv_imgbtn_set_src( apply_btn, LV_BTN_STATE_PRESSED, &check_32px);
lv_imgbtn_set_src( apply_btn, LV_BTN_STATE_CHECKED_RELEASED, &check_32px);
lv_imgbtn_set_src( apply_btn, LV_BTN_STATE_CHECKED_PRESSED, &check_32px);
lv_obj_add_style( apply_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( apply_btn, wlan_password_pass_textfield, LV_ALIGN_OUT_BOTTOM_RIGHT, -10, 10 );
lv_obj_set_event_cb( apply_btn, apply_wifi_password_event_cb );
lv_obj_t *delete_btn = lv_imgbtn_create( wlan_password_tile1, NULL);
lv_imgbtn_set_src( delete_btn, LV_BTN_STATE_RELEASED, &trash_32px);
lv_imgbtn_set_src( delete_btn, LV_BTN_STATE_PRESSED, &trash_32px);
lv_imgbtn_set_src( delete_btn, LV_BTN_STATE_CHECKED_RELEASED, &trash_32px);
lv_imgbtn_set_src( delete_btn, LV_BTN_STATE_CHECKED_PRESSED, &trash_32px);
lv_obj_add_style( delete_btn, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( delete_btn, wlan_password_pass_textfield, LV_ALIGN_OUT_BOTTOM_LEFT, 10, 10 );
lv_obj_set_event_cb( delete_btn, delete_wifi_password_event_cb );
}
static void apply_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
if(event == LV_EVENT_CLICKED) {
motor_vibe( 1 );
wifictl_insert_network( lv_label_get_text( wlan_password_name_label ), lv_textarea_get_text( wlan_password_pass_textfield ) );
keyboard_hide();
mainbar_jump_to_tilenumber( WLAN_SETTINGS_TILE, LV_ANIM_ON );
}
}
static void delete_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
if(event == LV_EVENT_CLICKED) {
motor_vibe( 1 );
wifictl_delete_network( lv_label_get_text( wlan_password_name_label ) );
keyboard_hide();
mainbar_jump_to_tilenumber( WLAN_SETTINGS_TILE, LV_ANIM_ON );
}
}
static void wlan_password_event_cb( lv_obj_t * obj, lv_event_t event )
{
if( event == LV_EVENT_CLICKED ) {
motor_vibe( 1 );
keyboard_set_textarea( obj );
static void enter_wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( wifi_settings_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( SETUP_TILE, LV_ANIM_OFF );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
break;
}
}
static void exit_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): keyboard_hide();
motor_vibe( 1 );
mainbar_jump_to_tilenumber( WLAN_SETTINGS_TILE, LV_ANIM_ON );
break;
void WiFiScanDone(WiFiEvent_t event, WiFiEventInfo_t info) {
while ( lv_list_remove( wifiname_list, 0 ) );
int len = WiFi.scanComplete();
for( int i = 0 ; i < len ; i++ ) {
if ( wifictl_is_known( WiFi.SSID(i).c_str() ) ) {
lv_obj_t * wifiname_list_btn = lv_list_add_btn( wifiname_list, &unlock_16px, WiFi.SSID(i).c_str() );
lv_obj_set_event_cb( wifiname_list_btn, wifi_settings_enter_pass_event_cb);
}
else {
lv_obj_t * wifiname_list_btn = lv_list_add_btn( wifiname_list, &lock_16px, WiFi.SSID(i).c_str() );
lv_obj_set_event_cb( wifiname_list_btn, wifi_settings_enter_pass_event_cb);
}
}
}
@@ -238,25 +173,108 @@ static void wifi_onoff_event_handler(lv_obj_t * obj, lv_event_t event) {
void wifi_settings_enter_pass_event_cb( lv_obj_t * obj, lv_event_t event ) {
if(event == LV_EVENT_CLICKED) {
motor_vibe( 1 );
lv_label_set_text( wlan_password_name_label, lv_list_get_btn_text(obj) );
lv_textarea_set_text( wlan_password_pass_textfield, "");
mainbar_jump_to_tilenumber( WLAN_PASSWORD_TILE, LV_ANIM_ON );
lv_label_set_text( wifi_password_name_label, lv_list_get_btn_text(obj) );
lv_textarea_set_text( wifi_password_pass_textfield, "");
mainbar_jump_to_tilenumber( wifi_password_tile_num, LV_ANIM_ON );
}
}
void WiFiScanDone(WiFiEvent_t event, WiFiEventInfo_t info) {
static void exit_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event );
static void wlan_password_event_cb(lv_obj_t * obj, lv_event_t event);
static void apply_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event );
static void delete_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event );
while (lv_list_remove( wifiname_list, 0 ) );
void wlan_password_tile_setup( uint32_t wifi_password_tile_num ) {
// get an app tile and copy mainstyle
wifi_password_tile = mainbar_get_tile_obj( wifi_password_tile_num );
lv_style_copy( &wifi_password_style, mainbar_get_style() );
lv_style_set_bg_color( &wifi_password_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY);
lv_style_set_bg_opa( &wifi_password_style, LV_OBJ_PART_MAIN, LV_OPA_100);
lv_style_set_border_width( &wifi_password_style, LV_OBJ_PART_MAIN, 0);
lv_obj_add_style( wifi_password_tile, LV_OBJ_PART_MAIN, &wifi_password_style );
int len = WiFi.scanComplete();
for( int i = 0 ; i < len ; i++ ) {
if ( wifictl_is_known( WiFi.SSID(i).c_str() ) ) {
lv_obj_t * wifiname_list_btn = lv_list_add_btn( wifiname_list, &unlock_16px, WiFi.SSID(i).c_str() );
lv_obj_set_event_cb( wifiname_list_btn, wifi_settings_enter_pass_event_cb);
}
else {
lv_obj_t * wifiname_list_btn = lv_list_add_btn( wifiname_list, &lock_16px, WiFi.SSID(i).c_str() );
lv_obj_set_event_cb( wifiname_list_btn, wifi_settings_enter_pass_event_cb);
}
lv_obj_t *exit_btn = lv_imgbtn_create( wifi_password_tile, NULL);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &wifi_password_style );
lv_obj_align( exit_btn, wifi_password_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn, exit_wifi_password_event_cb );
wifi_password_name_label = lv_label_create( wifi_password_tile, NULL);
lv_obj_add_style( wifi_password_name_label, LV_OBJ_PART_MAIN, &wifi_password_style );
lv_label_set_text( wifi_password_name_label, "wlan setting");
lv_obj_align( wifi_password_name_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
wifi_password_pass_textfield = lv_textarea_create( wifi_password_tile, NULL);
lv_textarea_set_text( wifi_password_pass_textfield, "");
lv_textarea_set_pwd_mode( wifi_password_pass_textfield, false);
lv_textarea_set_one_line( wifi_password_pass_textfield, true);
lv_textarea_set_cursor_hidden( wifi_password_pass_textfield, true);
lv_obj_set_width( wifi_password_pass_textfield, LV_HOR_RES );
lv_obj_align( wifi_password_pass_textfield, wifi_password_tile, LV_ALIGN_IN_TOP_LEFT, 0, 75);
lv_obj_set_event_cb( wifi_password_pass_textfield, wlan_password_event_cb );
lv_obj_t *mac_label = lv_label_create( wifi_password_tile, NULL);
lv_obj_add_style( mac_label, LV_IMGBTN_PART_MAIN, &wifi_password_style );
lv_obj_set_width( mac_label, LV_HOR_RES);
lv_obj_align( mac_label, wifi_password_tile, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text_fmt( mac_label, "MAC: %s", WiFi.macAddress().c_str());
lv_obj_t *apply_btn = lv_imgbtn_create( wifi_password_tile, NULL);
lv_imgbtn_set_src( apply_btn, LV_BTN_STATE_RELEASED, &check_32px);
lv_imgbtn_set_src( apply_btn, LV_BTN_STATE_PRESSED, &check_32px);
lv_imgbtn_set_src( apply_btn, LV_BTN_STATE_CHECKED_RELEASED, &check_32px);
lv_imgbtn_set_src( apply_btn, LV_BTN_STATE_CHECKED_PRESSED, &check_32px);
lv_obj_add_style( apply_btn, LV_IMGBTN_PART_MAIN, &wifi_password_style );
lv_obj_align( apply_btn, wifi_password_pass_textfield, LV_ALIGN_OUT_BOTTOM_RIGHT, -10, 10 );
lv_obj_set_event_cb( apply_btn, apply_wifi_password_event_cb );
lv_obj_t *delete_btn = lv_imgbtn_create( wifi_password_tile, NULL);
lv_imgbtn_set_src( delete_btn, LV_BTN_STATE_RELEASED, &trash_32px);
lv_imgbtn_set_src( delete_btn, LV_BTN_STATE_PRESSED, &trash_32px);
lv_imgbtn_set_src( delete_btn, LV_BTN_STATE_CHECKED_RELEASED, &trash_32px);
lv_imgbtn_set_src( delete_btn, LV_BTN_STATE_CHECKED_PRESSED, &trash_32px);
lv_obj_add_style( delete_btn, LV_IMGBTN_PART_MAIN, &wifi_password_style );
lv_obj_align( delete_btn, wifi_password_pass_textfield, LV_ALIGN_OUT_BOTTOM_LEFT, 10, 10 );
lv_obj_set_event_cb( delete_btn, delete_wifi_password_event_cb );
}
static void apply_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
wifictl_insert_network( lv_label_get_text( wifi_password_name_label ), lv_textarea_get_text( wifi_password_pass_textfield ) );
keyboard_hide();
mainbar_jump_to_tilenumber( wifi_settings_tile_num, LV_ANIM_ON );
break;
}
}
}
static void delete_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
wifictl_delete_network( lv_label_get_text( wifi_password_name_label ) );
keyboard_hide();
mainbar_jump_to_tilenumber( wifi_settings_tile_num, LV_ANIM_ON );
break;
}
}
static void wlan_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
keyboard_set_textarea( obj );
break;
}
}
static void exit_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): keyboard_hide();
motor_vibe( 1 );
mainbar_jump_to_tilenumber( wifi_settings_tile_num, LV_ANIM_ON );
break;
}
}

View File

@@ -24,7 +24,7 @@
#include <TTGO.h>
void wlan_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void wlan_password_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void wlan_settings_tile_setup( void );
void wlan_password_tile_setup( uint32_t wifi_password_tile_num );
#endif // _WLAN_SETTINGS_H

View File

@@ -73,13 +73,13 @@ void powermgm_loop( TTGOClass *ttgo ) {
ttgo->power->setDCDC3Voltage( 3300 );
// normal wake up from standby
if ( powermgm_get_event( POWERMGM_PMU_BUTTON | POWERMGM_PMU_BATTERY | POWERMGM_BMA_WAKEUP ) ) {
log_e("wakeup");
log_i("wakeup");
display_go_wakeup( ttgo );
motor_vibe( 1 );
}
// silence wakeup request from standby
else if ( powermgm_get_event( POWERMGM_SILENCE_WAKEUP_REQUEST ) ) {
log_e("silence wakeup");
log_i("silence wakeup");
display_go_silence_wakeup( ttgo );
powermgm_set_event( POWERMGM_SILENCE_WAKEUP );
}
@@ -94,7 +94,7 @@ void powermgm_loop( TTGOClass *ttgo ) {
ttgo->power->offTimer();
}
else {
log_e("go to standby");
log_i("go to standby");
display_go_sleep( ttgo );
timesyncToRTC();
if ( powermgm_get_event( POWERMGM_WIFI_ACTIVE ) ) wifictl_off();

View File

@@ -68,6 +68,7 @@ void setup()
gui_setup();
lv_task_handler();
ttgo->bl->adjust( 32 );
/*
* add apps and widgets here!!!

Binary file not shown.

View File

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