This commit is contained in:
fvanroie 2020-12-24 00:33:57 +00:00
commit 643f991435
27 changed files with 306 additions and 233 deletions

View File

@ -2,10 +2,9 @@
* Getting started * Getting started
* [Quick start](quickstart.md) - [Hardware](./01-hardware.md)
* [Writing more pages](more-pages.md) - [Firmware Install](./02-installation.md)
* [Custom navbar](custom-navbar.md) - [Initial Setup](./03-wifi-setup.md)
* [Cover page](cover.md)
* Objects * Objects
* [Button](13-objects?id=button) * [Button](13-objects?id=button)

View File

@ -60,6 +60,7 @@ build_flags =
-D HASP_VERSION_MAJOR=0 -D HASP_VERSION_MAJOR=0
-D HASP_VERSION_MINOR=3 -D HASP_VERSION_MINOR=3
-D HASP_VERSION_REVISION=1 -D HASP_VERSION_REVISION=1
-D HASP_USE_CONFIG=1 ; Native application, not library
; -- Shared library dependencies in all environments ; -- Shared library dependencies in all environments
; Warning : don't put comments after github links => causes infinite download loop ; Warning : don't put comments after github links => causes infinite download loop

View File

@ -527,7 +527,7 @@ void haspLoadPage(const char * pages)
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_CONFIG > 0
bool haspGetConfig(const JsonObject & settings) bool haspGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -584,3 +584,4 @@ bool haspSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG

View File

@ -1,6 +1,8 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2020 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0
#include "ArduinoJson.h" #include "ArduinoJson.h"
#include "StreamUtils.h" // For EEPromStream #include "StreamUtils.h" // For EEPromStream
@ -479,3 +481,5 @@ bool configClearEeprom()
return false; return false;
#endif #endif
} }
#endif // HAS_USE_CONFIG

View File

@ -1,6 +1,8 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2020 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0
#ifndef HASP_CONFIG_H #ifndef HASP_CONFIG_H
#define HASP_CONFIG_H #define HASP_CONFIG_H
@ -60,3 +62,5 @@ const char F_GPIO_CONFIG[] PROGMEM = "config";
const char HASP_CONFIG_FILE[] PROGMEM = "/config.json"; const char HASP_CONFIG_FILE[] PROGMEM = "/config.json";
#endif #endif
#endif // HASP_USE_CONFIG

View File

@ -193,6 +193,7 @@ void debugStop()
if(debugSerialStarted) Serial.flush(); if(debugSerialStarted) Serial.flush();
} }
#if HASP_USE_CONFIG > 0
bool debugGetConfig(const JsonObject & settings) bool debugGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -253,6 +254,7 @@ bool debugSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG
inline void debugSendAnsiCode(const __FlashStringHelper * code, Print * _logOutput) inline void debugSendAnsiCode(const __FlashStringHelper * code, Print * _logOutput)
{ {
@ -605,7 +607,11 @@ void debugPreSetup(JsonObject settings)
Log.setPrefix(debugPrintPrefix); // Uncomment to get timestamps as prefix Log.setPrefix(debugPrintPrefix); // Uncomment to get timestamps as prefix
Log.setSuffix(debugPrintSuffix); // Uncomment to get newline as suffix Log.setSuffix(debugPrintSuffix); // Uncomment to get newline as suffix
uint32_t baudrate = settings[FPSTR(F_CONFIG_BAUD)].as<uint32_t>() * 10; uint32_t baudrate = 0;
#if HASP_USE_CONFIG > 0
baudrate = settings[FPSTR(F_CONFIG_BAUD)].as<uint32_t>() * 10;
#endif
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 */

View File

@ -24,8 +24,10 @@ void debugStopSyslog(void);
// void syslogSend(uint8_t log, const char * debugText); // void syslogSend(uint8_t log, const char * debugText);
/* ===== Read/Write Configuration ===== */ /* ===== Read/Write Configuration ===== */
#if HASP_USE_CONFIG > 0
bool debugGetConfig(const JsonObject & settings); bool debugGetConfig(const JsonObject & settings);
bool debugSetConfig(const JsonObject & settings); bool debugSetConfig(const JsonObject & settings);
#endif
// void debugPrintPrefix(int level, Print * _logOutput); // void debugPrintPrefix(int level, Print * _logOutput);
// void debugPrintSuffix(int level, Print * _logOutput); // void debugPrintSuffix(int level, Print * _logOutput);

View File

@ -8,7 +8,6 @@
#include "hasp_dispatch.h" #include "hasp_dispatch.h"
#include "hasp_network.h" // for network_get_status() #include "hasp_network.h" // for network_get_status()
#include "hasp_config.h"
#include "hasp_debug.h" #include "hasp_debug.h"
#include "hasp_object.h" #include "hasp_object.h"
#include "hasp_gui.h" #include "hasp_gui.h"
@ -18,6 +17,10 @@
#include "hasp_hal.h" #include "hasp_hal.h"
#include "hasp.h" #include "hasp.h"
#if HASP_USE_CONFIG > 0
#include "hasp_config.h"
#endif
extern unsigned long debugLastMillis; // UpdateStatus timer extern unsigned long debugLastMillis; // UpdateStatus timer
uint8_t nCommands = 0; uint8_t nCommands = 0;
@ -123,13 +126,16 @@ void dispatch_command(const char * topic, const char * payload)
} else if(topic == strstr_P(topic, PSTR("p["))) { } else if(topic == strstr_P(topic, PSTR("p["))) {
dispatch_process_button_attribute(topic, payload); dispatch_process_button_attribute(topic, payload);
#if HASP_USE_CONFIG > 0
#if HASP_USE_WIFI > 0 #if HASP_USE_WIFI > 0
} else if(!strcmp_P(topic, F_CONFIG_SSID) || !strcmp_P(topic, F_CONFIG_PASS)) { } else if(!strcmp_P(topic, F_CONFIG_SSID) || !strcmp_P(topic, F_CONFIG_PASS)) {
DynamicJsonDocument settings(45); DynamicJsonDocument settings(45);
settings[topic] = payload; settings[topic] = payload;
wifiSetConfig(settings.as<JsonObject>()); wifiSetConfig(settings.as<JsonObject>());
#endif #endif // HASP_USE_WIFI
#if HASP_USE_MQTT > 0
} else if(!strcmp_P(topic, PSTR("mqtthost")) || !strcmp_P(topic, PSTR("mqttport")) || } else if(!strcmp_P(topic, PSTR("mqtthost")) || !strcmp_P(topic, PSTR("mqttport")) ||
!strcmp_P(topic, PSTR("mqttport")) || !strcmp_P(topic, PSTR("mqttuser")) || !strcmp_P(topic, PSTR("mqttport")) || !strcmp_P(topic, PSTR("mqttuser")) ||
!strcmp_P(topic, PSTR("hostname"))) { !strcmp_P(topic, PSTR("hostname"))) {
@ -137,11 +143,12 @@ void dispatch_command(const char * topic, const char * payload)
// memset(item, 0, sizeof(item)); // memset(item, 0, sizeof(item));
// strncpy(item, topic + 4, 4); // strncpy(item, topic + 4, 4);
#if HASP_USE_MQTT > 0
DynamicJsonDocument settings(45); DynamicJsonDocument settings(45);
settings[topic + 4] = payload; settings[topic + 4] = payload;
mqttSetConfig(settings.as<JsonObject>()); mqttSetConfig(settings.as<JsonObject>());
#endif #endif // HASP_USE_MQTT
#endif // HASP_USE_CONFIG
} else { } else {
if(strlen(payload) == 0) { if(strlen(payload) == 0) {
@ -167,11 +174,13 @@ void dispatch_topic_payload(const char * topic, const char * payload)
return; return;
} }
#if HASP_USE_CONFIG > 0
if(topic == strstr_P(topic, PSTR("config/"))) { // startsWith command/ if(topic == strstr_P(topic, PSTR("config/"))) { // startsWith command/
topic += 7u; topic += 7u;
dispatch_config(topic, (char *)payload); dispatch_config(topic, (char *)payload);
return; return;
} }
#endif
dispatch_command(topic, (char *)payload); // dispatch as is dispatch_command(topic, (char *)payload); // dispatch as is
} }
@ -237,6 +246,7 @@ void IRAM_ATTR dispatch_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, co
dispatch_state_msg(F("json"), payload); dispatch_state_msg(F("json"), payload);
} }
#if HASP_USE_CONFIG > 0
// Get or Set a part of the config.json file // Get or Set a part of the config.json file
static void dispatch_config(const char * topic, const char * payload) static void dispatch_config(const char * topic, const char * payload)
{ {
@ -325,6 +335,7 @@ static void dispatch_config(const char * topic, const char * payload)
dispatch_state_msg(F("config"), buffer); dispatch_state_msg(F("config"), buffer);
} }
} }
#endif // HASP_USE_CONFIG
/********************************************** Input Events *******************************************/ /********************************************** Input Events *******************************************/
// Map events to either ON or OFF (UP or DOWN) // Map events to either ON or OFF (UP or DOWN)
@ -603,7 +614,9 @@ void dispatch_web_update(const char *, const char * espOtaUrl)
// restart the device // restart the device
void dispatch_reboot(bool saveConfig) void dispatch_reboot(bool saveConfig)
{ {
#if HASP_USE_CONFIG > 0
if(saveConfig) configWriteConfig(); if(saveConfig) configWriteConfig();
#endif
#if HASP_USE_MQTT > 0 #if HASP_USE_MQTT > 0
mqttStop(); // Stop the MQTT Client first mqttStop(); // Stop the MQTT Client first
#endif #endif
@ -723,7 +736,9 @@ void dispatchSetup()
dispatch_add_command(PSTR("restart"), dispatch_reboot); dispatch_add_command(PSTR("restart"), dispatch_reboot);
dispatch_add_command(PSTR("screenshot"), dispatch_screenshot); dispatch_add_command(PSTR("screenshot"), dispatch_screenshot);
dispatch_add_command(PSTR("factoryreset"), dispatch_factory_reset); dispatch_add_command(PSTR("factoryreset"), dispatch_factory_reset);
#if HASP_USE_CONFIG > 0
dispatch_add_command(PSTR("setupap"), oobeFakeSetup); dispatch_add_command(PSTR("setupap"), oobeFakeSetup);
#endif
/* WARNING: remember to expand the commands array when adding new commands */ /* WARNING: remember to expand the commands array when adding new commands */
} }

View File

@ -437,6 +437,7 @@ hasp_gpio_config_t gpioGetPinConfig(uint8_t num)
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_CONFIG > 0
bool gpioGetConfig(const JsonObject & settings) bool gpioGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -511,3 +512,4 @@ bool gpioSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG

View File

@ -30,8 +30,11 @@ bool gpioInUse(uint8_t gpio);
bool gpioConfigInUse(uint8_t num); bool gpioConfigInUse(uint8_t num);
int8_t gpioGetFreeConfigId(); int8_t gpioGetFreeConfigId();
hasp_gpio_config_t gpioGetPinConfig(uint8_t num); hasp_gpio_config_t gpioGetPinConfig(uint8_t num);
#if HASP_USE_CONFIG > 0
bool gpioGetConfig(const JsonObject & settings); bool gpioGetConfig(const JsonObject & settings);
bool gpioSetConfig(const JsonObject & settings); bool gpioSetConfig(const JsonObject & settings);
#endif
#define HASP_GPIO_FREE 0x00 #define HASP_GPIO_FREE 0x00
#define HASP_GPIO_USED 0x01 #define HASP_GPIO_USED 0x01

View File

@ -730,6 +730,7 @@ int8_t guiGetDim()
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_CONFIG > 0
bool guiGetConfig(const JsonObject & settings) bool guiGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -845,6 +846,7 @@ bool guiSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG
/* **************************** SCREENSHOTS ************************************** */ /* **************************** SCREENSHOTS ************************************** */
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 || HASP_USE_HTTP > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 || HASP_USE_HTTP > 0

View File

@ -32,9 +32,9 @@ bool guiGetBacklight();
bool IRAM_ATTR guiCheckSleep(); bool IRAM_ATTR guiCheckSleep();
/* ===== Read/Write Configuration ===== */ /* ===== Read/Write Configuration ===== */
#if HASP_USE_CONFIG > 0
bool guiGetConfig(const JsonObject & settings); bool guiGetConfig(const JsonObject & settings);
bool guiSetConfig(const JsonObject & settings); bool guiSetConfig(const JsonObject & settings);
#endif
// lv_res_t guiChangeTheme(uint8_t themeid, uint16_t hue, String font, uint8_t fontsize);
#endif #endif

View File

@ -900,6 +900,7 @@ void handleFileList()
#endif #endif
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_CONFIG > 0
void webHandleConfig() void webHandleConfig()
{ // http://plate01/config { // http://plate01/config
if(!httpIsAuthenticated(F("config"))) return; if(!httpIsAuthenticated(F("config"))) return;
@ -1571,6 +1572,7 @@ void webHandleHaspConfig()
// httpMessage.clear(); // httpMessage.clear();
webSendFooter(); webSendFooter();
} }
#endif // HASP_USE_CONFIG
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void httpHandleNotFound() void httpHandleNotFound()
@ -1602,14 +1604,6 @@ void httpHandleNotFound()
webServer.send(404, PSTR("text/plain"), httpMessage.c_str()); webServer.send(404, PSTR("text/plain"), httpMessage.c_str());
} }
////////////////////////////////////////////////////////////////////////////////////////////////////
void webHandleSaveConfig()
{
if(!httpIsAuthenticated(F("saveConfig"))) return;
configWriteConfig();
}
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void webHandleFirmware() void webHandleFirmware()
{ {
@ -1664,6 +1658,15 @@ void httpHandleEspFirmware()
// espStartOta(webServer.arg("espFirmware")); // espStartOta(webServer.arg("espFirmware"));
} }
////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_CONFIG > 0
void webHandleSaveConfig()
{
if(!httpIsAuthenticated(F("saveConfig"))) return;
configWriteConfig();
}
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void httpHandleResetConfig() void httpHandleResetConfig()
{ // http://plate01/resetConfig { // http://plate01/resetConfig
@ -1713,6 +1716,7 @@ void httpHandleResetConfig()
dispatch_reboot(false); // Do not save the current config dispatch_reboot(false); // Do not save the current config
} }
} }
#endif // HASP_USE_CONFIG
void httpStart() void httpStart()
{ {
@ -1750,12 +1754,26 @@ void httpSetup()
{ {
// httpSetConfig(settings); // httpSetConfig(settings);
// ask server to track these headers
const char * headerkeys[] = {"Content-Length"}; // "Authentication"
size_t headerkeyssize = sizeof(headerkeys) / sizeof(char *);
webServer.collectHeaders(headerkeys, headerkeyssize);
// Shared pages
webServer.on(F("/about"), webHandleAbout);
webServer.onNotFound(httpHandleNotFound);
#if HASP_USE_WIFI > 0 #if HASP_USE_WIFI > 0
#if !defined(STM32F4xx) #if !defined(STM32F4xx)
#if HASP_USE_CONFIG > 0
if(WiFi.getMode() != WIFI_STA) { if(WiFi.getMode() != WIFI_STA) {
Log.notice(TAG_HTTP, F("Wifi access point")); Log.notice(TAG_HTTP, F("Wifi access point"));
webServer.on(F("/"), webHandleWifiConfig); webServer.on(F("/"), webHandleWifiConfig);
} else { return;
}
#endif
#endif #endif
#endif #endif
@ -1788,25 +1806,14 @@ void httpSetup()
handleFileUpload); handleFileUpload);
#endif #endif
// get heap status, analog input value and all GPIO statuses in one json call
/*webServer.on(F("/all"), HTTP_GET, []() {
String json;
json.reserve(128);
json += F("{\"heap\":");
json += String(ESP.getFreeHeap());
json += F(", \"analog\":");
json += String(analogRead(A0));
json += F("}");
char mimetype[128];
sprintf(mimetype, PSTR("text/json"));
webServer.send(200, mimetype, json);
json.clear();
});*/
webServer.on(F("/"), webHandleRoot); webServer.on(F("/"), webHandleRoot);
webServer.on(F("/info"), webHandleInfo); webServer.on(F("/info"), webHandleInfo);
webServer.on(F("/screenshot"), webHandleScreenshot);
webServer.on(F("/firmware"), webHandleFirmware);
webServer.on(F("/reboot"), httpHandleReboot);
webServer.onNotFound(httpHandleNotFound);
#if HASP_USE_CONFIG > 0
webServer.on(F("/config/hasp"), webHandleHaspConfig); webServer.on(F("/config/hasp"), webHandleHaspConfig);
webServer.on(F("/config/http"), webHandleHttpConfig); webServer.on(F("/config/http"), webHandleHttpConfig);
webServer.on(F("/config/gui"), webHandleGuiConfig); webServer.on(F("/config/gui"), webHandleGuiConfig);
@ -1821,10 +1828,11 @@ void httpSetup()
webServer.on(F("/config/gpio"), webHandleGpioConfig); webServer.on(F("/config/gpio"), webHandleGpioConfig);
webServer.on(F("/config/gpio/options"), webHandleGpioOptions); webServer.on(F("/config/gpio/options"), webHandleGpioOptions);
#endif #endif
webServer.on(F("/screenshot"), webHandleScreenshot);
webServer.on(F("/saveConfig"), webHandleSaveConfig); webServer.on(F("/saveConfig"), webHandleSaveConfig);
webServer.on(F("/resetConfig"), httpHandleResetConfig); webServer.on(F("/resetConfig"), httpHandleResetConfig);
webServer.on(F("/firmware"), webHandleFirmware); webServer.on(F("/config"), webHandleConfig);
#endif // HASP_USE_CONFIG
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
webServer.on( webServer.on(
F("/update"), HTTP_POST, F("/update"), HTTP_POST,
@ -1835,23 +1843,6 @@ void httpSetup()
webHandleFirmwareUpdate); webHandleFirmwareUpdate);
webServer.on(F("/espfirmware"), httpHandleEspFirmware); webServer.on(F("/espfirmware"), httpHandleEspFirmware);
#endif #endif
webServer.on(F("/reboot"), httpHandleReboot);
webServer.onNotFound(httpHandleNotFound);
#if HASP_USE_WIFI > 0
#if !defined(STM32F4xx)
}
#endif
#endif
// Shared pages
webServer.on(F("/about"), webHandleAbout);
webServer.on(F("/config"), webHandleConfig);
webServer.onNotFound(httpHandleNotFound);
// ask server to track these headers
const char * headerkeys[] = {"Content-Length"}; // "Authentication"
size_t headerkeyssize = sizeof(headerkeys) / sizeof(char *);
webServer.collectHeaders(headerkeys, headerkeyssize);
Log.trace(TAG_HTTP, F("Setup Complete")); Log.trace(TAG_HTTP, F("Setup Complete"));
// webStart(); Wait for network connection // webStart(); Wait for network connection
@ -1886,6 +1877,7 @@ void httpEvery5Seconds()
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_CONFIG > 0
bool httpGetConfig(const JsonObject & settings) bool httpGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -1932,6 +1924,7 @@ bool httpSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG
size_t httpClientWrite(const uint8_t * buf, size_t size) size_t httpClientWrite(const uint8_t * buf, size_t size)
{ {

View File

@ -15,7 +15,9 @@ void httpStop(void);
size_t httpClientWrite(const uint8_t * buf, size_t size); // Screenshot Write Data size_t httpClientWrite(const uint8_t * buf, size_t size); // Screenshot Write Data
#if HASP_USE_CONFIG > 0
bool httpGetConfig(const JsonObject & settings); bool httpGetConfig(const JsonObject & settings);
bool httpSetConfig(const JsonObject & settings); bool httpSetConfig(const JsonObject & settings);
#endif // HASP_USE_CONFIG
#endif #endif

View File

@ -83,6 +83,7 @@ void mdnsStop()
#endif #endif
} }
#if HASP_USE_CONFIG > 0
bool mdnsGetConfig(const JsonObject & settings) bool mdnsGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -108,5 +109,6 @@ bool mdnsSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG
#endif // HASP_USE_MDNS #endif // HASP_USE_MDNS

View File

@ -13,7 +13,9 @@ void mdnsStart(void);
void mdnsStop(void); void mdnsStop(void);
/* ===== Read/Write Configuration ===== */ /* ===== Read/Write Configuration ===== */
#if HASP_USE_CONFIG > 0
bool mdnsGetConfig(const JsonObject & settings); bool mdnsGetConfig(const JsonObject & settings);
bool mdnsSetConfig(const JsonObject & settings); bool mdnsSetConfig(const JsonObject & settings);
#endif
#endif #endif

View File

@ -409,6 +409,7 @@ void mqttStop()
} }
} }
#if HASP_USE_CONFIG > 0
bool mqttGetConfig(const JsonObject & settings) bool mqttGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -493,5 +494,6 @@ bool mqttSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG
#endif // HASP_USE_MQTT #endif // HASP_USE_MQTT

View File

@ -17,8 +17,10 @@ void IRAM_ATTR mqtt_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, const
bool IRAM_ATTR mqttIsConnected(); bool IRAM_ATTR mqttIsConnected();
#if HASP_USE_CONFIG > 0
bool mqttGetConfig(const JsonObject & settings); bool mqttGetConfig(const JsonObject & settings);
bool mqttSetConfig(const JsonObject & settings); bool mqttSetConfig(const JsonObject & settings);
#endif
String mqttGetNodename(void); String mqttGetNodename(void);

View File

@ -1,6 +1,8 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2020 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0
#include "hasp_conf.h" #include "hasp_conf.h"
#include "lvgl.h" #include "lvgl.h"
@ -363,3 +365,4 @@ void oobeFakeSetup(const char *, const char *)
} }
#endif #endif
} }
#endif // HASP_USE_CONFIG

View File

@ -1,6 +1,10 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2020 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0
void oobeSetAutoCalibrate(bool cal); void oobeSetAutoCalibrate(bool cal);
bool oobeSetup(); bool oobeSetup();
void oobeFakeSetup(const char *, const char *); // for testing purposes only void oobeFakeSetup(const char *, const char *); // for testing purposes only
#endif // HASP_USE_CONFIG

View File

@ -313,6 +313,7 @@ void IRAM_ATTR telnetLoop()
#endif #endif
} }
#if HASP_USE_CONFIG > 0
bool telnetGetConfig(const JsonObject & settings) bool telnetGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -345,5 +346,6 @@ bool telnetSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG
#endif #endif

View File

@ -22,9 +22,10 @@ void telnetStop(void);
/* ===== Getter and Setter Functions ===== */ /* ===== Getter and Setter Functions ===== */
/* ===== Read/Write Configuration ===== */ /* ===== Read/Write Configuration ===== */
#if HASP_USE_CONFIG > 0
bool telnetSetConfig(const JsonObject & settings); bool telnetSetConfig(const JsonObject & settings);
bool telnetGetConfig(const JsonObject & settings); bool telnetGetConfig(const JsonObject & settings);
#endif
#define TELNET_UNAUTHENTICATED 0 #define TELNET_UNAUTHENTICATED 0
#define TELNET_USERNAME_OK 10 #define TELNET_USERNAME_OK 10

View File

@ -508,7 +508,7 @@ void wifi_get_statusupdate(char * buffer, size_t len)
} }
/* ============ Confiuration =============================================================== */ /* ============ Confiuration =============================================================== */
#if HASP_USE_CONFIG > 0
bool wifiGetConfig(const JsonObject & settings) bool wifiGetConfig(const JsonObject & settings)
{ {
bool changed = false; bool changed = false;
@ -549,5 +549,6 @@ bool wifiSetConfig(const JsonObject & settings)
return changed; return changed;
} }
#endif // HASP_USE_CONFIG
#endif #endif

View File

@ -15,7 +15,9 @@ void wifiStop(void);
bool wifiValidateSsid(const char * ssid, const char * pass); bool wifiValidateSsid(const char * ssid, const char * pass);
void wifi_get_statusupdate(char * buffer, size_t len); void wifi_get_statusupdate(char * buffer, size_t len);
#if HASP_USE_CONFIG > 0
bool wifiGetConfig(const JsonObject & settings); bool wifiGetConfig(const JsonObject & settings);
bool wifiSetConfig(const JsonObject & settings); bool wifiSetConfig(const JsonObject & settings);
#endif
#endif #endif

View File

@ -36,7 +36,9 @@ void setup()
/**************************** /****************************
* Read & Apply User Configuration * Read & Apply User Configuration
***************************/ ***************************/
#if HASP_USE_CONFIG > 0
configSetup(); // also runs debugPreSetup(), debugSetup() and debugStart() configSetup(); // also runs debugPreSetup(), debugSetup() and debugStart()
#endif
dispatchSetup(); dispatchSetup();
guiSetup(); guiSetup();
@ -57,7 +59,10 @@ void setup()
networkSetup(); networkSetup();
#endif #endif
if(!oobeSetup()) { #if HASP_USE_CONFIG > 0
if(!oobeSetup())
#endif
{
haspSetup(); haspSetup();
} }

View File

@ -20,7 +20,7 @@ build_flags =
${esp32.build_flags} ${esp32.build_flags}
;region -- TFT_eSPI build options ------------------------ ;region -- TFT_eSPI build options ------------------------
${lcd.st7789} ${lcd.st7789v}
-D TFT_RST=19 ; FCP pin2 RESET -D TFT_RST=19 ; FCP pin2 RESET
-D TFT_CLK=18 ; FCP pin3 SCL -D TFT_CLK=18 ; FCP pin3 SCL
-D TFT_DC=21 ; FCP pin4 D/C -D TFT_DC=21 ; FCP pin4 D/C

View File

@ -23,7 +23,7 @@ lolin24 =
-D SPI_TOUCH_FREQUENCY=2500000 -D SPI_TOUCH_FREQUENCY=2500000
-D SPI_READ_FREQUENCY=20000000 -D SPI_READ_FREQUENCY=20000000
-D USER_SETUP_LOADED=1 -D USER_SETUP_LOADED=1
-D TOUCH_DRIVER=2046 ; XPT2046 Resistive touch panel driver -D TOUCH_DRIVER=2046 ; XPT2046 Resistive SPI touch panel driver
-D SUPPORT_TRANSACTIONS -D SUPPORT_TRANSACTIONS
raspberrypi = raspberrypi =
@ -35,7 +35,7 @@ raspberrypi =
-D SPI_FREQUENCY=80000000 -D SPI_FREQUENCY=80000000
-D SPI_TOUCH_FREQUENCY=2500000 -D SPI_TOUCH_FREQUENCY=2500000
-D USER_SETUP_LOADED=1 -D USER_SETUP_LOADED=1
-D TOUCH_DRIVER=2046 ; XPT2046 Resistive touch panel driver -D TOUCH_DRIVER=2046 ; XPT2046 Resistive SPI touch panel driver
-D SUPPORT_TRANSACTIONS -D SUPPORT_TRANSACTIONS
mrb3511 = mrb3511 =
@ -45,18 +45,31 @@ mrb3511 =
-D TFT_HEIGHT=480 -D TFT_HEIGHT=480
-D TFT_ROTATION=0 ; see TFT_ROTATION values -D TFT_ROTATION=0 ; see TFT_ROTATION values
-D USER_SETUP_LOADED=1 -D USER_SETUP_LOADED=1
-D TOUCH_DRIVER=911 ; GT911 Capacitive touch panel driver -D TOUCH_DRIVER=911 ; GT911 Capacitive I2C touch panel driver
-D SUPPORT_TRANSACTIONS -D SUPPORT_TRANSACTIONS
st7789 = st7789v =
-D ST7789_DRIVER=1 -D ST7789_DRIVER=1
-D CGRAM_OFFSET=1 ; Library will add offsets required ;-D CGRAM_OFFSET=1 ; Library will add offsets required, only for 240x240
-D TFT_SDA_READ ; Read from display, it only provides an SDA pin
-D TFT_WIDTH=240 -D TFT_WIDTH=240
-D TFT_HEIGHT=320 -D TFT_HEIGHT=320
-D TFT_ROTATION=0 ; see TFT_ROTATION values -D TFT_ROTATION=0 ; see TFT_ROTATION values
-D SPI_FREQUENCY=25000000 -D TFT_RGB_ORDER=TFT_RGB ; Colour order Red-Green-Blue
-D SPI_TOUCH_FREQUENCY=2500000 ;-D TFT_RGB_ORDER TFT_BGR ; Colour order Blue-Green-Red
-D SPI_FREQUENCY=80000000
-D SPI_READ_FREQUENCY=6000000
-D USER_SETUP_LOADED=1
-D TOUCH_DRIVER=6336 ; FT6336U Capacitive I2C touch panel driver
-D SUPPORT_TRANSACTIONS
wireless-tag =
-D ST7796_DRIVER=1
-D TFT_WIDTH=320
-D TFT_HEIGHT=480
-D TFT_ROTATION=0 ; see TFT_ROTATION values
-D SPI_FREQUENCY=40000000
-D SPI_READ_FREQUENCY=20000000 -D SPI_READ_FREQUENCY=20000000
-D USER_SETUP_LOADED=1 -D USER_SETUP_LOADED=1
-D TOUCH_DRIVER=2046 ; XPT2046 Resistive touch panel driver -D TOUCH_DRIVER=6336 ; FT6336U Capacitive I2C touch panel driver
-D SUPPORT_TRANSACTIONS -D SUPPORT_TRANSACTIONS