migration to a dynamic tile management
This commit is contained in:
@@ -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 ) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user