more feature

This commit is contained in:
sharandac
2020-07-09 16:43:48 +02:00
parent dbe29b31b1
commit 8ac776e670
49 changed files with 1638 additions and 442 deletions

View File

@@ -0,0 +1,54 @@
#include "config.h"
#include "../mainbar.h"
#include "app_tile.h"
static void btn_event_cb( lv_obj_t * obj, lv_event_t event );
LV_IMG_DECLARE(wifi_64px);
LV_IMG_DECLARE(bluetooth_64px);
LV_IMG_DECLARE(time_64px);
LV_IMG_DECLARE(brightness_64px);
void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
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, 48, 48 );
lv_obj_set_event_cb( wifi_setup, btn_event_cb );
lv_obj_t * bluetooth_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src(bluetooth_setup, LV_BTN_STATE_RELEASED, &bluetooth_64px);
lv_imgbtn_set_src(bluetooth_setup, LV_BTN_STATE_PRESSED, &bluetooth_64px);
lv_imgbtn_set_src(bluetooth_setup, LV_BTN_STATE_CHECKED_RELEASED, &bluetooth_64px);
lv_imgbtn_set_src(bluetooth_setup, LV_BTN_STATE_CHECKED_PRESSED, &bluetooth_64px);
lv_obj_add_style(bluetooth_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align(bluetooth_setup, tile, LV_ALIGN_IN_TOP_LEFT, 48+86, 48 );
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, 48, 48+86 );
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, 48+86, 48+86 );
}
static void btn_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_to_maintile( LV_ANIM_OFF );
break;
}
}

View File

@@ -0,0 +1,8 @@
#ifndef _APP_TILE_H
#define _APP_TILE_H
#include <TTGO.h>
void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
#endif // _APP_TILE_H

View File

@@ -0,0 +1,72 @@
#include <stdio.h>
#include <time.h>
#include "config.h"
#include "../mainbar.h"
#include "main_tile.h"
static lv_obj_t *timelabel = NULL;
static lv_obj_t *datelabel = NULL;
static lv_style_t timestyle;
static lv_style_t datestyle;
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 ) {
lv_style_copy( &timestyle, style);
lv_style_set_text_font( &timestyle, LV_STATE_DEFAULT, &Ubuntu_72px);
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);
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, &timestyle );
lv_obj_align(timelabel, NULL, LV_ALIGN_CENTER, 0, 0);
datelabel = lv_label_create(tile, 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 );
lv_obj_align(datelabel, timelabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
time_t now;
struct tm info;
char buf[64];
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);
task = lv_task_create(main_tile_task, 1000, LV_TASK_PRIO_MID, NULL );
}
/*
*
*/
void main_tile_task( lv_task_t * task ) {
time_t now;
struct tm info;
char buf[64];
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);
}

View File

@@ -0,0 +1,9 @@
#ifndef _MAIL_TILE_H
#define _MAIL_TILE_H
#include <TTGO.h>
void main_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void main_tile_task( lv_task_t * task );
#endif // _MAIL_TILE_H

View File

@@ -0,0 +1,81 @@
#include <stdio.h>
#include "config.h"
#include "mainbar.h"
#include "main_tile/main_tile.h"
#include "setup_tile/setup.h"
#include "note_tile/note_tile.h"
#include "app_tile/app_tile.h"
#include "setup_tile/wlan_settings/wlan_settings.h"
#include "setup_tile/move_settings/move_settings.h"
#include "setup_tile/display_settings/display_settings.h"
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, MAIN_TILE, main_tile_setup, { 0 , 0 } },
{ NULL, NOTE_TILE, note_tile_setup, { 1 , 0 } },
{ NULL, APP_TILE, app_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 } }
};
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);
lv_style_set_bg_opa(&mainbarstyle, LV_OBJ_PART_MAIN, LV_OPA_0);
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_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 );
}
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_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;
}
}
}

51
src/gui/mainbar/mainbar.h Normal file
View File

@@ -0,0 +1,51 @@
#ifndef _MAINBAR_H
#define _MAINBAR_H
#include <TTGO.h>
typedef void ( * TILE_CALLBACK_FUNC ) ( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
typedef enum {
MAIN_TILE,
SETUP_TILE,
NOTE_TILE,
APP_TILE,
WLAN_SETTINGS_TILE,
WLAN_PASSWORD_TILE,
MOVE_SETTINGS_TILE,
DISPLAY_SETTINGS_TILE,
TILE_NUM
} lv_tile_number;
typedef struct {
lv_obj_t *tile;
lv_tile_number tile_number;
TILE_CALLBACK_FUNC tilecallback;
lv_point_t pos;
} lv_tile_entry_t;
/*
* @brief mainbar setup funktion
* @param none
*/
void mainbar_setup( void );
/*
* @brief jump to the given tile
* @param x x coordinate
* @param y y coordinate
*/
void mainbar_jump_to_tile( lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim );
/*
* @brief jump to the given tile
* @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 );
/*
* @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 );
#endif // _MAINBAR_H

View File

@@ -0,0 +1,54 @@
#include "config.h"
#include "../mainbar.h"
#include "note_tile.h"
static void btn_event_cb( lv_obj_t * obj, lv_event_t event );
LV_IMG_DECLARE(wifi_64px);
LV_IMG_DECLARE(bluetooth_64px);
LV_IMG_DECLARE(time_64px);
LV_IMG_DECLARE(brightness_64px);
void note_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
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, 48, 48 );
lv_obj_set_event_cb( wifi_setup, btn_event_cb );
lv_obj_t * bluetooth_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src(bluetooth_setup, LV_BTN_STATE_RELEASED, &bluetooth_64px);
lv_imgbtn_set_src(bluetooth_setup, LV_BTN_STATE_PRESSED, &bluetooth_64px);
lv_imgbtn_set_src(bluetooth_setup, LV_BTN_STATE_CHECKED_RELEASED, &bluetooth_64px);
lv_imgbtn_set_src(bluetooth_setup, LV_BTN_STATE_CHECKED_PRESSED, &bluetooth_64px);
lv_obj_add_style(bluetooth_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align(bluetooth_setup, tile, LV_ALIGN_IN_TOP_LEFT, 48+86, 48 );
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, 48, 48+86 );
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, 48+86, 48+86 );
}
static void btn_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_to_maintile( LV_ANIM_ON );
break;
}
}

View File

@@ -0,0 +1,8 @@
#ifndef _NOTE_TILE_H
#define _NOTE_TILE_H
#include <TTGO.h>
void note_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
#endif // _NOTE_TILE_H

View File

@@ -0,0 +1,113 @@
#include "config.h"
#include "display_settings.h"
#include "gui/mainbar/mainbar.h"
#include "gui/statusbar.h"
#include "hardware/display.h"
lv_obj_t *display_settings_tile1 = NULL;
lv_obj_t *display_brightness_slider = NULL;
lv_obj_t *display_timeout_slider = NULL;
lv_obj_t *display_timeout_slider_label = NULL;
lv_style_t display_settings_style;
LV_IMG_DECLARE(exit_32px);
LV_IMG_DECLARE(brightness_64px);
LV_IMG_DECLARE(time_64px);
static void exit_display_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void exit_display_brightness_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void exit_display_timeout_setup_event_cb( 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);
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);
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 );
lv_obj_t *exit_btn = lv_imgbtn_create( display_settings_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, display_settings_tile1, 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_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 , 80 );
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 );
display_brightness_slider = lv_slider_create( brightness_cont, NULL );
lv_slider_set_range( display_brightness_slider, 32, 255 );
lv_obj_set_size( display_brightness_slider, hres - 100 , 10 );
lv_obj_align( display_brightness_slider, brightness_cont, LV_ALIGN_IN_RIGHT_MID, -15, 0 );
lv_obj_set_event_cb( display_brightness_slider, exit_display_brightness_setup_event_cb );
lv_obj_t *brightness_icon = lv_img_create( brightness_cont, NULL );
lv_img_set_src( brightness_icon, &brightness_64px );
lv_obj_align( brightness_icon, brightness_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_obj_t *timeout_cont = lv_obj_create( display_settings_tile1, NULL );
lv_obj_set_size( timeout_cont, hres , 80 );
lv_obj_add_style( timeout_cont, LV_OBJ_PART_MAIN, 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, 15, 300 );
lv_obj_set_size(display_timeout_slider, hres - 100 , 10 );
lv_obj_align( display_timeout_slider, timeout_cont, LV_ALIGN_IN_RIGHT_MID, -15, 0 );
lv_obj_set_event_cb( display_timeout_slider, exit_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_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_64px );
lv_obj_align( timeout_icon, timeout_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_slider_set_value( display_brightness_slider, display_get_brightness(), LV_ANIM_OFF );
lv_slider_set_value( display_timeout_slider, display_get_timeout(), LV_ANIM_OFF );
char temp[16]="";
snprintf( temp, sizeof( temp ), "%d secounds", display_get_timeout() );
lv_label_set_text( display_timeout_slider_label, temp );
lv_obj_align( display_timeout_slider_label, display_timeout_slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
}
static void exit_display_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 );
display_save_config();
break;
}
}
static void exit_display_brightness_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_VALUE_CHANGED ): display_set_brightness( lv_slider_get_value( obj ) );
break;
}
}
static void exit_display_timeout_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_VALUE_CHANGED ): display_set_timeout( lv_slider_get_value( obj ) );
char temp[16]="";
snprintf( temp, sizeof( temp ), "%d secounds", lv_slider_get_value(obj) );
lv_label_set_text( display_timeout_slider_label, temp );
lv_obj_align( display_timeout_slider_label, display_timeout_slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 15 );
break;
}
}

View File

@@ -0,0 +1,8 @@
#ifndef _DISPLAY_SETTINGS_H
#define _DISPLAY_SETTINGS_H
#include <TTGO.h>
void display_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
#endif // _DISPLAY_SETTINGS_H

View File

@@ -0,0 +1,113 @@
#include "config.h"
#include "move_settings.h"
#include "gui/mainbar/mainbar.h"
#include "gui/statusbar.h"
#include "hardware/bma.h"
lv_obj_t *move_settings_tile1=NULL;
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);
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);
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);
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 );
lv_obj_t *exit_btn = lv_imgbtn_create( move_settings_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, move_settings_tile1, 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_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 );
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_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_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_label_set_text( doubleclick_label, "double click");
lv_obj_align( doubleclick_label, doubleclick_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
if ( bma_get_config( BMA_DOUBLECLICK ) )
lv_switch_on( doubleclick_onoff, LV_ANIM_OFF );
else
lv_switch_off( doubleclick_onoff, LV_ANIM_OFF );
if ( bma_get_config( BMA_STEPCOUNTER ) )
lv_switch_on( stepcounter_onoff, LV_ANIM_OFF );
else
lv_switch_off( stepcounter_onoff, LV_ANIM_OFF );
}
static void exit_move_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 stepcounter_onoff_event_handler(lv_obj_t * obj, lv_event_t event) {
if(event == LV_EVENT_VALUE_CHANGED) {
if( lv_switch_get_state( obj ) ) {
bma_set_config( BMA_STEPCOUNTER, true );
}
else {
bma_set_config( BMA_STEPCOUNTER, false );
}
}
}
static void doubleclick_onoff_event_handler(lv_obj_t * obj, lv_event_t event) {
if(event == LV_EVENT_VALUE_CHANGED) {
if( lv_switch_get_state( obj ) ) {
bma_set_config( BMA_DOUBLECLICK, true );
}
else {
bma_set_config( BMA_DOUBLECLICK, false );
}
}
}

View File

@@ -0,0 +1,8 @@
#ifndef _MOVE_SETTINGS_H
#define _MOVE_SETTINGS_H
#include <TTGO.h>
void move_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
#endif // _MOVE_SETTINGS_TILE_H

View File

@@ -0,0 +1,72 @@
#include "config.h"
#include "setup.h"
#include "gui/mainbar/mainbar.h"
static void wifi_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 );
LV_IMG_DECLARE(wifi_64px);
LV_IMG_DECLARE(bluetooth_64px);
LV_IMG_DECLARE(move_64px);
LV_IMG_DECLARE(brightness_64px);
void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
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, 48, 48 );
lv_obj_set_event_cb( wifi_setup, wifi_setup_event_cb );
lv_obj_t * bluetooth_setup = lv_imgbtn_create(tile, NULL);
lv_imgbtn_set_src( bluetooth_setup, LV_BTN_STATE_RELEASED, &bluetooth_64px);
lv_imgbtn_set_src( bluetooth_setup, LV_BTN_STATE_PRESSED, &bluetooth_64px);
lv_imgbtn_set_src( bluetooth_setup, LV_BTN_STATE_CHECKED_RELEASED, &bluetooth_64px);
lv_imgbtn_set_src( bluetooth_setup, LV_BTN_STATE_CHECKED_PRESSED, &bluetooth_64px);
lv_obj_add_style( bluetooth_setup, LV_IMGBTN_PART_MAIN, style);
lv_obj_align( bluetooth_setup, tile, LV_ALIGN_IN_TOP_LEFT, 48+86, 48 );
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, 48, 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, 48+86, 48+86 );
lv_obj_set_event_cb( brightness_setup, display_setup_event_cb );
}
static void wifi_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( WLAN_SETTINGS_TILE, LV_ANIM_OFF );
break;
}
}
static void move_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( MOVE_SETTINGS_TILE, LV_ANIM_OFF );
break;
}
}
static void display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( DISPLAY_SETTINGS_TILE, LV_ANIM_OFF );
break;
}
}

View File

@@ -0,0 +1,8 @@
#ifndef _SETUP_H
#define _SETUP_H
#include <TTGO.h>
void setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
#endif // _SETUP_H

View File

@@ -0,0 +1,228 @@
#include "config.h"
#include "wlan_settings.h"
#include "gui/mainbar/mainbar.h"
#include "gui/statusbar.h"
#include "gui/keyboard.h"
#include "hardware/wifictl.h"
#include <WiFi.h>
LV_IMG_DECLARE(exit_32px);
lv_obj_t *wlan_settings_tile1=NULL;
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 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);
LV_IMG_DECLARE(lock_16px);
LV_IMG_DECLARE(unlock_16px);
LV_IMG_DECLARE(check_32px);
LV_IMG_DECLARE(exit_32px);
LV_IMG_DECLARE(trash_32px);
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);
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 );
lv_obj_t *exit_btn = lv_imgbtn_create( wlan_settings_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_settings_tile1, 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_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 );
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);
WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info) {
lv_switch_on( wifi_onoff, LV_ANIM_OFF );
}, WiFiEvent_t::SYSTEM_EVENT_WIFI_READY );
WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info) {
lv_switch_off( wifi_onoff, LV_ANIM_OFF );
while ( lv_list_remove( wifiname_list, 0 ) );
}, WiFiEvent_t::SYSTEM_EVENT_STA_STOP );
WiFi.onEvent( WiFiScanDone, WiFiEvent_t::SYSTEM_EVENT_SCAN_DONE );
}
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 *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) {
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) {
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 ) {
keyboard_set_textarea( obj );
}
}
static void exit_wifi_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 exit_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): keyboard_hide();
mainbar_jump_to_tilenumber( WLAN_SETTINGS_TILE, LV_ANIM_ON );
break;
}
}
static void wifi_onoff_event_handler(lv_obj_t * obj, lv_event_t event) {
if(event == LV_EVENT_VALUE_CHANGED) {
if( lv_switch_get_state( obj ) ) {
wifictl_on();
}
else {
wifictl_off();
}
}
}
void wifi_settings_enter_pass_event_cb( lv_obj_t * obj, lv_event_t event ) {
if(event == LV_EVENT_CLICKED) {
// strcpy( ssid, lv_list_get_btn_text(obj) );
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 );
}
}
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);
}
}
}

View File

@@ -0,0 +1,9 @@
#ifndef _WLAN_SETTINGS_H
#define _WLAN_SETTINGS_H
#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 );
#endif // _WLAN_SETTINGS_H