Merge branch '0.1.0-fsmc' of https://github.com/arovak/hasp-lvgl into 0.1.0-fsmc

This commit is contained in:
fvanroie 2020-05-29 23:32:31 +02:00
commit 7e3f06b76e
6 changed files with 40 additions and 10 deletions

View File

@ -8,7 +8,7 @@ lolin24 =
-D ILI9341_DRIVER=1
-D TFT_WIDTH=240
-D TFT_HEIGHT=320
-D TFT_ROTATION=2 ; 0=0, 1=90, 2=180 or 3=270 degree
-D TFT_ROTATION=0 ; 0=0, 1=90, 2=180 or 3=270 degree
-D SPI_FREQUENCY=40000000
-D SPI_TOUCH_FREQUENCY=2500000
-D SPI_READ_FREQUENCY=20000000

View File

@ -393,3 +393,27 @@ void configOutput(const JsonObject & settings)
if(password.length() > 2) output.replace(password, passmask);
Log.trace(F("CONF: %s"), output.c_str());
}
bool configClear()
{
#if defined(STM32F4xx)
Log.verbose(F("CONF: Clearing EEPROM"));
char buffer[1024 + 128];
memset(buffer, 1 ,sizeof(buffer));
if(sizeof(buffer) > 0) {
uint16_t i;
for(i = 0; i < sizeof(buffer); i++) eeprom_buffered_write_byte(i, buffer[i]);
eeprom_buffered_write_byte(i, 0);
eeprom_buffer_flush();
Log.verbose(F("CONF: [SUCCESS] Cleared EEPROM"));
return true;
} else {
Log.error(F("CONF: Failed to clear to EEPROM"));
return false;
}
#elif HASP_USE_SPIFFS > 0
return SPIFFS.format();
#else
return false;
#endif
}

View File

@ -43,5 +43,6 @@ void configOutput(const JsonObject & settings);
bool configSet(int8_t & value, const JsonVariant & setting, const char * name);
bool configSet(uint8_t & value, const JsonVariant & setting, const char * name);
bool configSet(uint16_t & value, const JsonVariant & setting, const char * name);
bool configClear();
#endif

View File

@ -119,6 +119,9 @@ void dispatchAttribute(String strTopic, const char * payload)
} else if(strTopic == F("update")) {
dispatchWebUpdate(payload);
} else if(strTopic == F("clearconfig")) {
configClear();
} else if(strTopic == F("setupap")) {
// haspDisplayAP(String(F("HASP-ABC123")).c_str(), String(F("haspadmin")).c_str());

View File

@ -1555,15 +1555,13 @@ void httpHandleResetConfig()
httpMessage += F("</h1><hr>");
if(resetConfirmed) { // User has confirmed, so reset everything
#if HASP_USE_SPIFFS > 0
bool formatted = SPIFFS.format();
bool formatted = configClear();
if(formatted) {
httpMessage += F("<b>Resetting all saved settings and restarting device into WiFi AP mode</b>");
} else {
httpMessage += F("<b>Failed to format the internal flash partition</b>");
resetConfirmed = false;
}
#endif
} else {
httpMessage +=
F("<h2>Warning</h2><b>This process will reset all settings to the default values. The internal flash "

View File

@ -23,7 +23,7 @@ static WiFiEventHandler gotIpEventHandler, disconnectedEventHandler;
// #include <WiFi.h>
// #include "WiFiSpi.h"
// extern WiFiSpiClass WiFi;
SPIClass spi2(ESPSPI_MOSI, ESPSPI_MISO, ESPSPI_SCLK); // SPI port where esp is connected
SPIClass espSPI(ESPSPI_MOSI, ESPSPI_MISO, ESPSPI_SCLK); // SPI port where esp is connected
#endif
//#include "DNSserver.h"
@ -165,7 +165,7 @@ void wifiSetup()
//
// Initialize the WifiSpi library
WiFiSpi.init(ESPSPI_CS, 8000000, &spi2);
WiFiSpi.init(ESPSPI_CS, 8000000, &espSPI);
// check for the presence of the shield:
if (WiFiSpi.status() == WL_NO_SHIELD) {
@ -181,12 +181,14 @@ void wifiSetup()
}
// attempt to connect to Wifi network
int status = WL_IDLE_STATUS; // the Wifi radio's status
// int status = WL_IDLE_STATUS; // the Wifi radio's status
if(!wifiShowAP()) {
// while (status != WL_CONNECTED) {
Log.notice(F("WIFI: Connecting to : %s"), wifiSsid);
// Connect to WPA/WPA2 network
status = WiFi.begin(wifiSsid, wifiPassword);
// status = WiFi.begin(wifiSsid, wifiPassword);
WiFi.begin(wifiSsid, wifiPassword);
}
// }
#else
@ -214,7 +216,9 @@ void wifiSetup()
bool wifiEvery5Seconds()
{
#if defined(STM32F4xx)
if(WiFi.status() == WL_CONNECTED) {
if(wifiShowAP()) { // no ssid is set yet wait for user on-screen input
return false;
} else if(WiFi.status() == WL_CONNECTED) {
#else
if(WiFi.getMode() != WIFI_STA) {
return false;