Compare commits
5 Commits
2b33f61b32
...
078ec12cf6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
078ec12cf6 | ||
|
|
467e5cf0e6 | ||
|
|
daea3e145c | ||
|
|
d93c90e3c8 | ||
|
|
c335328ab4 |
@@ -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
|
||||
|
||||
@@ -104,7 +104,7 @@ void crypto_ticker_main_setup( uint32_t tile_num ) {
|
||||
|
||||
|
||||
lv_obj_t *crypto_ticker_main_last_price_cont = lv_obj_create( crypto_ticker_main_tile, NULL );
|
||||
lv_obj_set_size(crypto_ticker_main_last_price_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(crypto_ticker_main_last_price_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( crypto_ticker_main_last_price_cont, LV_OBJ_PART_MAIN, &crypto_ticker_main_style );
|
||||
lv_obj_align( crypto_ticker_main_last_price_cont, crypto_ticker_main_update_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20 );
|
||||
lv_obj_t *crypto_ticker_main_last_price_label = lv_label_create( crypto_ticker_main_last_price_cont, NULL);
|
||||
@@ -118,7 +118,7 @@ void crypto_ticker_main_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( crypto_ticker_main_last_price_value_label, NULL, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
lv_obj_t *crypto_ticker_main_price_change_cont = lv_obj_create( crypto_ticker_main_tile, NULL );
|
||||
lv_obj_set_size(crypto_ticker_main_price_change_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(crypto_ticker_main_price_change_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( crypto_ticker_main_price_change_cont, LV_OBJ_PART_MAIN, &crypto_ticker_main_style );
|
||||
lv_obj_align( crypto_ticker_main_price_change_cont, crypto_ticker_main_last_price_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5 );
|
||||
lv_obj_t *crypto_ticker_main_price_change_label = lv_label_create( crypto_ticker_main_price_change_cont, NULL);
|
||||
@@ -132,7 +132,7 @@ void crypto_ticker_main_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( crypto_ticker_main_price_change_value_label, NULL, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
lv_obj_t *crypto_ticker_main_volume_cont = lv_obj_create( crypto_ticker_main_tile, NULL );
|
||||
lv_obj_set_size(crypto_ticker_main_volume_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(crypto_ticker_main_volume_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( crypto_ticker_main_volume_cont, LV_OBJ_PART_MAIN, &crypto_ticker_main_style );
|
||||
lv_obj_align( crypto_ticker_main_volume_cont, crypto_ticker_main_price_change_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5 );
|
||||
lv_obj_t *crypto_ticker_main_volume_label = lv_label_create( crypto_ticker_main_volume_cont, NULL);
|
||||
@@ -142,7 +142,7 @@ void crypto_ticker_main_setup( uint32_t tile_num ) {
|
||||
crypto_ticker_main_volume_value_label = lv_label_create( crypto_ticker_main_volume_cont , NULL);
|
||||
lv_label_set_text( crypto_ticker_main_volume_value_label, "");
|
||||
lv_obj_reset_style_list( crypto_ticker_main_volume_value_label, LV_OBJ_PART_MAIN );
|
||||
lv_obj_set_width( crypto_ticker_main_volume_value_label, LV_HOR_RES /4 * 2 );
|
||||
lv_obj_set_width( crypto_ticker_main_volume_value_label, lv_disp_get_hor_res( NULL ) /4 * 2 );
|
||||
lv_obj_align( crypto_ticker_main_volume_value_label, NULL, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ void crypto_ticker_setup_setup( uint32_t tile_num ) {
|
||||
lv_obj_add_style( crypto_ticker_setup_tile, LV_OBJ_PART_MAIN, &crypto_ticker_setup_style );
|
||||
|
||||
lv_obj_t *exit_cont = lv_obj_create( crypto_ticker_setup_tile, NULL );
|
||||
lv_obj_set_size( exit_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size( exit_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( exit_cont, LV_OBJ_PART_MAIN, &crypto_ticker_setup_style );
|
||||
lv_obj_align( exit_cont, crypto_ticker_setup_tile, LV_ALIGN_IN_TOP_MID, 0, 10 );
|
||||
|
||||
@@ -75,7 +75,7 @@ void crypto_ticker_setup_setup( uint32_t tile_num ) {
|
||||
|
||||
|
||||
lv_obj_t *crypto_ticker_symbol_cont = lv_obj_create( crypto_ticker_setup_tile, NULL );
|
||||
lv_obj_set_size(crypto_ticker_symbol_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(crypto_ticker_symbol_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( crypto_ticker_symbol_cont, LV_OBJ_PART_MAIN, &crypto_ticker_setup_style );
|
||||
lv_obj_align( crypto_ticker_symbol_cont, exit_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20 );
|
||||
lv_obj_t *crypto_ticker_symbol_label = lv_label_create( crypto_ticker_symbol_cont, NULL);
|
||||
@@ -93,7 +93,7 @@ void crypto_ticker_setup_setup( uint32_t tile_num ) {
|
||||
|
||||
|
||||
lv_obj_t *crypto_ticker_autosync_switch_cont = lv_obj_create( crypto_ticker_setup_tile, NULL );
|
||||
lv_obj_set_size( crypto_ticker_autosync_switch_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size( crypto_ticker_autosync_switch_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( crypto_ticker_autosync_switch_cont, LV_OBJ_PART_MAIN, &crypto_ticker_setup_style );
|
||||
lv_obj_align( crypto_ticker_autosync_switch_cont, crypto_ticker_symbol_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0 );
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ void example_app_setup_setup( uint32_t tile_num ) {
|
||||
lv_obj_add_style( example_app_setup_tile, LV_OBJ_PART_MAIN, &example_app_setup_style );
|
||||
|
||||
lv_obj_t *exit_cont = lv_obj_create( example_app_setup_tile, NULL );
|
||||
lv_obj_set_size( exit_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size( exit_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( exit_cont, LV_OBJ_PART_MAIN, &example_app_setup_style );
|
||||
lv_obj_align( exit_cont, example_app_setup_tile, LV_ALIGN_IN_TOP_MID, 0, 10 );
|
||||
|
||||
@@ -68,7 +68,7 @@ void example_app_setup_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *example_app_foobar_switch_cont = lv_obj_create( example_app_setup_tile, NULL );
|
||||
lv_obj_set_size( example_app_foobar_switch_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size( example_app_foobar_switch_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( example_app_foobar_switch_cont, LV_OBJ_PART_MAIN, &example_app_setup_style );
|
||||
lv_obj_align( example_app_foobar_switch_cont, exit_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0 );
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ void weather_forecast_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( weather_forecast_update_label, weather_forecast_location_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0 );
|
||||
|
||||
lv_obj_t * weater_forecast_cont = lv_obj_create( weather_forecast_tile, NULL );
|
||||
lv_obj_set_size( weater_forecast_cont, LV_HOR_RES_MAX , 96 );
|
||||
lv_obj_set_size( weater_forecast_cont, lv_disp_get_hor_res( NULL ) , 96 );
|
||||
lv_obj_add_style( weater_forecast_cont, LV_OBJ_PART_MAIN, &weather_forecast_style );
|
||||
lv_obj_align( weater_forecast_cont, weather_forecast_tile, LV_ALIGN_CENTER, 0, 0 );
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
/*
|
||||
lv_obj_t *weather_geolocation_cont = lv_obj_create( weather_setup_tile, NULL );
|
||||
lv_obj_set_size( weather_geolocation_cont, LV_HOR_RES_MAX , 32);
|
||||
lv_obj_set_size( weather_geolocation_cont, lv_disp_get_hor_res( NULL ) , 32);
|
||||
lv_obj_add_style( weather_geolocation_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
|
||||
lv_obj_align( weather_geolocation_cont, weather_setup_tile, LV_ALIGN_IN_TOP_MID, 0, 49 );
|
||||
weather_geolocation_onoff = lv_switch_create( weather_geolocation_cont, NULL );
|
||||
@@ -101,7 +101,7 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( weather_geolocation_label, weather_geolocation_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
*/
|
||||
lv_obj_t *weather_apikey_cont = lv_obj_create( weather_setup_tile, NULL );
|
||||
lv_obj_set_size(weather_apikey_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(weather_apikey_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( weather_apikey_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
|
||||
lv_obj_align( weather_apikey_cont, weather_setup_tile, LV_ALIGN_IN_TOP_MID, 0, 49 );
|
||||
lv_obj_t *weather_apikey_label = lv_label_create( weather_apikey_cont, NULL);
|
||||
@@ -118,7 +118,7 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_set_event_cb( weather_apikey_textfield, weather_textarea_event_cb );
|
||||
|
||||
lv_obj_t *weather_lat_cont = lv_obj_create( weather_setup_tile, NULL );
|
||||
lv_obj_set_size(weather_lat_cont, LV_HOR_RES_MAX / 2 , 40 );
|
||||
lv_obj_set_size(weather_lat_cont, lv_disp_get_hor_res( NULL ) / 2 , 40 );
|
||||
lv_obj_add_style( weather_lat_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
|
||||
lv_obj_align( weather_lat_cont, weather_apikey_cont, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0 );
|
||||
lv_obj_t *weather_lat_label = lv_label_create( weather_lat_cont, NULL);
|
||||
@@ -130,12 +130,12 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_textarea_set_pwd_mode( weather_lat_textfield, false);
|
||||
lv_textarea_set_one_line( weather_lat_textfield, true);
|
||||
lv_textarea_set_cursor_hidden( weather_lat_textfield, true);
|
||||
lv_obj_set_width( weather_lat_textfield, LV_HOR_RES / 4 );
|
||||
lv_obj_set_width( weather_lat_textfield, lv_disp_get_hor_res( NULL ) / 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_textarea_event_cb );
|
||||
|
||||
lv_obj_t *weather_lon_cont = lv_obj_create( weather_setup_tile, NULL );
|
||||
lv_obj_set_size(weather_lon_cont, LV_HOR_RES_MAX / 2 , 40 );
|
||||
lv_obj_set_size(weather_lon_cont, lv_disp_get_hor_res( NULL ) / 2 , 40 );
|
||||
lv_obj_add_style( weather_lon_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
|
||||
lv_obj_align( weather_lon_cont, weather_apikey_cont, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0 );
|
||||
lv_obj_t *weather_lon_label = lv_label_create( weather_lon_cont, NULL);
|
||||
@@ -147,12 +147,12 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_textarea_set_pwd_mode( weather_lon_textfield, false);
|
||||
lv_textarea_set_one_line( weather_lon_textfield, true);
|
||||
lv_textarea_set_cursor_hidden( weather_lon_textfield, true);
|
||||
lv_obj_set_width( weather_lon_textfield, LV_HOR_RES / 4 );
|
||||
lv_obj_set_width( weather_lon_textfield, lv_disp_get_hor_res( NULL ) / 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_textarea_event_cb );
|
||||
|
||||
lv_obj_t *weather_autosync_cont = lv_obj_create( weather_setup_tile, NULL );
|
||||
lv_obj_set_size( weather_autosync_cont, LV_HOR_RES_MAX , 32);
|
||||
lv_obj_set_size( weather_autosync_cont, lv_disp_get_hor_res( NULL ) , 32);
|
||||
lv_obj_add_style( weather_autosync_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
|
||||
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 );
|
||||
@@ -167,7 +167,7 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
|
||||
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_setup_tile, NULL);
|
||||
lv_obj_set_size( weather_wind_cont, LV_HOR_RES_MAX, 32);
|
||||
lv_obj_set_size( weather_wind_cont, lv_disp_get_hor_res( NULL ), 32);
|
||||
lv_obj_add_style( weather_wind_cont, LV_OBJ_PART_MAIN, &weather_setup_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);
|
||||
@@ -182,7 +182,7 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( weather_wind_label, weather_wind_cont, LV_ALIGN_IN_LEFT_MID, 5, 0);
|
||||
|
||||
lv_obj_t *weather_imperial_cont = lv_obj_create( weather_setup_tile, NULL);
|
||||
lv_obj_set_size( weather_imperial_cont, LV_HOR_RES_MAX, 32);
|
||||
lv_obj_set_size( weather_imperial_cont, lv_disp_get_hor_res( NULL ), 32);
|
||||
lv_obj_add_style( weather_imperial_cont, LV_OBJ_PART_MAIN, &weather_setup_style );
|
||||
lv_obj_align( weather_imperial_cont, weather_wind_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
weather_imperial_onoff = lv_switch_create( weather_imperial_cont, NULL);
|
||||
|
||||
@@ -27,12 +27,11 @@
|
||||
#define LILYGO_WATCH_2020_V1 //To use T-Watch2020, please uncomment this line
|
||||
#define LILYGO_WATCH_LVGL //To use LVGL, you need to enable the macro LVGL
|
||||
#define TWATCH_USE_PSRAM_ALLOC_LVGL
|
||||
#define ENABLE_LVGL_FLUSH_DMA
|
||||
#include <LilyGoWatch.h>
|
||||
|
||||
/*
|
||||
* firmeware version string
|
||||
*/
|
||||
#define __FIRMWARE__ "2020082601"
|
||||
#define __FIRMWARE__ "2020082701"
|
||||
|
||||
#endif // _CONFIG_H
|
||||
|
||||
@@ -52,15 +52,12 @@ LV_IMG_DECLARE(bg2)
|
||||
*/
|
||||
void gui_setup(void)
|
||||
{
|
||||
lv_coord_t hres = lv_disp_get_hor_res(NULL);
|
||||
lv_coord_t vres = lv_disp_get_ver_res(NULL);
|
||||
|
||||
//Create wallpaper
|
||||
lv_obj_t *img_bin = lv_img_create( lv_scr_act() , NULL); /*Create an image object*/
|
||||
lv_img_set_src(img_bin, &bg2 );
|
||||
lv_obj_set_width( img_bin, hres );
|
||||
lv_obj_set_height( img_bin, vres );
|
||||
lv_obj_align(img_bin, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_t *img_bin = lv_img_create( lv_scr_act() , NULL );
|
||||
lv_img_set_src( img_bin, &bg2 );
|
||||
lv_obj_set_width( img_bin, lv_disp_get_hor_res( NULL ) );
|
||||
lv_obj_set_height( img_bin, lv_disp_get_ver_res( NULL ) );
|
||||
lv_obj_align( img_bin, NULL, LV_ALIGN_CENTER, 0, 0 );
|
||||
|
||||
mainbar_setup();
|
||||
/* add the four mainbar screens */
|
||||
@@ -79,7 +76,7 @@ void gui_setup(void)
|
||||
update_tile_setup();
|
||||
|
||||
statusbar_setup();
|
||||
lv_disp_trig_activity(NULL);
|
||||
lv_disp_trig_activity( NULL );
|
||||
|
||||
keyboard_setup();
|
||||
|
||||
@@ -89,7 +86,7 @@ void gui_setup(void)
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void gui_loop( TTGOClass *ttgo ) {
|
||||
void gui_loop( void ) {
|
||||
// if we run in silence mode
|
||||
if ( powermgm_get_event( POWERMGM_SILENCE_WAKEUP ) ) {
|
||||
if ( lv_disp_get_inactive_time(NULL) < display_get_timeout() * 1000 ) {
|
||||
|
||||
@@ -26,6 +26,6 @@
|
||||
#include <TTGO.h>
|
||||
|
||||
void gui_setup( void );
|
||||
void gui_loop( TTGOClass *ttgo );
|
||||
void gui_loop( void );
|
||||
|
||||
#endif // _STATUSBAR_H
|
||||
@@ -20,6 +20,7 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <TTGO.h>
|
||||
|
||||
#include "keyboard.h"
|
||||
|
||||
@@ -45,17 +46,17 @@ void keyboard_setup( void ) {
|
||||
|
||||
kb_screen = lv_cont_create( lv_scr_act(), NULL );
|
||||
lv_obj_add_style( kb_screen, LV_OBJ_PART_MAIN, &kb_style );
|
||||
lv_obj_set_size( kb_screen, LV_HOR_RES_MAX , LV_VER_RES_MAX - 20 );
|
||||
lv_obj_set_size( kb_screen, lv_disp_get_hor_res( NULL ) , lv_disp_get_ver_res( NULL ) - 20 );
|
||||
lv_obj_align( kb_screen, lv_scr_act(), LV_ALIGN_CENTER, 0, 20);
|
||||
|
||||
kb_textarea = lv_textarea_create( kb_screen, NULL );
|
||||
lv_obj_add_protect( kb_textarea, LV_PROTECT_CLICK_FOCUS);
|
||||
lv_obj_set_size( kb_textarea, LV_HOR_RES_MAX - 10, 60 );
|
||||
lv_obj_set_size( kb_textarea, lv_disp_get_hor_res( NULL ) - 10, 60 );
|
||||
lv_textarea_set_one_line( kb_textarea, true);
|
||||
lv_obj_align( kb_textarea, kb_screen, LV_ALIGN_IN_TOP_MID, 0, 5 );
|
||||
|
||||
kb = lv_keyboard_create( lv_scr_act() , NULL);
|
||||
lv_obj_set_size (kb, LV_HOR_RES, ( LV_VER_RES / 4 ) * 3 - 20);
|
||||
lv_obj_set_size (kb, lv_disp_get_hor_res( NULL ), ( lv_disp_get_ver_res( NULL ) / 4 ) * 3 - 20);
|
||||
lv_obj_align( kb, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0 );
|
||||
lv_keyboard_set_cursor_manage( kb, true);
|
||||
lv_obj_set_event_cb( kb, kb_event_cb );
|
||||
|
||||
@@ -59,7 +59,7 @@ void main_tile_setup( void ) {
|
||||
lv_style_set_text_font( &datestyle, LV_STATE_DEFAULT, &Ubuntu_16px);
|
||||
|
||||
clock_cont = mainbar_obj_create( main_cont );
|
||||
lv_obj_set_size( clock_cont, LV_HOR_RES , LV_VER_RES / 2 );
|
||||
lv_obj_set_size( clock_cont, lv_disp_get_hor_res( NULL ) , lv_disp_get_ver_res( NULL ) / 2 );
|
||||
lv_obj_add_style( clock_cont, LV_OBJ_PART_MAIN, style );
|
||||
lv_obj_align( clock_cont, main_cont, LV_ALIGN_CENTER, 0, 0 );
|
||||
|
||||
|
||||
@@ -113,10 +113,10 @@ uint32_t mainbar_add_tile( uint16_t x, uint16_t y ) {
|
||||
tile[ tile_entrys - 1 ].tile = my_tile;
|
||||
tile[ tile_entrys - 1 ].activate_cb = NULL;
|
||||
tile[ tile_entrys - 1 ].hibernate_cb = NULL;
|
||||
lv_obj_set_size( tile[ tile_entrys - 1 ].tile, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_size( tile[ tile_entrys - 1 ].tile, lv_disp_get_hor_res( NULL ), LV_VER_RES);
|
||||
//lv_obj_reset_style_list( tile[ tile_entrys - 1 ].tile, LV_OBJ_PART_MAIN );
|
||||
lv_obj_add_style( tile[ tile_entrys - 1 ].tile, LV_OBJ_PART_MAIN, &mainbar_style );
|
||||
lv_obj_set_pos( tile[ tile_entrys - 1 ].tile, tile_pos_table[ tile_entrys - 1 ].x * LV_HOR_RES , tile_pos_table[ tile_entrys - 1 ].y * LV_VER_RES );
|
||||
lv_obj_set_pos( tile[ tile_entrys - 1 ].tile, tile_pos_table[ tile_entrys - 1 ].x * lv_disp_get_hor_res( NULL ) , tile_pos_table[ tile_entrys - 1 ].y * LV_VER_RES );
|
||||
lv_tileview_add_element( mainbar, tile[ tile_entrys - 1 ].tile );
|
||||
lv_tileview_set_valid_positions( mainbar, tile_pos_table, tile_entrys );
|
||||
log_i("add tile: x=%d, y=%d", tile_pos_table[ tile_entrys - 1 ].x, tile_pos_table[ tile_entrys - 1 ].y );
|
||||
|
||||
@@ -97,7 +97,7 @@ void battery_settings_tile_setup( void ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *battery_silence_wakeup_switch_cont = lv_obj_create( battery_settings_tile, NULL );
|
||||
lv_obj_set_size(battery_silence_wakeup_switch_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(battery_silence_wakeup_switch_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( battery_silence_wakeup_switch_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
|
||||
lv_obj_align( battery_silence_wakeup_switch_cont, battery_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
battery_silence_wakeup_switch = lv_switch_create( battery_silence_wakeup_switch_cont, NULL );
|
||||
@@ -112,7 +112,7 @@ void battery_settings_tile_setup( void ) {
|
||||
lv_obj_align( battery_silence_wakeup_label, battery_silence_wakeup_switch_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *battery_setup_label_cont = lv_obj_create( battery_settings_tile, NULL );
|
||||
lv_obj_set_size(battery_setup_label_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(battery_setup_label_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( battery_setup_label_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
|
||||
lv_obj_align( battery_setup_label_cont, battery_silence_wakeup_switch_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *battery_setup_label = lv_label_create( battery_setup_label_cont, NULL);
|
||||
@@ -121,7 +121,7 @@ void battery_settings_tile_setup( void ) {
|
||||
lv_obj_align( battery_setup_label, battery_setup_label_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *battery_percent_switch_cont = lv_obj_create( battery_settings_tile, NULL );
|
||||
lv_obj_set_size(battery_percent_switch_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(battery_percent_switch_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( battery_percent_switch_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
|
||||
lv_obj_align( battery_percent_switch_cont, battery_setup_label_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
battery_percent_switch = lv_switch_create( battery_percent_switch_cont, NULL );
|
||||
@@ -136,7 +136,7 @@ void battery_settings_tile_setup( void ) {
|
||||
lv_obj_align( stepcounter_label, battery_percent_switch_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *battery_experimental_switch_cont = lv_obj_create( battery_settings_tile, NULL );
|
||||
lv_obj_set_size(battery_experimental_switch_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(battery_experimental_switch_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( battery_experimental_switch_cont, LV_OBJ_PART_MAIN, &battery_settings_style );
|
||||
lv_obj_align( battery_experimental_switch_cont, battery_percent_switch_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
battery_experimental_switch = lv_switch_create( battery_experimental_switch_cont, NULL );
|
||||
|
||||
@@ -87,7 +87,7 @@ void battery_view_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *battery_design_cont = lv_obj_create( battery_view_tile, NULL );
|
||||
lv_obj_set_size( battery_design_cont, LV_HOR_RES_MAX , 25 );
|
||||
lv_obj_set_size( battery_design_cont, lv_disp_get_hor_res( NULL ) , 25 );
|
||||
lv_obj_add_style( battery_design_cont, LV_OBJ_PART_MAIN, &battery_view_style );
|
||||
lv_obj_align( battery_design_cont, battery_view_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
lv_obj_t *battery_design_cap_label = lv_label_create( battery_design_cont, NULL);
|
||||
@@ -100,7 +100,7 @@ void battery_view_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( battery_view_design_cap, battery_design_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
lv_obj_t *battery_current_cont = lv_obj_create( battery_view_tile, NULL );
|
||||
lv_obj_set_size( battery_current_cont, LV_HOR_RES_MAX , 25 );
|
||||
lv_obj_set_size( battery_current_cont, lv_disp_get_hor_res( NULL ) , 25 );
|
||||
lv_obj_add_style( battery_current_cont, LV_OBJ_PART_MAIN, &battery_view_style );
|
||||
lv_obj_align( battery_current_cont, battery_design_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *battery_current_cap_label = lv_label_create( battery_current_cont, NULL);
|
||||
@@ -113,7 +113,7 @@ void battery_view_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( battery_view_current_cap, battery_current_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
lv_obj_t *battery_voltage_cont = lv_obj_create( battery_view_tile, NULL );
|
||||
lv_obj_set_size( battery_voltage_cont, LV_HOR_RES_MAX , 25 );
|
||||
lv_obj_set_size( battery_voltage_cont, lv_disp_get_hor_res( NULL ) , 25 );
|
||||
lv_obj_add_style( battery_voltage_cont, LV_OBJ_PART_MAIN, &battery_view_style );
|
||||
lv_obj_align( battery_voltage_cont, battery_current_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *battery_voltage_label = lv_label_create( battery_voltage_cont, NULL);
|
||||
@@ -126,7 +126,7 @@ void battery_view_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( battery_view_voltage, battery_voltage_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
lv_obj_t *battery_charge_cont = lv_obj_create( battery_view_tile, NULL );
|
||||
lv_obj_set_size( battery_charge_cont, LV_HOR_RES_MAX , 25 );
|
||||
lv_obj_set_size( battery_charge_cont, lv_disp_get_hor_res( NULL ) , 25 );
|
||||
lv_obj_add_style( battery_charge_cont, LV_OBJ_PART_MAIN, &battery_view_style );
|
||||
lv_obj_align( battery_charge_cont, battery_voltage_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 5 );
|
||||
lv_obj_t *battery_charge_label = lv_label_create( battery_charge_cont, NULL);
|
||||
@@ -139,7 +139,7 @@ void battery_view_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( charge_view_current, battery_charge_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
lv_obj_t *battery_discharge_cont = lv_obj_create( battery_view_tile, NULL );
|
||||
lv_obj_set_size( battery_discharge_cont, LV_HOR_RES_MAX , 25 );
|
||||
lv_obj_set_size( battery_discharge_cont, lv_disp_get_hor_res( NULL ) , 25 );
|
||||
lv_obj_add_style( battery_discharge_cont, LV_OBJ_PART_MAIN, &battery_view_style );
|
||||
lv_obj_align( battery_discharge_cont, battery_charge_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *battery_discharge_label = lv_label_create( battery_discharge_cont, NULL);
|
||||
@@ -152,7 +152,7 @@ void battery_view_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( discharge_view_current, battery_discharge_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
lv_obj_t *vbus_voltage_cont = lv_obj_create( battery_view_tile, NULL );
|
||||
lv_obj_set_size( vbus_voltage_cont, LV_HOR_RES_MAX , 25 );
|
||||
lv_obj_set_size( vbus_voltage_cont, lv_disp_get_hor_res( NULL ) , 25 );
|
||||
lv_obj_add_style( vbus_voltage_cont, LV_OBJ_PART_MAIN, &battery_view_style );
|
||||
lv_obj_align( vbus_voltage_cont, battery_discharge_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *vbus_voltage_label = lv_label_create( vbus_voltage_cont, NULL);
|
||||
@@ -196,10 +196,9 @@ static void exit_battery_view_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
||||
|
||||
void battery_view_update_task( lv_task_t *task ) {
|
||||
char temp[16]="";
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
if ( pmu_get_battery_percent( ttgo ) >= 0 ) {
|
||||
snprintf( temp, sizeof( temp ), "%0.1fmAh", ttgo->power->getCoulombData() );
|
||||
if ( pmu_get_battery_percent( ) >= 0 ) {
|
||||
snprintf( temp, sizeof( temp ), "%0.1fmAh", pmu_get_coulumb_data() );
|
||||
}
|
||||
else {
|
||||
snprintf( temp, sizeof( temp ), "unknown" );
|
||||
@@ -211,19 +210,19 @@ void battery_view_update_task( lv_task_t *task ) {
|
||||
lv_label_set_text( battery_view_design_cap, temp );
|
||||
lv_obj_align( battery_view_design_cap, lv_obj_get_parent( battery_view_design_cap ), LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
snprintf( temp, sizeof( temp ), "%0.2fV", ttgo->power->getBattVoltage() / 1000 );
|
||||
snprintf( temp, sizeof( temp ), "%0.2fV", pmu_get_battery_voltage() / 1000 );
|
||||
lv_label_set_text( battery_view_voltage, temp );
|
||||
lv_obj_align( battery_view_voltage, lv_obj_get_parent( battery_view_voltage ), LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
snprintf( temp, sizeof( temp ), "%0.1fmA", ttgo->power->getBattChargeCurrent() );
|
||||
snprintf( temp, sizeof( temp ), "%0.1fmA", pmu_get_battery_charge_current() );
|
||||
lv_label_set_text( charge_view_current, temp );
|
||||
lv_obj_align( charge_view_current, lv_obj_get_parent( charge_view_current ), LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
snprintf( temp, sizeof( temp ), "%0.1fmA", ttgo->power->getBattDischargeCurrent() );
|
||||
snprintf( temp, sizeof( temp ), "%0.1fmA", pmu_get_battery_discharge_current() );
|
||||
lv_label_set_text( discharge_view_current, temp );
|
||||
lv_obj_align( discharge_view_current, lv_obj_get_parent( discharge_view_current ), LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
|
||||
snprintf( temp, sizeof( temp ), "%0.2fV", ttgo->power->getVbusVoltage() / 1000 );
|
||||
snprintf( temp, sizeof( temp ), "%0.2fV", pmu_get_vbus_voltage() / 1000 );
|
||||
lv_label_set_text( vbus_view_voltage, temp );
|
||||
lv_obj_align( vbus_view_voltage, lv_obj_get_parent( vbus_view_voltage ), LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ void bluetooth_message_tile_setup( void ) {
|
||||
lv_obj_align( bluetooth_message_sender_label, bluetooth_message_img, LV_ALIGN_OUT_BOTTOM_LEFT, 5, 5 );
|
||||
|
||||
bluetooth_message_page = lv_page_create( bluetooth_message_tile, NULL);
|
||||
lv_obj_set_size( bluetooth_message_page, LV_HOR_RES_MAX - 20, 160 );
|
||||
lv_obj_set_size( bluetooth_message_page, lv_disp_get_hor_res( NULL ) - 20, 160 );
|
||||
lv_obj_add_style( bluetooth_message_page, LV_OBJ_PART_MAIN, &bluetooth_message_style );
|
||||
lv_page_set_scrlbar_mode( bluetooth_message_page, LV_SCRLBAR_MODE_DRAG );
|
||||
lv_obj_align( bluetooth_message_page, bluetooth_message_sender_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5 );
|
||||
|
||||
@@ -92,7 +92,7 @@ void bluetooth_settings_tile_setup( void ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *bluetooth_advertising_cont = lv_obj_create( bluetooth_settings_tile, NULL );
|
||||
lv_obj_set_size( bluetooth_advertising_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size( bluetooth_advertising_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( bluetooth_advertising_cont, LV_OBJ_PART_MAIN, &bluetooth_settings_style );
|
||||
lv_obj_align( bluetooth_advertising_cont, bluetooth_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
bluetooth_advertising_onoff = lv_switch_create( bluetooth_advertising_cont, NULL );
|
||||
@@ -107,7 +107,7 @@ void bluetooth_settings_tile_setup( void ) {
|
||||
lv_obj_align( bluetooth_advertising_label, bluetooth_advertising_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *bluettoth_info_label_cont = lv_obj_create( bluetooth_settings_tile, NULL );
|
||||
lv_obj_set_size(bluettoth_info_label_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(bluettoth_info_label_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( bluettoth_info_label_cont, LV_OBJ_PART_MAIN, &bluetooth_settings_style );
|
||||
lv_obj_align( bluettoth_info_label_cont, bluetooth_advertising_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *bluetooth_info_label = lv_label_create( bluettoth_info_label_cont, NULL);
|
||||
@@ -116,7 +116,7 @@ void bluetooth_settings_tile_setup( void ) {
|
||||
lv_obj_align( bluetooth_info_label, bluettoth_info_label_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *bluetooth_standby_cont = lv_obj_create( bluetooth_settings_tile, NULL );
|
||||
lv_obj_set_size( bluetooth_standby_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size( bluetooth_standby_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( bluetooth_standby_cont, LV_OBJ_PART_MAIN, &bluetooth_settings_style );
|
||||
lv_obj_align( bluetooth_standby_cont, bluettoth_info_label_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
bluetooth_standby_onoff = lv_switch_create( bluetooth_standby_cont, NULL );
|
||||
|
||||
@@ -126,7 +126,7 @@ void display_settings_tile_setup( void ) {
|
||||
lv_obj_set_event_cb( up_btn_1, up_display_setup_event_cb );
|
||||
|
||||
lv_obj_t *brightness_cont = lv_obj_create( display_settings_tile_1, NULL );
|
||||
lv_obj_set_size( brightness_cont, LV_HOR_RES_MAX , 48 );
|
||||
lv_obj_set_size( brightness_cont, lv_disp_get_hor_res( NULL ) , 48 );
|
||||
lv_obj_add_style( brightness_cont, LV_OBJ_PART_MAIN, &display_settings_style );
|
||||
lv_obj_align( brightness_cont, display_settings_tile_1, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
display_brightness_slider = lv_slider_create( brightness_cont, NULL );
|
||||
@@ -134,7 +134,7 @@ void display_settings_tile_setup( void ) {
|
||||
lv_obj_add_style( display_brightness_slider, LV_SLIDER_PART_INDIC, mainbar_get_slider_style() );
|
||||
lv_obj_add_style( display_brightness_slider, LV_SLIDER_PART_KNOB, mainbar_get_slider_style() );
|
||||
lv_slider_set_range( display_brightness_slider, DISPLAY_MIN_BRIGHTNESS, DISPLAY_MAX_BRIGHTNESS );
|
||||
lv_obj_set_size( display_brightness_slider, LV_HOR_RES_MAX - 100 , 10 );
|
||||
lv_obj_set_size( display_brightness_slider, lv_disp_get_hor_res( NULL ) - 100 , 10 );
|
||||
lv_obj_align( display_brightness_slider, brightness_cont, LV_ALIGN_IN_RIGHT_MID, -30, 0 );
|
||||
lv_obj_set_event_cb( display_brightness_slider, display_brightness_setup_event_cb );
|
||||
lv_obj_t *brightness_icon = lv_img_create( brightness_cont, NULL );
|
||||
@@ -142,7 +142,7 @@ void display_settings_tile_setup( void ) {
|
||||
lv_obj_align( brightness_icon, brightness_cont, LV_ALIGN_IN_LEFT_MID, 15, 0 );
|
||||
|
||||
lv_obj_t *timeout_cont = lv_obj_create( display_settings_tile_1, NULL );
|
||||
lv_obj_set_size( timeout_cont, LV_HOR_RES_MAX , 58 );
|
||||
lv_obj_set_size( timeout_cont, lv_disp_get_hor_res( NULL ) , 58 );
|
||||
lv_obj_add_style( timeout_cont, LV_OBJ_PART_MAIN, &display_settings_style );
|
||||
lv_obj_align( timeout_cont, brightness_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
display_timeout_slider = lv_slider_create( timeout_cont, NULL );
|
||||
@@ -150,7 +150,7 @@ void display_settings_tile_setup( void ) {
|
||||
lv_obj_add_style( display_timeout_slider, LV_SLIDER_PART_INDIC, mainbar_get_slider_style() );
|
||||
lv_obj_add_style( display_timeout_slider, LV_SLIDER_PART_KNOB, mainbar_get_slider_style() );
|
||||
lv_slider_set_range( display_timeout_slider, DISPLAY_MIN_TIMEOUT, DISPLAY_MAX_TIMEOUT );
|
||||
lv_obj_set_size(display_timeout_slider, LV_HOR_RES_MAX - 100 , 10 );
|
||||
lv_obj_set_size(display_timeout_slider, lv_disp_get_hor_res( NULL ) - 100 , 10 );
|
||||
lv_obj_align( display_timeout_slider, timeout_cont, LV_ALIGN_IN_TOP_RIGHT, -30, 10 );
|
||||
lv_obj_set_event_cb( display_timeout_slider, display_timeout_setup_event_cb );
|
||||
display_timeout_slider_label = lv_label_create( timeout_cont, NULL );
|
||||
@@ -162,7 +162,7 @@ void display_settings_tile_setup( void ) {
|
||||
lv_obj_align( timeout_icon, timeout_cont, LV_ALIGN_IN_LEFT_MID, 15, 0 );
|
||||
|
||||
lv_obj_t *rotation_cont = lv_obj_create( display_settings_tile_1, NULL );
|
||||
lv_obj_set_size(rotation_cont, LV_HOR_RES_MAX , 40 );
|
||||
lv_obj_set_size(rotation_cont, lv_disp_get_hor_res( NULL ) , 40 );
|
||||
lv_obj_add_style( rotation_cont, LV_OBJ_PART_MAIN, &display_settings_style );
|
||||
lv_obj_align( rotation_cont, timeout_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *display_rotation_label = lv_label_create( rotation_cont, NULL );
|
||||
@@ -176,7 +176,7 @@ void display_settings_tile_setup( void ) {
|
||||
lv_obj_set_event_cb(display_rotation_list, display_rotation_event_handler);
|
||||
|
||||
lv_obj_t *vibe_cont = lv_obj_create( display_settings_tile_2, NULL );
|
||||
lv_obj_set_size(vibe_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(vibe_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( vibe_cont, LV_OBJ_PART_MAIN, &display_settings_style );
|
||||
lv_obj_align( vibe_cont, display_settings_tile_2, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
display_vibe_onoff = lv_switch_create( vibe_cont, NULL );
|
||||
@@ -191,7 +191,7 @@ void display_settings_tile_setup( void ) {
|
||||
lv_obj_align( display_vibe_label, vibe_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *block_return_maintile_cont = lv_obj_create( display_settings_tile_2, NULL );
|
||||
lv_obj_set_size(block_return_maintile_cont, LV_HOR_RES_MAX , 40 );
|
||||
lv_obj_set_size(block_return_maintile_cont, lv_disp_get_hor_res( NULL ) , 40 );
|
||||
lv_obj_add_style( block_return_maintile_cont, LV_OBJ_PART_MAIN, &display_settings_style );
|
||||
lv_obj_align( block_return_maintile_cont, vibe_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
display_block_return_maintile_onoff = lv_switch_create( block_return_maintile_cont, NULL );
|
||||
|
||||
@@ -79,7 +79,7 @@ void move_settings_tile_setup( void ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *stepcounter_cont = lv_obj_create( move_settings_tile, NULL );
|
||||
lv_obj_set_size(stepcounter_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(stepcounter_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( stepcounter_cont, LV_OBJ_PART_MAIN, &move_settings_style );
|
||||
lv_obj_align( stepcounter_cont, move_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
stepcounter_onoff = lv_switch_create( stepcounter_cont, NULL );
|
||||
@@ -94,7 +94,7 @@ void move_settings_tile_setup( void ) {
|
||||
lv_obj_align( stepcounter_label, stepcounter_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *doubleclick_cont = lv_obj_create( move_settings_tile, NULL );
|
||||
lv_obj_set_size(doubleclick_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(doubleclick_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( doubleclick_cont, LV_OBJ_PART_MAIN, &move_settings_style );
|
||||
lv_obj_align( doubleclick_cont, stepcounter_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
doubleclick_onoff = lv_switch_create( doubleclick_cont, NULL );
|
||||
|
||||
@@ -83,7 +83,7 @@ void time_settings_tile_setup( void ) {
|
||||
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, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(wifisync_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( wifisync_cont, LV_OBJ_PART_MAIN, &time_settings_style );
|
||||
lv_obj_align( wifisync_cont, time_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
wifisync_onoff = lv_switch_create( wifisync_cont, NULL );
|
||||
@@ -98,7 +98,7 @@ void time_settings_tile_setup( void ) {
|
||||
lv_obj_align( wifisync_label, wifisync_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *daylight_cont = lv_obj_create( time_settings_tile, NULL );
|
||||
lv_obj_set_size(daylight_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(daylight_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( daylight_cont, LV_OBJ_PART_MAIN, &time_settings_style );
|
||||
lv_obj_align( daylight_cont, wifisync_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
daylight_onoff = lv_switch_create( daylight_cont, NULL );
|
||||
@@ -113,7 +113,7 @@ void time_settings_tile_setup( void ) {
|
||||
lv_obj_align( daylight_label, daylight_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, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(utczone_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( utczone_cont, LV_OBJ_PART_MAIN, &time_settings_style );
|
||||
lv_obj_align( utczone_cont, daylight_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *utczone_label = lv_label_create( utczone_cont, NULL);
|
||||
|
||||
@@ -114,7 +114,7 @@ void update_tile_setup( void ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *update_version_cont = lv_obj_create( update_settings_tile, NULL );
|
||||
lv_obj_set_size(update_version_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(update_version_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( update_version_cont, LV_OBJ_PART_MAIN, &update_settings_style );
|
||||
lv_obj_align( update_version_cont, update_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
lv_obj_t *update_version_label = lv_label_create( update_version_cont, NULL);
|
||||
|
||||
@@ -77,7 +77,7 @@ void update_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *update_check_autosync_cont = lv_obj_create( update_setup_tile, NULL );
|
||||
lv_obj_set_size(update_check_autosync_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(update_check_autosync_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( update_check_autosync_cont, LV_OBJ_PART_MAIN, &update_setup_style );
|
||||
lv_obj_align( update_check_autosync_cont, update_setup_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
|
||||
@@ -93,7 +93,7 @@ void update_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_obj_align( update_check_autosync_label, update_check_autosync_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *update_check_url_cont = lv_obj_create( update_setup_tile, NULL );
|
||||
lv_obj_set_size(update_check_url_cont, LV_HOR_RES_MAX , 60);
|
||||
lv_obj_set_size(update_check_url_cont, lv_disp_get_hor_res( NULL ) , 60);
|
||||
lv_obj_add_style( update_check_url_cont, LV_OBJ_PART_MAIN, &update_setup_style );
|
||||
lv_obj_align( update_check_url_cont, update_check_autosync_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_t *update_check_url_label = lv_label_create( update_check_url_cont, NULL);
|
||||
@@ -105,7 +105,7 @@ void update_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_textarea_set_pwd_mode( update_check_url_textfield, false);
|
||||
lv_textarea_set_one_line( update_check_url_textfield, true);
|
||||
lv_textarea_set_cursor_hidden( update_check_url_textfield, true);
|
||||
lv_obj_set_width( update_check_url_textfield, LV_HOR_RES - 10 );
|
||||
lv_obj_set_width( update_check_url_textfield, lv_disp_get_hor_res( NULL ) - 10 );
|
||||
lv_obj_align( update_check_url_textfield, update_check_url_cont, LV_ALIGN_IN_BOTTOM_MID, 0, 0 );
|
||||
lv_obj_set_event_cb( update_check_url_textfield, update_check_url_textarea_event_cb );
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ void wlan_settings_tile_setup( void ) {
|
||||
lv_obj_set_event_cb( wifi_onoff, wifi_onoff_event_handler);
|
||||
|
||||
wifiname_list = lv_list_create( wifi_settings_tile, NULL);
|
||||
lv_obj_set_size( wifiname_list, LV_HOR_RES_MAX, 160);
|
||||
lv_obj_set_size( wifiname_list, lv_disp_get_hor_res( NULL ), 160);
|
||||
lv_style_init( &wifi_list_style );
|
||||
lv_style_set_border_width( &wifi_list_style , LV_OBJ_PART_MAIN, 0);
|
||||
lv_style_set_radius( &wifi_list_style , LV_OBJ_PART_MAIN, 0);
|
||||
@@ -235,13 +235,13 @@ void wlan_password_tile_setup( uint32_t wifi_password_tile_num ) {
|
||||
lv_textarea_set_pwd_mode( wifi_password_pass_textfield, false);
|
||||
lv_textarea_set_one_line( wifi_password_pass_textfield, true);
|
||||
lv_textarea_set_cursor_hidden( wifi_password_pass_textfield, true);
|
||||
lv_obj_set_width( wifi_password_pass_textfield, LV_HOR_RES );
|
||||
lv_obj_set_width( wifi_password_pass_textfield, lv_disp_get_hor_res( NULL ) );
|
||||
lv_obj_align( wifi_password_pass_textfield, wifi_password_tile, LV_ALIGN_IN_TOP_LEFT, 0, 75);
|
||||
lv_obj_set_event_cb( wifi_password_pass_textfield, wlan_password_event_cb );
|
||||
|
||||
lv_obj_t *mac_label = lv_label_create( wifi_password_tile, NULL);
|
||||
lv_obj_add_style( mac_label, LV_IMGBTN_PART_MAIN, &wifi_password_style );
|
||||
lv_obj_set_width( mac_label, LV_HOR_RES);
|
||||
lv_obj_set_width( mac_label, lv_disp_get_hor_res( NULL ) );
|
||||
lv_obj_align( mac_label, wifi_password_tile, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||
lv_label_set_text_fmt( mac_label, "MAC: %s", WiFi.macAddress().c_str());
|
||||
|
||||
@@ -328,7 +328,7 @@ void wlan_setup_tile_setup( uint32_t wifi_setup_tile_num ) {
|
||||
lv_obj_align( exit_label, exit_btn, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
lv_obj_t *wifi_autoon_onoff_cont = lv_obj_create( wifi_setup_tile, NULL );
|
||||
lv_obj_set_size(wifi_autoon_onoff_cont, LV_HOR_RES_MAX , 40);
|
||||
lv_obj_set_size(wifi_autoon_onoff_cont, lv_disp_get_hor_res( NULL ) , 40);
|
||||
lv_obj_add_style( wifi_autoon_onoff_cont, LV_OBJ_PART_MAIN, &wifi_setup_style );
|
||||
lv_obj_align( wifi_autoon_onoff_cont, wifi_setup_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
|
||||
|
||||
@@ -344,7 +344,7 @@ void wlan_setup_tile_setup( uint32_t wifi_setup_tile_num ) {
|
||||
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_set_size(wifi_webserver_onoff_cont, lv_disp_get_hor_res( NULL ) , 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 );
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ uint16_t *png;
|
||||
static void screenshot_disp_flush( lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p );
|
||||
|
||||
void screenshot_setup( void ) {
|
||||
png = (uint16_t*)ps_malloc( LV_HOR_RES_MAX * LV_VER_RES_MAX * sizeof( lv_color_t ) );
|
||||
png = (uint16_t*)ps_malloc( lv_disp_get_hor_res( NULL ) * lv_disp_get_ver_res( NULL ) * sizeof( lv_color_t ) );
|
||||
if ( png == NULL ) {
|
||||
log_e("error memory alloc");
|
||||
while(1);
|
||||
@@ -50,7 +50,7 @@ void screenshot_save( void ) {
|
||||
SPIFFS.remove( SCREENSHOT_FILE_NAME );
|
||||
fs::File file = SPIFFS.open( SCREENSHOT_FILE_NAME, FILE_WRITE );
|
||||
|
||||
file.write( (uint8_t *)png, LV_HOR_RES_MAX * LV_VER_RES_MAX * 2 );
|
||||
file.write( (uint8_t *)png, lv_disp_get_hor_res( NULL ) * lv_disp_get_ver_res( NULL ) * 2 );
|
||||
file.close();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ static void screenshot_disp_flush( lv_disp_drv_t *disp_drv, const lv_area_t *are
|
||||
|
||||
for(y = area->y1; y <= area->y2; y++) {
|
||||
for(x = area->x1; x <= area->x2; x++) {
|
||||
*(png + (y * LV_HOR_RES_MAX + x )) = *data;
|
||||
*(png + (y * lv_disp_get_hor_res( NULL ) + x )) = *data;
|
||||
data++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
*/
|
||||
void screenshot_save( void );
|
||||
|
||||
/*
|
||||
struct PNG_IMAGE {
|
||||
uint8_t png[ 8 ];
|
||||
uint32_t IHDR_len;
|
||||
@@ -59,5 +60,6 @@
|
||||
uint8_t IEND[ 4 ];
|
||||
uint32_t IEND_crc;
|
||||
} __attribute__((packed));
|
||||
*/
|
||||
|
||||
#endif // _SCREENSHOT_H
|
||||
@@ -27,7 +27,10 @@ lv_obj_t *preload = NULL;
|
||||
lv_obj_t *preload_label = NULL;
|
||||
lv_style_t style;
|
||||
|
||||
void splash_screen_stage_one( TTGOClass *ttgo ) {
|
||||
void splash_screen_stage_one( void ) {
|
||||
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
lv_style_init( &style );
|
||||
lv_style_set_radius(&style, LV_OBJ_PART_MAIN, 0);
|
||||
lv_style_set_bg_color(&style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK);
|
||||
@@ -36,12 +39,12 @@ void splash_screen_stage_one( TTGOClass *ttgo ) {
|
||||
lv_style_set_text_color(&style, LV_OBJ_PART_MAIN, LV_COLOR_WHITE);
|
||||
|
||||
lv_obj_t *background = lv_bar_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size( background, LV_HOR_RES_MAX, LV_VER_RES_MAX );
|
||||
lv_obj_set_size( background, lv_disp_get_hor_res( NULL ), lv_disp_get_ver_res( NULL ) );
|
||||
lv_obj_add_style( background, LV_OBJ_PART_MAIN, &style );
|
||||
lv_obj_align(background, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
preload = lv_bar_create( background, NULL);
|
||||
lv_obj_set_size(preload, LV_HOR_RES_MAX - 40, 20);
|
||||
lv_obj_set_size(preload, lv_disp_get_hor_res( NULL ) - 40, 20);
|
||||
lv_obj_add_style( preload, LV_OBJ_PART_MAIN, &style );
|
||||
lv_obj_align(preload, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_bar_set_anim_time(preload, 2000);
|
||||
@@ -75,12 +78,14 @@ void splash_screen_stage_update( const char* msg, int value ) {
|
||||
lv_task_handler();
|
||||
}
|
||||
|
||||
void splash_screen_stage_finish( TTGOClass *ttgo ) {
|
||||
// ttgo->bl->adjust( 0 );
|
||||
void splash_screen_stage_finish( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
for( int bl = display_get_brightness() ; bl > 0 ; bl-- ) {
|
||||
ttgo->bl->adjust( bl );
|
||||
delay(1);
|
||||
}
|
||||
lv_obj_del( preload );
|
||||
lv_obj_del( preload_label );
|
||||
lv_task_handler();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
*
|
||||
* @param ttgo pointer to TTGOClass
|
||||
*/
|
||||
void splash_screen_stage_one( TTGOClass *ttgo );
|
||||
void splash_screen_stage_one( void );
|
||||
/*
|
||||
* @brief update spash screen text and bar
|
||||
*
|
||||
@@ -40,6 +40,6 @@
|
||||
*
|
||||
* @param ttgo pointer to TTGOClass
|
||||
*/
|
||||
void splash_screen_stage_finish( TTGOClass *ttgo );
|
||||
void splash_screen_stage_finish( void );
|
||||
|
||||
#endif // _SPLASHSCREEN_H
|
||||
@@ -41,8 +41,10 @@
|
||||
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_obj_t *statusbar_tagRSSI = NULL;
|
||||
static lv_style_t statusbarstyle[ STATUSBAR_STYLE_NUM ];
|
||||
|
||||
lv_status_bar_t statusicon[ STATUSBAR_NUM ] =
|
||||
@@ -171,6 +173,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 );
|
||||
@@ -183,13 +192,23 @@ void statusbar_setup( void )
|
||||
lv_label_set_text(statusbar_stepcounterlabel, "0");
|
||||
lv_obj_align(statusbar_stepcounterlabel, statusbar_stepicon, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
|
||||
|
||||
statusbar_tagRSSI = lv_label_create(statusbar, NULL);
|
||||
lv_obj_reset_style_list( statusbar_tagRSSI, LV_OBJ_PART_MAIN );
|
||||
lv_obj_add_style( statusbar_tagRSSI, LV_OBJ_PART_MAIN, &statusbarstyle[ STATUSBAR_STYLE_WHITE ] );
|
||||
lv_label_set_text(statusbar_tagRSSI, "0");
|
||||
lv_obj_align(statusbar_tagRSSI, statusbar, LV_ALIGN_CENTER, -30, 0 );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
statusbar_hide_icon( STATUSBAR_BELL );
|
||||
statusbar_hide_icon( STATUSBAR_WARNING );
|
||||
statusbar_hide_icon( STATUSBAR_WIFI );
|
||||
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 +235,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 +303,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);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -363,6 +396,15 @@ void statusbar_update_stepcounter( int step ) {
|
||||
snprintf( stepcounter, sizeof( stepcounter ), "%d", step );
|
||||
lv_label_set_text( statusbar_stepcounterlabel, (const char *)stepcounter );
|
||||
}
|
||||
|
||||
|
||||
void statusbar_update_rssi( int rssi ) {
|
||||
char rssidisplay[4]="";
|
||||
snprintf( rssidisplay, sizeof( rssidisplay ), "%d", rssi );
|
||||
lv_label_set_text( statusbar_tagRSSI, (const char *)rssidisplay );
|
||||
log_i("update rssi: %s",rssidisplay);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
@@ -112,5 +113,7 @@
|
||||
*/
|
||||
void statusbar_hide( bool hide );
|
||||
|
||||
void statusbar_update_rssi( int rssi );
|
||||
|
||||
#endif // _STATUSBAR_H
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#include <BLEServer.h>
|
||||
#include <BLEUtils.h>
|
||||
#include <BLE2902.h>
|
||||
#include <BLEAdvertisedDevice.h>
|
||||
#include <BLEscan.h>
|
||||
#include "hardware/motor.h"
|
||||
|
||||
#include "blectl.h"
|
||||
#include "json_psram_allocator.h"
|
||||
@@ -51,6 +54,15 @@ BLECharacteristic *pTxCharacteristic;
|
||||
BLECharacteristic *pRxCharacteristic;
|
||||
uint8_t txValue = 0;
|
||||
|
||||
//scan stuff
|
||||
BLEScan *pBLEScan = NULL;
|
||||
const int scantime = 1;
|
||||
const BLEAddress testmac = BLEAddress("ed:19:fd:19:43:0a");
|
||||
int currentRSSI = -99;
|
||||
bool deviceFound = false;
|
||||
const unsigned int bleNotfoundreload = 5;
|
||||
unsigned int bleNotfoundCountdown = bleNotfoundreload;
|
||||
|
||||
BLECharacteristic *pBatteryLevelCharacteristic;
|
||||
BLECharacteristic *pBatteryPowerStateCharacteristic;
|
||||
|
||||
@@ -210,6 +222,52 @@ class BleCtlCallbacks : public BLECharacteristicCallbacks
|
||||
};
|
||||
|
||||
|
||||
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
||||
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
||||
if (advertisedDevice.getAddress().equals(testmac))
|
||||
{
|
||||
log_i("BLE Tag found, rssi: %i ", advertisedDevice.getRSSI());
|
||||
currentRSSI = advertisedDevice.getRSSI();
|
||||
deviceFound = true;
|
||||
bleNotfoundCountdown = bleNotfoundreload;
|
||||
statusbar_update_rssi(currentRSSI);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void myscanCompleteCB(BLEScanResults result)
|
||||
{
|
||||
if(!deviceFound )
|
||||
{
|
||||
currentRSSI = 0;
|
||||
if(!bleNotfoundCountdown--)
|
||||
{
|
||||
motor_vibe(10);
|
||||
}
|
||||
}
|
||||
deviceFound = false;
|
||||
pBLEScan->clearResults();
|
||||
pBLEScan->start(scantime,myscanCompleteCB,true);
|
||||
log_i("BLE scan re-started...");
|
||||
}
|
||||
|
||||
int blectl_get_tagRSSI( void ){
|
||||
log_i("Rssi requested %i",currentRSSI);
|
||||
return currentRSSI;
|
||||
}
|
||||
|
||||
void blectl_start_scan( void )
|
||||
{
|
||||
pBLEScan->start(scantime,myscanCompleteCB,true);
|
||||
log_i("BLE tag scan started...");
|
||||
}
|
||||
|
||||
void blectl_stop_scan( void )
|
||||
{
|
||||
pBLEScan->stop();
|
||||
log_i("BLE tag scan stopped.");
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@@ -231,6 +289,14 @@ void blectl_setup( void ) {
|
||||
// The minimum power level (-12dbm) ESP_PWR_LVL_N12 was too low
|
||||
BLEDevice::setPower( ESP_PWR_LVL_N9 );
|
||||
|
||||
// BLE scan
|
||||
pBLEScan = BLEDevice::getScan();
|
||||
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
|
||||
pBLEScan->setActiveScan(true);
|
||||
pBLEScan->setInterval(100);
|
||||
pBLEScan->setWindow(99);
|
||||
|
||||
|
||||
// Enable encryption
|
||||
BLEServer* pServer = BLEDevice::createServer();
|
||||
BLEDevice::setEncryptionLevel( ESP_BLE_SEC_ENCRYPT_NO_MITM );
|
||||
@@ -306,6 +372,8 @@ void blectl_setup( void ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@@ -386,13 +454,19 @@ void blectl_send_event_cb( EventBits_t event, char *msg ) {
|
||||
void blectl_standby( void ) {
|
||||
/*
|
||||
*/
|
||||
blectl_stop_scan();
|
||||
}
|
||||
|
||||
|
||||
void blectl_wakeup( void ) {
|
||||
/*
|
||||
*/
|
||||
blectl_start_scan();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void blectl_set_enable_on_standby( bool enable_on_standby ) {
|
||||
blectl_config.enable_on_standby = enable_on_standby;
|
||||
blectl_save_config();
|
||||
|
||||
@@ -122,4 +122,9 @@
|
||||
|
||||
void blectl_update_battery( int32_t percent, bool charging, bool plug );
|
||||
|
||||
int blectl_get_tagRSSI( void );
|
||||
void blectl_start_scan( void );
|
||||
void blectl_stop_scan( void );
|
||||
|
||||
|
||||
#endif // _BLECTL_H
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "json_psram_allocator.h"
|
||||
|
||||
#include "gui/statusbar.h"
|
||||
#include "hardware/blectl.h"
|
||||
|
||||
|
||||
EventGroupHandle_t bma_event_handle = NULL;
|
||||
bma_config_t bma_config[ BMA_CONFIG_NUM ];
|
||||
@@ -41,7 +43,8 @@ void IRAM_ATTR bma_irq( void );
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void bma_setup( TTGOClass *ttgo ) {
|
||||
void bma_setup( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
bma_event_handle = xEventGroupCreate();
|
||||
|
||||
@@ -90,6 +93,8 @@ void bma_wakeup( void ) {
|
||||
|
||||
stepcounter_before_reset = ttgo->bma->getCounter();
|
||||
statusbar_update_stepcounter( stepcounter + ttgo->bma->getCounter() );
|
||||
statusbar_update_rssi( blectl_get_tagRSSI() );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -120,7 +125,8 @@ void IRAM_ATTR bma_irq( void ) {
|
||||
/*
|
||||
* loop routine for handling IRQ in main loop
|
||||
*/
|
||||
void bma_loop( TTGOClass *ttgo ) {
|
||||
void bma_loop( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
/*
|
||||
* handle IRQ event
|
||||
*/
|
||||
@@ -136,6 +142,7 @@ void bma_loop( TTGOClass *ttgo ) {
|
||||
if ( !powermgm_get_event( POWERMGM_STANDBY ) && xEventGroupGetBitsFromISR( bma_event_handle ) & BMA_EVENT_INT ) {
|
||||
stepcounter_before_reset = ttgo->bma->getCounter();
|
||||
statusbar_update_stepcounter( stepcounter + ttgo->bma->getCounter() );
|
||||
statusbar_update_rssi(blectl_get_tagRSSI());
|
||||
xEventGroupClearBitsFromISR( bma_event_handle, BMA_EVENT_INT );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void bma_setup( TTGOClass *ttgo );
|
||||
void bma_setup( void );
|
||||
/*
|
||||
* @brief loop function for activity measurement
|
||||
*/
|
||||
void bma_loop( TTGOClass *ttgo );
|
||||
void bma_loop( void );
|
||||
/*
|
||||
* @brief put bma into standby, depending on ther config
|
||||
*/
|
||||
|
||||
@@ -35,9 +35,11 @@ static uint8_t brightness = 0;
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void display_setup( TTGOClass *ttgo ) {
|
||||
void display_setup( void ) {
|
||||
display_read_config();
|
||||
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
ttgo->openBL();
|
||||
ttgo->bl->adjust( 0 );
|
||||
ttgo->tft->setRotation( display_config.rotation / 90 );
|
||||
@@ -46,7 +48,9 @@ void display_setup( TTGOClass *ttgo ) {
|
||||
/*
|
||||
* loop routine for handling IRQ in main loop
|
||||
*/
|
||||
void display_loop( TTGOClass *ttgo ) {
|
||||
void display_loop( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
if ( !powermgm_get_event( POWERMGM_STANDBY ) && !powermgm_get_event( POWERMGM_SILENCE_WAKEUP )) {
|
||||
if ( dest_brightness != brightness ) {
|
||||
if ( brightness < dest_brightness ) {
|
||||
|
||||
@@ -46,13 +46,13 @@
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void display_setup( TTGOClass *ttgo );
|
||||
void display_setup( void );
|
||||
/*
|
||||
* @brief display loop
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void display_loop( TTGOClass *ttgo );
|
||||
void display_loop( void );
|
||||
/*
|
||||
* @brief save config for display to spiffs
|
||||
*/
|
||||
|
||||
94
src/hardware/driver/i2c_bus.cpp
Normal file
94
src/hardware/driver/i2c_bus.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
#include "i2c_bus.h"
|
||||
#include "Wire.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
void I2C_Bus::scan(void)
|
||||
{
|
||||
uint8_t err, addr;
|
||||
int nDevices = 0;
|
||||
for (addr = 1; addr < 127; addr++) {
|
||||
_port->beginTransmission(addr);
|
||||
err = _port->endTransmission();
|
||||
if (err == 0) {
|
||||
Serial.print("I2C device found at address 0x");
|
||||
if (addr < 16)
|
||||
Serial.print("0");
|
||||
Serial.print(addr, HEX);
|
||||
Serial.println(" !");
|
||||
nDevices++;
|
||||
} else if (err == 4) {
|
||||
Serial.print("Unknow error at address 0x");
|
||||
if (addr < 16)
|
||||
Serial.print("0");
|
||||
Serial.println(addr, HEX);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0)
|
||||
Serial.println("No I2C devices found\n");
|
||||
else
|
||||
Serial.println("done\n");
|
||||
}
|
||||
|
||||
|
||||
uint16_t I2C_Bus::readBytes(uint8_t addr, uint8_t *data, uint16_t len, uint16_t delay_ms)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
xSemaphoreTakeRecursive(_i2c_mux, portMAX_DELAY);
|
||||
uint8_t cnt = _port->requestFrom(addr, (uint8_t)len, (uint8_t)1);
|
||||
if (!cnt) {
|
||||
ret = 1 << 13;
|
||||
}
|
||||
uint16_t index = 0;
|
||||
while (_port->available()) {
|
||||
if (index > len)return 1 << 14;
|
||||
if (delay_ms)delay(delay_ms);
|
||||
data[index++] = _port->read();
|
||||
}
|
||||
xSemaphoreGiveRecursive(_i2c_mux);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uint16_t I2C_Bus::readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
xSemaphoreTakeRecursive(_i2c_mux, portMAX_DELAY);
|
||||
_port->beginTransmission(addr);
|
||||
_port->write(reg);
|
||||
_port->endTransmission(false);
|
||||
uint8_t cnt = _port->requestFrom(addr, (uint8_t)len, (uint8_t)1);
|
||||
if (!cnt) {
|
||||
ret = 1 << 13;
|
||||
}
|
||||
uint16_t index = 0;
|
||||
while (_port->available()) {
|
||||
if (index > len)return 1 << 14;
|
||||
data[index++] = _port->read();
|
||||
}
|
||||
xSemaphoreGiveRecursive(_i2c_mux);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint16_t I2C_Bus::writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
xSemaphoreTakeRecursive(_i2c_mux, portMAX_DELAY);
|
||||
_port->beginTransmission(addr);
|
||||
_port->write(reg);
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
_port->write(data[i]);
|
||||
}
|
||||
ret = _port->endTransmission();
|
||||
xSemaphoreGiveRecursive(_i2c_mux);
|
||||
return ret ? 1 << 12 : ret;
|
||||
}
|
||||
|
||||
bool I2C_Bus::deviceProbe(uint8_t addr)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
xSemaphoreTakeRecursive(_i2c_mux, portMAX_DELAY);
|
||||
_port->beginTransmission(addr);
|
||||
ret = _port->endTransmission();
|
||||
xSemaphoreGiveRecursive(_i2c_mux);
|
||||
return (ret == 0);
|
||||
}
|
||||
26
src/hardware/driver/i2c_bus.h
Normal file
26
src/hardware/driver/i2c_bus.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef I2C_BUS_H
|
||||
#define I2C_BUS_H
|
||||
|
||||
#include <Wire.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
class I2C_Bus {
|
||||
public:
|
||||
I2C_Bus(TwoWire &port = Wire, int sda = 21, int scl = 22)
|
||||
{
|
||||
_port = &port;
|
||||
_port->begin(sda, scl);
|
||||
_i2c_mux = xSemaphoreCreateRecursiveMutex();
|
||||
};
|
||||
void scan();
|
||||
uint16_t readBytes(uint8_t addr, uint8_t *data, uint16_t len, uint16_t delay_ms = 0);
|
||||
uint16_t readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len);
|
||||
uint16_t writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len);
|
||||
bool deviceProbe(uint8_t addr);
|
||||
private:
|
||||
TwoWire *_port;
|
||||
SemaphoreHandle_t _i2c_mux = NULL;
|
||||
};
|
||||
|
||||
#endif // I2C_BUS_H
|
||||
0
src/hardware/driver/rtc
Normal file
0
src/hardware/driver/rtc
Normal file
@@ -13,19 +13,19 @@
|
||||
#include "gui/statusbar.h"
|
||||
|
||||
EventGroupHandle_t pmu_event_handle = NULL;
|
||||
|
||||
void IRAM_ATTR pmu_irq( void );
|
||||
|
||||
pmu_config_t pmu_config;
|
||||
|
||||
/*
|
||||
* init the pmu: AXP202
|
||||
*/
|
||||
void pmu_setup( TTGOClass *ttgo ) {
|
||||
void pmu_setup( void ) {
|
||||
pmu_event_handle = xEventGroupCreate();
|
||||
|
||||
pmu_read_config();
|
||||
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
// Turn on the IRQ used
|
||||
ttgo->power->adc1Enable( AXP202_BATT_VOL_ADC1 | AXP202_BATT_CUR_ADC1 | AXP202_VBUS_VOL_ADC1 | AXP202_VBUS_CUR_ADC1, AXP202_ON);
|
||||
ttgo->power->enableIRQ( AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_CHARGING_FINISHED_IRQ | AXP202_TIMER_TIMEOUT_IRQ, AXP202_ON );
|
||||
@@ -249,10 +249,12 @@ void pmu_set_experimental_power_save( bool value ) {
|
||||
/*
|
||||
* loop routine for handling IRQ in main loop
|
||||
*/
|
||||
void pmu_loop( TTGOClass *ttgo ) {
|
||||
void pmu_loop( void ) {
|
||||
static uint64_t nextmillis = 0;
|
||||
bool updatetrigger = false;
|
||||
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
/*
|
||||
* handle IRQ event
|
||||
*/
|
||||
@@ -294,13 +296,15 @@ void pmu_loop( TTGOClass *ttgo ) {
|
||||
if ( !powermgm_get_event( POWERMGM_STANDBY ) ) {
|
||||
if ( nextmillis < millis() || updatetrigger == true ) {
|
||||
nextmillis = millis() + 1000;
|
||||
statusbar_update_battery( pmu_get_battery_percent( ttgo ), ttgo->power->isChargeing(), ttgo->power->isVBUSPlug() );
|
||||
blectl_update_battery( pmu_get_battery_percent( ttgo ), ttgo->power->isChargeing(), ttgo->power->isVBUSPlug() );
|
||||
statusbar_update_battery( pmu_get_battery_percent(), ttgo->power->isChargeing(), ttgo->power->isVBUSPlug() );
|
||||
blectl_update_battery( pmu_get_battery_percent(), ttgo->power->isChargeing(), ttgo->power->isVBUSPlug() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t pmu_get_battery_percent( TTGOClass *ttgo ) {
|
||||
int32_t pmu_get_battery_percent( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
if ( ttgo->power->getBattChargeCoulomb() < ttgo->power->getBattDischargeCoulomb() || ttgo->power->getBattVoltage() < 3200 ) {
|
||||
ttgo->power->ClearCoulombcounter();
|
||||
}
|
||||
@@ -311,4 +315,39 @@ int32_t pmu_get_battery_percent( TTGOClass *ttgo ) {
|
||||
else {
|
||||
return( ttgo->power->getBattPercentage() );
|
||||
}
|
||||
}
|
||||
|
||||
float pmu_get_battery_voltage( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
return( ttgo->power->getBattVoltage() );
|
||||
}
|
||||
|
||||
float pmu_get_battery_charge_current( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
return( ttgo->power->getBattChargeCurrent() );
|
||||
}
|
||||
|
||||
float pmu_get_battery_discharge_current( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
return( ttgo->power->getBattDischargeCurrent() );
|
||||
}
|
||||
|
||||
float pmu_get_vbus_voltage( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
return( ttgo->power->getVbusVoltage() );
|
||||
}
|
||||
|
||||
float pmu_get_coulumb_data( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
return( ttgo->power->getCoulombData() );
|
||||
}
|
||||
|
||||
bool pmu_is_charging( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
return( ttgo->power->isChargeing() );
|
||||
}
|
||||
|
||||
bool pmu_is_vbus_plug( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
return( ttgo->power->isVBUSPlug() );
|
||||
}
|
||||
@@ -48,13 +48,13 @@
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void pmu_setup( TTGOClass *ttgo );
|
||||
void pmu_setup( void );
|
||||
/*
|
||||
* @brief pmu loop routine, call from powermgm. not for user use
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void pmu_loop( TTGOClass *ttgo );
|
||||
void pmu_loop( void );
|
||||
/*
|
||||
*
|
||||
* @brief get the charge of battery in percent
|
||||
@@ -63,7 +63,7 @@
|
||||
*
|
||||
* @return charge in percent or -1 if unknown
|
||||
*/
|
||||
int32_t pmu_get_battery_percent( TTGOClass *ttgo );
|
||||
int32_t pmu_get_battery_percent( void );
|
||||
/*
|
||||
* @brief set the axp202 in standby
|
||||
*/
|
||||
@@ -99,5 +99,12 @@
|
||||
int32_t pmu_get_designed_battery_cap( void );
|
||||
bool pmu_get_silence_wakeup( void );
|
||||
void pmu_set_silence_wakeup( bool value );
|
||||
float pmu_get_battery_voltage( void );
|
||||
float pmu_get_battery_charge_current( void );
|
||||
float pmu_get_battery_discharge_current( void );
|
||||
float pmu_get_vbus_voltage( void );
|
||||
float pmu_get_coulumb_data( void );
|
||||
bool pmu_is_charging( void );
|
||||
bool pmu_is_vbus_plug( void );
|
||||
|
||||
#endif // _PMU_H
|
||||
@@ -48,23 +48,25 @@ portMUX_TYPE powermgmMux = portMUX_INITIALIZER_UNLOCKED;
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void powermgm_setup( TTGOClass *ttgo ) {
|
||||
void powermgm_setup( void ) {
|
||||
|
||||
powermgm_status = xEventGroupCreate();
|
||||
|
||||
pmu_setup( ttgo );
|
||||
bma_setup( ttgo );
|
||||
pmu_setup();
|
||||
bma_setup();
|
||||
wifictl_setup();
|
||||
blectl_read_config();
|
||||
timesync_setup( ttgo );
|
||||
touch_setup( ttgo );
|
||||
timesync_setup();
|
||||
touch_setup();
|
||||
sound_setup();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void powermgm_loop( TTGOClass *ttgo ) {
|
||||
void powermgm_loop( void ) {
|
||||
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
// check if a button or doubleclick was release
|
||||
if( powermgm_get_event( POWERMGM_PMU_BUTTON | POWERMGM_BMA_DOUBLECLICK ) ) {
|
||||
@@ -162,13 +164,13 @@ void powermgm_loop( TTGOClass *ttgo ) {
|
||||
|
||||
if ( powermgm_get_event( POWERMGM_STANDBY ) ) {
|
||||
vTaskDelay( 100 );
|
||||
pmu_loop( ttgo );
|
||||
bma_loop( ttgo );
|
||||
pmu_loop();
|
||||
bma_loop();
|
||||
}
|
||||
else {
|
||||
pmu_loop( ttgo );
|
||||
bma_loop( ttgo );
|
||||
display_loop( ttgo );
|
||||
pmu_loop();
|
||||
bma_loop();
|
||||
display_loop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void powermgm_setup( TTGOClass *ttgo );
|
||||
void powermgm_setup( void );
|
||||
/*
|
||||
* @brief power managment loop routine, call from loop. not for user use
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void powermgm_loop( TTGOClass *ttgo );
|
||||
void powermgm_loop( void );
|
||||
/*
|
||||
* @brief trigger a power managemt event
|
||||
*
|
||||
|
||||
@@ -37,7 +37,7 @@ timesync_config_t timesync_config;
|
||||
|
||||
void timesync_wifictl_event_cb( EventBits_t event, char* msg );
|
||||
|
||||
void timesync_setup( TTGOClass *ttgo ) {
|
||||
void timesync_setup( void ) {
|
||||
|
||||
timesync_read_config();
|
||||
time_event_handle = xEventGroupCreate();
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void timesync_setup( TTGOClass *ttgo );
|
||||
void timesync_setup( void );
|
||||
/*
|
||||
* @brief save config for timesync to spiffs
|
||||
*/
|
||||
|
||||
@@ -29,13 +29,14 @@ lv_indev_t *touch_indev = NULL;
|
||||
static bool touch_read(lv_indev_drv_t * drv, lv_indev_data_t*data);
|
||||
static bool touch_getXY( int16_t &x, int16_t &y );
|
||||
|
||||
void touch_setup( TTGOClass *ttgo ) {
|
||||
void touch_setup( void ) {
|
||||
touch_indev = lv_indev_get_next( NULL );
|
||||
|
||||
touch_indev->driver.read_cb = touch_read;
|
||||
}
|
||||
|
||||
static bool touch_getXY( int16_t &x, int16_t &y ) {
|
||||
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
TP_Point p;
|
||||
static bool touch_press = false;
|
||||
@@ -78,10 +79,10 @@ static bool touch_getXY( int16_t &x, int16_t &y ) {
|
||||
}
|
||||
|
||||
// issue https://github.com/sharandac/My-TTGO-Watch/issues/18 fix
|
||||
float temp_x = ( x - ( LV_HOR_RES_MAX / 2 ) ) * 1.15;
|
||||
float temp_y = ( y - ( LV_VER_RES_MAX / 2 ) ) * 1.0;
|
||||
x = temp_x + ( LV_HOR_RES_MAX / 2 );
|
||||
y = temp_y + ( LV_VER_RES_MAX / 2 );
|
||||
float temp_x = ( x - ( lv_disp_get_hor_res( NULL ) / 2 ) ) * 1.15;
|
||||
float temp_y = ( y - ( lv_disp_get_ver_res( NULL ) / 2 ) ) * 1.0;
|
||||
x = temp_x + ( lv_disp_get_hor_res( NULL ) / 2 );
|
||||
y = temp_y + ( lv_disp_get_ver_res( NULL ) / 2 );
|
||||
|
||||
return( true );
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@
|
||||
*
|
||||
* @param ttgo pointer to an TTGOClass
|
||||
*/
|
||||
void touch_setup( TTGOClass *ttgo );
|
||||
void touch_setup( void );
|
||||
|
||||
#endif // _TOUCH_H
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "hardware/motor.h"
|
||||
#include "hardware/wifictl.h"
|
||||
#include "hardware/blectl.h"
|
||||
#include "hardware/pmu.h"
|
||||
#include "hardware/timesync.h"
|
||||
|
||||
#include "app/weather/weather.h"
|
||||
#include "app/stopwatch/stopwatch_app.h"
|
||||
@@ -51,17 +53,13 @@ void setup()
|
||||
ttgo->lvgl_begin();
|
||||
|
||||
SPIFFS.begin();
|
||||
|
||||
motor_setup();
|
||||
|
||||
// force to store all new heap allocations in psram to get more internal ram
|
||||
heap_caps_malloc_extmem_enable( 1 );
|
||||
|
||||
display_setup( ttgo );
|
||||
|
||||
display_setup();
|
||||
screenshot_setup();
|
||||
|
||||
splash_screen_stage_one( ttgo );
|
||||
splash_screen_stage_one();
|
||||
splash_screen_stage_update( "init serial", 10 );
|
||||
|
||||
splash_screen_stage_update( "init spiff", 20 );
|
||||
@@ -71,11 +69,9 @@ void setup()
|
||||
}
|
||||
|
||||
splash_screen_stage_update( "init rtc", 50 );
|
||||
ttgo->rtc->syncToSystem();
|
||||
|
||||
timesyncToSystem();
|
||||
splash_screen_stage_update( "init powermgm", 60 );
|
||||
powermgm_setup( ttgo );
|
||||
|
||||
powermgm_setup();
|
||||
splash_screen_stage_update( "init gui", 80 );
|
||||
gui_setup();
|
||||
/*
|
||||
@@ -89,13 +85,11 @@ void setup()
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
if (wifictl_get_autoon() && (ttgo->power->isChargeing() || ttgo->power->isVBUSPlug() || (ttgo->power->getBattVoltage() > 3400)))
|
||||
if ( wifictl_get_autoon() && ( pmu_is_charging() || pmu_is_vbus_plug() || ( pmu_get_battery_voltage() > 3400) ) )
|
||||
wifictl_on();
|
||||
|
||||
splash_screen_stage_finish( ttgo );
|
||||
splash_screen_stage_finish();
|
||||
display_set_brightness( display_get_brightness() );
|
||||
|
||||
// enable to store data in normal heap
|
||||
heap_caps_malloc_extmem_enable( 16*1024 );
|
||||
blectl_setup();
|
||||
@@ -111,6 +105,6 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
delay(5);
|
||||
gui_loop( ttgo );
|
||||
powermgm_loop( ttgo );
|
||||
gui_loop();
|
||||
powermgm_loop();
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
{"version":"2020082601","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"}
|
||||
|
||||
Reference in New Issue
Block a user