add docu and silence wakeup option

This commit is contained in:
sharandac
2020-08-10 20:33:13 +02:00
parent eb813a2799
commit 20d2daefce
13 changed files with 160 additions and 17 deletions

View File

@@ -32,6 +32,6 @@
/* /*
* firmeware version string * firmeware version string
*/ */
#define __FIRMWARE__ "2020081005" #define __FIRMWARE__ "2020081007"
#endif // _CONFIG_H #endif // _CONFIG_H

View File

@@ -44,7 +44,7 @@ LV_FONT_DECLARE(Ubuntu_16px);
lv_task_t * task; lv_task_t * task;
void main_tile_task( 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 ) { void main_tile_setup( void ) {
main_tile_num = mainbar_add_tile( 0, 0 ); 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 ) { if ( widget_entry[ widget ].active == false ) {
widget_entry[ widget ].active = true; widget_entry[ widget ].active = true;
lv_obj_set_hidden( widget_entry[ widget ].widget, false ); lv_obj_set_hidden( widget_entry[ widget ].widget, false );
main_tile_aling_widgets(); main_tile_align_widgets();
return( widget_entry[ widget ].widget ); return( widget_entry[ widget ].widget );
} }
} }
@@ -112,7 +112,7 @@ lv_obj_t *main_tile_register_widget( void ) {
return( NULL ); return( NULL );
} }
void main_tile_aling_widgets( void ) { void main_tile_align_widgets( void ) {
int active_widgets = 0; int active_widgets = 0;
lv_coord_t xpos = 0; lv_coord_t xpos = 0;

View File

@@ -106,9 +106,13 @@
* @return lv_style_t * @return lv_style_t
*/ */
lv_style_t *mainbar_get_slider_style( void ); lv_style_t *mainbar_get_slider_style( void );
/*
* @brief
*/
lv_obj_t * mainbar_obj_create(lv_obj_t *parent); lv_obj_t * mainbar_obj_create(lv_obj_t *parent);
/*
* @brief
*/
void mainbar_add_slide_element(lv_obj_t *element); void mainbar_add_slide_element(lv_obj_t *element);
#endif // _MAINBAR_H #endif // _MAINBAR_H

View File

@@ -37,6 +37,7 @@ uint32_t battery_settings_tile_num;
lv_obj_t *battery_setup_icon_cont = NULL; lv_obj_t *battery_setup_icon_cont = NULL;
lv_obj_t *battery_setup_info_img = 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_percent_switch = NULL;
lv_obj_t *battery_experimental_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 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 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_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 ); static void battery_experimental_switch_event_handler( lv_obj_t * obj, lv_event_t event );
void battery_set_experimental_indicator( void ); 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_t *exit_label = lv_label_create( battery_settings_tile, NULL );
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &battery_settings_style ); 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_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_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_HOR_RES_MAX , 40);
lv_obj_add_style( battery_setup_label_cont, LV_OBJ_PART_MAIN, &battery_settings_style ); 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_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_obj_add_style( battery_setup_label, LV_OBJ_PART_MAIN, &battery_settings_style );
lv_label_set_text( battery_setup_label, "experimental functions"); lv_label_set_text( battery_setup_label, "experimental functions");
@@ -144,6 +161,12 @@ void battery_settings_tile_setup( void ) {
else else
lv_switch_off( battery_experimental_switch, LV_ANIM_OFF); 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(); battery_set_experimental_indicator();
} }
@@ -155,6 +178,14 @@ void battery_set_experimental_indicator( void ) {
lv_obj_set_hidden( battery_setup_info_img, true ); 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 ) { static void battery_percent_switch_event_handler( lv_obj_t * obj, lv_event_t event ) {
switch( event ) { switch( event ) {
case( LV_EVENT_VALUE_CHANGED ): pmu_set_calculated_percent( lv_switch_get_state( obj ) ); case( LV_EVENT_VALUE_CHANGED ): pmu_set_calculated_percent( lv_switch_get_state( obj ) );

View File

@@ -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_t *exit_label = lv_label_create( battery_view_tile, NULL);
lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &battery_view_style ); 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_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_t *battery_design_cont = lv_obj_create( battery_view_tile, NULL );

View File

@@ -78,11 +78,37 @@
* @param style style name * @param style style name
*/ */
void statusbar_style_icon( statusbar_icon_t icon, statusbar_style_t style ); void statusbar_style_icon( statusbar_icon_t icon, statusbar_style_t style );
/*
* @brief refresh/redraw statusbar
*/
void statusbar_refresh( void ); void statusbar_refresh( void );
/*
* @brief update stepcounter from statusbar
*
* @param step stepcounter value
*/
void statusbar_update_stepcounter( int step ); 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 ); 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_wifi_set_state( bool state, const char *wifiname );
void statusbar_bluetooth_set_state( bool state ); 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 ); void statusbar_hide( bool hide );
#endif // _STATUSBAR_H #endif // _STATUSBAR_H

View File

@@ -36,14 +36,48 @@
#define BMA_COFIG_FILE "/bma.cfg" #define BMA_COFIG_FILE "/bma.cfg"
/*
* @brief setup bma activity measurement
*
* @param ttgo pointer to an TTGOClass
*/
void bma_setup( TTGOClass *ttgo ); void bma_setup( TTGOClass *ttgo );
/*
* @brief loop function for activity measurement
*/
void bma_loop( TTGOClass *ttgo ); void bma_loop( TTGOClass *ttgo );
/*
* @brief put bma into standby, depending on ther config
*/
void bma_standby( void ); void bma_standby( void );
/*
* @brief wakeup activity measurement
*/
void bma_wakeup( void ); void bma_wakeup( void );
/*
* @brief reload config
*/
void bma_reload_settings( void ); void bma_reload_settings( void );
/*
* @ brief save the config structure to SPIFF
*/
void bma_save_config( void ); void bma_save_config( void );
/*
* @ brief read the config structure from SPIFF
*/
void bma_read_config( void ); void bma_read_config( void );
/*
* @brief get config
*
* @param config configitem
*/
bool bma_get_config( int config ); 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 ); void bma_set_config( int config, bool enable );
#endif // _BMA_H #endif // _BMA_H

View File

@@ -69,11 +69,15 @@ void pmu_standby( void ) {
TTGOClass *ttgo = TTGOClass::getWatch(); TTGOClass *ttgo = TTGOClass::getWatch();
ttgo->power->clearTimerStatus(); ttgo->power->clearTimerStatus();
if ( ttgo->power->isChargeing() ) { if ( pmu_get_silence_wakeup() ) {
ttgo->power->setTimer( 10 ); if ( ttgo->power->isChargeing() || ttgo->power->isVBUSPlug() ) {
} ttgo->power->setTimer( 3 );
else { log_i("enable silence wakeup timer, 3min");
ttgo->power->setTimer( 60 ); }
else {
ttgo->power->setTimer( 60 );
log_i("enable silence wakeup timer, 60min");
}
} }
if ( pmu_get_experimental_power_save() ) { 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 ) { bool pmu_get_calculated_percent( void ) {
return( pmu_config.compute_percent ); return( pmu_config.compute_percent );

View File

@@ -31,6 +31,7 @@
typedef struct { typedef struct {
bool compute_percent = false; bool compute_percent = false;
bool experimental_power_save = false; bool experimental_power_save = false;
bool silence_wakeup = true;
} pmu_config_t; } pmu_config_t;
/* /*
@@ -54,13 +55,39 @@
* @return charge in percent or -1 if unknown * @return charge in percent or -1 if unknown
*/ */
int32_t pmu_get_battery_percent( TTGOClass *ttgo ); int32_t pmu_get_battery_percent( TTGOClass *ttgo );
/*
* @brief set the axp202 in standby
*/
void pmu_standby( void ); void pmu_standby( void );
/*
* @brief wakeup to axp202
*/
void pmu_wakeup( void ); void pmu_wakeup( void );
/*
* @ brief save the config structure to SPIFF
*/
void pmu_save_config( void ); void pmu_save_config( void );
/*
* @ brief read the config structure from SPIFF
*/
void pmu_read_config( void ); void pmu_read_config( void );
/*
* @brief read the config for calculated mAh based on the axp202 coloumb counter
*/
bool pmu_get_calculated_percent( void ); bool pmu_get_calculated_percent( void );
/*
* @brief read the config for experimental power save
*/
bool pmu_get_experimental_power_save( void ); bool pmu_get_experimental_power_save( void );
/*
* @brief set the config to use calculated mAh
*/
void pmu_set_calculated_percent( bool value ); void pmu_set_calculated_percent( bool value );
/*
* @brief set experimental power save
*/
void pmu_set_experimental_power_save( bool value ); void pmu_set_experimental_power_save( bool value );
bool pmu_get_silence_wakeup( void );
void pmu_set_silence_wakeup( bool value );
#endif // _PMU_H #endif // _PMU_H

View File

@@ -84,8 +84,13 @@
* @param timezone timezone from UTC-12 to UTC+12 * @param timezone timezone from UTC-12 to UTC+12
*/ */
void timesync_set_timezone( int32_t timezone ); void timesync_set_timezone( int32_t timezone );
/*
* @brief wrapper function to sync the system with rtc
*/
void timesyncToSystem( void ); void timesyncToSystem( void );
/*
* @brief wrapper function to sync the rtc with system
*/
void timesyncToRTC( void ); void timesyncToRTC( void );
#endif // _TIME_SYNC_H #endif // _TIME_SYNC_H

View File

@@ -24,7 +24,11 @@
#define _TOUCH_H #define _TOUCH_H
#include "TTGO.h" #include "TTGO.h"
/*
* @brief setup touch
*
* @param ttgo pointer to an TTGOClass
*/
void touch_setup( TTGOClass *ttgo ); void touch_setup( TTGOClass *ttgo );
#endif // _TOUCH_H #endif // _TOUCH_H

Binary file not shown.

View File

@@ -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"}