new weather app function adapted

This commit is contained in:
sharandac
2020-07-29 08:44:16 +02:00
parent 6c3b2d6fdb
commit c67db70f22
6 changed files with 51 additions and 59 deletions

View File

@@ -86,7 +86,7 @@ void weather_app_setup( void ) {
lv_obj_reset_style_list( weather_widget_wind_label, LV_OBJ_PART_MAIN );
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
if( weather_config.showWind)
if( weather_config.showWind )
{
lv_obj_align( weather_widget_temperature_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, -20);
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, +5);
@@ -152,15 +152,15 @@ void weather_widget_sync_Task( void * pvParameters ) {
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_CHECKED_RELEASED, resolve_owm_icon( weather_today.icon ) );
lv_imgbtn_set_src( weather_widget_condition_img, LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_today.icon ) );
if (weather_config.showWind)
if ( weather_config.showWind )
{
lv_label_set_text( weather_widget_wind_label, weather_today.wind);
lv_label_set_text( weather_widget_wind_label, weather_today.wind );
lv_obj_align( weather_widget_temperature_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, -22);
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
}
else
{
lv_label_set_text( weather_widget_wind_label, "");
lv_label_set_text( weather_widget_wind_label, "" );
lv_obj_align( weather_widget_temperature_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_align( weather_widget_wind_label, weather_widget_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
}

View File

@@ -49,8 +49,6 @@
typedef weather_config_t_v2 weather_config_t;
typedef struct {
bool valide = false;
time_t timestamp = 0;

View File

@@ -40,7 +40,7 @@ lv_style_t weather_widget_setup_style;
LV_IMG_DECLARE(exit_32px);
static void weather_apikey_event_cb( lv_obj_t * obj, lv_event_t event );
static void weather_textarea_event_cb( lv_obj_t * obj, lv_event_t event );
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 );
@@ -91,7 +91,7 @@ void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
lv_textarea_set_cursor_hidden( weather_apikey_textfield, true);
lv_obj_set_width( weather_apikey_textfield, LV_HOR_RES /4 * 3 );
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_apikey_event_cb );
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 );
@@ -108,7 +108,7 @@ void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
lv_textarea_set_cursor_hidden( weather_lat_textfield, true);
lv_obj_set_width( weather_lat_textfield, LV_HOR_RES / 4 );
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_apikey_event_cb );
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 );
@@ -125,37 +125,39 @@ void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
lv_textarea_set_cursor_hidden( weather_lon_textfield, true);
lv_obj_set_width( weather_lon_textfield, LV_HOR_RES / 4 );
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_apikey_event_cb );
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_align( weather_autosync_cont, weather_lat_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, -5 );
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, -5 );
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_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, -5 );
if (weather_config->autosync)
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_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_label_set_text( weather_wind_label, "Display wind");
lv_obj_align( weather_wind_label, weather_wind_cont, LV_ALIGN_IN_LEFT_MID, 5, 0);
if ( weather_config->autosync)
lv_switch_on(weather_autosync_onoff, LV_ANIM_OFF);
else
lv_switch_off(weather_autosync_onoff, LV_ANIM_OFF);
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_align(weather_wind_cont, weather_lat_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10);
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, 10);
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_label_set_text(weather_wind_label, "Display wind");
lv_obj_align(weather_wind_label, weather_wind_cont, LV_ALIGN_IN_LEFT_MID, 5, 10);
if ( weather_config->showWind )
lv_switch_on( weather_wind_onoff, LV_ANIM_OFF );
else
@@ -163,46 +165,38 @@ void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hre
log_e("Display wind currently set to %d", weather_config->showWind);
}
static void weather_apikey_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void weather_textarea_event_cb( lv_obj_t * obj, lv_event_t event ) {
if( event == LV_EVENT_CLICKED ) {
keyboard_set_textarea( obj );
}
}
static void weather_autosync_onoff_event_handler( lv_obj_t * obj, lv_event_t event ) {
if(event == LV_EVENT_VALUE_CHANGED) {
weather_config_t *weather_config = weather_get_config();
if( lv_switch_get_state( obj ) ) {
weather_config->autosync = true;
}
else {
weather_config->autosync = false;
}
}
}
static void exit_weather_widget_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): keyboard_hide();
weather_config_t *weather_config = weather_get_config();
strcpy( weather_config->apikey, lv_textarea_get_text( weather_apikey_textfield ) );
strcpy( weather_config->lat, lv_textarea_get_text( weather_lat_textfield ) );
strcpy( weather_config->lon, lv_textarea_get_text( weather_lon_textfield ) );
weather_save_config();
weather_jump_to_forecast();
break;
switch (event) {
case (LV_EVENT_VALUE_CHANGED): weather_config_t *weather_config = weather_get_config();
weather_config->autosync = lv_switch_get_state( obj );
break;
}
}
static void weather_wind_onoff_event_handler(lv_obj_t *obj, lv_event_t event)
{
switch (event)
{
case (LV_EVENT_CLICKED):
weather_config_t *weather_config = weather_get_config();
weather_config->showWind = lv_switch_get_state( weather_wind_onoff);
weather_save_config();
weather_jump_to_forecast();
break;
switch (event) {
case ( LV_EVENT_VALUE_CHANGED ): weather_config_t *weather_config = weather_get_config();
weather_config->showWind = lv_switch_get_state( obj );
break;
}
}
}
static void exit_weather_widget_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): keyboard_hide();
weather_config_t *weather_config = weather_get_config();
strcpy( weather_config->apikey, lv_textarea_get_text( weather_apikey_textfield ) );
strcpy( weather_config->lat, lv_textarea_get_text( weather_lat_textfield ) );
strcpy( weather_config->lon, lv_textarea_get_text( weather_lon_textfield ) );
weather_save_config();
weather_jump_to_forecast();
break;
}
}

View File

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

Binary file not shown.

View File

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