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

View File

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

View File

@ -895,7 +895,6 @@ void dispatch_output_statusupdate(const char *, const char *)
char data[3 * 128];
{
/*
char buffer[128];
haspGetVersion(buffer, sizeof(buffer));
@ -908,7 +907,7 @@ void dispatch_output_statusupdate(const char *, const char *)
strcat(data, buffer);
#endif
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);
snprintf_P(buffer, sizeof(buffer), PSTR("\"espCanUpdate\":\"false\",\"page\":%u,\"numPages\":%u,"),
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}"),
halDisplayDriverName().c_str(), (TFT_WIDTH), (TFT_HEIGHT));
strcat(data, buffer);
*/
}
mqtt_send_state(F("statusupdate"), data);
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();
haspDevice.pre_setup();
haspDevice.init();
/****************************
* Storage initializations
@ -100,7 +100,7 @@ void setup()
telnetSetup();
#endif
#if HASP_USE_TASMOTA_SLAVE > 0
#if HASP_USE_TASMOTA_CLINET > 0
slaveSetup();
#endif
@ -111,51 +111,24 @@ void setup()
void loop()
{
networkLoop();
guiLoop();
haspLoop();
networkLoop();
#if HASP_USE_MQTT > 0
mqttLoop();
#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
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

View File

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