mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 04:36:38 +00:00
Updates for stmf407vg
This commit is contained in:
parent
f7fc8b21dc
commit
d1118f310e
@ -1,20 +1,24 @@
|
|||||||
#include "ArduinoJson.h"
|
#include "ArduinoJson.h"
|
||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "time.h"
|
//#include "time.h"
|
||||||
|
|
||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include <sntp.h> // sntp_servermode_dhcp()
|
#include <sntp.h> // sntp_servermode_dhcp()
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#else
|
|
||||||
#include <Wifi.h>
|
|
||||||
#endif
|
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
|
#elif defined(ARDUINO_ARCH_ESP32)
|
||||||
|
#include <Wifi.h>
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "hasp_hal.h"
|
#include "hasp_hal.h"
|
||||||
|
#if HASP_USE_MQTT>0
|
||||||
#include "hasp_mqtt.h"
|
#include "hasp_mqtt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
#include "hasp_config.h"
|
#include "hasp_config.h"
|
||||||
#include "hasp_dispatch.h"
|
#include "hasp_dispatch.h"
|
||||||
@ -70,6 +74,7 @@ Syslog * syslog;
|
|||||||
// Serial Settings
|
// Serial Settings
|
||||||
uint16_t debugSerialBaud = SERIAL_SPEED / 10; // Multiplied by 10
|
uint16_t debugSerialBaud = SERIAL_SPEED / 10; // Multiplied by 10
|
||||||
bool debugSerialStarted = false;
|
bool debugSerialStarted = false;
|
||||||
|
bool debugAnsiCodes = true;
|
||||||
|
|
||||||
//#define TERM_COLOR_Black "\u001b[30m"
|
//#define TERM_COLOR_Black "\u001b[30m"
|
||||||
#define TERM_COLOR_GRAY "\e[37m"
|
#define TERM_COLOR_GRAY "\e[37m"
|
||||||
@ -212,20 +217,20 @@ static void debugPrintTimestamp(int level, Print * _logOutput)
|
|||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm * timeinfo;
|
struct tm * timeinfo;
|
||||||
|
|
||||||
time(&rawtime);
|
//time(&rawtime);
|
||||||
timeinfo = localtime(&rawtime);
|
//timeinfo = localtime(&rawtime);
|
||||||
|
|
||||||
// strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S.", timeinfo);
|
// strftime(buffer, sizeof(buffer), "%b %d %H:%M:%S.", timeinfo);
|
||||||
// Serial.println(buffer);
|
// Serial.println(buffer);
|
||||||
|
|
||||||
debugSendAnsiCode(F(TERM_COLOR_CYAN), _logOutput);
|
debugSendAnsiCode(F(TERM_COLOR_CYAN), _logOutput);
|
||||||
|
|
||||||
if(timeinfo->tm_year >= 120) {
|
/* if(timeinfo->tm_year >= 120) {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
strftime(buffer, sizeof(buffer), "[%b %d %H:%M:%S.", timeinfo); // Literal String
|
strftime(buffer, sizeof(buffer), "[%b %d %H:%M:%S.", timeinfo); // Literal String
|
||||||
_logOutput->print(buffer);
|
_logOutput->print(buffer);
|
||||||
_logOutput->printf(PSTR("%03lu]"), millis() % 1000);
|
_logOutput->printf(PSTR("%03lu]"), millis() % 1000);
|
||||||
} else {
|
} else */ {
|
||||||
_logOutput->printf(PSTR("[%20.3f]"), (float)millis() / 1000);
|
_logOutput->printf(PSTR("[%20.3f]"), (float)millis() / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +238,7 @@ static void debugPrintTimestamp(int level, Print * _logOutput)
|
|||||||
static void debugPrintHaspMemory(int level, Print * _logOutput)
|
static void debugPrintHaspMemory(int level, Print * _logOutput)
|
||||||
{
|
{
|
||||||
size_t maxfree = halGetMaxFreeBlock();
|
size_t maxfree = halGetMaxFreeBlock();
|
||||||
uint32_t totalfree = ESP.getFreeHeap();
|
uint32_t totalfree = halGetFreeHeap();
|
||||||
uint8_t frag = halGetHeapFragmentation();
|
uint8_t frag = halGetHeapFragmentation();
|
||||||
|
|
||||||
/* Print HASP Memory Info */
|
/* Print HASP Memory Info */
|
||||||
@ -325,12 +330,17 @@ void debugPreSetup(JsonObject settings)
|
|||||||
uint32_t baudrate = settings[FPSTR(F_CONFIG_BAUD)].as<uint32_t>() * 10;
|
uint32_t baudrate = settings[FPSTR(F_CONFIG_BAUD)].as<uint32_t>() * 10;
|
||||||
if(baudrate == 0) baudrate = SERIAL_SPEED;
|
if(baudrate == 0) baudrate = SERIAL_SPEED;
|
||||||
if(baudrate >= 9600u) { /* the baudrates are stored divided by 10 */
|
if(baudrate >= 9600u) { /* the baudrates are stored divided by 10 */
|
||||||
|
|
||||||
|
#ifdef STM32_CORE_VERSION_MAJOR
|
||||||
|
Serial.setRx(PA3); // User Serial2
|
||||||
|
Serial.setTx(PA2);
|
||||||
|
#endif
|
||||||
Serial.begin(baudrate); /* prepare for possible serial debug */
|
Serial.begin(baudrate); /* prepare for possible serial debug */
|
||||||
delay(10);
|
delay(10);
|
||||||
|
Log.registerOutput(0, &Serial, LOG_LEVEL_VERBOSE, true);
|
||||||
debugSerialStarted = true;
|
debugSerialStarted = true;
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Log.registerOutput(0, &Serial, LOG_LEVEL_VERBOSE, true);
|
Log.trace(("Serial started at %u baud"), baudrate);
|
||||||
Log.trace(F("Serial started at %u baud"), baudrate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
50
src/main.cpp
50
src/main.cpp
@ -10,45 +10,6 @@
|
|||||||
#include "hasp_oobe.h"
|
#include "hasp_oobe.h"
|
||||||
#include "hasp_gpio.h"
|
#include "hasp_gpio.h"
|
||||||
|
|
||||||
#if HASP_USE_SPIFFS
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
|
||||||
#include "SPIFFS.h"
|
|
||||||
#endif
|
|
||||||
#include <FS.h> // Include the SPIFFS library
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_EEPROM
|
|
||||||
#include "hasp_eeprom.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_WIFI
|
|
||||||
#include "hasp_wifi.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_MQTT
|
|
||||||
#include "hasp_mqtt.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_HTTP
|
|
||||||
#include "hasp_http.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_TELNET
|
|
||||||
#include "hasp_telnet.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_MDNS
|
|
||||||
#include "hasp_mdns.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_BUTTON
|
|
||||||
#include "hasp_button.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HASP_USE_OTA
|
|
||||||
#include "hasp_ota.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool isConnected;
|
bool isConnected;
|
||||||
uint8_t mainLoopCounter = 0;
|
uint8_t mainLoopCounter = 0;
|
||||||
unsigned long mainLastLoopTime = 0;
|
unsigned long mainLastLoopTime = 0;
|
||||||
@ -181,16 +142,25 @@ void loop()
|
|||||||
|
|
||||||
/* Run Every 5 Seconds */
|
/* Run Every 5 Seconds */
|
||||||
if(mainLoopCounter == 0 || mainLoopCounter == 4) {
|
if(mainLoopCounter == 0 || mainLoopCounter == 4) {
|
||||||
|
#if HASP_USE_HTTP
|
||||||
httpEvery5Seconds();
|
httpEvery5Seconds();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HASP_USE_WIFI
|
||||||
isConnected = wifiEvery5Seconds();
|
isConnected = wifiEvery5Seconds();
|
||||||
|
|
||||||
|
#if HASP_USE_MQTT
|
||||||
mqttEvery5Seconds(isConnected);
|
mqttEvery5Seconds(isConnected);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update counters */
|
/* Update counters */
|
||||||
mainLastLoopTime += 1000;
|
mainLastLoopTime += 1000;
|
||||||
mainLoopCounter++;
|
mainLoopCounter++;
|
||||||
if(mainLoopCounter >= 10) {
|
if(mainLoopCounter >= 10) {
|
||||||
mainLoopCounter = 0;
|
mainLoopCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user