Post latest updates

This commit is contained in:
fvanroie 2021-02-17 22:12:56 +01:00
parent 4a993392fd
commit 046ecb0b7a
7 changed files with 469 additions and 312 deletions

View File

@ -40,7 +40,7 @@ BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true BreakStringLiterals: true
ColumnLimit: 120 ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:' CommentPragmas: "^ IWYU pragma:"
ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4 ContinuationIndentWidth: 4
@ -54,9 +54,9 @@ IncludeCategories:
Priority: 2 Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)' - Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3 Priority: 3
- Regex: '.*' - Regex: ".*"
Priority: 1 Priority: 1
IncludeIsMainRegex: '$' IncludeIsMainRegex: "$"
IndentCaseLabels: true IndentCaseLabels: true
IndentWidth: 4 IndentWidth: 4
IndentWrappedFunctionNames: false IndentWrappedFunctionNames: false
@ -64,8 +64,8 @@ IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave JavaScriptQuotes: Leave
JavaScriptWrapImports: true JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: '' MacroBlockBegin: ""
MacroBlockEnd: '' MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
NamespaceIndentation: None NamespaceIndentation: None
ObjCBlockIndentWidth: 2 ObjCBlockIndentWidth: 2
@ -77,7 +77,7 @@ PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000 PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60 PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Middle PointerAlignment: Left
ReflowComments: true ReflowComments: true
SortIncludes: false SortIncludes: false
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
@ -94,4 +94,3 @@ SpacesInSquareBrackets: false
Standard: Cpp11 Standard: Cpp11
TabWidth: 4 TabWidth: 4
UseTab: Never UseTab: Never
...

View File

@ -196,19 +196,19 @@ static WiFiSpiClass WiFi;
#endif #endif
#if HASP_USE_HTTP > 0 #if HASP_USE_HTTP > 0
#include "svc/hasp_http.h" #include "sys/svc/hasp_http.h"
#endif #endif
#if HASP_USE_TELNET > 0 #if HASP_USE_TELNET > 0
#include "svc/hasp_telnet.h" #include "sys/svc/hasp_telnet.h"
#endif #endif
#if HASP_USE_MDNS > 0 #if HASP_USE_MDNS > 0
#include "svc/hasp_mdns.h" #include "sys/svc/hasp_mdns.h"
#endif #endif
#if HASP_USE_OTA > 0 #if HASP_USE_OTA > 0
#include "svc/hasp_ota.h" #include "sys/svc/hasp_ota.h"
#ifndef HASP_OTA_PORT #ifndef HASP_OTA_PORT
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#define HASP_OTA_PORT 3232 #define HASP_OTA_PORT 3232
@ -218,8 +218,8 @@ static WiFiSpiClass WiFi;
#endif #endif
#endif #endif
#if HASP_USE_TASMOTA_SLAVE > 0 #if HASP_USE_TASMOTA_CLIENT > 0
#include "svc/hasp_slave.h" #include "sys/svc/hasp_slave.h"
#endif #endif
#ifdef WINDOWS #ifdef WINDOWS
@ -275,7 +275,7 @@ static WiFiSpiClass WiFi;
#define guiSetDim(x) #define guiSetDim(x)
#define guiGetBacklight() 1 #define guiGetBacklight() 1
#define guiSetBacklight(x) #define guiSetBacklight(x)
#define guiCalibrate() //#define guiCalibrate()
#endif #endif
#endif // HASP_CONF_H #endif // HASP_CONF_H

View File

@ -895,7 +895,6 @@ void dispatch_output_statusupdate(const char *, const char *)
char data[3 * 128]; char data[3 * 128];
{ {
/*
char buffer[128]; char buffer[128];
haspGetVersion(buffer, sizeof(buffer)); haspGetVersion(buffer, sizeof(buffer));
@ -908,7 +907,7 @@ void dispatch_output_statusupdate(const char *, const char *)
strcat(data, buffer); strcat(data, buffer);
#endif #endif
snprintf_P(buffer, sizeof(buffer), PSTR("\"heapFree\":%u,\"heapFrag\":%u,\"espCore\":\"%s\","), snprintf_P(buffer, sizeof(buffer), PSTR("\"heapFree\":%u,\"heapFrag\":%u,\"espCore\":\"%s\","),
halGetFreeHeap(), halGetHeapFragmentation(), halGetCoreVersion().c_str()); haspDevice.get_free_heap(), haspDevice.get_heap_fragmentation(), halGetCoreVersion().c_str());
strcat(data, buffer); strcat(data, buffer);
snprintf_P(buffer, sizeof(buffer), PSTR("\"espCanUpdate\":\"false\",\"page\":%u,\"numPages\":%u,"), snprintf_P(buffer, sizeof(buffer), PSTR("\"espCanUpdate\":\"false\",\"page\":%u,\"numPages\":%u,"),
haspGetPage(), (HASP_NUM_PAGES)); haspGetPage(), (HASP_NUM_PAGES));
@ -922,7 +921,6 @@ void dispatch_output_statusupdate(const char *, const char *)
snprintf_P(buffer, sizeof(buffer), PSTR("\"tftDriver\":\"%s\",\"tftWidth\":%u,\"tftHeight\":%u}"), snprintf_P(buffer, sizeof(buffer), PSTR("\"tftDriver\":\"%s\",\"tftWidth\":%u,\"tftHeight\":%u}"),
halDisplayDriverName().c_str(), (TFT_WIDTH), (TFT_HEIGHT)); halDisplayDriverName().c_str(), (TFT_WIDTH), (TFT_HEIGHT));
strcat(data, buffer); strcat(data, buffer);
*/
} }
mqtt_send_state(F("statusupdate"), data); mqtt_send_state(F("statusupdate"), data);
dispatchLastMillis = millis(); dispatchLastMillis = millis();

194
src/main_arduino copy.cpp Normal file
View File

@ -0,0 +1,194 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#if 0 && ARDUINO
#include <Arduino.h>
#include "lvgl.h"
#include "hasp_conf.h" // load first
#if HASP_USE_CONFIG > 0
#include "hasp_debug.h"
#endif
#if HASP_USE_CONFIG > 0
#include "hasp_config.h"
#include "hasp_gui.h"
#endif
#include "hasp_oobe.h"
#include "hasp/hasp_dispatch.h"
#include "hasp/hasp.h"
#include "sys/net/hasp_network.h"
#include "dev/device.h"
bool isConnected;
uint8_t mainLoopCounter = 0;
unsigned long mainLastLoopTime = 0;
void setup()
{
hal_setup();
haspDevice.init();
/****************************
* Storage initializations
***************************/
#if HASP_USE_EEPROM > 0
eepromSetup(); // Don't start at boot, only at write
#endif
// #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
// filesystemSetup(); // FS mount is done in configSetup()
// #endif
// #if HASP_USE_SDCARD > 0
// sdcardSetup();
// #endif
/****************************
* Read & Apply User Configuration
***************************/
#if HASP_USE_CONFIG > 0
configSetup(); // also runs debugPreSetup(), debugSetup() and debugStart()
#endif
dispatchSetup();
guiSetup();
debugSetup(); // Init the console
#if HASP_USE_GPIO > 0
gpioSetup();
#endif
/****************************
* Apply User Configuration
***************************/
#if HASP_USE_MQTT > 0
mqttSetup(); // Load Hostname before starting WiFi
#endif
#if HASP_USE_WIFI > 0 || HASP_USE_ETHERNET > 0
networkSetup();
#endif
#if HASP_USE_CONFIG > 0
if(!oobeSetup())
#endif
{
haspSetup();
}
#if HASP_USE_MDNS > 0
mdnsSetup();
#endif
#if HASP_USE_OTA > 0
otaSetup();
#endif
#if HASP_USE_HTTP > 0
httpSetup();
#endif
#if HASP_USE_TELNET > 0
telnetSetup();
#endif
#if HASP_USE_TASMOTA_CLIENT > 0
slaveSetup();
#endif
mainLastLoopTime = millis() - 1000; // reset loop counter
delay(250);
guiStart();
}
void loop()
{
networkLoop();
guiLoop();
haspLoop();
#if HASP_USE_MQTT > 0
mqttLoop();
#endif // MQTT
#if HASP_USE_TASMOTA_CLIENT > 0
slaveLoop();
#endif // TASMOTASLAVE
#if HASP_USE_HTTP > 0
httpLoop();
#endif // HTTP
#if HASP_USE_GPIO > 0
gpioLoop();
#endif // GPIO
#if HASP_USE_OTA > 0
otaLoop();
#endif // OTA
#if HASP_USE_MDNS > 0
mdnsLoop();
#endif // MDNS
#if HASP_USE_TELNET > 0
telnetLoop(); // Console
#endif // TELNET
debugLoop(); // Console
haspDevice.loop();
/* Timer Loop */
if(millis() - mainLastLoopTime >= 1000) {
/* Runs Every Second */
haspEverySecond(); // sleep timer
debugEverySecond(); // statusupdate
#if HASP_USE_OTA > 0
otaEverySecond(); // progressbar
#endif
/* Runs Every 5 Seconds */
if(mainLoopCounter == 0 || mainLoopCounter == 5) {
isConnected = networkEvery5Seconds(); // Check connection
#if HASP_USE_HTTP > 0
// httpEvery5Seconds();
#endif
#if HASP_USE_MQTT > 0
mqttEvery5Seconds(isConnected);
#endif
#if HASP_USE_GPIO > 0
// gpioEvery5Seconds();
#endif
haspDevice.loop_5s();
}
/* Reset loop counter every 10 seconds */
if(mainLoopCounter >= 9) {
mainLoopCounter = 0;
} else {
mainLoopCounter++;
}
mainLastLoopTime += 1000;
}
#ifdef ARDUINO_ARCH_ESP8266
delay(2);
#else
delay(6);
#endif
}
#endif

View File

@ -33,7 +33,7 @@ void setup()
{ {
// hal_setup(); // hal_setup();
haspDevice.pre_setup(); haspDevice.init();
/**************************** /****************************
* Storage initializations * Storage initializations
@ -100,7 +100,7 @@ void setup()
telnetSetup(); telnetSetup();
#endif #endif
#if HASP_USE_TASMOTA_SLAVE > 0 #if HASP_USE_TASMOTA_CLINET > 0
slaveSetup(); slaveSetup();
#endif #endif
@ -111,51 +111,24 @@ void setup()
void loop() void loop()
{ {
networkLoop();
guiLoop(); guiLoop();
haspLoop(); haspLoop();
networkLoop();
#if HASP_USE_MQTT > 0 #if HASP_USE_MQTT > 0
mqttLoop(); mqttLoop();
#endif // MQTT #endif // MQTT
#if HASP_USE_TASMOTA_SLAVE > 0
slaveLoop();
#endif // TASMOTASLAVE
#if HASP_USE_HTTP > 0
httpLoop();
#endif // HTTP
#if HASP_USE_GPIO > 0
gpioLoop();
#endif // GPIO
#if HASP_USE_OTA > 0
otaLoop();
#endif // OTA
#if HASP_USE_MDNS > 0
mdnsLoop();
#endif // MDNS
#if HASP_USE_TELNET > 0
telnetLoop(); // Console
#endif // TELNET
debugLoop(); // Console debugLoop(); // Console
haspDevice.loop(); haspDevice.loop();
/* Timer Loop */ /* Timer Loop */
if(millis() - mainLastLoopTime >= 1000) { if(millis() - mainLastLoopTime >= 1000) {
/* Runs Every Second */ /* Runs Every Second */
haspEverySecond(); // sleep timer haspEverySecond(); // sleep timer
debugEverySecond(); // statusupdate debugEverySecond(); // statusupdate
#if HASP_USE_OTA > 0
otaEverySecond(); // progressbar
#endif
/* Runs Every 5 Seconds */ /* Runs Every 5 Seconds */
if(mainLoopCounter == 0 || mainLoopCounter == 5) { if(mainLoopCounter == 0 || mainLoopCounter == 5) {
isConnected = networkEvery5Seconds(); // Check connection isConnected = networkEvery5Seconds(); // Check connection

View File

@ -3,19 +3,22 @@
#ifdef WINDOWS #ifdef WINDOWS
#include "hasp_conf.h"
#include "lvgl.h" #include "lvgl.h"
#include "app_hal.h" #include "app_hal.h"
#include "hasp_conf.h"
#include "hasp_debug.h" #include "hasp_debug.h"
#include "hasp_gui.h"
#include "hasp/hasp_dispatch.h" #include "hasp/hasp_dispatch.h"
#include "hasp/hasp.h" #include "hasp/hasp.h"
#include "dev/device.h" #include "dev/device.h"
#include "app_hal.h"
bool isConnected; bool isConnected;
bool isRunning = 1;
uint8_t mainLoopCounter = 0; uint8_t mainLoopCounter = 0;
unsigned long mainLastLoopTime = 0; unsigned long mainLastLoopTime = 0;
@ -27,19 +30,19 @@ void debugLvglLogEvent(lv_log_level_t level, const char * file, uint32_t line, c
void setup() void setup()
{ {
printf("%s %d\n", __FILE__, __LINE__); // Load Settings
fflush(stdout);
// Init debug log
// debug_init();
// Initialize lvgl environment
lv_init(); lv_init();
lv_log_register_print_cb(debugLvglLogEvent); lv_log_register_print_cb(debugLvglLogEvent);
printf("%s %d\n", __FILE__, __LINE__); haspDevice.init();
fflush(stdout);
hal_setup(); hal_setup();
guiSetup();
printf("%s %d\n", __FILE__, __LINE__);
haspDevice.pre_setup();
printf("%s %d\n", __FILE__, __LINE__);
dispatchSetup(); dispatchSetup();
// debugSetup(); // Init the console // debugSetup(); // Init the console
@ -62,6 +65,7 @@ void loop()
// debugLoop(); // Console // debugLoop(); // Console
haspDevice.loop(); haspDevice.loop();
guiLoop();
/* Timer Loop */ /* Timer Loop */
if(millis() - mainLastLoopTime >= 1000) { if(millis() - mainLastLoopTime >= 1000) {
@ -93,29 +97,18 @@ void loop()
#ifdef WINDOWS #ifdef WINDOWS
int main(int argv, char ** args) int main(int argv, char ** args)
{ {
printf("%s %d\n", __FILE__, __LINE__); // printf("%s %d\n", __FILE__, __LINE__);
fflush(stdout); // fflush(stdout);
setup(); setup();
std::cout << "HSetup OK\n";
while(isRunning) {
while(1) { loop();
SDL_Delay(5); // std::cout << "HSetup OK\n";
lv_task_handler();
fflush(stdout);
} }
std::cout << "Hloop OK\n";
return 0; return 0;
} }
#else
void loop()
{
delay(5);
lv_task_handler();
}
#endif #endif
#endif #endif