cleanup powermgm and add haptic feedback

This commit is contained in:
sharandac
2020-08-03 09:04:33 +02:00
parent 69b9a54408
commit ae45eac491
24 changed files with 168 additions and 125 deletions

View File

@@ -132,8 +132,7 @@ void weather_app_setup( void ) {
static void enter_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( weather_app_tile_num, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( weather_app_tile_num, LV_ANIM_OFF );
break;
}
}

View File

@@ -145,24 +145,21 @@ void weather_forecast_tile_setup( uint32_t tile_num ) {
static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_maintile( LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_maintile( LV_ANIM_OFF );
break;
}
}
static void setup_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
weather_jump_to_setup();
case( LV_EVENT_CLICKED ): weather_jump_to_setup();
break;
}
}
static void refresh_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
weather_forecast_sync_request();
case( LV_EVENT_CLICKED ): weather_forecast_sync_request();
weather_widget_sync_request();
break;
}

View File

@@ -131,6 +131,7 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
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 );
lv_obj_add_protect( weather_autosync_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( weather_autosync_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( weather_autosync_onoff, LV_ANIM_ON );
lv_obj_align( weather_autosync_onoff, weather_autosync_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
@@ -145,6 +146,7 @@ void weather_setup_tile_setup( uint32_t tile_num ) {
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);
lv_obj_add_protect( weather_wind_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( weather_wind_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( weather_wind_onoff, LV_ANIM_ON);
lv_obj_align( weather_wind_onoff, weather_wind_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0);

View File

@@ -31,6 +31,6 @@
/*
* firmeware version string
*/
#define __FIRMWARE__ "2020080101"
#define __FIRMWARE__ "2020080301"
#endif // _CONFIG_H

View File

@@ -106,6 +106,7 @@ void battery_settings_tile_setup( void ) {
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 );
lv_obj_add_protect( battery_percent_switch, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( battery_percent_switch, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( battery_percent_switch, LV_ANIM_ON );
lv_obj_align( battery_percent_switch, battery_percent_switch_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
@@ -120,6 +121,7 @@ void battery_settings_tile_setup( void ) {
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 );
lv_obj_add_protect( battery_experimental_switch, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( battery_experimental_switch, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( battery_experimental_switch, LV_ANIM_ON );
lv_obj_align( battery_experimental_switch, battery_experimental_switch_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
@@ -144,16 +146,14 @@ void battery_settings_tile_setup( void ) {
static void battery_percent_switch_event_handler( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_VALUE_CHANGED ): motor_vibe( 1 );
pmu_set_calculated_percent( lv_switch_get_state( obj ) );
case( LV_EVENT_VALUE_CHANGED ): pmu_set_calculated_percent( lv_switch_get_state( obj ) );
break;
}
}
static void battery_experimental_switch_event_handler( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_VALUE_CHANGED ): motor_vibe( 1 );
pmu_set_experimental_power_save( lv_switch_get_state( obj ) );
case( LV_EVENT_VALUE_CHANGED ): pmu_set_experimental_power_save( lv_switch_get_state( obj ) );
if ( pmu_get_experimental_power_save() )
lv_obj_set_hidden( battery_setup_info_img, false );
else
@@ -164,8 +164,7 @@ static void battery_experimental_switch_event_handler( lv_obj_t * obj, lv_event_
static void enter_battery_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( battery_settings_tile_num, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( battery_settings_tile_num, LV_ANIM_OFF );
break;
}
@@ -173,8 +172,7 @@ 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 ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( battery_settings_tile_num, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( battery_settings_tile_num, LV_ANIM_OFF );
break;
}
}

View File

@@ -168,8 +168,7 @@ void battery_view_tile_setup( uint32_t tile_num ) {
static void enter_battery_view_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( battery_view_tile_num, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( battery_view_tile_num, LV_ANIM_OFF );
break;
}
@@ -177,8 +176,7 @@ static void enter_battery_view_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void enter_battery_settings_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( battery_view_tile_num + 1, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( battery_view_tile_num + 1, LV_ANIM_OFF );
break;
}
@@ -186,8 +184,7 @@ static void enter_battery_settings_event_cb( lv_obj_t * obj, lv_event_t event )
static void exit_battery_view_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( setup_get_tile_num() , LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( setup_get_tile_num() , LV_ANIM_OFF );
break;
}
}

View File

@@ -88,6 +88,7 @@ void display_settings_tile_setup( void ) {
lv_obj_add_style( brightness_cont, LV_OBJ_PART_MAIN, &display_settings_style );
lv_obj_align( brightness_cont, display_settings_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
display_brightness_slider = lv_slider_create( brightness_cont, NULL );
lv_obj_add_protect( display_brightness_slider, LV_PROTECT_CLICK_FOCUS);
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 );
@@ -103,6 +104,7 @@ void display_settings_tile_setup( void ) {
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 );
lv_obj_add_protect( display_timeout_slider, LV_PROTECT_CLICK_FOCUS);
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 );
@@ -147,8 +149,7 @@ void display_settings_tile_setup( void ) {
static void enter_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( display_tile_num, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( display_tile_num, LV_ANIM_OFF );
break;
}
@@ -156,8 +157,7 @@ static void enter_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void exit_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
display_save_config();
break;
}

View File

@@ -82,6 +82,7 @@ void move_settings_tile_setup( void ) {
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 );
lv_obj_add_protect( stepcounter_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( stepcounter_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( stepcounter_onoff, LV_ANIM_ON );
lv_obj_align( stepcounter_onoff, stepcounter_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
@@ -96,6 +97,7 @@ void move_settings_tile_setup( void ) {
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 );
lv_obj_add_protect( doubleclick_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( doubleclick_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( doubleclick_onoff, LV_ANIM_ON );
lv_obj_align( doubleclick_onoff, doubleclick_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
@@ -119,16 +121,14 @@ void move_settings_tile_setup( void ) {
static void enter_move_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( move_tile_num, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( move_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_move_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
break;
}
}

View File

@@ -86,6 +86,7 @@ void time_settings_tile_setup( void ) {
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 );
lv_obj_add_protect( wifisync_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( wifisync_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( wifisync_onoff, LV_ANIM_ON );
lv_obj_align( wifisync_onoff, wifisync_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
@@ -100,6 +101,7 @@ void time_settings_tile_setup( void ) {
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 );
lv_obj_add_protect( daylight_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( daylight_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( daylight_onoff, LV_ANIM_ON );
lv_obj_align( daylight_onoff, daylight_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
@@ -138,16 +140,14 @@ void time_settings_tile_setup( void ) {
static void enter_time_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( time_tile_num, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( time_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_time_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
break;
}
}

View File

@@ -147,23 +147,20 @@ void update_tile_setup( void ) {
static void enter_update_setup_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( update_tile_num + 1, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( update_tile_num + 1, LV_ANIM_OFF );
break;
}
}
static void enter_update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( update_tile_num, LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( update_tile_num, LV_ANIM_OFF );
break;
}
}
static void exit_update_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF );
break;
}
}

View File

@@ -80,6 +80,7 @@ void update_setup_tile_setup( uint32_t tile_num ) {
lv_obj_align( update_check_autosync_cont, update_setup_tile, LV_ALIGN_IN_TOP_RIGHT, 0, 75 );
update_check_autosync_onoff = lv_switch_create( update_check_autosync_cont, NULL );
lv_obj_add_protect( update_check_autosync_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( update_check_autosync_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( update_check_autosync_onoff, LV_ANIM_ON );
lv_obj_align( update_check_autosync_onoff, update_check_autosync_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
@@ -99,8 +100,7 @@ void update_setup_tile_setup( uint32_t tile_num ) {
static void update_check_autosync_onoff_event_handler( lv_obj_t * obj, lv_event_t event ) {
switch (event) {
case (LV_EVENT_VALUE_CHANGED): motor_vibe( 1 );
update_config.autosync = lv_switch_get_state( obj );
case (LV_EVENT_VALUE_CHANGED): update_config.autosync = lv_switch_get_state( obj );
update_save_config();
break;
}
@@ -108,8 +108,7 @@ static void update_check_autosync_onoff_event_handler( lv_obj_t * obj, lv_event_
static void exit_update_check_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
mainbar_jump_to_tilenumber( update_setup_tile_num - 1, false );
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( update_setup_tile_num - 1, false );
break;
}
}

View File

@@ -99,6 +99,7 @@ void wlan_settings_tile_setup( void ) {
/*Copy the first switch and turn it ON*/
wifi_onoff = lv_switch_create( wifi_settings_tile, NULL );
lv_obj_add_protect( wifi_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( wifi_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( wifi_onoff, LV_ANIM_ON );
lv_obj_align( wifi_onoff, exit_label, LV_ALIGN_OUT_RIGHT_MID, 30, 0 );
@@ -245,8 +246,7 @@ void wlan_password_tile_setup( uint32_t wifi_password_tile_num ) {
static void apply_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
wifictl_insert_network( lv_label_get_text( wifi_password_name_label ), lv_textarea_get_text( wifi_password_pass_textfield ) );
case( LV_EVENT_CLICKED ): wifictl_insert_network( lv_label_get_text( wifi_password_name_label ), lv_textarea_get_text( wifi_password_pass_textfield ) );
keyboard_hide();
mainbar_jump_to_tilenumber( wifi_settings_tile_num, LV_ANIM_ON );
break;
@@ -255,8 +255,7 @@ static void apply_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void delete_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
wifictl_delete_network( lv_label_get_text( wifi_password_name_label ) );
case( LV_EVENT_CLICKED ): wifictl_delete_network( lv_label_get_text( wifi_password_name_label ) );
keyboard_hide();
mainbar_jump_to_tilenumber( wifi_settings_tile_num, LV_ANIM_ON );
break;
@@ -265,8 +264,7 @@ static void delete_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void wlan_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
keyboard_set_textarea( obj );
case( LV_EVENT_CLICKED ): keyboard_set_textarea( obj );
break;
}
}
@@ -274,7 +272,6 @@ static void wlan_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
static void exit_wifi_password_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_CLICKED ): keyboard_hide();
motor_vibe( 1 );
mainbar_jump_to_tilenumber( wifi_settings_tile_num, LV_ANIM_ON );
break;
}

View File

@@ -65,6 +65,20 @@ void bma_setup( TTGOClass *ttgo ) {
bma_reload_settings();
}
void bma_standby( void ) {
TTGOClass *ttgo = TTGOClass::getWatch();
if ( bma_get_config( BMA_STEPCOUNTER ) )
ttgo->bma->enableStepCountInterrupt( false );
}
void bma_wakeup( void ) {
TTGOClass *ttgo = TTGOClass::getWatch();
if ( bma_get_config( BMA_STEPCOUNTER ) )
ttgo->bma->enableStepCountInterrupt( true );
}
/*
*
*/

View File

@@ -38,7 +38,8 @@
void bma_setup( TTGOClass *ttgo );
void bma_loop( TTGOClass *ttgo );
void bma_standby( void );
void bma_wakeup( void );
void bma_reload_settings( void );
void bma_save_config( void );
void bma_read_config( void );

View File

@@ -24,6 +24,7 @@
#include "display.h"
#include "powermgm.h"
#include "motor.h"
display_config_t display_config;
@@ -66,29 +67,41 @@ void display_loop( TTGOClass *ttgo ) {
}
}
void display_go_wakeup( TTGOClass *ttgo ) {
ttgo->openBL();
ttgo->displayWakeup();
ttgo->bl->adjust( 0 );
brightness = 0;
dest_brightness = display_get_brightness();
}
void display_standby( void ) {
TTGOClass *ttgo = TTGOClass::getWatch();
void display_go_silence_wakeup( TTGOClass *ttgo ) {
ttgo->openBL();
ttgo->displayWakeup();
ttgo->bl->adjust( 0 );
brightness = 0;
dest_brightness = 0;
}
void display_go_sleep( TTGOClass *ttgo ) {
ttgo->bl->adjust( 0 );
ttgo->displaySleep();
ttgo->closeBL();
brightness = 0;
dest_brightness = 0;
}
void display_wakeup( void ) {
TTGOClass *ttgo = TTGOClass::getWatch();
// normal wake up from standby
if ( powermgm_get_event( POWERMGM_PMU_BUTTON | POWERMGM_PMU_BATTERY | POWERMGM_BMA_WAKEUP ) ) {
log_i("wakeup");
ttgo->openBL();
ttgo->displayWakeup();
ttgo->bl->adjust( 0 );
brightness = 0;
dest_brightness = display_get_brightness();
motor_vibe( 1 );
}
// silence wakeup request from standby
else if ( powermgm_get_event( POWERMGM_SILENCE_WAKEUP_REQUEST ) ) {
log_i("silence wakeup");
ttgo->openBL();
ttgo->displayWakeup();
ttgo->bl->adjust( 0 );
brightness = 0;
dest_brightness = 0;
powermgm_set_event( POWERMGM_SILENCE_WAKEUP );
}
}
/*
*
*/

View File

@@ -95,8 +95,14 @@
* @param rotation from 0-270 in 90 degree steps
*/
void display_set_rotation( uint32_t rotation );
void display_go_silence_wakeup( TTGOClass *ttgo );
void display_go_wakeup( TTGOClass *ttgo );
void display_go_sleep( TTGOClass *ttgo );
/*
* @brief set display into standby
*/
void display_standby( void );
/*
* @brief set display into normal mode or leave it in standby if a silence wakeup occur
*/
void display_wakeup( void );
#endif // _DISPLAY_H

View File

@@ -2,6 +2,7 @@
#include <TTGO.h>
#include <soc/rtc.h>
#include "display.h"
#include "pmu.h"
#include "powermgm.h"
#include "motor.h"
@@ -66,6 +67,37 @@ void IRAM_ATTR pmu_irq( void ) {
setCpuFrequencyMhz(240);
}
void pmu_standby( void ) {
TTGOClass *ttgo = TTGOClass::getWatch();
ttgo->power->clearTimerStatus();
ttgo->power->setTimer( 60 );
if ( pmu_get_experimental_power_save() ) {
ttgo->power->setDCDC3Voltage( 2700 );
log_i("enable 2.7V standby voltage");
}
else {
ttgo->power->setDCDC3Voltage( 3000 );
log_i("enable 3.0V standby voltage");
}
}
void pmu_wakeup( void ) {
TTGOClass *ttgo = TTGOClass::getWatch();
if ( pmu_get_experimental_power_save() ) {
ttgo->power->setDCDC3Voltage( 3000 );
log_i("enable 3.0V voltage");
}
else {
ttgo->power->setDCDC3Voltage( 3300 );
log_i("enable 3.3V voltage");
}
ttgo->power->clearTimerStatus();
ttgo->power->offTimer();
}
/*
*
*/
@@ -185,5 +217,4 @@ int32_t pmu_get_battery_percent( TTGOClass *ttgo ) {
else {
return( ttgo->power->getBattPercentage() );
}
// discharg coulumb higher then charge coulumb, battery state unknow and set to zero
}

View File

@@ -54,6 +54,8 @@
* @return charge in percent or -1 if unknown
*/
int32_t pmu_get_battery_percent( TTGOClass *ttgo );
void pmu_standby( void );
void pmu_wakeup( void );
void pmu_save_config( void );
void pmu_read_config( void );
bool pmu_get_calculated_percent( void );

View File

@@ -70,64 +70,36 @@ void powermgm_loop( TTGOClass *ttgo ) {
if ( powermgm_get_event( POWERMGM_STANDBY ) ) {
powermgm_clear_event( POWERMGM_STANDBY );
if ( pmu_get_experimental_power_save() ) {
ttgo->power->setDCDC3Voltage( 3000 );
log_e("enable 3.0V voltage");
}
else {
ttgo->power->setDCDC3Voltage( 3300 );
log_e("enable 3.3V voltage");
}
// normal wake up from standby
if ( powermgm_get_event( POWERMGM_PMU_BUTTON | POWERMGM_PMU_BATTERY | POWERMGM_BMA_WAKEUP ) ) {
log_i("wakeup");
display_go_wakeup( ttgo );
motor_vibe( 1 );
}
// silence wakeup request from standby
else if ( powermgm_get_event( POWERMGM_SILENCE_WAKEUP_REQUEST ) ) {
log_i("silence wakeup");
display_go_silence_wakeup( ttgo );
powermgm_set_event( POWERMGM_SILENCE_WAKEUP );
}
pmu_wakeup();
bma_wakeup();
display_wakeup();
timesyncToSystem();
ttgo->startLvglTick();
mainbar_jump_to_maintile( LV_ANIM_OFF );
lv_disp_trig_activity(NULL);
if ( bma_get_config( BMA_STEPCOUNTER ) )
ttgo->bma->enableStepCountInterrupt( true );
if ( ttgo->power->getBattVoltage() > 3300 ) {
wifictl_on();
}
ttgo->power->clearTimerStatus();
ttgo->power->offTimer();
wifictl_wakeup();
log_i("go wakeup");
}
else {
log_i("go to standby");
display_go_sleep( ttgo );
timesyncToRTC();
if ( powermgm_get_event( POWERMGM_WIFI_ACTIVE ) ) wifictl_off();
while( powermgm_get_event( POWERMGM_WIFI_ACTIVE | POWERMGM_WIFI_CONNECTED | POWERMGM_WIFI_OFF_REQUEST | POWERMGM_WIFI_ON_REQUEST | POWERMGM_WIFI_SCAN ) ) { yield(); }
log_i("go standby");
display_standby();
mainbar_jump_to_maintile( LV_ANIM_OFF );
ttgo->stopLvglTick();
if ( bma_get_config( BMA_STEPCOUNTER ) )
ttgo->bma->enableStepCountInterrupt( false );
timesyncToRTC();
bma_standby();
pmu_standby();
wifictl_standby();
powermgm_set_event( POWERMGM_STANDBY );
powermgm_clear_event( POWERMGM_SILENCE_WAKEUP );
ttgo->power->clearTimerStatus();
ttgo->power->setTimer( 60 );
if ( pmu_get_experimental_power_save() ) {
ttgo->power->setDCDC3Voltage( 2700 );
log_e("enable 2.7V standby voltage");
}
else {
ttgo->power->setDCDC3Voltage( 3000 );
log_e("enable 3.0V standby voltage");
}
setCpuFrequencyMhz( 10 );
gpio_wakeup_enable ((gpio_num_t)AXP202_INT, GPIO_INTR_LOW_LEVEL);
gpio_wakeup_enable ((gpio_num_t)BMA423_INT1, GPIO_INTR_HIGH_LEVEL);
gpio_wakeup_enable ( (gpio_num_t)AXP202_INT, GPIO_INTR_LOW_LEVEL );
gpio_wakeup_enable ( (gpio_num_t)BMA423_INT1, GPIO_INTR_HIGH_LEVEL );
esp_sleep_enable_gpio_wakeup ();
esp_light_sleep_start();
}

View File

@@ -22,6 +22,7 @@
#include "config.h"
#include "touch.h"
#include "powermgm.h"
#include "motor.h"
lv_indev_t *touch_indev = NULL;
@@ -37,6 +38,7 @@ void touch_setup( TTGOClass *ttgo ) {
static bool touch_getXY( int16_t &x, int16_t &y ) {
TTGOClass *ttgo = TTGOClass::getWatch();
TP_Point p;
static bool touch_press = false;
// disable touch when we are in standby or silence wakeup
if ( powermgm_get_event( POWERMGM_STANDBY | POWERMGM_SILENCE_WAKEUP ) ) {
@@ -44,9 +46,15 @@ static bool touch_getXY( int16_t &x, int16_t &y ) {
}
if ( !ttgo->touch->touched() ) {
touch_press = false;
return( false );
}
if ( !touch_press ) {
touch_press = true;
motor_vibe( 2 );
}
p = ttgo->touch->getPoint();
uint8_t rotation = ttgo->tft->getRotation();

View File

@@ -31,7 +31,6 @@
#include "webserver/webserver.h"
bool wifi_init = false;
TaskHandle_t _WIFICTL_Task;
void wifictl_StartTask( void );
void wifictl_Task( void * pvParameters );
@@ -128,7 +127,8 @@ void wifictl_setup( void ) {
5000, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
&_wifictl_Task ); /* Task handle. */
&_wifictl_Task ); /* Task handle. */
vTaskSuspend( _wifictl_Task );
}
/*
@@ -263,6 +263,14 @@ void wifictl_off( void ) {
}
}
void wifictl_standby( void ) {
if ( powermgm_get_event( POWERMGM_WIFI_ACTIVE ) ) wifictl_off();
while( powermgm_get_event( POWERMGM_WIFI_ACTIVE | POWERMGM_WIFI_CONNECTED | POWERMGM_WIFI_OFF_REQUEST | POWERMGM_WIFI_ON_REQUEST | POWERMGM_WIFI_SCAN ) ) { yield(); }
}
void wifictl_wakeup( void ) {
wifictl_on();
}
/*
*
*/
@@ -271,7 +279,7 @@ void wifictl_Task( void * pvParameters ) {
return;
while ( true ) {
vTaskDelay( 100 );
vTaskDelay( 500 );
if ( powermgm_get_event( POWERMGM_WIFI_ON_REQUEST ) ) {
statusbar_wifi_set_state( true, "activate" );
WiFi.mode( WIFI_STA );

View File

@@ -66,5 +66,7 @@
* @brief switch off wifi
*/
void wifictl_off( void );
void wifictl_standby( void );
void wifictl_wakeup( void );
#endif // _WIFICTL_H

Binary file not shown.

View File

@@ -1 +1 @@
{"version":"2020080101","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
{"version":"2020080301","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}