some fixes and firmware stabilization
This commit is contained in:
@@ -32,6 +32,7 @@ EventGroupHandle_t bma_event_handle = NULL;
|
||||
bma_config_t bma_config[ BMA_CONFIG_NUM ];
|
||||
|
||||
__NOINIT_ATTR uint32_t stepcounter_valid;
|
||||
__NOINIT_ATTR uint32_t stepcounter_before_reset;
|
||||
__NOINIT_ATTR uint32_t stepcounter;
|
||||
|
||||
void IRAM_ATTR bma_irq( void );
|
||||
@@ -49,10 +50,13 @@ void bma_setup( TTGOClass *ttgo ) {
|
||||
|
||||
if ( stepcounter_valid != 0xa5a5a5a5 ) {
|
||||
stepcounter = 0;
|
||||
stepcounter_before_reset = 0;
|
||||
stepcounter_valid = 0xa5a5a5a5;
|
||||
log_e("stepcounter not valid. reset");
|
||||
log_i("stepcounter not valid. reset");
|
||||
}
|
||||
|
||||
stepcounter = stepcounter + stepcounter_before_reset;
|
||||
|
||||
bma_read_config();
|
||||
|
||||
ttgo->bma->begin();
|
||||
@@ -68,6 +72,8 @@ void bma_setup( TTGOClass *ttgo ) {
|
||||
void bma_standby( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
log_i("standby");
|
||||
|
||||
if ( bma_get_config( BMA_STEPCOUNTER ) )
|
||||
ttgo->bma->enableStepCountInterrupt( false );
|
||||
|
||||
@@ -76,11 +82,13 @@ void bma_standby( void ) {
|
||||
void bma_wakeup( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
log_i("wakeup");
|
||||
|
||||
if ( bma_get_config( BMA_STEPCOUNTER ) )
|
||||
ttgo->bma->enableStepCountInterrupt( true );
|
||||
|
||||
stepcounter =+ ttgo->bma->getCounter();
|
||||
statusbar_update_stepcounter( stepcounter );
|
||||
stepcounter_before_reset = ttgo->bma->getCounter();
|
||||
statusbar_update_stepcounter( stepcounter + ttgo->bma->getCounter() );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -126,8 +134,8 @@ void bma_loop( TTGOClass *ttgo ) {
|
||||
}
|
||||
|
||||
if ( !powermgm_get_event( POWERMGM_STANDBY ) && xEventGroupGetBitsFromISR( bma_event_handle ) & BMA_EVENT_INT ) {
|
||||
stepcounter =+ ttgo->bma->getCounter();
|
||||
statusbar_update_stepcounter( stepcounter );
|
||||
stepcounter_before_reset = ttgo->bma->getCounter();
|
||||
statusbar_update_stepcounter( stepcounter + ttgo->bma->getCounter() );
|
||||
xEventGroupClearBitsFromISR( bma_event_handle, BMA_EVENT_INT );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ void display_loop( TTGOClass *ttgo ) {
|
||||
|
||||
void display_standby( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
log_i("standby");
|
||||
ttgo->bl->adjust( 0 );
|
||||
ttgo->displaySleep();
|
||||
ttgo->closeBL();
|
||||
|
||||
@@ -74,7 +74,12 @@ void pmu_standby( void ) {
|
||||
TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
ttgo->power->clearTimerStatus();
|
||||
ttgo->power->setTimer( 60 );
|
||||
if ( ttgo->power->isChargeing() ) {
|
||||
ttgo->power->setTimer( 10 );
|
||||
}
|
||||
else {
|
||||
ttgo->power->setTimer( 60 );
|
||||
}
|
||||
|
||||
if ( pmu_get_experimental_power_save() ) {
|
||||
ttgo->power->setDCDC3Voltage( 2700 );
|
||||
@@ -213,11 +218,11 @@ void pmu_loop( TTGOClass *ttgo ) {
|
||||
}
|
||||
|
||||
int32_t pmu_get_battery_percent( TTGOClass *ttgo ) {
|
||||
if ( ttgo->power->getBattChargeCoulomb() < ttgo->power->getBattDischargeCoulomb() || ttgo->power->getBattVoltage() < 3200 ) {
|
||||
ttgo->power->ClearCoulombcounter();
|
||||
}
|
||||
|
||||
if ( pmu_get_calculated_percent() ) {
|
||||
if ( ttgo->power->getBattChargeCoulomb() < ttgo->power->getBattDischargeCoulomb() || ttgo->power->getBattVoltage() < 3200 ) {
|
||||
ttgo->power->ClearCoulombcounter();
|
||||
return( -1 );
|
||||
}
|
||||
return( ( ttgo->power->getCoulombData() / PMU_BATTERY_CAP ) * 100 );
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -24,7 +24,10 @@
|
||||
#include <soc/rtc.h>
|
||||
#include <WiFi.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_bt.h>
|
||||
#include <esp_bt_main.h>
|
||||
#include <time.h>
|
||||
#include "driver/adc.h"
|
||||
|
||||
#include "pmu.h"
|
||||
#include "bma.h"
|
||||
@@ -73,6 +76,8 @@ void powermgm_loop( TTGOClass *ttgo ) {
|
||||
if ( powermgm_get_event( POWERMGM_STANDBY ) ) {
|
||||
powermgm_clear_event( POWERMGM_STANDBY );
|
||||
|
||||
log_i("go wakeup");
|
||||
|
||||
pmu_wakeup();
|
||||
bma_wakeup();
|
||||
display_wakeup();
|
||||
@@ -82,10 +87,8 @@ void powermgm_loop( TTGOClass *ttgo ) {
|
||||
lv_disp_trig_activity(NULL);
|
||||
|
||||
wifictl_wakeup();
|
||||
log_i("go wakeup");
|
||||
}
|
||||
else {
|
||||
log_i("go standby");
|
||||
display_standby();
|
||||
mainbar_jump_to_maintile( LV_ANIM_OFF );
|
||||
|
||||
@@ -99,11 +102,17 @@ void powermgm_loop( TTGOClass *ttgo ) {
|
||||
powermgm_set_event( POWERMGM_STANDBY );
|
||||
powermgm_clear_event( POWERMGM_SILENCE_WAKEUP );
|
||||
|
||||
setCpuFrequencyMhz( 10 );
|
||||
adc_power_off();
|
||||
|
||||
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?
|
||||
}
|
||||
// clear event
|
||||
powermgm_clear_event( POWERMGM_PMU_BUTTON | POWERMGM_PMU_BATTERY | POWERMGM_BMA_WAKEUP | POWERMGM_STANDBY_REQUEST | POWERMGM_SILENCE_WAKEUP_REQUEST );
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "gui/sound/snd_start.h"
|
||||
#include "gui/sound/snd_signal.h"
|
||||
|
||||
EventGroupHandle_t sound_event_handle = NULL;
|
||||
TaskHandle_t _sound_Task;
|
||||
void sound_Task( void * pvParameters );
|
||||
|
||||
@@ -63,6 +64,8 @@ void sound_setup( void ) {
|
||||
while (true);
|
||||
}
|
||||
|
||||
sound_event_handle = xEventGroupCreate();
|
||||
|
||||
xTaskCreate( sound_Task, /* Function to implement the task */
|
||||
"sound Task", /* Name of the task */
|
||||
2000, /* Stack size in words */
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
#include <TTGO.h>
|
||||
|
||||
#define SOUND_EVENT_PLAYING _BV(0)
|
||||
#define SOUND_EVENT_STARTUP _BV(1)
|
||||
#define SOUND_EVENT_NOTIFICATION _BV(2)
|
||||
|
||||
#define I2S_PORT I2S_NUM_0
|
||||
|
||||
void sound_setup( void );
|
||||
|
||||
@@ -313,12 +313,14 @@ void wifictl_off( void ) {
|
||||
}
|
||||
|
||||
void wifictl_standby( void ) {
|
||||
log_i("standby");
|
||||
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 ) {
|
||||
if ( wifictl_config.autoon ) {
|
||||
log_i("wakeup");
|
||||
wifictl_on();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user