diff --git a/src/config.h b/src/config.h index acb8556..829221a 100644 --- a/src/config.h +++ b/src/config.h @@ -32,6 +32,6 @@ /* * firmeware version string */ - #define __FIRMWARE__ "2020081005" + #define __FIRMWARE__ "2020081007" #endif // _CONFIG_H diff --git a/src/gui/mainbar/main_tile/main_tile.cpp b/src/gui/mainbar/main_tile/main_tile.cpp index 415ba98..d0a2dba 100644 --- a/src/gui/mainbar/main_tile/main_tile.cpp +++ b/src/gui/mainbar/main_tile/main_tile.cpp @@ -44,7 +44,7 @@ LV_FONT_DECLARE(Ubuntu_16px); lv_task_t * task; void main_tile_task( lv_task_t * task ); -void main_tile_aling_widgets( void ); +void main_tile_align_widgets( void ); void main_tile_setup( void ) { main_tile_num = mainbar_add_tile( 0, 0 ); @@ -104,7 +104,7 @@ lv_obj_t *main_tile_register_widget( void ) { if ( widget_entry[ widget ].active == false ) { widget_entry[ widget ].active = true; lv_obj_set_hidden( widget_entry[ widget ].widget, false ); - main_tile_aling_widgets(); + main_tile_align_widgets(); return( widget_entry[ widget ].widget ); } } @@ -112,7 +112,7 @@ lv_obj_t *main_tile_register_widget( void ) { return( NULL ); } -void main_tile_aling_widgets( void ) { +void main_tile_align_widgets( void ) { int active_widgets = 0; lv_coord_t xpos = 0; diff --git a/src/gui/mainbar/mainbar.h b/src/gui/mainbar/mainbar.h index 9ff0e20..cff160e 100644 --- a/src/gui/mainbar/mainbar.h +++ b/src/gui/mainbar/mainbar.h @@ -106,9 +106,13 @@ * @return lv_style_t */ lv_style_t *mainbar_get_slider_style( void ); - + /* + * @brief + */ lv_obj_t * mainbar_obj_create(lv_obj_t *parent); - + /* + * @brief + */ void mainbar_add_slide_element(lv_obj_t *element); #endif // _MAINBAR_H \ No newline at end of file diff --git a/src/gui/mainbar/setup_tile/battery_settings/battery_settings.cpp b/src/gui/mainbar/setup_tile/battery_settings/battery_settings.cpp index aba1fa5..48911a4 100644 --- a/src/gui/mainbar/setup_tile/battery_settings/battery_settings.cpp +++ b/src/gui/mainbar/setup_tile/battery_settings/battery_settings.cpp @@ -37,6 +37,7 @@ uint32_t battery_settings_tile_num; lv_obj_t *battery_setup_icon_cont = NULL; lv_obj_t *battery_setup_info_img = NULL; +lv_obj_t *battery_silence_wakeup_switch = NULL; lv_obj_t *battery_percent_switch = NULL; lv_obj_t *battery_experimental_switch = NULL; @@ -46,6 +47,7 @@ LV_IMG_DECLARE(info_update_16px); static void enter_battery_setup_event_cb( lv_obj_t * obj, lv_event_t event ); static void exit_battery_setup_event_cb( lv_obj_t * obj, lv_event_t event ); +static void battery_silence_wakeup_switch_event_handler( lv_obj_t * obj, lv_event_t event ); static void battery_percent_switch_event_handler( lv_obj_t * obj, lv_event_t event ); static void battery_experimental_switch_event_handler( lv_obj_t * obj, lv_event_t event ); void battery_set_experimental_indicator( void ); @@ -91,13 +93,28 @@ void battery_settings_tile_setup( void ) { lv_obj_t *exit_label = lv_label_create( battery_settings_tile, NULL ); lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &battery_settings_style ); - lv_label_set_text( exit_label, "battery settings"); + lv_label_set_text( exit_label, "energy settings"); 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_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 ); + lv_obj_add_protect( battery_silence_wakeup_switch, LV_PROTECT_CLICK_FOCUS); + lv_obj_add_style( battery_silence_wakeup_switch, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() ); + lv_switch_off( battery_silence_wakeup_switch, LV_ANIM_ON ); + lv_obj_align( battery_silence_wakeup_switch, battery_silence_wakeup_switch_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 ); + lv_obj_set_event_cb( battery_silence_wakeup_switch, battery_silence_wakeup_switch_event_handler ); + lv_obj_t *battery_silence_wakeup_label = lv_label_create( battery_silence_wakeup_switch_cont, NULL); + lv_obj_add_style( battery_silence_wakeup_label, LV_OBJ_PART_MAIN, &battery_settings_style ); + lv_label_set_text( battery_silence_wakeup_label, "silence wakeup"); + 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_add_style( battery_setup_label_cont, LV_OBJ_PART_MAIN, &battery_settings_style ); - lv_obj_align( battery_setup_label_cont, battery_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 ); + 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); lv_obj_add_style( battery_setup_label, LV_OBJ_PART_MAIN, &battery_settings_style ); lv_label_set_text( battery_setup_label, "experimental functions"); @@ -144,6 +161,12 @@ void battery_settings_tile_setup( void ) { else lv_switch_off( battery_experimental_switch, LV_ANIM_OFF); + if ( pmu_get_silence_wakeup() ) { + lv_switch_on( battery_silence_wakeup_switch, LV_ANIM_OFF); + } + else + lv_switch_off( battery_silence_wakeup_switch, LV_ANIM_OFF); + battery_set_experimental_indicator(); } @@ -155,6 +178,14 @@ void battery_set_experimental_indicator( void ) { lv_obj_set_hidden( battery_setup_info_img, true ); } } + +static void battery_silence_wakeup_switch_event_handler( lv_obj_t * obj, lv_event_t event ) { + switch( event ) { + case( LV_EVENT_VALUE_CHANGED ): pmu_set_silence_wakeup( lv_switch_get_state( obj ) ); + break; + } +} + static void battery_percent_switch_event_handler( lv_obj_t * obj, lv_event_t event ) { switch( event ) { case( LV_EVENT_VALUE_CHANGED ): pmu_set_calculated_percent( lv_switch_get_state( obj ) ); diff --git a/src/gui/mainbar/setup_tile/battery_settings/battery_view.cpp b/src/gui/mainbar/setup_tile/battery_settings/battery_view.cpp index 4dcae00..410a4fd 100644 --- a/src/gui/mainbar/setup_tile/battery_settings/battery_view.cpp +++ b/src/gui/mainbar/setup_tile/battery_settings/battery_view.cpp @@ -82,7 +82,7 @@ void battery_view_tile_setup( uint32_t tile_num ) { lv_obj_t *exit_label = lv_label_create( battery_view_tile, NULL); lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &battery_view_style ); - lv_label_set_text( exit_label, "battery"); + lv_label_set_text( exit_label, "battery / energy"); 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 ); diff --git a/src/gui/statusbar.h b/src/gui/statusbar.h index bb7ce0e..b1d2a92 100644 --- a/src/gui/statusbar.h +++ b/src/gui/statusbar.h @@ -78,11 +78,37 @@ * @param style style name */ void statusbar_style_icon( statusbar_icon_t icon, statusbar_style_t style ); + /* + * @brief refresh/redraw statusbar + */ void statusbar_refresh( void ); + /* + * @brief update stepcounter from statusbar + * + * @param step stepcounter value + */ void statusbar_update_stepcounter( int step ); + /* + * @brief update battery icon and ther state + * + * @param percent displayed value in percent + * @param charging true or false, true means charging + * @param plug true or false, true means pluged + */ void statusbar_update_battery( int32_t percent, bool charging, bool plug ); + /* + * @brief set wifistate and label + * + * @param state true or false, true means active + * @param wifiname label to displayed text like "scan","connecting" and so on + */ void statusbar_wifi_set_state( bool state, const char *wifiname ); void statusbar_bluetooth_set_state( bool state ); + /* + * @brief hide the statusbar + * + * @param hide true or false, ture means statusbar is hide + */ void statusbar_hide( bool hide ); #endif // _STATUSBAR_H diff --git a/src/hardware/bma.h b/src/hardware/bma.h index b19e22b..cc4fe58 100644 --- a/src/hardware/bma.h +++ b/src/hardware/bma.h @@ -36,14 +36,48 @@ #define BMA_COFIG_FILE "/bma.cfg" + /* + * @brief setup bma activity measurement + * + * @param ttgo pointer to an TTGOClass + */ void bma_setup( TTGOClass *ttgo ); + /* + * @brief loop function for activity measurement + */ void bma_loop( TTGOClass *ttgo ); + /* + * @brief put bma into standby, depending on ther config + */ void bma_standby( void ); + /* + * @brief wakeup activity measurement + */ void bma_wakeup( void ); + /* + * @brief reload config + */ void bma_reload_settings( void ); + /* + * @ brief save the config structure to SPIFF + */ void bma_save_config( void ); + /* + * @ brief read the config structure from SPIFF + */ void bma_read_config( void ); + /* + * @brief get config + * + * @param config configitem + */ bool bma_get_config( int config ); + /* + * @brief set config + * + * @param config configitem + * @param enable true or false + */ void bma_set_config( int config, bool enable ); #endif // _BMA_H \ No newline at end of file diff --git a/src/hardware/pmu.cpp b/src/hardware/pmu.cpp index e414313..a7b3064 100644 --- a/src/hardware/pmu.cpp +++ b/src/hardware/pmu.cpp @@ -69,11 +69,15 @@ void pmu_standby( void ) { TTGOClass *ttgo = TTGOClass::getWatch(); ttgo->power->clearTimerStatus(); - if ( ttgo->power->isChargeing() ) { - ttgo->power->setTimer( 10 ); - } - else { - ttgo->power->setTimer( 60 ); + if ( pmu_get_silence_wakeup() ) { + if ( ttgo->power->isChargeing() || ttgo->power->isVBUSPlug() ) { + ttgo->power->setTimer( 3 ); + log_i("enable silence wakeup timer, 3min"); + } + else { + ttgo->power->setTimer( 60 ); + log_i("enable silence wakeup timer, 60min"); + } } if ( pmu_get_experimental_power_save() ) { @@ -140,6 +144,14 @@ void pmu_read_config( void ) { } } +bool pmu_get_silence_wakeup( void ) { + return( pmu_config.silence_wakeup ); +} + +void pmu_set_silence_wakeup( bool value ) { + pmu_config.silence_wakeup = value; + pmu_save_config(); +} bool pmu_get_calculated_percent( void ) { return( pmu_config.compute_percent ); diff --git a/src/hardware/pmu.h b/src/hardware/pmu.h index 1e01908..fa9938c 100644 --- a/src/hardware/pmu.h +++ b/src/hardware/pmu.h @@ -31,6 +31,7 @@ typedef struct { bool compute_percent = false; bool experimental_power_save = false; + bool silence_wakeup = true; } pmu_config_t; /* @@ -54,13 +55,39 @@ * @return charge in percent or -1 if unknown */ int32_t pmu_get_battery_percent( TTGOClass *ttgo ); + /* + * @brief set the axp202 in standby + */ void pmu_standby( void ); + /* + * @brief wakeup to axp202 + */ void pmu_wakeup( void ); + /* + * @ brief save the config structure to SPIFF + */ void pmu_save_config( void ); + /* + * @ brief read the config structure from SPIFF + */ void pmu_read_config( void ); + /* + * @brief read the config for calculated mAh based on the axp202 coloumb counter + */ bool pmu_get_calculated_percent( void ); + /* + * @brief read the config for experimental power save + */ bool pmu_get_experimental_power_save( void ); + /* + * @brief set the config to use calculated mAh + */ void pmu_set_calculated_percent( bool value ); + /* + * @brief set experimental power save + */ void pmu_set_experimental_power_save( bool value ); + bool pmu_get_silence_wakeup( void ); + void pmu_set_silence_wakeup( bool value ); #endif // _PMU_H \ No newline at end of file diff --git a/src/hardware/timesync.h b/src/hardware/timesync.h index be46075..2fe5f6a 100644 --- a/src/hardware/timesync.h +++ b/src/hardware/timesync.h @@ -84,8 +84,13 @@ * @param timezone timezone from UTC-12 to UTC+12 */ void timesync_set_timezone( int32_t timezone ); - + /* + * @brief wrapper function to sync the system with rtc + */ void timesyncToSystem( void ); + /* + * @brief wrapper function to sync the rtc with system + */ void timesyncToRTC( void ); #endif // _TIME_SYNC_H diff --git a/src/hardware/touch.h b/src/hardware/touch.h index d0fd714..1c178b2 100644 --- a/src/hardware/touch.h +++ b/src/hardware/touch.h @@ -24,7 +24,11 @@ #define _TOUCH_H #include "TTGO.h" - + /* + * @brief setup touch + * + * @param ttgo pointer to an TTGOClass + */ void touch_setup( TTGOClass *ttgo ); #endif // _TOUCH_H \ No newline at end of file diff --git a/ttgo-t-watch2020_v1.ino.bin b/ttgo-t-watch2020_v1.ino.bin index 3479c68..bbdeecd 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 9cc8ec8..83f1599 100644 --- a/ttgo-t-watch2020_v1.version.json +++ b/ttgo-t-watch2020_v1.version.json @@ -1 +1 @@ -{"version":"2020081005","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"} +{"version":"2020081007","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}