diff --git a/src/config.h b/src/config.h index d8caf92..eb3174e 100644 --- a/src/config.h +++ b/src/config.h @@ -32,6 +32,6 @@ /* * firmeware version string */ - #define __FIRMWARE__ "2020081304" + #define __FIRMWARE__ "2020081307" #endif // _CONFIG_H diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ba57783..f69c8fb 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -40,6 +40,7 @@ #include "mainbar/setup_tile/time_settings/time_settings.h" #include "mainbar/setup_tile/update/update.h" #include "mainbar/setup_tile/wlan_settings/wlan_settings.h" +#include "mainbar/setup_tile/bluetooth_settings/bluetooth_settings.h" #include "hardware/powermgm.h" #include "hardware/display.h" @@ -72,8 +73,9 @@ void gui_setup(void) battery_settings_tile_setup(); display_settings_tile_setup(); move_settings_tile_setup(); - time_settings_tile_setup(); wlan_settings_tile_setup(); + bluetooth_settings_tile_setup(); + time_settings_tile_setup(); update_tile_setup(); statusbar_setup(); diff --git a/src/gui/mainbar/setup_tile/bluetooth_settings/bluetooth_settings.cpp b/src/gui/mainbar/setup_tile/bluetooth_settings/bluetooth_settings.cpp new file mode 100644 index 0000000..1e566ef --- /dev/null +++ b/src/gui/mainbar/setup_tile/bluetooth_settings/bluetooth_settings.cpp @@ -0,0 +1,176 @@ +/**************************************************************************** + * Tu May 22 21:23:51 2020 + * Copyright 2020 Dirk Brosswick + * Email: dirk.brosswick@googlemail.com + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include "config.h" +#include "bluetooth_settings.h" + +#include "gui/mainbar/mainbar.h" +#include "gui/mainbar/setup_tile/setup.h" +#include "gui/statusbar.h" +#include "hardware/blectl.h" + +lv_obj_t *bluetooth_settings_tile=NULL; +lv_style_t bluetooth_settings_style; +uint32_t bluetooth_tile_num; + +lv_obj_t *bluetooth_setup_icon_cont = NULL; +lv_obj_t *bluetooth_setup_info_img = NULL; + +lv_obj_t *bluetooth_standby_onoff = NULL; +lv_obj_t *bluetooth_advertising_onoff = NULL; + +LV_IMG_DECLARE(exit_32px); +LV_IMG_DECLARE(bluetooth_64px); +LV_IMG_DECLARE(info_fail_16px); + +static void enter_bluetooth_setup_event_cb( lv_obj_t * obj, lv_event_t event ); +static void exit_bluetooth_setup_event_cb( lv_obj_t * obj, lv_event_t event ); +static void bluetooth_standby_onoff_event_handler(lv_obj_t * obj, lv_event_t event); +static void bluetooth_advertising_onoff_event_handler(lv_obj_t * obj, lv_event_t event); + +void bluetooth_settings_tile_setup( void ) { + // get an app tile and copy mainstyle + bluetooth_tile_num = mainbar_add_app_tile( 1, 1 ); + bluetooth_settings_tile = mainbar_get_tile_obj( bluetooth_tile_num ); + + lv_style_copy( &bluetooth_settings_style, mainbar_get_style() ); + lv_style_set_bg_color( &bluetooth_settings_style, LV_OBJ_PART_MAIN, LV_COLOR_GRAY); + lv_style_set_bg_opa( &bluetooth_settings_style, LV_OBJ_PART_MAIN, LV_OPA_100); + lv_style_set_border_width( &bluetooth_settings_style, LV_OBJ_PART_MAIN, 0); + lv_obj_add_style( bluetooth_settings_tile, LV_OBJ_PART_MAIN, &bluetooth_settings_style ); + + // register an setup icon an set an callback + bluetooth_setup_icon_cont = setup_tile_register_setup(); + lv_obj_t *bluetooth_setup = lv_imgbtn_create ( bluetooth_setup_icon_cont, NULL); + mainbar_add_slide_element( bluetooth_setup ); + lv_imgbtn_set_src( bluetooth_setup, LV_BTN_STATE_RELEASED, &bluetooth_64px); + lv_imgbtn_set_src( bluetooth_setup, LV_BTN_STATE_PRESSED, &bluetooth_64px); + lv_imgbtn_set_src( bluetooth_setup, LV_BTN_STATE_CHECKED_RELEASED, &bluetooth_64px); + lv_imgbtn_set_src( bluetooth_setup, LV_BTN_STATE_CHECKED_PRESSED, &bluetooth_64px); + lv_obj_add_style( bluetooth_setup, LV_IMGBTN_PART_MAIN, mainbar_get_style() ); + lv_obj_align( bluetooth_setup, NULL, LV_ALIGN_CENTER, 0, 0 ); + lv_obj_set_event_cb( bluetooth_setup, enter_bluetooth_setup_event_cb ); + + bluetooth_setup_info_img = lv_img_create( bluetooth_setup_icon_cont, NULL ); + lv_img_set_src( bluetooth_setup_info_img, &info_fail_16px ); + lv_obj_align( bluetooth_setup_info_img, bluetooth_setup_icon_cont, LV_ALIGN_IN_TOP_RIGHT, 0, 0 ); + lv_obj_set_hidden( bluetooth_setup_info_img, true ); + + lv_obj_t *exit_btn = lv_imgbtn_create( bluetooth_settings_tile, NULL); + lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_RELEASED, &exit_32px); + lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_PRESSED, &exit_32px); + lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px); + lv_imgbtn_set_src( exit_btn, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px); + lv_obj_add_style( exit_btn, LV_IMGBTN_PART_MAIN, &bluetooth_settings_style ); + lv_obj_align( exit_btn, bluetooth_settings_tile, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 ); + lv_obj_set_event_cb( exit_btn, exit_bluetooth_setup_event_cb ); + + lv_obj_t *exit_label = lv_label_create( bluetooth_settings_tile, NULL); + lv_obj_add_style( exit_label, LV_OBJ_PART_MAIN, &bluetooth_settings_style ); + lv_label_set_text( exit_label, "bluetooth settings"); + 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_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 ); + lv_obj_add_protect( bluetooth_advertising_onoff, LV_PROTECT_CLICK_FOCUS); + lv_obj_add_style( bluetooth_advertising_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() ); + lv_switch_off( bluetooth_advertising_onoff, LV_ANIM_ON ); + lv_obj_align( bluetooth_advertising_onoff, bluetooth_advertising_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 ); + lv_obj_set_event_cb( bluetooth_advertising_onoff, bluetooth_advertising_onoff_event_handler ); + lv_obj_t *bluetooth_advertising_label = lv_label_create( bluetooth_advertising_cont, NULL); + lv_obj_add_style( bluetooth_advertising_label, LV_OBJ_PART_MAIN, &bluetooth_settings_style ); + lv_label_set_text( bluetooth_advertising_label, "advertising"); + 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_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); + lv_obj_add_style( bluetooth_info_label, LV_OBJ_PART_MAIN, &bluetooth_settings_style ); + lv_label_set_text( bluetooth_info_label, "increase battery life"); + 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_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 ); + lv_obj_add_protect( bluetooth_standby_onoff, LV_PROTECT_CLICK_FOCUS); + lv_obj_add_style( bluetooth_standby_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() ); + lv_switch_off( bluetooth_standby_onoff, LV_ANIM_ON ); + lv_obj_align( bluetooth_standby_onoff, bluetooth_standby_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 ); + lv_obj_set_event_cb( bluetooth_standby_onoff, bluetooth_standby_onoff_event_handler ); + lv_obj_t *bluetooth_standby_label = lv_label_create( bluetooth_standby_cont, NULL); + lv_obj_add_style( bluetooth_standby_label, LV_OBJ_PART_MAIN, &bluetooth_settings_style ); + lv_label_set_text( bluetooth_standby_label, "allway on"); + lv_obj_align( bluetooth_standby_label, bluetooth_standby_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 ); + + if ( blectl_get_advertising() ) { + lv_switch_on( bluetooth_advertising_onoff, LV_ANIM_OFF ); + } + else { + lv_switch_off( bluetooth_advertising_onoff, LV_ANIM_OFF ); + } + + if ( blectl_get_enable_on_standby() ) { + lv_obj_set_hidden( bluetooth_setup_info_img, false ); + lv_switch_on( bluetooth_standby_onoff, LV_ANIM_OFF ); + } + else { + lv_switch_off( bluetooth_standby_onoff, LV_ANIM_OFF ); + } +} + +static void enter_bluetooth_setup_event_cb( lv_obj_t * obj, lv_event_t event ) { + switch( event ) { + case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( bluetooth_tile_num, LV_ANIM_OFF ); + break; + } +} + +static void exit_bluetooth_setup_event_cb( lv_obj_t * obj, lv_event_t event ) { + switch( event ) { + case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( setup_get_tile_num(), LV_ANIM_OFF ); + break; + } +} + +static void bluetooth_advertising_onoff_event_handler(lv_obj_t * obj, lv_event_t event) { + switch( event ) { + case ( LV_EVENT_VALUE_CHANGED): blectl_set_advertising( lv_switch_get_state( obj ) ); + } +} + +static void bluetooth_standby_onoff_event_handler(lv_obj_t * obj, lv_event_t event) { + switch( event ) { + case ( LV_EVENT_VALUE_CHANGED): blectl_set_enable_on_standby( lv_switch_get_state( obj ) ); + if( lv_switch_get_state( obj ) ) { + lv_obj_set_hidden( bluetooth_setup_info_img, false ); + } + else { + lv_obj_set_hidden( bluetooth_setup_info_img, true ); + } + } +} diff --git a/src/gui/mainbar/setup_tile/bluetooth_settings/bluetooth_settings.h b/src/gui/mainbar/setup_tile/bluetooth_settings/bluetooth_settings.h new file mode 100644 index 0000000..df47bdc --- /dev/null +++ b/src/gui/mainbar/setup_tile/bluetooth_settings/bluetooth_settings.h @@ -0,0 +1,29 @@ +/**************************************************************************** + * Aug 13 12:37:31 2020 + * Copyright 2020 Dirk Brosswick + * Email: dirk.brosswick@googlemail.com + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef _BLUETOOTH_SETTINGS_H + #define _BLUETOOTH_SETTINGS_H + + #include + + void bluetooth_settings_tile_setup( void ); + +#endif // _BLUETOOTH_SETTINGS_H \ No newline at end of file diff --git a/src/hardware/blectl.cpp b/src/hardware/blectl.cpp index ca89926..01dfb09 100644 --- a/src/hardware/blectl.cpp +++ b/src/hardware/blectl.cpp @@ -33,12 +33,15 @@ #include #include "blectl.h" +#include "json_psram_allocator.h" #include "gui/statusbar.h" EventGroupHandle_t blectl_status = NULL; portMUX_TYPE blectlMux = portMUX_INITIALIZER_UNLOCKED; +blectl_config_t blectl_config; + BLEServer *pServer = NULL; BLECharacteristic *pTxCharacteristic; uint8_t txValue = 0; @@ -61,8 +64,10 @@ class BleCtlServerCallbacks: public BLEServerCallbacks { statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_GRAY ); log_i("BLE disconnected"); delay(500); - pServer->getAdvertising()->start(); - log_i("BLE advertising..."); + if ( blectl_get_advertising() ) { + pServer->getAdvertising()->start(); + log_i("BLE advertising..."); + } } }; @@ -151,6 +156,7 @@ class BleCtlCallbacks : public BLECharacteristicCallbacks * */ void blectl_setup( void ) { + blectl_status = xEventGroupCreate(); blectl_set_event( BLECTL_CONNECT | BLECTL_OFF_REQUEST | BLECTL_ON_REQUEST | BLECTL_PAIRING | BLECTL_STANDBY_REQUEST | BLECTL_ACTIVE | BLECTL_SCAN ); @@ -205,8 +211,11 @@ void blectl_setup( void ) { // The maximum 0x4000 interval of ~16 sec was too slow, I could not reliably connect pServer->getAdvertising()->setMinInterval( 100 ); pServer->getAdvertising()->setMaxInterval( 200 ); - pServer->getAdvertising()->start(); - log_i("BLE advertising..."); + + if ( blectl_get_advertising() ) { + pServer->getAdvertising()->start(); + log_i("BLE advertising..."); + } } /* @@ -243,4 +252,80 @@ void blectl_standby( void ) { void blectl_wakeup( void ) { statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_GRAY ); +} + +void blectl_set_enable_on_standby( bool enable_on_standby ) { + blectl_config.enable_on_standby = enable_on_standby; + blectl_save_config(); +} + +void blectl_set_advertising( bool advertising ) { + blectl_config.advertising = advertising; + blectl_save_config(); + if ( blectl_get_event( BLECTL_CONNECT ) ) + return; + + if ( advertising ) { + pServer->getAdvertising()->start(); + } + else { + pServer->getAdvertising()->stop(); + } +} + +bool blectl_get_enable_on_standby( void ) { + return( blectl_config.enable_on_standby ); +} + +bool blectl_get_advertising( void ) { + return( blectl_config.enable_on_standby ); +} +/* + * + */ +void blectl_save_config( void ) { + fs::File file = SPIFFS.open( BLECTL_JSON_COFIG_FILE, FILE_WRITE ); + + if (!file) { + log_e("Can't open file: %s!", BLECTL_JSON_COFIG_FILE ); + } + else { + SpiRamJsonDocument doc( 1000 ); + + doc["advertising"] = blectl_config.advertising; + doc["enable_on_standby"] = blectl_config.enable_on_standby; + + if ( serializeJsonPretty( doc, file ) == 0) { + log_e("Failed to write config file"); + } + doc.clear(); + } + file.close(); +} + +/* + * + */ +void blectl_read_config( void ) { + if ( SPIFFS.exists( BLECTL_JSON_COFIG_FILE ) ) { + fs::File file = SPIFFS.open( BLECTL_JSON_COFIG_FILE, FILE_READ ); + if (!file) { + log_e("Can't open file: %s!", BLECTL_JSON_COFIG_FILE ); + } + else { + int filesize = file.size(); + SpiRamJsonDocument doc( filesize * 2 ); + + DeserializationError error = deserializeJson( doc, file ); + if ( error ) { + log_e("blectl deserializeJson() failed: %s", error.c_str() ); + } + else { + blectl_config.advertising = doc["advertising"].as(); + blectl_config.enable_on_standby = doc["enable_on_standby"].as(); + } + doc.clear(); + } + file.close(); + } } \ No newline at end of file diff --git a/src/hardware/blectl.h b/src/hardware/blectl.h index d342e24..a3fac75 100644 --- a/src/hardware/blectl.h +++ b/src/hardware/blectl.h @@ -30,6 +30,13 @@ #define CHARACTERISTIC_UUID_RX BLEUUID("6E400002-B5A3-F393-E0A9-E50E24DCCA9E") #define CHARACTERISTIC_UUID_TX BLEUUID("6E400003-B5A3-F393-E0A9-E50E24DCCA9E") + #define BLECTL_JSON_COFIG_FILE "/blectl.json" + + typedef struct { + bool advertising = true; + bool enable_on_standby = false; + } blectl_config_t; + #define BLECTL_CONNECT _BV(0) #define BLECTL_STANDBY_REQUEST _BV(1) #define BLECTL_ON_REQUEST _BV(2) @@ -60,5 +67,11 @@ EventBits_t blectl_get_event( EventBits_t bits ); void blectl_standby( void ); void blectl_wakeup( void ); + void blectl_set_enable_on_standby( bool enable_on_standby ); + void blectl_set_advertising( bool advertising ); + bool blectl_get_enable_on_standby( void ); + bool blectl_get_advertising( void ); + void blectl_save_config( void ); + void blectl_read_config( void ); #endif // _BLECTL_H \ No newline at end of file diff --git a/src/hardware/bma.cpp b/src/hardware/bma.cpp index a3b9526..b79773a 100644 --- a/src/hardware/bma.cpp +++ b/src/hardware/bma.cpp @@ -124,9 +124,7 @@ void bma_loop( TTGOClass *ttgo ) { /* * handle IRQ event */ - if ( xEventGroupGetBitsFromISR( bma_event_handle ) & BMA_EVENT_INT ) { - setCpuFrequencyMhz(240); - + if ( xEventGroupGetBitsFromISR( bma_event_handle ) & BMA_EVENT_INT ) { while( !ttgo->bma->readInterrupt() ); if ( ttgo->bma->isDoubleClick() ) { powermgm_set_event( POWERMGM_BMA_WAKEUP ); diff --git a/src/hardware/json_psram_allocator.h b/src/hardware/json_psram_allocator.h index 1fd0f94..f27bbf7 100644 --- a/src/hardware/json_psram_allocator.h +++ b/src/hardware/json_psram_allocator.h @@ -7,7 +7,6 @@ struct SpiRamAllocator { void* allocate( size_t size ) { void *psram = ps_calloc( size, 1 ); if ( psram ) { - log_i("allocate %d bytes (%p) json psram", size, psram ); return( psram ); } else { @@ -16,7 +15,6 @@ struct SpiRamAllocator { } } void deallocate( void* pointer ) { - log_i("deallocate (%p) json psram", pointer ); free( pointer ); } }; diff --git a/src/hardware/pmu.cpp b/src/hardware/pmu.cpp index b871e76..5513fc0 100644 --- a/src/hardware/pmu.cpp +++ b/src/hardware/pmu.cpp @@ -36,7 +36,7 @@ void pmu_setup( TTGOClass *ttgo ) { log_e("target voltage set failed!"); if ( ttgo->power->setChargeControlCur( 300 ) ) log_e("charge current set failed!"); - if ( ttgo->power->setAdcSamplingRate( AXP_ADC_SAMPLING_RATE_200HZ ) ) + if ( ttgo->power->setAdcSamplingRate( AXP_ADC_SAMPLING_RATE_25HZ ) ) log_e("adc sample set failed!"); // Turn off unused power @@ -225,7 +225,6 @@ void pmu_loop( TTGOClass *ttgo ) { * handle IRQ event */ if ( xEventGroupGetBitsFromISR( pmu_event_handle ) & PMU_EVENT_AXP_INT ) { - setCpuFrequencyMhz(240); if ( powermgm_get_event( POWERMGM_PMU_BATTERY | POWERMGM_PMU_BUTTON | POWERMGM_STANDBY_REQUEST ) ) { ttgo->power->clearIRQ(); xEventGroupClearBits( pmu_event_handle, PMU_EVENT_AXP_INT ); diff --git a/src/hardware/powermgm.cpp b/src/hardware/powermgm.cpp index e59938b..d52e875 100644 --- a/src/hardware/powermgm.cpp +++ b/src/hardware/powermgm.cpp @@ -54,6 +54,7 @@ void powermgm_setup( TTGOClass *ttgo ) { pmu_setup( ttgo ); bma_setup( ttgo ); wifictl_setup(); + blectl_read_config(); timesync_setup( ttgo ); touch_setup( ttgo ); sound_setup(); @@ -78,6 +79,8 @@ void powermgm_loop( TTGOClass *ttgo ) { log_i("go wakeup"); + setCpuFrequencyMhz(240); + pmu_wakeup(); bma_wakeup(); display_wakeup(); @@ -120,18 +123,24 @@ void powermgm_loop( TTGOClass *ttgo ) { adc_power_off(); - motor_vibe(1); - delay(50); - - log_i("go standby"); - - setCpuFrequencyMhz( 80 ); - 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(); - // from here, the consumption is round about 2.5mA - // total standby time is 152h (6days) without use? + if ( !blectl_get_enable_on_standby() ) { + motor_vibe(3); + delay(50); + log_i("go standby"); + 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 ); + esp_sleep_enable_gpio_wakeup (); + esp_light_sleep_start(); + // from here, the consumption is round about 2.5mA + // total standby time is 152h (6days) without use? + } + else { + log_i("standby block by bluetooth"); + setCpuFrequencyMhz( 80 ); + // from here, the consumption is round about 23mA + // total standby time is 19h without use? + } } // clear event powermgm_clear_event( POWERMGM_PMU_BUTTON | POWERMGM_PMU_BATTERY | POWERMGM_BMA_WAKEUP | POWERMGM_STANDBY_REQUEST | POWERMGM_SILENCE_WAKEUP_REQUEST ); diff --git a/ttgo-t-watch2020_v1.ino.bin b/ttgo-t-watch2020_v1.ino.bin index 5af2f73..a5b6270 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 a3590bf..dfdf0a1 100644 --- a/ttgo-t-watch2020_v1.version.json +++ b/ttgo-t-watch2020_v1.version.json @@ -1 +1 @@ -{"version":"2020081304","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"} +{"version":"2020081307","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}