Merge branch 'master' into master

This commit is contained in:
Dirk Broßwick
2020-07-29 08:13:59 +02:00
committed by GitHub
40 changed files with 118 additions and 55 deletions

View File

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

View File

@@ -29,8 +29,6 @@
#include "keyboard.h"
#include "mainbar/mainbar.h"
#include "widget/weather/weather.h"
#include "hardware/powermgm.h"
#include "hardware/display.h"
@@ -56,8 +54,6 @@ void gui_setup(void)
keyboard_setup();
lv_disp_trig_activity(NULL);
weather_widget_setup();
return;
}

View File

@@ -23,8 +23,10 @@
#include "../mainbar.h"
#include "app_tile.h"
static lv_obj_t *applabel = NULL;
lv_app_entry_t app_entry[ MAX_APPS_ICON ];
static lv_obj_t *app_cont = NULL;
static lv_obj_t *applabel = NULL;
static lv_style_t appstyle;
LV_FONT_DECLARE(Ubuntu_72px);
@@ -32,6 +34,8 @@ LV_FONT_DECLARE(Ubuntu_16px);
void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
app_cont = tile;
lv_style_copy( &appstyle, style);
lv_style_set_text_font( &appstyle, LV_STATE_DEFAULT, &Ubuntu_72px);
@@ -40,4 +44,39 @@ void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coor
lv_obj_reset_style_list( applabel, LV_OBJ_PART_MAIN );
lv_obj_add_style( applabel, LV_OBJ_PART_MAIN, &appstyle );
lv_obj_align(applabel, NULL, LV_ALIGN_CENTER, 0, 0);
for ( int app = 0 ; app < MAX_APPS_ICON ; app++ ) {
// set x, y and mark it as inactive
app_entry[ app ].x = APP_FIRST_X_POS + ( ( app % MAX_APPS_ICON_HORZ ) * ( APP_ICON_X_SIZE + APP_ICON_X_CLEARENCE ) );
app_entry[ app ].y = APP_FIRST_Y_POS + ( ( app % MAX_APPS_ICON_VERT ) * ( APP_ICON_Y_SIZE + APP_ICON_Y_CLEARENCE ) );
app_entry[ app ].active = false;
// create app icon container
app_entry[ app ].app = lv_obj_create( app_cont, NULL );
lv_obj_reset_style_list( app_entry[ app ].app, LV_OBJ_PART_MAIN );
lv_obj_add_style( app_entry[ app ].app, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( app_entry[ app ].app, APP_ICON_X_SIZE, APP_ICON_Y_SIZE );
lv_obj_align( app_entry[ app ].app , app_cont, LV_ALIGN_IN_TOP_LEFT, app_entry[ app ].x, app_entry[ app ].y );
// create app label
app_entry[ app ].label = lv_label_create( app_cont, NULL );
lv_obj_reset_style_list( app_entry[ app ].label, LV_OBJ_PART_MAIN );
lv_obj_add_style( app_entry[ app ].label, LV_OBJ_PART_MAIN, style );
lv_obj_set_size( app_entry[ app ].label, APP_LABEL_X_SIZE, APP_LABEL_Y_SIZE );
lv_obj_align( app_entry[ app ].app , app_entry[ app ].app, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
lv_obj_set_hidden( app_entry[ app ].app, true );
lv_obj_set_hidden( app_entry[ app ].label, true );
}
}
lv_obj_t *app_tile_register_app( const char* appname ) {
for( int app = 0 ; app < MAX_APPS_ICON ; app++ ) {
if ( app_entry[ app ].active == false ) {
app_entry[ app ].active = true;
lv_obj_set_hidden( app_entry[ app ].app, false );
return( app_entry[ app ].app );
}
}
return( NULL );
}

View File

@@ -24,6 +24,28 @@
#include <TTGO.h>
#define MAX_APPS_ICON_HORZ 3
#define MAX_APPS_ICON_VERT 2
#define MAX_APPS_ICON ( MAX_APPS_ICON_HORZ * MAX_APPS_ICON_VERT )
#define APP_ICON_X_SIZE 48
#define APP_ICON_Y_SIZE 48
#define APP_ICON_X_CLEARENCE 32
#define APP_ICON_Y_CLEARENCE 32
#define APP_LABEL_X_SIZE APP_ICON_X_SIZE + APP_ICON_X_CLEARENCE
#define APP_LABEL_Y_SIZE APP_ICON_Y_CLEARENCE / 2
#define APP_FIRST_X_POS ( 240 - ( APP_ICON_X_SIZE * MAX_APPS_ICON_HORZ + APP_ICON_X_CLEARENCE * ( MAX_APPS_ICON_HORZ - 1 ) ) ) / 2
#define APP_FIRST_Y_POS ( 240 - ( APP_ICON_Y_SIZE * MAX_APPS_ICON_VERT + APP_ICON_Y_CLEARENCE * ( MAX_APPS_ICON_VERT - 1 ) ) ) / 2
typedef struct {
lv_obj_t *app;
lv_obj_t *label;
lv_coord_t x;
lv_coord_t y;
bool active;
} lv_app_entry_t;
void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
#endif // _APP_TILE_H

View File

@@ -33,7 +33,7 @@ uint64_t update_check_new_version( void ) {
uint64_t retval = -1;
if ( !check_version_client.connect( FIRMWARE_HOST, FIRMWARE_HOST_PORT ) ) {
Serial.printf("connection failed\r\n");
Serial.printf( __FILE__ "connection failed\r\n");
return( -1 );
}
@@ -48,15 +48,15 @@ uint64_t update_check_new_version( void ) {
uint64_t startMillis = millis();
while ( check_version_client.available() == 0 ) {
if ( millis() - startMillis > 5000 ) {
Serial.printf("connection timeout\r\n");
Serial.printf( __FILE__ "connection timeout\r\n");
check_version_client.stop();
return( retval );
}
}
char *json = (char *)ps_malloc( 100 );
char *json = (char *)ps_malloc( 200 );
if ( json == NULL ) {
Serial.printf("memory alloc failed\r\n");
Serial.printf( __FILE__ "memory alloc failed\r\n");
check_version_client.stop();
return( retval );
}
@@ -82,11 +82,11 @@ uint64_t update_check_new_version( void ) {
}
check_version_client.stop();
DynamicJsonDocument doc(200);
DynamicJsonDocument doc( 400 );
DeserializationError error = deserializeJson( doc, json);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.print(F( __FILE__ "update version deserializeJson() failed: "));
Serial.println(error.c_str());
doc.clear();
free( json );

View File

@@ -21,8 +21,6 @@
*/
#include "config.h"
#include <TTGO.h>
#include "weather.h"
#include "weather_fetch.h"
#include <WiFi.h>
#include "gui/mainbar/mainbar.h"
@@ -30,9 +28,12 @@
#include "gui/statusbar.h"
#include "gui/keyboard.h"
#include "images/resolve_owm_icon.h"
#include "hardware/motor.h"
#include "weather.h"
#include "weather_fetch.h"
#include "weather_setup.h"
EventGroupHandle_t weather_widget_event_handle = NULL;
TaskHandle_t _weather_widget_sync_Task;
void weather_widget_sync_Task( void * pvParameters );
@@ -51,7 +52,7 @@ static void enter_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event );
LV_IMG_DECLARE(owm_01d_64px);
LV_FONT_DECLARE(Ubuntu_16px);
void weather_widget_setup( void ) {
void weather_app_setup( void ) {
weather_load_config();
@@ -59,8 +60,8 @@ void weather_widget_setup( void ) {
weather_widget_tile_num = mainbar_get_next_free_tile( TILE_TYPE_WIDGET_TILE );
weather_widget_setup_tile_num = mainbar_get_next_free_tile( TILE_TYPE_WIDGET_SETUP );
// register the widget setup function
mainbar_set_tile_setup_cb( weather_widget_tile_num, weather_widget_tile_setup );
mainbar_set_tile_setup_cb( weather_widget_setup_tile_num, weather_widget_setup_tile_setup );
mainbar_set_tile_setup_cb( weather_widget_tile_num, weather_tile_setup );
mainbar_set_tile_setup_cb( weather_widget_setup_tile_num, weather_setup_tile_setup );
// get an widget container from main_tile
weather_widget_cont = main_tile_register_widget();
@@ -179,7 +180,7 @@ void weather_save_config( void ) {
fs::File file = SPIFFS.open( WEATHER_CONFIG_FILE, FILE_WRITE );
if ( !file ) {
Serial.printf("Can't save file: %s\r\n", WEATHER_CONFIG_FILE );
Serial.printf( __FILE__ "Can't save file: %s\r\n", WEATHER_CONFIG_FILE );
}
else {
file.write( (uint8_t *)&weather_config, sizeof( weather_config ) );
@@ -195,7 +196,7 @@ void weather_load_config( void ) {
fs::File file = SPIFFS.open( WEATHER_CONFIG_FILE, FILE_READ );
if (!file) {
Serial.printf("Can't open file: %s\r\n", WEATHER_CONFIG_FILE );
Serial.printf( __FILE__ "Can't open file: %s\r\n", WEATHER_CONFIG_FILE );
}
else {
size_t filesize = file.size();

View File

@@ -62,11 +62,9 @@
char wind[8] = "";
} weather_forcast_t;
void weather_widget_setup( void );
void weather_app_setup( void );
void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void weather_widget_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void weather_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
weather_config_t *weather_get_config( void );

View File

@@ -40,7 +40,7 @@ uint32_t weather_fetch_today( weather_config_t *weather_config, weather_forcast_
uint32_t retval = -1;
if ( !today_client.connect( OWM_HOST, OWM_PORT ) ) {
Serial.printf("connection failed\r\n");
Serial.printf( __FILE__ "connection failed\r\n");
return( -1 );
}
@@ -55,7 +55,7 @@ uint32_t weather_fetch_today( weather_config_t *weather_config, weather_forcast_
uint64_t startMillis = millis();
while ( today_client.available() == 0 ) {
if ( millis() - startMillis > 5000 ) {
Serial.printf("connection timeout\r\n");
Serial.printf( __FILE__ "connection timeout\r\n");
today_client.stop();
return( retval );
}
@@ -63,7 +63,7 @@ uint32_t weather_fetch_today( weather_config_t *weather_config, weather_forcast_
char *json = (char *)ps_malloc( WEATHER_TODAY_BUFFER_SIZE );
if ( json == NULL ) {
Serial.printf("memory alloc failed\r\n");
Serial.printf( __FILE__ "memory alloc failed\r\n");
today_client.stop();
return( retval );
}
@@ -93,7 +93,7 @@ uint32_t weather_fetch_today( weather_config_t *weather_config, weather_forcast_
DeserializationError error = deserializeJson( doc, json);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.print(F( __FILE__ "weather today deserializeJson() failed: "));
Serial.println(error.c_str());
doc.clear();
free( json );
@@ -103,7 +103,7 @@ uint32_t weather_fetch_today( weather_config_t *weather_config, weather_forcast_
retval = doc["cod"].as<int>();
if ( retval != 200 ) {
Serial.printf("get weather failed, returncode: %d\r\n", retval );
Serial.printf( __FILE__ "get weather failed, returncode: %d\r\n", retval );
doc.clear();
free( json );
return( retval );
@@ -131,7 +131,7 @@ uint32_t weather_fetch_forecast( weather_config_t *weather_config, weather_forca
uint32_t retval = -1;
if ( !forecast_client.connect( OWM_HOST, OWM_PORT ) ) {
Serial.printf("connection failed\r\n");
Serial.printf( __FILE__ "connection failed\r\n");
return( retval );
}
@@ -146,7 +146,7 @@ uint32_t weather_fetch_forecast( weather_config_t *weather_config, weather_forca
uint64_t startMillis = millis();
while ( forecast_client.available() == 0 ) {
if ( millis() - startMillis > 5000 ) {
Serial.printf("connection timeout\r\n");
Serial.printf( __FILE__ "connection timeout\r\n");
forecast_client.stop();
return( retval );
}
@@ -154,7 +154,7 @@ uint32_t weather_fetch_forecast( weather_config_t *weather_config, weather_forca
char *json = (char *)ps_malloc( WEATHER_FORECAST_BUFFER_SIZE );
if ( json == NULL ) {
Serial.printf("memory alloc failed\r\n");
Serial.printf( __FILE__ "memory alloc failed\r\n");
forecast_client.stop();
return( retval );
}
@@ -182,7 +182,7 @@ uint32_t weather_fetch_forecast( weather_config_t *weather_config, weather_forca
DynamicJsonDocument doc(20000);
DeserializationError error = deserializeJson( doc, json );
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.print(F( __FILE__ "weather forecast deserializeJson() failed: "));
Serial.println(error.c_str());
doc.clear();
free( json );
@@ -192,7 +192,7 @@ uint32_t weather_fetch_forecast( weather_config_t *weather_config, weather_forca
retval = doc["cod"].as<int>();
if ( retval != 200 ) {
Serial.printf("get weather forecast failed, returncode: %d\r\n", retval );
Serial.printf( __FILE__ "get weather forecast failed, returncode: %d\r\n", retval );
doc.clear();
free( json );
return( retval );

View File

@@ -58,7 +58,7 @@ static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event );
static void setup_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event );
static void refresh_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event );
void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
void weather_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
lv_obj_t * exit_btn = lv_imgbtn_create(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);

View File

@@ -6,7 +6,7 @@
#define WEATHER_FORECAST_SYNC_REQUEST _BV(0)
#define WEATHER_MAX_FORECAST 16
void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void weather_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void weather_forecast_sync_request( void );
#endif // _WEATHER_FORECAST_H

View File

@@ -45,7 +45,7 @@ static void exit_weather_widget_setup_event_cb( lv_obj_t * obj, lv_event_t event
static void weather_autosync_onoff_event_handler( lv_obj_t * obj, lv_event_t event );
static void weather_wind_onoff_event_handler( lv_obj_t *obj, lv_event_t event );
void weather_widget_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
weather_config_t *weather_config = weather_get_config();

View File

@@ -3,6 +3,6 @@
#include <TTGO.h>
void weather_widget_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
void weather_setup_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
#endif // _WEATHER_SETUP_H

View File

@@ -113,7 +113,7 @@ void bma_save_config( void ) {
fs::File file = SPIFFS.open( BMA_COFIG_FILE, FILE_WRITE );
if ( !file ) {
Serial.printf("Can't save file: %s\r\n", BMA_COFIG_FILE );
Serial.printf( __FILE__ "Can't save file: %s\r\n", BMA_COFIG_FILE );
}
else {
file.write( (uint8_t *)bma_config, sizeof( bma_config ) );
@@ -128,12 +128,12 @@ void bma_read_config( void ) {
fs::File file = SPIFFS.open( BMA_COFIG_FILE, FILE_READ );
if (!file) {
Serial.printf("Can't open file: %s!\r\n", BMA_COFIG_FILE );
Serial.printf( __FILE__ "Can't open file: %s!\r\n", BMA_COFIG_FILE );
}
else {
int filesize = file.size();
if ( filesize > sizeof( bma_config ) ) {
Serial.printf("Failed to read configfile. Wrong filesize!\r\n" );
Serial.printf( __FILE__ "Failed to read configfile. Wrong filesize!\r\n" );
}
else {
file.read( (uint8_t *)bma_config, filesize );

View File

@@ -96,7 +96,7 @@ void display_save_config( void ) {
fs::File file = SPIFFS.open( DISPLAY_CONFIG_FILE, FILE_WRITE );
if ( !file ) {
Serial.printf("Can't save file: %s\r\n", DISPLAY_CONFIG_FILE );
Serial.printf( __FILE__ "Can't save file: %s\r\n", DISPLAY_CONFIG_FILE );
}
else {
file.write( (uint8_t *)&display_config, sizeof( display_config ) );
@@ -111,12 +111,12 @@ void display_read_config( void ) {
fs::File file = SPIFFS.open( DISPLAY_CONFIG_FILE, FILE_READ );
if (!file) {
Serial.printf("Can't open file: %s!\r\n", DISPLAY_CONFIG_FILE );
Serial.printf( __FILE__ "Can't open file: %s!\r\n", DISPLAY_CONFIG_FILE );
}
else {
int filesize = file.size();
if ( filesize > sizeof( display_config ) ) {
Serial.printf("Failed to read configfile. Wrong filesize!\r\n" );
Serial.printf( __FILE__ "Failed to read configfile. Wrong filesize!\r\n" );
}
else {
file.read( (uint8_t *)&display_config, filesize );

View File

@@ -25,13 +25,13 @@ void pmu_setup( TTGOClass *ttgo ) {
// enable coulumb counter
if ( ttgo->power->EnableCoulombcounter() )
Serial.printf("enable coulumb counter failed!\r\n");
Serial.printf( __FILE__ "enable coulumb counter failed!\r\n");
if ( ttgo->power->setChargingTargetVoltage( AXP202_TARGET_VOL_4_2V ) )
Serial.printf("target voltage set failed!\r\n");
Serial.printf( __FILE__ "target voltage set failed!\r\n");
if ( ttgo->power->setChargeControlCur( 300 ) )
Serial.printf("charge current set failed!\r\n");
Serial.printf( __FILE__ "charge current set failed!\r\n");
if ( ttgo->power->setAdcSamplingRate( AXP_ADC_SAMPLING_RATE_200HZ ) )
Serial.printf("adc sample set failed!\r\n");
Serial.printf( __FILE__ "adc sample set failed!\r\n");
// Turn off unused power
ttgo->power->setPowerOutPut( AXP202_EXTEN, AXP202_OFF );

View File

@@ -106,7 +106,7 @@ void powermgm_loop( TTGOClass *ttgo ) {
powermgm_clear_event( POWERMGM_SILENCE_WAKEUP );
ttgo->power->setDCDC3Voltage( 3000 );
ttgo->power->clearTimerStatus();
ttgo->power->setTimer( 30 );
ttgo->power->setTimer( 60 );
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);

View File

@@ -33,6 +33,8 @@
#include "hardware/motor.h"
#include "hardware/wifictl.h"
#include "gui/widget/weather/weather.h"
TTGOClass *ttgo = TTGOClass::getWatch();
void setup()
@@ -67,12 +69,17 @@ void setup()
gui_setup();
lv_task_handler();
for( int bl = 0 ; bl < display_get_brightness() ; bl++ ) {
ttgo->bl->adjust( bl );
delay(5);
}
/*
* add apps and widgets here!!!
*/
weather_app_setup();
/*
*
*/
wifictl_on();
display_set_brightness( display_get_brightness() );
Serial.printf("Total heap: %d\r\n", ESP.getHeapSize());
Serial.printf("Free heap: %d\r\n", ESP.getFreeHeap());
Serial.printf("Total PSRAM: %d\r\n", ESP.getPsramSize());

Binary file not shown.

View File

@@ -1 +1 @@
{"version":"2020072804"}
{"version":"2020072805","url":"http://www.neo-guerillaz.de/ttgo-t-watch2020_v1.ino.bin"}