migrate from binary config to json config
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "gui/keyboard.h"
|
||||
#include "hardware/motor.h"
|
||||
#include "hardware/powermgm.h"
|
||||
#include "hardware/json_config_psram_allocator.h"
|
||||
|
||||
EventGroupHandle_t weather_widget_event_handle = NULL;
|
||||
TaskHandle_t _weather_widget_sync_Task;
|
||||
@@ -211,37 +212,81 @@ void weather_widget_sync_Task( void * pvParameters ) {
|
||||
*
|
||||
*/
|
||||
void weather_save_config( void ) {
|
||||
if ( SPIFFS.exists( WEATHER_CONFIG_FILE ) ) {
|
||||
SPIFFS.remove( WEATHER_CONFIG_FILE );
|
||||
log_i("remove old binary weather config");
|
||||
}
|
||||
|
||||
fs::File file = SPIFFS.open( WEATHER_CONFIG_FILE, FILE_WRITE );
|
||||
fs::File file = SPIFFS.open( WEATHER_JSON_CONFIG_FILE, FILE_WRITE );
|
||||
|
||||
if ( !file ) {
|
||||
log_e( "Can't save file: %s\r\n", WEATHER_CONFIG_FILE );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", WEATHER_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)&weather_config, sizeof( weather_config ) );
|
||||
file.close();
|
||||
SpiRamJsonDocument doc( 1000 );
|
||||
|
||||
doc["apikey"] = weather_config.apikey;
|
||||
doc["lat"] = weather_config.lat;
|
||||
doc["lon"] = weather_config.lon;
|
||||
doc["autosync"] = weather_config.autosync;
|
||||
doc["showWind"] = weather_config.showWind;
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void weather_load_config( void ) {
|
||||
|
||||
fs::File file = SPIFFS.open( WEATHER_CONFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e( "Can't open file: %s\r\n", WEATHER_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( weather_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
if ( SPIFFS.exists( WEATHER_JSON_CONFIG_FILE ) ) {
|
||||
fs::File file = SPIFFS.open( WEATHER_JSON_CONFIG_FILE, FILE_READ );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", WEATHER_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&weather_config, filesize );
|
||||
int filesize = file.size();
|
||||
SpiRamJsonDocument doc( filesize * 2 );
|
||||
|
||||
DeserializationError error = deserializeJson( doc, file );
|
||||
if ( error ) {
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
strlcpy( weather_config.apikey, doc["apikey"], sizeof( weather_config.apikey ) );
|
||||
strlcpy( weather_config.lat, doc["lat"], sizeof( weather_config.lat ) );
|
||||
strlcpy( weather_config.lon, doc["lon"], sizeof( weather_config.lon ) );
|
||||
weather_config.autosync = doc["autosync"].as<bool>();
|
||||
weather_config.showWind = doc["showWind"].as<bool>();
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
log_i("no json config exists, read from binary");
|
||||
fs::File file = SPIFFS.open( WEATHER_CONFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", WEATHER_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( weather_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&weather_config, filesize );
|
||||
file.close();
|
||||
weather_save_config();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <TTGO.h>
|
||||
|
||||
#define WEATHER_CONFIG_FILE "/weather.cfg"
|
||||
#define WEATHER_JSON_CONFIG_FILE "/weather.json"
|
||||
|
||||
#define WEATHER_WIDGET_SYNC_REQUEST _BV(0)
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "ArduinoJson.h"
|
||||
#include "HTTPClient.h"
|
||||
|
||||
#include "weather.h"
|
||||
@@ -28,27 +27,7 @@
|
||||
#include "weather_forecast.h"
|
||||
|
||||
#include "hardware/powermgm.h"
|
||||
|
||||
// arduinoJson allocator for external PSRAM
|
||||
// see: https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/
|
||||
struct WeatherSpiRamAllocator {
|
||||
void* allocate( size_t size ) {
|
||||
void *psram = ps_calloc( size, 1 );
|
||||
if ( psram ) {
|
||||
log_i("allocate %dbytes(%p) json psram", size, psram );
|
||||
return( psram );
|
||||
}
|
||||
else {
|
||||
log_e("allocate %dbytes(%p) json psram failed", size, psram );
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
void deallocate( void* pointer ) {
|
||||
log_i("deallocate (%p) json psram", pointer );
|
||||
free( pointer );
|
||||
}
|
||||
};
|
||||
using WeatherSpiRamJsonDocument = BasicJsonDocument<WeatherSpiRamAllocator>;
|
||||
#include "hardware/json_config_psram_allocator.h"
|
||||
|
||||
/* Utility function to convert numbers to directions */
|
||||
static void weather_wind_to_string( weather_forcast_t* container, int speed, int directionDegree);
|
||||
@@ -71,7 +50,7 @@ int weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *we
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
WeatherSpiRamJsonDocument doc( today_client.getSize() * 2 );
|
||||
SpiRamJsonDocument doc( today_client.getSize() * 2 );
|
||||
|
||||
DeserializationError error = deserializeJson( doc, today_client.getStream() );
|
||||
if (error) {
|
||||
@@ -116,7 +95,7 @@ int weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
WeatherSpiRamJsonDocument doc( forecast_client.getSize() * 2 );
|
||||
SpiRamJsonDocument doc( forecast_client.getSize() * 2 );
|
||||
|
||||
DeserializationError error = deserializeJson( doc, forecast_client.getStream() );
|
||||
if (error) {
|
||||
|
||||
@@ -32,6 +32,6 @@
|
||||
/*
|
||||
* firmeware version string
|
||||
*/
|
||||
#define __FIRMWARE__ "2020081102"
|
||||
#define __FIRMWARE__ "2020081103"
|
||||
|
||||
#endif // _CONFIG_H
|
||||
|
||||
@@ -20,31 +20,11 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "ArduinoJson.h"
|
||||
#include "HTTPClient.h"
|
||||
|
||||
#include "update_check_version.h"
|
||||
|
||||
// arduinoJson allocator for external PSRAM
|
||||
// see: https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/
|
||||
struct UpdateSpiRamAllocator {
|
||||
void* allocate( size_t size ) {
|
||||
void *psram = ps_calloc( size, 1 );
|
||||
if ( psram ) {
|
||||
log_i("allocate %dbytes(%p) json psram", size, psram );
|
||||
return( psram );
|
||||
}
|
||||
else {
|
||||
log_e("allocate %dbytes(%p) json psram failed", size, psram );
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
void deallocate( void* pointer ) {
|
||||
log_i("deallocate (%p) json psram", pointer );
|
||||
free( pointer );
|
||||
}
|
||||
};
|
||||
using SpiRamJsonDocument = BasicJsonDocument<UpdateSpiRamAllocator>;
|
||||
#include "hardware/json_config_psram_allocator.h"
|
||||
|
||||
uint64_t update_check_new_version( void ) {
|
||||
char url[512]="";
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "gui/statusbar.h"
|
||||
#include "gui/keyboard.h"
|
||||
|
||||
#include "hardware/json_config_psram_allocator.h"
|
||||
|
||||
update_config_t update_config;
|
||||
|
||||
lv_obj_t *update_setup_tile = NULL;
|
||||
@@ -88,7 +90,7 @@ void update_setup_tile_setup( uint32_t tile_num ) {
|
||||
lv_label_set_text( update_check_autosync_label, "check for updates");
|
||||
lv_obj_align( update_check_autosync_label, update_check_autosync_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||
|
||||
if ( update_config.autosync)
|
||||
if ( update_config.autosync )
|
||||
lv_switch_on( update_check_autosync_onoff, LV_ANIM_OFF);
|
||||
else
|
||||
lv_switch_off( update_check_autosync_onoff, LV_ANIM_OFF);
|
||||
@@ -112,33 +114,71 @@ static void exit_update_check_setup_event_cb( lv_obj_t * obj, lv_event_t event )
|
||||
}
|
||||
|
||||
void update_save_config( void ) {
|
||||
fs::File file = SPIFFS.open( UPDATE_CONFIG_FILE, FILE_WRITE );
|
||||
if ( SPIFFS.exists( UPDATE_CONFIG_FILE ) ) {
|
||||
SPIFFS.remove( UPDATE_CONFIG_FILE );
|
||||
log_i("remove old binary update config");
|
||||
}
|
||||
|
||||
if ( !file ) {
|
||||
log_e("Can't save file: %s", UPDATE_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)&update_config, sizeof( update_config ) );
|
||||
fs::File file = SPIFFS.open( UPDATE_JSON_CONFIG_FILE, FILE_WRITE );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", UPDATE_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
SpiRamJsonDocument doc( 1000 );
|
||||
|
||||
doc["autosync"] = update_config.autosync;
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void update_read_config( void ) {
|
||||
fs::File file = SPIFFS.open( UPDATE_CONFIG_FILE, FILE_READ );
|
||||
if ( SPIFFS.exists( UPDATE_JSON_CONFIG_FILE ) ) {
|
||||
fs::File file = SPIFFS.open( UPDATE_JSON_CONFIG_FILE, FILE_READ );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", UPDATE_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
SpiRamJsonDocument doc( filesize * 2 );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", UPDATE_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( update_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
DeserializationError error = deserializeJson( doc, file );
|
||||
if ( error ) {
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
update_config.autosync = doc["autosync"].as<bool>();
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&update_config, filesize );
|
||||
log_i("no json config exists, read from binary");
|
||||
fs::File file = SPIFFS.open( UPDATE_CONFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", UPDATE_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( update_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&update_config, filesize );
|
||||
file.close();
|
||||
update_save_config();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
bool update_setup_get_autosync( void ) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <TTGO.h>
|
||||
|
||||
#define UPDATE_CONFIG_FILE "/update.cfg"
|
||||
#define UPDATE_JSON_CONFIG_FILE "/update.json"
|
||||
|
||||
typedef struct {
|
||||
bool autosync = true;
|
||||
|
||||
@@ -32,6 +32,7 @@ void screenshot_setup( void ) {
|
||||
log_e("error memory alloc");
|
||||
while(1);
|
||||
}
|
||||
SPIFFS.remove( SCREENSHOT_FILE_NAME );
|
||||
}
|
||||
|
||||
void screenshot_take( void ) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "bma.h"
|
||||
#include "powermgm.h"
|
||||
#include "json_config_psram_allocator.h"
|
||||
|
||||
#include "gui/statusbar.h"
|
||||
|
||||
@@ -145,36 +146,76 @@ void bma_loop( TTGOClass *ttgo ) {
|
||||
*
|
||||
*/
|
||||
void bma_save_config( void ) {
|
||||
fs::File file = SPIFFS.open( BMA_COFIG_FILE, FILE_WRITE );
|
||||
if ( SPIFFS.exists( BMA_COFIG_FILE ) ) {
|
||||
SPIFFS.remove( BMA_COFIG_FILE );
|
||||
log_i("remove old binary bma config");
|
||||
}
|
||||
|
||||
if ( !file ) {
|
||||
log_e("Can't save file: %s", BMA_COFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)bma_config, sizeof( bma_config ) );
|
||||
fs::File file = SPIFFS.open( BMA_JSON_COFIG_FILE, FILE_WRITE );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", BMA_JSON_COFIG_FILE );
|
||||
}
|
||||
else {
|
||||
SpiRamJsonDocument doc( 1000 );
|
||||
|
||||
doc["stepcounter"] = bma_config[ BMA_STEPCOUNTER ].enable;
|
||||
doc["doubleclick"] = bma_config[ BMA_DOUBLECLICK ].enable;
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void bma_read_config( void ) {
|
||||
fs::File file = SPIFFS.open( BMA_COFIG_FILE, FILE_READ );
|
||||
if ( SPIFFS.exists( BMA_JSON_COFIG_FILE ) ) {
|
||||
fs::File file = SPIFFS.open( BMA_JSON_COFIG_FILE, FILE_READ );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", BMA_JSON_COFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
SpiRamJsonDocument doc( filesize * 2 );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", BMA_COFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( bma_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
DeserializationError error = deserializeJson( doc, file );
|
||||
if ( error ) {
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
bma_config[ BMA_STEPCOUNTER ].enable = doc["stepcounter"].as<bool>();
|
||||
bma_config[ BMA_DOUBLECLICK ].enable = doc["doubleclick"].as<bool>();
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)bma_config, filesize );
|
||||
log_i("no json config exists, read from binary");
|
||||
fs::File file = SPIFFS.open( BMA_COFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", BMA_COFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( bma_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)bma_config, filesize );
|
||||
file.close();
|
||||
bma_save_config();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
#ifndef _BMA_H
|
||||
#define _BMA_H
|
||||
|
||||
#define BMA_EVENT_INT _BV(0)
|
||||
#define BMA_EVENT_INT _BV(0)
|
||||
|
||||
#define BMA_COFIG_FILE "/bma.cfg"
|
||||
#define BMA_JSON_COFIG_FILE "/bma.json"
|
||||
|
||||
typedef struct {
|
||||
bool enable=true;
|
||||
@@ -34,8 +37,6 @@
|
||||
BMA_CONFIG_NUM
|
||||
};
|
||||
|
||||
#define BMA_COFIG_FILE "/bma.cfg"
|
||||
|
||||
/*
|
||||
* @brief setup bma activity measurement
|
||||
*
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "powermgm.h"
|
||||
#include "motor.h"
|
||||
|
||||
#include "json_config_psram_allocator.h"
|
||||
|
||||
display_config_t display_config;
|
||||
|
||||
static uint8_t dest_brightness = 0;
|
||||
@@ -106,36 +108,78 @@ void display_wakeup( void ) {
|
||||
*
|
||||
*/
|
||||
void display_save_config( void ) {
|
||||
fs::File file = SPIFFS.open( DISPLAY_CONFIG_FILE, FILE_WRITE );
|
||||
if ( SPIFFS.exists( DISPLAY_CONFIG_FILE ) ) {
|
||||
SPIFFS.remove( DISPLAY_CONFIG_FILE );
|
||||
log_i("remove old binary display config");
|
||||
}
|
||||
|
||||
if ( !file ) {
|
||||
log_e("Can't save file: %s", DISPLAY_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)&display_config, sizeof( display_config ) );
|
||||
fs::File file = SPIFFS.open( DISPLAY_JSON_CONFIG_FILE, FILE_WRITE );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", DISPLAY_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
SpiRamJsonDocument doc( 1000 );
|
||||
|
||||
doc["brightness"] = display_config.brightness;
|
||||
doc["rotation"] = display_config.rotation;
|
||||
doc["timeout"] = display_config.timeout;
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void display_read_config( void ) {
|
||||
fs::File file = SPIFFS.open( DISPLAY_CONFIG_FILE, FILE_READ );
|
||||
if ( SPIFFS.exists( DISPLAY_JSON_CONFIG_FILE ) ) {
|
||||
fs::File file = SPIFFS.open( DISPLAY_JSON_CONFIG_FILE, FILE_READ );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", DISPLAY_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
SpiRamJsonDocument doc( filesize * 2 );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", DISPLAY_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( display_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
DeserializationError error = deserializeJson( doc, file );
|
||||
if ( error ) {
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
display_config.brightness = doc["brightness"].as<uint32_t>();
|
||||
display_config.rotation = doc["rotation"].as<uint32_t>();
|
||||
display_config.timeout = doc["timeout"].as<uint32_t>();
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&display_config, filesize );
|
||||
log_i("no json config exists, read from binary");
|
||||
fs::File file = SPIFFS.open( DISPLAY_CONFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", DISPLAY_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( display_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&display_config, filesize );
|
||||
file.close();
|
||||
display_save_config();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t display_get_timeout( void ) {
|
||||
|
||||
@@ -32,12 +32,13 @@
|
||||
#define DISPLAY_MAX_ROTATE 270
|
||||
|
||||
typedef struct {
|
||||
uint32_t brightness = DISPLAY_MIN_BRIGHTNESS;
|
||||
uint32_t brightness = DISPLAY_MAX_BRIGHTNESS;
|
||||
uint32_t timeout = DISPLAY_MIN_TIMEOUT;
|
||||
uint32_t rotation = 0;
|
||||
} display_config_t;
|
||||
|
||||
#define DISPLAY_CONFIG_FILE "/display.cfg"
|
||||
#define DISPLAY_CONFIG_FILE "/display.cfg"
|
||||
#define DISPLAY_JSON_CONFIG_FILE "/display.json"
|
||||
|
||||
/*
|
||||
* @brief setup display
|
||||
|
||||
23
src/hardware/json_config_psram_allocator.h
Normal file
23
src/hardware/json_config_psram_allocator.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "config.h"
|
||||
#include "ArduinoJson.h"
|
||||
|
||||
// arduinoJson allocator for external PSRAM
|
||||
// see: https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/
|
||||
struct SpiRamAllocator {
|
||||
void* allocate( size_t size ) {
|
||||
void *psram = ps_calloc( size, 1 );
|
||||
if ( psram ) {
|
||||
log_i("allocate %dbytes(%p) json psram", size, psram );
|
||||
return( psram );
|
||||
}
|
||||
else {
|
||||
log_e("allocate %dbytes(%p) json psram failed", size, psram );
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
void deallocate( void* pointer ) {
|
||||
log_i("deallocate (%p) json psram", pointer );
|
||||
free( pointer );
|
||||
}
|
||||
};
|
||||
using SpiRamJsonDocument = BasicJsonDocument<SpiRamAllocator>;
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <TTGO.h>
|
||||
#include "json_config_psram_allocator.h"
|
||||
|
||||
#include "motor.h"
|
||||
#include "powermgm.h"
|
||||
@@ -55,6 +56,8 @@ void motor_setup( void ) {
|
||||
if ( motor_init == true )
|
||||
return;
|
||||
|
||||
motor_read_config();
|
||||
|
||||
pinMode(GPIO_NUM_4, OUTPUT);
|
||||
timer = timerBegin(0, 80, true);
|
||||
timerAttachInterrupt(timer, &onTimer, true);
|
||||
@@ -92,34 +95,72 @@ void motor_set_vibe_config( bool enable ) {
|
||||
*
|
||||
*/
|
||||
void motor_save_config( void ) {
|
||||
fs::File file = SPIFFS.open( MOTOR_CONFIG_FILE, FILE_WRITE );
|
||||
if ( SPIFFS.exists( MOTOR_CONFIG_FILE ) ) {
|
||||
SPIFFS.remove( MOTOR_CONFIG_FILE );
|
||||
log_i("remove old binary motor config");
|
||||
}
|
||||
|
||||
if ( !file ) {
|
||||
log_e("Can't save file: %s", MOTOR_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)&motor_config, sizeof( motor_config ) );
|
||||
fs::File file = SPIFFS.open( MOTOR_JSON_CONFIG_FILE, FILE_WRITE );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", MOTOR_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
SpiRamJsonDocument doc( 1000 );
|
||||
|
||||
doc["motor"] = motor_config.vibe;
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void motor_read_config( void ) {
|
||||
fs::File file = SPIFFS.open( MOTOR_CONFIG_FILE, FILE_READ );
|
||||
if ( SPIFFS.exists( MOTOR_JSON_CONFIG_FILE ) ) {
|
||||
fs::File file = SPIFFS.open( MOTOR_JSON_CONFIG_FILE, FILE_READ );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", MOTOR_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
SpiRamJsonDocument doc( filesize * 2 );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", MOTOR_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( motor_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
DeserializationError error = deserializeJson( doc, file );
|
||||
if ( error ) {
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
motor_config.vibe = doc["motor"].as<bool>();
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&motor_config, filesize );
|
||||
log_i("no json config exists, read from binary");
|
||||
fs::File file = SPIFFS.open( MOTOR_CONFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", MOTOR_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( motor_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&motor_config, filesize );
|
||||
file.close();
|
||||
motor_save_config();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "TTGO.h"
|
||||
|
||||
#define MOTOR_CONFIG_FILE "/motor.cfg"
|
||||
#define MOTOR_JSON_CONFIG_FILE "/motor.json"
|
||||
|
||||
typedef struct {
|
||||
bool vibe = true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "config.h"
|
||||
#include <TTGO.h>
|
||||
#include <soc/rtc.h>
|
||||
#include "json_config_psram_allocator.h"
|
||||
|
||||
#include "display.h"
|
||||
#include "pmu.h"
|
||||
@@ -112,36 +113,78 @@ void pmu_wakeup( void ) {
|
||||
*
|
||||
*/
|
||||
void pmu_save_config( void ) {
|
||||
fs::File file = SPIFFS.open( PMU_CONFIG_FILE, FILE_WRITE );
|
||||
if ( SPIFFS.exists( PMU_CONFIG_FILE ) ) {
|
||||
SPIFFS.remove( PMU_CONFIG_FILE );
|
||||
log_i("remove old binary pmu config");
|
||||
}
|
||||
|
||||
if ( !file ) {
|
||||
log_e("Can't save file: %s", PMU_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)&pmu_config, sizeof( pmu_config ) );
|
||||
fs::File file = SPIFFS.open( PMU_JSON_CONFIG_FILE, FILE_WRITE );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", PMU_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
SpiRamJsonDocument doc( 1000 );
|
||||
|
||||
doc["silence_wakeup"] = pmu_config.silence_wakeup;
|
||||
doc["experimental_power_save"] = pmu_config.experimental_power_save;
|
||||
doc["compute_percent"] = pmu_config.compute_percent;
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void pmu_read_config( void ) {
|
||||
fs::File file = SPIFFS.open( PMU_CONFIG_FILE, FILE_READ );
|
||||
if ( SPIFFS.exists( PMU_JSON_CONFIG_FILE ) ) {
|
||||
fs::File file = SPIFFS.open( PMU_JSON_CONFIG_FILE, FILE_READ );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", PMU_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
SpiRamJsonDocument doc( filesize * 2 );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", PMU_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( pmu_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
DeserializationError error = deserializeJson( doc, file );
|
||||
if ( error ) {
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
pmu_config.silence_wakeup = doc["silence_wakeup"].as<bool>();
|
||||
pmu_config.experimental_power_save = doc["experimental_power_save"].as<bool>();
|
||||
pmu_config.compute_percent = doc["compute_percent"].as<bool>();
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&pmu_config, filesize );
|
||||
log_i("no json config exists, read from binary");
|
||||
fs::File file = SPIFFS.open( PMU_CONFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", PMU_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( pmu_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&pmu_config, filesize );
|
||||
file.close();
|
||||
pmu_save_config();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
bool pmu_get_silence_wakeup( void ) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#define PMU_BATTERY_CAP 300
|
||||
|
||||
#define PMU_CONFIG_FILE "/pmu.cfg"
|
||||
#define PMU_JSON_CONFIG_FILE "/pmu.json"
|
||||
|
||||
typedef struct {
|
||||
bool compute_percent = false;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "config.h"
|
||||
#include "timesync.h"
|
||||
#include "powermgm.h"
|
||||
#include "json_config_psram_allocator.h"
|
||||
|
||||
EventGroupHandle_t time_event_handle = NULL;
|
||||
TaskHandle_t _timesync_Task;
|
||||
@@ -57,33 +58,75 @@ void timesync_setup( TTGOClass *ttgo ) {
|
||||
}
|
||||
|
||||
void timesync_save_config( void ) {
|
||||
fs::File file = SPIFFS.open( TIMESYNC_CONFIG_FILE, FILE_WRITE );
|
||||
if ( SPIFFS.exists( TIMESYNC_CONFIG_FILE ) ) {
|
||||
SPIFFS.remove( TIMESYNC_CONFIG_FILE );
|
||||
log_i("remove old binary timesync config");
|
||||
}
|
||||
|
||||
if ( !file ) {
|
||||
log_e("Can't save file: %s", TIMESYNC_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)×ync_config, sizeof( timesync_config ) );
|
||||
fs::File file = SPIFFS.open( TIMESYNC_JSON_CONFIG_FILE, FILE_WRITE );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", TIMESYNC_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
SpiRamJsonDocument doc( 1000 );
|
||||
|
||||
doc["daylightsave"] = timesync_config.daylightsave;
|
||||
doc["timesync"] = timesync_config.timesync;
|
||||
doc["timezone"] = timesync_config.timezone;
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void timesync_read_config( void ) {
|
||||
fs::File file = SPIFFS.open( TIMESYNC_CONFIG_FILE, FILE_READ );
|
||||
if ( SPIFFS.exists( TIMESYNC_JSON_CONFIG_FILE ) ) {
|
||||
fs::File file = SPIFFS.open( TIMESYNC_JSON_CONFIG_FILE, FILE_READ );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", TIMESYNC_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
SpiRamJsonDocument doc( filesize * 2 );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", TIMESYNC_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( timesync_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
DeserializationError error = deserializeJson( doc, file );
|
||||
if ( error ) {
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
timesync_config.daylightsave = doc["daylightsave"].as<bool>();
|
||||
timesync_config.timesync = doc["timesync"].as<bool>();
|
||||
timesync_config.timezone = doc["timezone"].as<uint32_t>();
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)×ync_config, filesize );
|
||||
log_i("no json config exists, read from binary");
|
||||
fs::File file = SPIFFS.open( TIMESYNC_CONFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", TIMESYNC_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( timesync_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)×ync_config, filesize );
|
||||
file.close();
|
||||
timesync_save_config();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
bool timesync_get_timesync( void ) {
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
|
||||
#include <TTGO.h>
|
||||
|
||||
#define TIME_SYNC_REQUEST _BV(0)
|
||||
#define TIME_SYNC_REQUEST _BV(0)
|
||||
|
||||
#define TIMESYNC_CONFIG_FILE "/timesync.cfg"
|
||||
#define TIMESYNC_CONFIG_FILE "/timesync.cfg"
|
||||
#define TIMESYNC_JSON_CONFIG_FILE "/timesync.json"
|
||||
|
||||
typedef struct {
|
||||
bool timesync = true;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "powermgm.h"
|
||||
#include "wifictl.h"
|
||||
#include "json_config_psram_allocator.h"
|
||||
|
||||
#include "gui/statusbar.h"
|
||||
#include "webserver/webserver.h"
|
||||
@@ -67,8 +68,7 @@ void wifictl_setup( void ) {
|
||||
wifictl_networklist[ entry ].password[ 0 ] = '\0';
|
||||
}
|
||||
|
||||
// load network list from spiff
|
||||
wifictl_load_network();
|
||||
// load config from spiff
|
||||
wifictl_load_config();
|
||||
|
||||
// register WiFi events
|
||||
@@ -185,36 +185,91 @@ void wifictl_setup( void ) {
|
||||
*
|
||||
*/
|
||||
void wifictl_save_config( void ) {
|
||||
fs::File file = SPIFFS.open( WIFICTL_CONFIG_FILE, FILE_WRITE );
|
||||
if ( SPIFFS.exists( WIFICTL_CONFIG_FILE ) ) {
|
||||
SPIFFS.remove( WIFICTL_CONFIG_FILE );
|
||||
log_i("remove old binary wificfg config");
|
||||
}
|
||||
if ( SPIFFS.exists( WIFICTL_LIST_FILE ) ) {
|
||||
SPIFFS.remove( WIFICTL_LIST_FILE );
|
||||
log_i("remove old binary wifilist config");
|
||||
}
|
||||
|
||||
if ( !file ) {
|
||||
log_e("Can't save file: %s", WIFICTL_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)&wifictl_config, sizeof( wifictl_config ) );
|
||||
fs::File file = SPIFFS.open( WIFICTL_JSON_CONFIG_FILE, FILE_WRITE );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", WIFICTL_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
SpiRamJsonDocument doc( 10000 );
|
||||
|
||||
doc["autoon"] = wifictl_config.autoon;
|
||||
doc["webserver"] = wifictl_config.webserver;
|
||||
for ( int i = 0 ; i < NETWORKLIST_ENTRYS ; i++ ) {
|
||||
doc["networklist"][ i ]["ssid"] = wifictl_networklist[ i ].ssid;
|
||||
doc["networklist"][ i ]["psk"] = wifictl_networklist[ i ].password;
|
||||
}
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void wifictl_load_config( void ) {
|
||||
fs::File file = SPIFFS.open( WIFICTL_CONFIG_FILE, FILE_READ );
|
||||
if ( SPIFFS.exists( WIFICTL_JSON_CONFIG_FILE ) ) {
|
||||
fs::File file = SPIFFS.open( WIFICTL_JSON_CONFIG_FILE, FILE_READ );
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", WIFICTL_JSON_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
SpiRamJsonDocument doc( filesize * 2 );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s", WIFICTL_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( wifictl_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
DeserializationError error = deserializeJson( doc, file );
|
||||
if ( error ) {
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
wifictl_config.autoon = doc["autoon"].as<bool>();
|
||||
wifictl_config.webserver = doc["webserver"].as<bool>();
|
||||
for ( int i = 0 ; i < NETWORKLIST_ENTRYS ; i++ ) {
|
||||
strlcpy( wifictl_networklist[ i ].ssid , doc["networklist"][ i ]["ssid"], sizeof( wifictl_networklist[ i ].ssid ) );
|
||||
strlcpy( wifictl_networklist[ i ].password, doc["networklist"][ i ]["psk"], sizeof( wifictl_networklist[ i ].password ) );
|
||||
}
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&wifictl_config, filesize );
|
||||
log_i("no json config exists, read from binary");
|
||||
|
||||
wifictl_load_network();
|
||||
|
||||
fs::File file = SPIFFS.open( WIFICTL_CONFIG_FILE, FILE_READ );
|
||||
|
||||
if (!file) {
|
||||
log_e("Can't open file: %s!", WIFICTL_CONFIG_FILE );
|
||||
}
|
||||
else {
|
||||
int filesize = file.size();
|
||||
if ( filesize > sizeof( wifictl_config ) ) {
|
||||
log_e("Failed to read configfile. Wrong filesize!" );
|
||||
}
|
||||
else {
|
||||
file.read( (uint8_t *)&wifictl_config, filesize );
|
||||
file.close();
|
||||
wifictl_save_config();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
bool wifictl_get_autoon( void ) {
|
||||
@@ -234,20 +289,6 @@ void wifictl_set_webserver( bool webserver ) {
|
||||
wifictl_config.webserver = webserver;
|
||||
wifictl_save_config();
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void wifictl_save_network( void ) {
|
||||
fs::File file = SPIFFS.open( WIFICTL_LIST_FILE, FILE_WRITE );
|
||||
|
||||
if ( !file ) {
|
||||
log_e("Can't save file: %s", WIFICTL_LIST_FILE );
|
||||
}
|
||||
else {
|
||||
file.write( (uint8_t *)wifictl_networklist, sizeof( wifictl_networklist ) );
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
@@ -296,7 +337,7 @@ bool wifictl_delete_network( const char *ssid ) {
|
||||
if( !strcmp( ssid, wifictl_networklist[ entry ].ssid ) ) {
|
||||
wifictl_networklist[ entry ].ssid[ 0 ] = '\0';
|
||||
wifictl_networklist[ entry ].password[ 0 ] = '\0';
|
||||
wifictl_save_network();
|
||||
wifictl_save_config();
|
||||
return( true );
|
||||
}
|
||||
}
|
||||
@@ -314,7 +355,7 @@ bool wifictl_insert_network( const char *ssid, const char *password ) {
|
||||
for( int entry = 0 ; entry < NETWORKLIST_ENTRYS; entry++ ) {
|
||||
if( !strcmp( ssid, wifictl_networklist[ entry ].ssid ) ) {
|
||||
strncpy( wifictl_networklist[ entry ].password, password, sizeof( wifictl_networklist[ entry ].password ) );
|
||||
wifictl_save_network();
|
||||
wifictl_save_config();
|
||||
WiFi.scanNetworks();
|
||||
powermgm_set_event( POWERMGM_WIFI_SCAN );
|
||||
return( true );
|
||||
@@ -325,7 +366,7 @@ bool wifictl_insert_network( const char *ssid, const char *password ) {
|
||||
if( strlen( wifictl_networklist[ entry ].ssid ) == 0 ) {
|
||||
strncpy( wifictl_networklist[ entry ].ssid, ssid, sizeof( wifictl_networklist[ entry ].ssid ) );
|
||||
strncpy( wifictl_networklist[ entry ].password, password, sizeof( wifictl_networklist[ entry ].password ) );
|
||||
wifictl_save_network();
|
||||
wifictl_save_config();
|
||||
WiFi.scanNetworks();
|
||||
powermgm_set_event( POWERMGM_WIFI_SCAN );
|
||||
return( true );
|
||||
|
||||
@@ -22,16 +22,17 @@
|
||||
#ifndef _WIFICTL_H
|
||||
#define _WIFICTL_H
|
||||
|
||||
#define WIFICTL_DELAY 10
|
||||
#define NETWORKLIST_ENTRYS 20
|
||||
#define WIFICTL_LIST_FILE "/wifilist.cfg"
|
||||
#define WIFICTL_CONFIG_FILE "/wificfg.cfg"
|
||||
#define WIFICTL_DELAY 10
|
||||
#define NETWORKLIST_ENTRYS 20
|
||||
#define WIFICTL_LIST_FILE "/wifilist.cfg"
|
||||
#define WIFICTL_CONFIG_FILE "/wificfg.cfg"
|
||||
#define WIFICTL_JSON_CONFIG_FILE "/wificfg.json"
|
||||
|
||||
#define ESP_WPS_MODE WPS_TYPE_PBC
|
||||
#define ESP_MANUFACTURER "ESPRESSIF"
|
||||
#define ESP_MODEL_NUMBER "ESP32"
|
||||
#define ESP_MODEL_NAME "LILYGO T-WATCH2020 V1"
|
||||
#define ESP_DEVICE_NAME "ESP STATION"
|
||||
#define ESP_WPS_MODE WPS_TYPE_PBC
|
||||
#define ESP_MANUFACTURER "ESPRESSIF"
|
||||
#define ESP_MODEL_NUMBER "ESP32"
|
||||
#define ESP_MODEL_NAME "LILYGO T-WATCH2020 V1"
|
||||
#define ESP_DEVICE_NAME "ESP STATION"
|
||||
|
||||
struct networklist {
|
||||
char ssid[64]="";
|
||||
|
||||
@@ -40,13 +40,15 @@ TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
void setup()
|
||||
{
|
||||
motor_setup();
|
||||
Serial.begin(115200);
|
||||
Serial.printf("starting t-watch V1, version: " __FIRMWARE__ "\r\n");
|
||||
ttgo->begin();
|
||||
ttgo->lvgl_begin();
|
||||
|
||||
SPIFFS.begin();
|
||||
|
||||
motor_setup();
|
||||
|
||||
display_setup( ttgo );
|
||||
|
||||
screenshot_setup();
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
{"version":"2020081102","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
|
||||
{"version":"2020081103","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
|
||||
|
||||
Reference in New Issue
Block a user