add timesync and timezone setup
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "../mainbar.h"
|
||||
#include "main_tile.h"
|
||||
|
||||
static lv_obj_t *clock_cont = NULL;
|
||||
static lv_obj_t *timelabel = NULL;
|
||||
static lv_obj_t *datelabel = NULL;
|
||||
|
||||
@@ -24,14 +25,18 @@ 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);
|
||||
|
||||
/*Tile1: just a label*/
|
||||
timelabel = lv_label_create(tile, NULL);
|
||||
clock_cont = lv_obj_create( tile, NULL );
|
||||
lv_obj_set_size( clock_cont, hres , hres/2 );
|
||||
lv_obj_add_style( clock_cont, LV_OBJ_PART_MAIN, style );
|
||||
lv_obj_align( clock_cont, tile, LV_ALIGN_CENTER, 0, 0 );
|
||||
|
||||
timelabel = lv_label_create( clock_cont , NULL);
|
||||
lv_label_set_text(timelabel, "00:00");
|
||||
lv_obj_reset_style_list( timelabel, LV_OBJ_PART_MAIN );
|
||||
lv_obj_add_style( timelabel, LV_OBJ_PART_MAIN, ×tyle );
|
||||
lv_obj_align(timelabel, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
datelabel = lv_label_create(tile, NULL);
|
||||
datelabel = lv_label_create( clock_cont , NULL);
|
||||
lv_label_set_text(datelabel, "1.Jan 1970");
|
||||
lv_obj_reset_style_list( datelabel, LV_OBJ_PART_MAIN );
|
||||
lv_obj_add_style( datelabel, LV_OBJ_PART_MAIN, &datestyle );
|
||||
@@ -41,16 +46,16 @@ void main_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coo
|
||||
struct tm info;
|
||||
char buf[64];
|
||||
|
||||
time(&now);
|
||||
localtime_r(&now, &info);
|
||||
time( &now );
|
||||
localtime_r( &now, &info );
|
||||
|
||||
strftime(buf, sizeof(buf), "%H:%M", &info);
|
||||
lv_label_set_text(timelabel, buf);
|
||||
strftime(buf, sizeof(buf), "%a %d.%b %Y", &info);
|
||||
lv_label_set_text(datelabel, buf);
|
||||
lv_obj_align(datelabel, timelabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||
strftime( buf, sizeof(buf), "%H:%M", &info );
|
||||
lv_label_set_text( timelabel, buf );
|
||||
strftime( buf, sizeof(buf), "%a %d.%b %Y", &info );
|
||||
lv_label_set_text( datelabel, buf );
|
||||
lv_obj_align( datelabel, timelabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
|
||||
task = lv_task_create(main_tile_task, 1000, LV_TASK_PRIO_MID, NULL );
|
||||
task = lv_task_create( main_tile_task, 1000, LV_TASK_PRIO_MID, NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -61,12 +66,12 @@ void main_tile_task( lv_task_t * task ) {
|
||||
struct tm info;
|
||||
char buf[64];
|
||||
|
||||
time(&now);
|
||||
localtime_r(&now, &info);
|
||||
time( &now );
|
||||
localtime_r( &now, &info );
|
||||
|
||||
strftime(buf, sizeof(buf), "%H:%M", &info);
|
||||
lv_label_set_text(timelabel, buf);
|
||||
strftime(buf, sizeof(buf), "%a %d.%b %Y", &info);
|
||||
lv_label_set_text(datelabel, buf);
|
||||
lv_obj_align(datelabel, timelabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||
strftime( buf, sizeof(buf), "%H:%M", &info );
|
||||
lv_label_set_text( timelabel, buf );
|
||||
strftime( buf, sizeof(buf), "%a %d.%b %Y", &info );
|
||||
lv_label_set_text( datelabel, buf );
|
||||
lv_obj_align( datelabel, timelabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "setup_tile/wlan_settings/wlan_settings.h"
|
||||
#include "setup_tile/move_settings/move_settings.h"
|
||||
#include "setup_tile/display_settings/display_settings.h"
|
||||
#include "setup_tile/time_settings/time_settings.h"
|
||||
|
||||
static lv_style_t mainbarstyle;
|
||||
static lv_obj_t *mainbar = NULL;
|
||||
@@ -22,11 +23,12 @@ lv_tile_entry_t tile_entry[ TILE_NUM ] {
|
||||
{ NULL, APP_TILE, app_tile_setup, { 1 , 0 } },
|
||||
{ NULL, NOTE_TILE, note_tile_setup, { 0 , 1 } },
|
||||
{ NULL, SETUP_TILE, setup_tile_setup, { 1 , 1 } },
|
||||
{ NULL, WLAN_SETTINGS_TILE, wlan_settings_tile_setup, { 1,3 } },
|
||||
{ NULL, WLAN_PASSWORD_TILE, wlan_password_tile_setup, { 2,3 } },
|
||||
{ NULL, MOVE_SETTINGS_TILE, move_settings_tile_setup, { 3,3 } },
|
||||
{ NULL, DISPLAY_SETTINGS_TILE, display_settings_tile_setup, { 5,3 } },
|
||||
{ NULL, BATTERY_SETTINGS_TILE, battery_settings_tile_setup, { 7,3 } }
|
||||
{ NULL, WLAN_SETTINGS_TILE, wlan_settings_tile_setup, { 0,4 } },
|
||||
{ NULL, WLAN_PASSWORD_TILE, wlan_password_tile_setup, { 0,5 } },
|
||||
{ NULL, MOVE_SETTINGS_TILE, move_settings_tile_setup, { 2,4 } },
|
||||
{ NULL, DISPLAY_SETTINGS_TILE, display_settings_tile_setup, { 4,4 } },
|
||||
{ NULL, BATTERY_SETTINGS_TILE, battery_settings_tile_setup, { 6,4 } },
|
||||
{ NULL, TIME_SETTINGS_TILE, time_settings_tile_setup, { 8,4 } }
|
||||
};
|
||||
|
||||
void mainbar_setup( void ) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
MOVE_SETTINGS_TILE,
|
||||
DISPLAY_SETTINGS_TILE,
|
||||
BATTERY_SETTINGS_TILE,
|
||||
TIME_SETTINGS_TILE,
|
||||
TILE_NUM
|
||||
} lv_tile_number;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "gui/statusbar.h"
|
||||
#include "hardware/pmu.h"
|
||||
|
||||
lv_obj_t *battery_settings_tile1=NULL;
|
||||
lv_obj_t *battery_settings_tile=NULL;
|
||||
lv_style_t battery_settings_style;
|
||||
|
||||
lv_obj_t *battery_design_cap;
|
||||
@@ -30,29 +30,29 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
|
||||
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_tile1 = lv_obj_create( tile, NULL);
|
||||
lv_obj_set_size(battery_settings_tile1, hres , vres);
|
||||
lv_obj_align(battery_settings_tile1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_add_style( battery_settings_tile1, LV_OBJ_PART_MAIN, &battery_settings_style );
|
||||
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 );
|
||||
|
||||
lv_obj_t *exit_btn = lv_imgbtn_create( battery_settings_tile1, NULL);
|
||||
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_align( exit_btn, battery_settings_tile1, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
|
||||
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_tile1, NULL);
|
||||
lv_obj_t *exit_label = lv_label_create( battery_settings_tile, NULL);
|
||||
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, 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_tile1, NULL );
|
||||
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_align( battery_design_cont, battery_settings_tile1, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
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_label_set_text( battery_design_cap_label, "designed cap");
|
||||
@@ -62,7 +62,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
|
||||
lv_label_set_text( battery_design_cap, "380mAh");
|
||||
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_tile1, NULL );
|
||||
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_align( battery_current_cont, battery_design_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
@@ -75,7 +75,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
|
||||
lv_label_set_text( battery_current_cap, "380mAh");
|
||||
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_tile1, NULL );
|
||||
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_align( battery_voltage_cont, battery_current_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
@@ -88,7 +88,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
|
||||
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_tile1, NULL );
|
||||
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_align( battery_charge_cont, battery_voltage_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 5 );
|
||||
@@ -101,7 +101,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
|
||||
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_tile1, NULL );
|
||||
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_align( battery_discharge_cont, battery_charge_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
@@ -114,7 +114,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
|
||||
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_tile1, NULL );
|
||||
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_align( vbus_voltage_cont, battery_discharge_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
|
||||
@@ -7,11 +7,14 @@ 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 );
|
||||
|
||||
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);
|
||||
|
||||
|
||||
void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
|
||||
|
||||
@@ -21,7 +24,7 @@ void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_co
|
||||
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, 48, 48 );
|
||||
lv_obj_align(wifi_setup, tile, LV_ALIGN_IN_TOP_LEFT, 16, 48 );
|
||||
lv_obj_set_event_cb( wifi_setup, wifi_setup_event_cb );
|
||||
|
||||
lv_obj_t * battery_setup = lv_imgbtn_create(tile, NULL);
|
||||
@@ -30,7 +33,7 @@ void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_co
|
||||
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, 48+86, 48 );
|
||||
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_t * move_setup = lv_imgbtn_create(tile, NULL);
|
||||
@@ -39,7 +42,7 @@ void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_co
|
||||
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, 48, 48+86 );
|
||||
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);
|
||||
@@ -48,8 +51,17 @@ void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_co
|
||||
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, 48+86, 48+86 );
|
||||
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 );
|
||||
}
|
||||
|
||||
static void wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
||||
@@ -78,4 +90,11 @@ static void display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
||||
case( LV_EVENT_CLICKED ): 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 ): mainbar_jump_to_tilenumber( TIME_SETTINGS_TILE, LV_ANIM_OFF );
|
||||
break;
|
||||
}
|
||||
}
|
||||
107
src/gui/mainbar/setup_tile/time_settings/time_settings.cpp
Normal file
107
src/gui/mainbar/setup_tile/time_settings/time_settings.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "config.h"
|
||||
#include "time_settings.h"
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "gui/mainbar/mainbar.h"
|
||||
#include "gui/statusbar.h"
|
||||
#include "hardware/timesync.h"
|
||||
|
||||
lv_obj_t *time_settings_tile=NULL;
|
||||
lv_style_t time_settings_style;
|
||||
lv_obj_t *utczone_list = NULL;
|
||||
lv_obj_t *wifisync_onoff = NULL;
|
||||
|
||||
LV_IMG_DECLARE(exit_32px);
|
||||
LV_IMG_DECLARE(time_32px);
|
||||
|
||||
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 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);
|
||||
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 );
|
||||
|
||||
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_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_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_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_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 *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_align( utczone_cont, wifisync_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_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);
|
||||
lv_dropdown_set_options( utczone_list, "-12\n-11\n-10\n-9\n-8\n-7\n-6\n-5\n-4\n-3\n-2\n-1\n0\n+1\n+2\n+3\n+4\n+5\n+6\n+7\n+8\n+9\n+10\n+11\n+12\n" );
|
||||
lv_obj_align(utczone_list, utczone_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0);
|
||||
lv_obj_set_event_cb(utczone_list, utczone_event_handler);
|
||||
|
||||
if ( timesync_get_timesync() )
|
||||
lv_switch_on( wifisync_onoff, LV_ANIM_OFF );
|
||||
else
|
||||
lv_switch_off( wifisync_onoff, LV_ANIM_OFF );
|
||||
|
||||
lv_dropdown_set_selected( utczone_list, timesync_get_timezone() + 12 );
|
||||
}
|
||||
|
||||
static void exit_time_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
||||
switch( event ) {
|
||||
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( SETUP_TILE, LV_ANIM_OFF );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void wifisync_onoff_event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
if( lv_switch_get_state( obj ) ) {
|
||||
timesync_set_timesync( true );
|
||||
}
|
||||
else {
|
||||
timesync_set_timesync( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void utczone_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
timesync_set_timezone( lv_dropdown_get_selected( obj ) - 12 );
|
||||
printf("timezone: %d\n", lv_dropdown_get_selected( obj ) - 12 );
|
||||
}
|
||||
}
|
||||
16
src/gui/mainbar/setup_tile/time_settings/time_settings.h
Normal file
16
src/gui/mainbar/setup_tile/time_settings/time_settings.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef _TIME_SETTINGS_H
|
||||
#define _TIME_SETTINGS_H
|
||||
|
||||
#include <TTGO.h>
|
||||
|
||||
/*
|
||||
* @brief setup the display setup tile
|
||||
*
|
||||
* @param tile pointer to the tile obj
|
||||
* @param style pointer to the style obj
|
||||
* @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 );
|
||||
|
||||
#endif // _TIME_SETTINGS_H
|
||||
Reference in New Issue
Block a user