some fixes

This commit is contained in:
sharandac
2020-08-10 12:35:39 +02:00
parent 40794d8b0a
commit 400fcbd622
14 changed files with 107 additions and 23 deletions

View File

@@ -292,8 +292,10 @@ static void exit_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
}
lv_obj_t *wifi_autoon_onoff;
lv_obj_t *wifi_webserver_onoff;
static void wps_start_event_handler( lv_obj_t * obj, lv_event_t event );
static void wifi_autoon_onoff_event_handler( lv_obj_t * obj, lv_event_t event );
static void wifi_webserver_onoff_event_handler( lv_obj_t * obj, lv_event_t event );
void wlan_setup_tile_setup( uint32_t wifi_setup_tile_num ) {
// get an app tile and copy mainstyle
@@ -334,9 +336,25 @@ void wlan_setup_tile_setup( uint32_t wifi_setup_tile_num ) {
lv_label_set_text( wifi_autoon_label, "enable on wakeup");
lv_obj_align( wifi_autoon_label, wifi_autoon_onoff_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_obj_t *wifi_webserver_onoff_cont = lv_obj_create( wifi_setup_tile, NULL );
lv_obj_set_size(wifi_webserver_onoff_cont, LV_HOR_RES_MAX , 40);
lv_obj_add_style( wifi_webserver_onoff_cont, LV_OBJ_PART_MAIN, &wifi_setup_style );
lv_obj_align( wifi_webserver_onoff_cont, wifi_autoon_onoff_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
wifi_webserver_onoff = lv_switch_create( wifi_setup_tile, NULL );
lv_obj_add_protect( wifi_webserver_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( wifi_webserver_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( wifi_webserver_onoff, LV_ANIM_ON );
lv_obj_align( wifi_webserver_onoff, wifi_webserver_onoff_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( wifi_webserver_onoff, wifi_webserver_onoff_event_handler );
lv_obj_t *wifi_webserver_label = lv_label_create( wifi_webserver_onoff_cont, NULL);
lv_obj_add_style( wifi_webserver_label, LV_OBJ_PART_MAIN, &wifi_setup_style );
lv_label_set_text( wifi_webserver_label, "enable webserver");
lv_obj_align( wifi_webserver_label, wifi_webserver_onoff_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_obj_t *wps_btn = lv_btn_create( wifi_setup_tile, NULL);
lv_obj_set_event_cb( wps_btn, wps_start_event_handler );
lv_obj_align( wps_btn, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -40);
lv_obj_align( wps_btn, wifi_webserver_onoff_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_obj_t *wps_btn_label = lv_label_create( wps_btn, NULL );
lv_label_set_text( wps_btn_label, "start WPS");
@@ -344,6 +362,11 @@ void wlan_setup_tile_setup( uint32_t wifi_setup_tile_num ) {
lv_switch_on( wifi_autoon_onoff, LV_ANIM_OFF);
else
lv_switch_off( wifi_autoon_onoff, LV_ANIM_OFF);
if ( wifictl_get_webserver() )
lv_switch_on( wifi_webserver_onoff, LV_ANIM_OFF);
else
lv_switch_off( wifi_webserver_onoff, LV_ANIM_OFF);
}
static void wps_start_event_handler( lv_obj_t * obj, lv_event_t event ) {
@@ -372,4 +395,11 @@ static void wifi_autoon_onoff_event_handler( lv_obj_t * obj, lv_event_t event )
case (LV_EVENT_VALUE_CHANGED): wifictl_set_autoon( lv_switch_get_state( obj ) );
break;
}
}
static void wifi_webserver_onoff_event_handler( lv_obj_t * obj, lv_event_t event ) {
switch (event) {
case (LV_EVENT_VALUE_CHANGED): wifictl_set_webserver( lv_switch_get_state( obj ) );
break;
}
}