hardware driver separation

This commit is contained in:
sharandac
2020-08-26 15:20:44 +02:00
parent c335328ab4
commit d93c90e3c8
13 changed files with 42 additions and 28 deletions

View File

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

View File

@@ -86,7 +86,7 @@ void gui_setup(void)
/* /*
* *
*/ */
void gui_loop( TTGOClass *ttgo ) { void gui_loop( void ) {
// if we run in silence mode // if we run in silence mode
if ( powermgm_get_event( POWERMGM_SILENCE_WAKEUP ) ) { if ( powermgm_get_event( POWERMGM_SILENCE_WAKEUP ) ) {
if ( lv_disp_get_inactive_time(NULL) < display_get_timeout() * 1000 ) { if ( lv_disp_get_inactive_time(NULL) < display_get_timeout() * 1000 ) {

View File

@@ -26,6 +26,6 @@
#include <TTGO.h> #include <TTGO.h>
void gui_setup( void ); void gui_setup( void );
void gui_loop( TTGOClass *ttgo ); void gui_loop( void );
#endif // _STATUSBAR_H #endif // _STATUSBAR_H

View File

@@ -27,7 +27,10 @@ lv_obj_t *preload = NULL;
lv_obj_t *preload_label = NULL; lv_obj_t *preload_label = NULL;
lv_style_t style; 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_init( &style );
lv_style_set_radius(&style, LV_OBJ_PART_MAIN, 0); lv_style_set_radius(&style, LV_OBJ_PART_MAIN, 0);
lv_style_set_bg_color(&style, LV_OBJ_PART_MAIN, LV_COLOR_BLACK); 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(); lv_task_handler();
} }
void splash_screen_stage_finish( TTGOClass *ttgo ) { void splash_screen_stage_finish( void ) {
// ttgo->bl->adjust( 0 ); TTGOClass *ttgo = TTGOClass::getWatch();
for( int bl = display_get_brightness() ; bl > 0 ; bl-- ) { for( int bl = display_get_brightness() ; bl > 0 ; bl-- ) {
ttgo->bl->adjust( bl ); ttgo->bl->adjust( bl );
delay(1); delay(1);

View File

@@ -27,7 +27,7 @@
* *
* @param ttgo pointer to TTGOClass * @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 * @brief update spash screen text and bar
* *
@@ -40,6 +40,6 @@
* *
* @param ttgo pointer to TTGOClass * @param ttgo pointer to TTGOClass
*/ */
void splash_screen_stage_finish( TTGOClass *ttgo ); void splash_screen_stage_finish( void );
#endif // _SPLASHSCREEN_H #endif // _SPLASHSCREEN_H

View File

@@ -35,9 +35,11 @@ static uint8_t brightness = 0;
/* /*
* *
*/ */
void display_setup( TTGOClass *ttgo ) { void display_setup( void ) {
display_read_config(); display_read_config();
TTGOClass *ttgo = TTGOClass::getWatch();
ttgo->openBL(); ttgo->openBL();
ttgo->bl->adjust( 0 ); ttgo->bl->adjust( 0 );
ttgo->tft->setRotation( display_config.rotation / 90 ); ttgo->tft->setRotation( display_config.rotation / 90 );
@@ -46,7 +48,9 @@ void display_setup( TTGOClass *ttgo ) {
/* /*
* loop routine for handling IRQ in main loop * 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 ( !powermgm_get_event( POWERMGM_STANDBY ) && !powermgm_get_event( POWERMGM_SILENCE_WAKEUP )) {
if ( dest_brightness != brightness ) { if ( dest_brightness != brightness ) {
if ( brightness < dest_brightness ) { if ( brightness < dest_brightness ) {

View File

@@ -46,13 +46,13 @@
* *
* @param ttgo pointer to an TTGOClass * @param ttgo pointer to an TTGOClass
*/ */
void display_setup( TTGOClass *ttgo ); void display_setup( void );
/* /*
* @brief display loop * @brief display loop
* *
* @param ttgo pointer to an TTGOClass * @param ttgo pointer to an TTGOClass
*/ */
void display_loop( TTGOClass *ttgo ); void display_loop( void );
/* /*
* @brief save config for display to spiffs * @brief save config for display to spiffs
*/ */

View File

@@ -341,3 +341,13 @@ float pmu_get_coulumb_data( void ) {
TTGOClass *ttgo = TTGOClass::getWatch(); TTGOClass *ttgo = TTGOClass::getWatch();
return( ttgo->power->getCoulombData() ); 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() );
}

View File

@@ -104,5 +104,7 @@
float pmu_get_battery_discharge_current( void ); float pmu_get_battery_discharge_current( void );
float pmu_get_vbus_voltage( void ); float pmu_get_vbus_voltage( void );
float pmu_get_coulumb_data( void ); float pmu_get_coulumb_data( void );
bool pmu_is_charging( void );
bool pmu_is_vbus_plug( void );
#endif // _PMU_H #endif // _PMU_H

View File

@@ -170,7 +170,7 @@ void powermgm_loop( void ) {
else { else {
pmu_loop(); pmu_loop();
bma_loop(); bma_loop();
display_loop( ttgo ); display_loop();
} }
} }

View File

@@ -34,6 +34,8 @@
#include "hardware/motor.h" #include "hardware/motor.h"
#include "hardware/wifictl.h" #include "hardware/wifictl.h"
#include "hardware/blectl.h" #include "hardware/blectl.h"
#include "hardware/pmu.h"
#include "hardware/timesync.h"
#include "app/weather/weather.h" #include "app/weather/weather.h"
#include "app/stopwatch/stopwatch_app.h" #include "app/stopwatch/stopwatch_app.h"
@@ -51,17 +53,13 @@ void setup()
ttgo->lvgl_begin(); ttgo->lvgl_begin();
SPIFFS.begin(); SPIFFS.begin();
motor_setup(); motor_setup();
// force to store all new heap allocations in psram to get more internal ram // force to store all new heap allocations in psram to get more internal ram
heap_caps_malloc_extmem_enable( 1 ); heap_caps_malloc_extmem_enable( 1 );
display_setup();
display_setup( ttgo );
screenshot_setup(); screenshot_setup();
splash_screen_stage_one();
splash_screen_stage_one( ttgo );
splash_screen_stage_update( "init serial", 10 ); splash_screen_stage_update( "init serial", 10 );
splash_screen_stage_update( "init spiff", 20 ); splash_screen_stage_update( "init spiff", 20 );
@@ -71,11 +69,9 @@ void setup()
} }
splash_screen_stage_update( "init rtc", 50 ); splash_screen_stage_update( "init rtc", 50 );
ttgo->rtc->syncToSystem(); timesyncToSystem();
splash_screen_stage_update( "init powermgm", 60 ); splash_screen_stage_update( "init powermgm", 60 );
powermgm_setup(); powermgm_setup();
splash_screen_stage_update( "init gui", 80 ); splash_screen_stage_update( "init gui", 80 );
gui_setup(); gui_setup();
/* /*
@@ -89,13 +85,11 @@ void setup()
/* /*
* *
*/ */
if ( wifictl_get_autoon() && ( pmu_is_charging() || pmu_is_vbus_plug() || ( pmu_get_battery_voltage() > 3400) ) )
if (wifictl_get_autoon() && (ttgo->power->isChargeing() || ttgo->power->isVBUSPlug() || (ttgo->power->getBattVoltage() > 3400)))
wifictl_on(); wifictl_on();
splash_screen_stage_finish( ttgo ); splash_screen_stage_finish();
display_set_brightness( display_get_brightness() ); display_set_brightness( display_get_brightness() );
// enable to store data in normal heap // enable to store data in normal heap
heap_caps_malloc_extmem_enable( 16*1024 ); heap_caps_malloc_extmem_enable( 16*1024 );
blectl_setup(); blectl_setup();
@@ -111,6 +105,6 @@ void setup()
void loop() void loop()
{ {
delay(5); delay(5);
gui_loop( ttgo ); gui_loop();
powermgm_loop(); powermgm_loop();
} }

Binary file not shown.

View File

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