Updates for stmf407vg

This commit is contained in:
fvanroie 2020-04-28 01:07:17 +02:00
parent 4913c71419
commit f7fc8b21dc
8 changed files with 103 additions and 32 deletions

View File

@ -76,17 +76,15 @@ esp8266_flags=
${env.build_flags}
-D HTTP_UPLOAD_BUFLEN=640 ; lower http upload buffer
-D MQTT_MAX_PACKET_SIZE=1024 ; longer PubSubClient messages
-D MY_IRAM_ATTR=IRAM_ATTR
esp32_flags=
${env.build_flags}
-D HTTP_UPLOAD_BUFLEN=1024 ; lower http upload buffer
-D MQTT_MAX_PACKET_SIZE=2048 ; longer PubSubClient messages
-D MY_IRAM_ATTR=IRAM_ATTR
stm32_flags=
${env.build_flags}
-D MY_IRAM_ATTR=
-D IRAM_ATTR= ; No IRAM_ATTR available on STM32
; -- By default there are no ${override.build_flags} set
; -- to use it, copy platformio_override.ini from the template

View File

@ -11,13 +11,17 @@
//#include "../lib/lvgl/src/lv_widgets/lv_roller.h"
#if HASP_USE_SPIFFS
#if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP32)
#include "SPIFFS.h"
#endif
#include <FS.h> // Include the SPIFFS library
#endif
#if HASP_USE_SPIFFS > 0
//#include "lv_zifont.h"
#endif
#include "lv_fs_if.h"
#include "hasp_debug.h"
#include "hasp_config.h"
@ -25,7 +29,7 @@
#include "hasp_wifi.h"
#include "hasp_gui.h"
#include "hasp_tft.h"
#include "lv_zifont.h"
//#include "hasp_attr_get.h"
#include "hasp_attribute.h"
#include "hasp.h"
@ -369,14 +373,16 @@ void haspSetup()
/******* File System Test ********************************************************************/
/* ********** Font Initializations ********** */
defaultFont = LV_FONT_DEFAULT; // Use default font
#if HASP_USE_SPIFFS > 0
lv_zifont_init();
if(lv_zifont_font_init(&haspFonts[0], haspZiFontPath, 24) != 0) {
Log.error(F("HASP: Failed to set the custom font to %s"), haspZiFontPath);
defaultFont = LV_FONT_DEFAULT; // Use default font
} else {
defaultFont = haspFonts[0];
}
#endif
/* ********** Font Initializations ********** */
/* ********** Theme Initializations ********** */
@ -464,11 +470,22 @@ void haspSetup()
// lv_obj_set_size(pages[0], hres, vres);
}
#if HASP_USE_WIFI > 0
if(!wifiShowAP()) {
haspDisconnect();
haspLoadPage(haspPagesPath);
haspSetPage(haspStartPage);
}
#endif
haspLoadPage(haspPagesPath);
haspSetPage(haspStartPage);
// lv_obj_t * obj = lv_btn_create(pages[0], NULL);
// lv_obj_set_size(obj, 100, 100);
// lv_obj_set_user_data(obj, (lv_obj_user_data_t)15);
// /* lv_obj_t * label ; */
// lv_label_create(obj, NULL);
// // haspSetOpacity(obj, LV_OPA_COVER);
// lv_obj_set_event_cb(obj, btn_event_handler);
}
/**********************
@ -585,9 +602,7 @@ void IRAM_ATTR btn_event_handler(lv_obj_t * obj, lv_event_t event)
mqtt_send_state(F("wakeuptouch"), buffer);
#endif
} else {
#if HASP_USE_MQTT > 0
hasp_send_obj_attribute_event(obj, buffer);
#endif
}
}
@ -933,6 +948,7 @@ void haspNewObject(const JsonObject & config, uint8_t & saved_page_id)
void haspLoadPage(const char * pages)
{
#if HASP_USE_SPIFFS > 0
if(pages[0] == '\0') return;
if(!SPIFFS.begin()) {
@ -952,6 +968,7 @@ void haspLoadPage(const char * pages)
file.close();
Log.notice(F("HASP: File %s loaded"), pages);
#endif
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -8,7 +8,7 @@ std::string eepromRead(char addr);
void eepromSetup()
{
EEPROM.begin(1024);
// EEPROM.begin(1024);
// debugPrintln("EEPROM: Started Eeprom");
}
@ -29,7 +29,7 @@ void eepromWrite(uint16_t addr, std::string & data)
eepromUpdate(addr + i, data[i]);
}
eepromUpdate(addr + count, '\0');
EEPROM.commit();
// EEPROM.commit();
}
std::string eepromRead(uint16_t addr)

View File

@ -1,4 +1,7 @@
#if defined(ESP32) || defined(ESP8266)
#include <ESP.h>
#endif
#include "hasp_hal.h"
#if ESP32
@ -8,6 +11,15 @@
#if defined(ARDUINO_ARCH_ESP32)
#include <rom/rtc.h> // needed to get the ResetInfo
void halRestart(void)
{
#if defined(ESP32) || defined(ESP8266)
ESP.restart();
#else
NVIC_SystemReset();
#endif
}
// Compatibility function for ESP8266 getRestInfo
String esp32ResetReason(uint8_t cpuid)
{
@ -88,17 +100,39 @@ String halGetResetInfo()
resetReason += F(" / ");
resetReason += String(esp32ResetReason(1));
return resetReason;
#else
#elif defined(ARDUINO_ARCH_ESP8266)
return ESP.getResetInfo();
#else
return "";
#endif
}
#ifdef __arm__
// should use uinstd.h to define sbrk but Due causes a conflict
extern "C" char* sbrk(int incr);
#else // __ARM__
extern char *__brkval;
#endif // __arm__
int freeMemory() {
char top;
#ifdef __arm__
return &top - reinterpret_cast<char*>(sbrk(0));
#elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151)
return &top - __brkval;
#else // __arm__
return __brkval ? &top - __brkval : &top - __malloc_heap_start;
#endif // __arm__
}
uint8_t halGetHeapFragmentation()
{
#if defined(ARDUINO_ARCH_ESP32)
return (int8_t)(100.00f - (float)ESP.getMaxAllocHeap() * 100.00f / (float)ESP.getFreeHeap());
#else
#elif defined(ARDUINO_ARCH_ESP8266)
return ESP.getHeapFragmentation();
#else
return 255;
#endif
}
@ -106,8 +140,21 @@ size_t halGetMaxFreeBlock()
{
#if defined(ARDUINO_ARCH_ESP32)
return ESP.getMaxAllocHeap();
#else
#elif defined(ARDUINO_ARCH_ESP8266)
return ESP.getMaxFreeBlockSize();
#else
return freeMemory();
#endif
}
size_t halGetFreeHeap(void)
{
#if defined(ARDUINO_ARCH_ESP32)
return ESP.getFreeHeap();
#elif defined(ARDUINO_ARCH_ESP8266)
return ESP.getFreeHeap();
#else
return 1;
#endif
}
@ -115,8 +162,10 @@ String halGetCoreVersion()
{
#if defined(ARDUINO_ARCH_ESP32)
return String(ESP.getSdkVersion());
#else
#elif defined(ARDUINO_ARCH_ESP8266)
return String(ESP.getCoreVersion());
#else
return String(STM32_CORE_VERSION_MAJOR) + "." + STM32_CORE_VERSION_MINOR + "." + STM32_CORE_VERSION_PATCH;
#endif
}
@ -124,9 +173,10 @@ String halGetChipModel()
{
String model((char *)0);
model.reserve(128);
model = F("STM32");
#if ESP8266
model += F("ESP8266");
model = F("ESP8266");
#endif
#if ESP32
@ -139,13 +189,12 @@ String halGetChipModel()
case CHIP_ESP32:
model += F("ESP32");
break;
#ifndef CHIP_ESP32S2
#define CHIP_ESP32S2 2
#endif
#ifdef CHIP_ESP32S2
case CHIP_ESP32S2:
model += F("ESP32-S2");
break;
default:
#endif
default:
model = F("Unknown ESP");
}
model += F(" rev");

View File

@ -6,7 +6,9 @@
uint8_t halGetHeapFragmentation(void);
String halGetResetInfo(void);
size_t halGetMaxFreeBlock(void);
size_t halGetFreeHeap(void);
String halGetCoreVersion(void);
String halGetChipModel();
void halRestart(void);
#endif

View File

@ -11,7 +11,6 @@
#include "hasp_gui.h"
#include "hasp_hal.h"
#include "hasp_debug.h"
#include "hasp_http.h"
#include "hasp_mqtt.h"
#include "hasp_wifi.h"
#include "hasp_spiffs.h"
@ -442,24 +441,23 @@ bool httpSetConfig(const JsonObject & settings)
#include "hasp_gui.h"
#include "hasp_hal.h"
#include "hasp_debug.h"
#include "hasp_http.h"
#include "hasp_wifi.h"
#include "hasp_spiffs.h"
#include "hasp_config.h"
#include "hasp_dispatch.h"
#include "hasp.h"
#include "hasp_conf.h"
#if HASP_USE_MQTT
#include "hasp_mqtt.h"
#endif
#if defined(ARDUINO_ARCH_ESP32)
#include "SPIFFS.h"
#include <FS.h>
#endif
#include <FS.h>
#include <ESP.h>
#elif defined(ARDUINO_ARCH_ESP8266)
#include <FS.h>
#include <ESP.h>
#endif
#if HASP_USE_HTTP>0
bool httpEnable = true;
bool webServerStarted = false;
@ -1946,4 +1944,5 @@ bool httpSetConfig(const JsonObject & settings)
return changed;
}
#endif
#endif

View File

@ -3,20 +3,22 @@
#if defined(ARDUINO_ARCH_ESP32)
#include <ESPmDNS.h>
#else
#elif defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266mDNS.h>
// MDNSResponder::hMDNSService hMDNSService;
#endif
#include "hasp_conf.h"
#include "hasp_mdns.h"
#include "hasp_config.h"
#include "hasp_conf.h"
#if HASP_USE_MQTT
#include "hasp_mqtt.h"
#endif
#if HASP_USE_MDNS
#include "hasp_mdns.h"
#endif
uint8_t mdnsEnabled = true;
@ -28,7 +30,9 @@ void mdnsSetup()
void mdnsStart()
{
#if HASP_USE_MDNS > 0
if(mdnsEnabled) {
#if HASP_USE_MQTT > 0
String hasp2Node = mqttGetNodename();
#else
@ -57,6 +61,7 @@ void mdnsStart()
Log.error(F("MDNS: Responder failed to start %s"), hasp2Node.c_str());
};
}
#endif
}
void mdnsLoop()
@ -70,7 +75,9 @@ void mdnsLoop()
void mdnsStop()
{
#if HASP_USE_MDNS > 0
MDNS.end();
#endif
}
bool mdnsGetConfig(const JsonObject & settings)

View File

@ -41,7 +41,6 @@ void spiffsInfo()
Serial.print("Max path lenght: ");
Serial.println(fs_info.maxPathLength);
#else
Serial.println("File sistem info.");
Serial.print("Total space: ");