diff --git a/platformio.ini b/platformio.ini index bcb4398..f553a23 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,6 +25,7 @@ src_filter = +<*> lib_deps = TTGO TWatch Library@>=1.2.0 +; https://github.com/Xinyuan-LilyGO/TTGO_TWatch_Library.git ESP Async WebServer@>=1.2.0 AsyncTCP@>=1.1.1 ArduinoJson@>=6.15.2 diff --git a/src/config.h b/src/config.h index dfe6c90..837f8e6 100644 --- a/src/config.h +++ b/src/config.h @@ -32,6 +32,6 @@ /* * firmeware version string */ - #define __FIRMWARE__ "2020082604" + #define __FIRMWARE__ "2020082701" #endif // _CONFIG_H diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index 95f9fcb..56ebdea 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -41,6 +41,7 @@ static lv_obj_t *statusbar = NULL; static lv_obj_t *statusbar_wifi = NULL; static lv_obj_t *statusbar_wifilabel = NULL; +static lv_obj_t *statusbar_wifiiplabel = NULL; static lv_obj_t *statusbar_bluetooth = NULL; static lv_obj_t *statusbar_stepcounterlabel = NULL; static lv_style_t statusbarstyle[ STATUSBAR_STYLE_NUM ]; @@ -171,6 +172,13 @@ void statusbar_setup( void ) lv_label_set_text(statusbar_wifilabel, ""); lv_obj_align(statusbar_wifilabel, statusbar_wifi, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 ); + /*Create a label on the Image button*/ + statusbar_wifiiplabel = lv_label_create(statusbar, NULL); + lv_obj_reset_style_list( statusbar_wifiiplabel, LV_OBJ_PART_MAIN ); + lv_obj_add_style( statusbar_wifiiplabel, LV_OBJ_PART_MAIN, &statusbarstyle[ STATUSBAR_STYLE_GREEN ] ); + lv_label_set_text(statusbar_wifiiplabel, ""); + lv_obj_align(statusbar_wifiiplabel, statusbar_wifilabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 ); + lv_obj_t *statusbar_stepicon = lv_img_create(statusbar, NULL ); lv_img_set_src( statusbar_stepicon, &foot_16px ); lv_obj_reset_style_list( statusbar_stepicon, LV_OBJ_PART_MAIN ); @@ -189,7 +197,7 @@ void statusbar_setup( void ) statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_GRAY ); blectl_register_cb( BLECTL_CONNECT | BLECTL_DISCONNECT | BLECTL_PIN_AUTH , statusbar_blectl_event_cb ); - wifictl_register_cb( WIFICTL_CONNECT | WIFICTL_DISCONNECT | WIFICTL_OFF | WIFICTL_ON | WIFICTL_SCAN | WIFICTL_WPS_SUCCESS | WIFICTL_WPS_FAILED, statusbar_wifictl_event_cb ); + wifictl_register_cb( WIFICTL_CONNECT | WIFICTL_DISCONNECT | WIFICTL_OFF | WIFICTL_ON | WIFICTL_SCAN | WIFICTL_WPS_SUCCESS | WIFICTL_WPS_FAILED | WIFICTL_CONNECT_IP, statusbar_wifictl_event_cb ); statusbar_task = lv_task_create( statusbar_update_task, 500, LV_TASK_PRIO_MID, NULL ); } @@ -216,6 +224,10 @@ void statusbar_wifictl_event_cb( EventBits_t event, char* msg ) { statusbar_wifi_set_state( true, msg ); statusbar_show_icon( STATUSBAR_WIFI ); break; + case WIFICTL_CONNECT_IP: statusbar_style_icon( STATUSBAR_WIFI, STATUSBAR_STYLE_WHITE ); + statusbar_wifi_set_ip_state( true, msg ); + statusbar_show_icon( STATUSBAR_WIFI ); + break; case WIFICTL_DISCONNECT: statusbar_style_icon( STATUSBAR_WIFI, STATUSBAR_STYLE_GRAY ); statusbar_wifi_set_state( true, msg ); statusbar_show_icon( STATUSBAR_WIFI ); @@ -280,7 +292,17 @@ void statusbar_wifi_set_state( bool state, const char *wifiname ) { lv_imgbtn_set_state( statusbar_wifi, LV_BTN_STATE_CHECKED_RELEASED ); } lv_label_set_text( statusbar_wifilabel, wifiname); + lv_label_set_text( statusbar_wifiiplabel, "" ); lv_obj_align( statusbar_wifilabel, statusbar_wifi, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + lv_obj_align( statusbar_wifiiplabel, statusbar_wifilabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); +} + +/* + * + */ +void statusbar_wifi_set_ip_state( bool state, const char *ip ) { + lv_label_set_text( statusbar_wifiiplabel, ip ); + lv_obj_align( statusbar_wifiiplabel, statusbar_wifilabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); } /* diff --git a/src/gui/statusbar.h b/src/gui/statusbar.h index d5e5dae..732457c 100644 --- a/src/gui/statusbar.h +++ b/src/gui/statusbar.h @@ -26,7 +26,7 @@ #include "config.h" #define STATUSBAR_HEIGHT 26 - #define STATUSBAR_EXPAND_HEIGHT 128 + #define STATUSBAR_EXPAND_HEIGHT 160 typedef struct { lv_obj_t *icon; @@ -104,6 +104,7 @@ * @param wifiname label to displayed text like "scan","connecting" and so on */ void statusbar_wifi_set_state( bool state, const char *wifiname ); + void statusbar_wifi_set_ip_state( bool state, const char *ip ); void statusbar_bluetooth_set_state( bool state ); /* * @brief hide the statusbar diff --git a/src/hardware/wifictl.cpp b/src/hardware/wifictl.cpp index d90d3d1..d602f5f 100644 --- a/src/hardware/wifictl.cpp +++ b/src/hardware/wifictl.cpp @@ -115,10 +115,8 @@ void wifictl_setup( void ) { wifictl_save_config(); } wifictl_clear_event( WIFICTL_OFF_REQUEST | WIFICTL_ON_REQUEST | WIFICTL_SCAN | WIFICTL_WPS_REQUEST ); - String label( wifiname ); - label.concat(' '); - label.concat( WiFi.localIP().toString() ); - wifictl_send_event_cb( WIFICTL_CONNECT, (char *)label.c_str() ); + wifictl_send_event_cb( WIFICTL_CONNECT, (char*)WiFi.SSID().c_str() ); + wifictl_send_event_cb( WIFICTL_CONNECT_IP, (char*)WiFi.localIP().toString().c_str() ); if ( wifictl_config.webserver ) { asyncwebserver_start(); } diff --git a/src/hardware/wifictl.h b/src/hardware/wifictl.h index f4ca805..c812a58 100644 --- a/src/hardware/wifictl.h +++ b/src/hardware/wifictl.h @@ -54,7 +54,8 @@ } wifictl_event_t; #define WIFICTL_CONNECT _BV(0) - #define WIFICTL_DISCONNECT _BV(1) + #define WIFICTL_CONNECT_IP _BV(1) + #define WIFICTL_DISCONNECT _BV(2) #define WIFICTL_ON _BV(3) #define WIFICTL_OFF _BV(4) #define WIFICTL_ACTIVE _BV(5) diff --git a/ttgo-t-watch2020_v1.ino.bin b/ttgo-t-watch2020_v1.ino.bin index 5011782..b3c0084 100644 Binary files a/ttgo-t-watch2020_v1.ino.bin and b/ttgo-t-watch2020_v1.ino.bin differ diff --git a/ttgo-t-watch2020_v1.version.json b/ttgo-t-watch2020_v1.version.json index 590f19a..1dd3db3 100644 --- a/ttgo-t-watch2020_v1.version.json +++ b/ttgo-t-watch2020_v1.version.json @@ -1 +1 @@ -{"version":"2020082604","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"} +{"version":"2020082701","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}