diff --git a/src/config.h b/src/config.h index 9e26a3a..dfe6c90 100644 --- a/src/config.h +++ b/src/config.h @@ -32,6 +32,6 @@ /* * firmeware version string */ - #define __FIRMWARE__ "2020082603" + #define __FIRMWARE__ "2020082604" #endif // _CONFIG_H diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 4f51963..f52cb4b 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -86,7 +86,7 @@ void gui_setup(void) /* * */ -void gui_loop( TTGOClass *ttgo ) { +void gui_loop( void ) { // if we run in silence mode if ( powermgm_get_event( POWERMGM_SILENCE_WAKEUP ) ) { if ( lv_disp_get_inactive_time(NULL) < display_get_timeout() * 1000 ) { diff --git a/src/gui/gui.h b/src/gui/gui.h index 92cff30..f5fd227 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -26,6 +26,6 @@ #include void gui_setup( void ); - void gui_loop( TTGOClass *ttgo ); + void gui_loop( void ); #endif // _STATUSBAR_H \ No newline at end of file diff --git a/src/gui/splashscreen.cpp b/src/gui/splashscreen.cpp index 2ed9a58..3513370 100644 --- a/src/gui/splashscreen.cpp +++ b/src/gui/splashscreen.cpp @@ -27,7 +27,10 @@ lv_obj_t *preload = NULL; lv_obj_t *preload_label = NULL; lv_style_t style; -void splash_screen_stage_one( TTGOClass *ttgo ) { +void splash_screen_stage_one( void ) { + + TTGOClass *ttgo = TTGOClass::getWatch(); + lv_style_init( &style ); lv_style_set_radius(&style, LV_OBJ_PART_MAIN, 0); lv_style_set_bg_color(&style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK); @@ -75,8 +78,9 @@ void splash_screen_stage_update( const char* msg, int value ) { lv_task_handler(); } -void splash_screen_stage_finish( TTGOClass *ttgo ) { -// ttgo->bl->adjust( 0 ); +void splash_screen_stage_finish( void ) { + TTGOClass *ttgo = TTGOClass::getWatch(); + for( int bl = display_get_brightness() ; bl > 0 ; bl-- ) { ttgo->bl->adjust( bl ); delay(1); diff --git a/src/gui/splashscreen.h b/src/gui/splashscreen.h index 3e25169..a66731c 100644 --- a/src/gui/splashscreen.h +++ b/src/gui/splashscreen.h @@ -27,7 +27,7 @@ * * @param ttgo pointer to TTGOClass */ - void splash_screen_stage_one( TTGOClass *ttgo ); + void splash_screen_stage_one( void ); /* * @brief update spash screen text and bar * @@ -40,6 +40,6 @@ * * @param ttgo pointer to TTGOClass */ - void splash_screen_stage_finish( TTGOClass *ttgo ); + void splash_screen_stage_finish( void ); #endif // _SPLASHSCREEN_H \ No newline at end of file diff --git a/src/hardware/display.cpp b/src/hardware/display.cpp index 89e0ea0..31d0432 100644 --- a/src/hardware/display.cpp +++ b/src/hardware/display.cpp @@ -35,9 +35,11 @@ static uint8_t brightness = 0; /* * */ -void display_setup( TTGOClass *ttgo ) { +void display_setup( void ) { display_read_config(); + TTGOClass *ttgo = TTGOClass::getWatch(); + ttgo->openBL(); ttgo->bl->adjust( 0 ); ttgo->tft->setRotation( display_config.rotation / 90 ); @@ -46,7 +48,9 @@ void display_setup( TTGOClass *ttgo ) { /* * loop routine for handling IRQ in main loop */ -void display_loop( TTGOClass *ttgo ) { +void display_loop( void ) { + TTGOClass *ttgo = TTGOClass::getWatch(); + if ( !powermgm_get_event( POWERMGM_STANDBY ) && !powermgm_get_event( POWERMGM_SILENCE_WAKEUP )) { if ( dest_brightness != brightness ) { if ( brightness < dest_brightness ) { diff --git a/src/hardware/display.h b/src/hardware/display.h index 8becb3a..a27af4b 100644 --- a/src/hardware/display.h +++ b/src/hardware/display.h @@ -46,13 +46,13 @@ * * @param ttgo pointer to an TTGOClass */ - void display_setup( TTGOClass *ttgo ); + void display_setup( void ); /* * @brief display loop * * @param ttgo pointer to an TTGOClass */ - void display_loop( TTGOClass *ttgo ); + void display_loop( void ); /* * @brief save config for display to spiffs */ diff --git a/src/hardware/pmu.cpp b/src/hardware/pmu.cpp index 4a2bbef..2893693 100644 --- a/src/hardware/pmu.cpp +++ b/src/hardware/pmu.cpp @@ -341,3 +341,13 @@ float pmu_get_coulumb_data( void ) { TTGOClass *ttgo = TTGOClass::getWatch(); return( ttgo->power->getCoulombData() ); } + +bool pmu_is_charging( void ) { + TTGOClass *ttgo = TTGOClass::getWatch(); + return( ttgo->power->isChargeing() ); +} + +bool pmu_is_vbus_plug( void ) { + TTGOClass *ttgo = TTGOClass::getWatch(); + return( ttgo->power->isVBUSPlug() ); +} \ No newline at end of file diff --git a/src/hardware/pmu.h b/src/hardware/pmu.h index 5458308..d1f2921 100644 --- a/src/hardware/pmu.h +++ b/src/hardware/pmu.h @@ -104,5 +104,7 @@ float pmu_get_battery_discharge_current( void ); float pmu_get_vbus_voltage( void ); float pmu_get_coulumb_data( void ); + bool pmu_is_charging( void ); + bool pmu_is_vbus_plug( void ); #endif // _PMU_H \ No newline at end of file diff --git a/src/hardware/powermgm.cpp b/src/hardware/powermgm.cpp index ba2d94f..f992291 100644 --- a/src/hardware/powermgm.cpp +++ b/src/hardware/powermgm.cpp @@ -170,7 +170,7 @@ void powermgm_loop( void ) { else { pmu_loop(); bma_loop(); - display_loop( ttgo ); + display_loop(); } } diff --git a/src/my-ttgo-watch.ino b/src/my-ttgo-watch.ino index eafdc80..d5736c7 100644 --- a/src/my-ttgo-watch.ino +++ b/src/my-ttgo-watch.ino @@ -34,6 +34,8 @@ #include "hardware/motor.h" #include "hardware/wifictl.h" #include "hardware/blectl.h" +#include "hardware/pmu.h" +#include "hardware/timesync.h" #include "app/weather/weather.h" #include "app/stopwatch/stopwatch_app.h" @@ -51,17 +53,13 @@ void setup() ttgo->lvgl_begin(); SPIFFS.begin(); - motor_setup(); // force to store all new heap allocations in psram to get more internal ram heap_caps_malloc_extmem_enable( 1 ); - - display_setup( ttgo ); - + display_setup(); screenshot_setup(); - - splash_screen_stage_one( ttgo ); + splash_screen_stage_one(); splash_screen_stage_update( "init serial", 10 ); splash_screen_stage_update( "init spiff", 20 ); @@ -71,11 +69,9 @@ void setup() } splash_screen_stage_update( "init rtc", 50 ); - ttgo->rtc->syncToSystem(); - + timesyncToSystem(); splash_screen_stage_update( "init powermgm", 60 ); powermgm_setup(); - splash_screen_stage_update( "init gui", 80 ); gui_setup(); /* @@ -89,13 +85,11 @@ void setup() /* * */ - - if (wifictl_get_autoon() && (ttgo->power->isChargeing() || ttgo->power->isVBUSPlug() || (ttgo->power->getBattVoltage() > 3400))) + if ( wifictl_get_autoon() && ( pmu_is_charging() || pmu_is_vbus_plug() || ( pmu_get_battery_voltage() > 3400) ) ) wifictl_on(); - splash_screen_stage_finish( ttgo ); + splash_screen_stage_finish(); display_set_brightness( display_get_brightness() ); - // enable to store data in normal heap heap_caps_malloc_extmem_enable( 16*1024 ); blectl_setup(); @@ -111,6 +105,6 @@ void setup() void loop() { delay(5); - gui_loop( ttgo ); + gui_loop(); powermgm_loop(); } diff --git a/ttgo-t-watch2020_v1.ino.bin b/ttgo-t-watch2020_v1.ino.bin index 8241e75..5011782 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 9efb366..590f19a 100644 --- a/ttgo-t-watch2020_v1.version.json +++ b/ttgo-t-watch2020_v1.version.json @@ -1 +1 @@ -{"version":"2020082603","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"} +{"version":"2020082604","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}