Move #include "hasp_config.h" to hasplib

This commit is contained in:
fvanroie 2023-01-26 01:01:13 +01:00
parent 29fbb358dd
commit e2670ab702
29 changed files with 70 additions and 70 deletions

View File

@ -27,7 +27,6 @@
#if HASP_USE_CONFIG > 0
#include "lv_fs_if.h"
#include "hasp_config.h"
#include "font/hasp_font_loader.h"
// #include "hasp_filesystem.h" included in hasp_conf.h
#endif

View File

@ -37,10 +37,6 @@
#endif
#endif
#if HASP_USE_CONFIG > 0
#include "hasp_config.h"
#endif
dispatch_conf_t dispatch_setings = {.teleperiod = 300};
uint16_t dispatchSecondsToNextTeleperiod = 0;

View File

@ -57,8 +57,6 @@ const uint8_t* font_dummy_glyph_bitmap(const struct _lv_font_struct*, uint32_t)
void font_setup()
{
_lv_ll_init(&hasp_fonts_ll, sizeof(hasp_font_info_t));
#if(HASP_USE_FREETYPE > 0) // initialize the FreeType renderer
#if defined(ARDUINO_ARCH_ESP32)
@ -77,6 +75,8 @@ void font_setup()
#else
LOG_VERBOSE(TAG_FONT, F("FreeType " D_SERVICE_DISABLED));
#endif // HASP_USE_FREETYPE
_lv_ll_init(&hasp_fonts_ll, sizeof(hasp_font_info_t));
}
size_t font_split_payload(const char* payload)

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_NVS_H
@ -9,6 +9,8 @@
#include "hasplib.h"
#include <Preferences.h>
void nvs_setup();
bool nvs_user_begin(Preferences& preferences, const char* key, bool readonly);
bool nvs_clear_user_config();
bool nvsUpdateString(Preferences& preferences, const char* key, JsonVariant value);
bool nvsUpdateUInt(Preferences& preferences, const char* key, JsonVariant value);

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_OBJECT_H
@ -41,8 +41,10 @@ enum lv_hasp_obj_type_t {
LV_HASP_TABVIEW = 6, // placeholder
LV_HASP_TAB = 7, // placeholder
LV_HASP_PAGE = 8, // Obsolete in v8
LV_HASP_SPAN = 9, // placeholder
/* Controls */
LV_HASP_KEYBOARD = 10, // placeholder
LV_HASP_OBJECT = 11,
LV_HASP_BUTTON = 12,
LV_HASP_BTNMATRIX = 13,
@ -71,12 +73,14 @@ enum lv_hasp_obj_type_t {
LV_HASP_LIST = 31, // placeholder
LV_HASP_TABLE = 32,
LV_HASP_CALENDER = 33,
LV_HASP_MENU = 34, // placeholder
/* Graphics */
LV_HASP_LINE = 36,
LV_HASP_IMAGE = 37, // placeholder
LV_HASP_CANVAS = 38, // placeholder
LV_HASP_MASK = 39, // placeholder
LV_HASP_ANIMIMAGE = 38, // placeholder
LV_HASP_CANVAS = 39, // placeholder
LV_HASP_MASK = 40, // placeholder
/* Custom */
LV_HASP_ALARM = 60,

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include "hasplib.h"
@ -12,7 +12,6 @@ For full license information read the LICENSE file in the project folder */
#endif
#if HASP_USE_CONFIG > 0
#include "hasp_config.h"
#include "hasp_gui.h"
#endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0
@ -52,7 +52,9 @@ const char FP_CONFIG_NAME[] PROGMEM = "name";
const char FP_CONFIG_USER[] PROGMEM = "user";
const char FP_CONFIG_PASS[] PROGMEM = "pass";
const char FP_CONFIG_SSID[] PROGMEM = "ssid";
const char FP_CONFIG_NODE[] PROGMEM = "node";
const char FP_CONFIG_GROUP[] PROGMEM = "group";
const char FP_CONFIG_BROADCAST[] PROGMEM = "group";
const char FP_CONFIG_BAUD[] PROGMEM = "baud";
const char FP_CONFIG_LOG[] PROGMEM = "log";
const char FP_CONFIG_PROTOCOL[] PROGMEM = "proto";

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include "hasplib.h"
@ -12,7 +12,6 @@
#include "drv/touch/touch_driver.h"
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_gui.h"
#include "hasp_oobe.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0
@ -6,7 +6,6 @@
#include "hasplib.h"
#include "hasp_gui.h"
#include "hasp_config.h"
#include "sys/net/hasp_wifi.h"
#include "hasp/hasp_dispatch.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifdef ARDUINO
@ -44,6 +44,10 @@
#include "lv_freetype.h"
#endif
#if HASP_USE_CONFIG > 0
#include "hasp_config.h"
#endif
#if HASP_USE_PNGDECODE > 0
#include "lv_png.h"
#endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#if !(defined(WINDOWS) || defined(POSIX))
@ -25,7 +25,6 @@
#endif
#if HASP_USE_CONFIG > 0
#include "hasp_config.h"
#include "hasp_gui.h"
#endif
@ -51,6 +50,7 @@ void setup()
/****************************
* Storage initializations
***************************/
// nvs_setup();
#if HASP_USE_EEPROM > 0
eepromSetup(); // Don't start at boot, only at write
#endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_MQTT_H
@ -22,7 +22,7 @@ void mqttEvery5Seconds(bool wifiIsConnected);
void mqttStart();
void mqttStop();
int mqtt_send_object_state(uint8_t pageid, uint8_t btnid, const char* payload);
// int mqtt_send_object_state(uint8_t pageid, uint8_t btnid, const char* payload);
int mqtt_send_state(const char* subtopic, const char* payload);
int mqtt_send_discovery(const char* payload, size_t len);
int mqttPublish(const char* topic, const char* payload, size_t len, bool retain);

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
/* Single threaded synchronous paho client */
@ -238,13 +238,13 @@ int mqtt_send_discovery(const char* payload, size_t len)
return mqttPublish(tmp_topic, payload, len, false);
}
int mqtt_send_object_state(uint8_t pageid, uint8_t btnid, const char* payload)
{
char tmp_topic[mqttNodeTopic.length() + 20];
snprintf_P(tmp_topic, sizeof(tmp_topic), PSTR("%s" MQTT_TOPIC_STATE "/p%ub%u"), mqttNodeTopic.c_str(), pageid,
btnid);
return mqttPublish(tmp_topic, payload, strlen(payload), false);
}
// int mqtt_send_object_state(uint8_t pageid, uint8_t btnid, const char* payload)
// {
// char tmp_topic[mqttNodeTopic.length() + 20];
// snprintf_P(tmp_topic, sizeof(tmp_topic), PSTR("%s" MQTT_TOPIC_STATE "/p%ub%u"), mqttNodeTopic.c_str(), pageid,
// btnid);
// return mqttPublish(tmp_topic, payload, strlen(payload), false);
// }
static void onConnect(void* context)
{

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h"
@ -109,13 +109,13 @@ bool mqtt_send_lwt(bool online)
return res;
}
int mqtt_send_object_state(uint8_t pageid, uint8_t btnid, const char* payload)
{
char tmp_topic[strlen(mqttNodeTopic) + 16];
snprintf_P(tmp_topic, sizeof(tmp_topic), PSTR("%s" MQTT_TOPIC_STATE "/" HASP_OBJECT_NOTATION), mqttNodeTopic,
pageid, btnid);
return mqttPublish(tmp_topic, payload, false);
}
// int mqtt_send_object_state(uint8_t pageid, uint8_t btnid, const char* payload)
// {
// char tmp_topic[strlen(mqttNodeTopic) + 16];
// snprintf_P(tmp_topic, sizeof(tmp_topic), PSTR("%s" MQTT_TOPIC_STATE "/" HASP_OBJECT_NOTATION), mqttNodeTopic,
// pageid, btnid);
// return mqttPublish(tmp_topic, payload, false);
// }
int mqtt_send_state(const char* subtopic, const char* payload)
{

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include "lv_conf.h" // For timing defines
@ -6,7 +6,6 @@
#include "hasplib.h"
#include "hasp_gpio.h"
#include "hasp_config.h"
// Device Drivers
#include "dev/device.h"

View File

@ -1,3 +1,6 @@
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include <time.h>
#include <sys/time.h>
@ -47,15 +50,15 @@ void timeSetup()
#endif
#if defined(ARDUINO_ARCH_ESP32)
Preferences preferences;
preferences.begin("time", true);
nvs_user_begin(preferences,"time", true);
mytz = preferences.getString("tz", MYTZ);
ntp1 = preferences.getString("ntp1", NTPSERVER1);
ntp2 = preferences.getString("ntp2", NTPSERVER2);
ntp3 = preferences.getString("ntp3", NTPSERVER3);
LOG_WARNING(TAG_TIME, F("TIMEZONE: %s"), mytz.c_str());
LOG_WARNING(TAG_TIME, F("NTPSERVER: %s %s %s"), ntp1.c_str(), ntp2.c_str(), ntp3.c_str());
LOG_VERBOSE(TAG_TIME, F("TIMEZONE: %s"), mytz.c_str());
LOG_VERBOSE(TAG_TIME, F("NTPSERVER: %s %s %s"), ntp1.c_str(), ntp2.c_str(), ntp3.c_str());
configTzTime(mytz.c_str(), ntp1.c_str(), ntp2.c_str(), ntp3.c_str());
preferences.end();
@ -69,7 +72,7 @@ bool timeGetConfig(const JsonObject& settings)
Preferences preferences;
bool changed = false;
preferences.begin("time", true);
nvs_user_begin(preferences,"time", true);
settings["tz"] = preferences.getString("tz", MYTZ);
settings["ntp"][0] = preferences.getString("ntp1", NTPSERVER1);
settings["ntp"][1] = preferences.getString("ntp2", NTPSERVER2);
@ -94,7 +97,7 @@ bool timeGetConfig(const JsonObject& settings)
bool timeSetConfig(const JsonObject& settings)
{
Preferences preferences;
preferences.begin("time", false);
nvs_user_begin(preferences,"time", false);
configOutput(settings, TAG_TIME);
bool changed = false;

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_TIME_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_WIFI_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include "hasplib.h"
@ -9,7 +9,6 @@
#include <StreamUtils.h>
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_console.h"
#include "../../hasp/hasp_dispatch.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_CONSOLE_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include "hasplib.h"
@ -6,7 +6,6 @@
#if HASP_USE_FTP > 0
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_ftp.h"
#include "hasp_http.h"
#include "hasp_filesystem.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_FTP_H

View File

@ -20,7 +20,6 @@
#include "hasp_gui.h"
#include "hasp_debug.h"
#include "hasp_config.h"
#if HASP_USE_HTTP > 0
#include "sys/net/hasp_network.h"
@ -2506,7 +2505,7 @@ static inline void webStartConfigPortal()
void httpSetup()
{
Preferences preferences;
preferences.begin("http", true);
nvs_user_begin(preferences,"http", true);
String password = preferences.getString(FP_CONFIG_PASS, HTTP_PASSWORD);
strncpy(http_config.password, password.c_str(), sizeof(http_config.password));
LOG_DEBUG(TAG_HTTP, F(D_BULLET "Read %s => %s (%d bytes)"), FP_CONFIG_PASS, password.c_str(), password.length());
@ -2654,7 +2653,7 @@ bool httpGetConfig(const JsonObject& settings)
bool httpSetConfig(const JsonObject& settings)
{
Preferences preferences;
preferences.begin("http", false);
nvs_user_begin(preferences,"http", false);
configOutput(settings, TAG_HTTP);
bool changed = false;

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_HTTP_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
//#include "webServer.h"
@ -15,7 +15,6 @@
#include "hasp_gui.h"
#include "hasp_debug.h"
#include "hasp_config.h"
#if HASP_USE_HTTP_ASYNC > 0
#include "sys/net/hasp_network.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#ifndef HASP_MDNS_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
@ -6,7 +6,6 @@
#include "hasplib.h"
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_ota.h"
#if defined(ARDUINO_ARCH_ESP8266)
@ -370,7 +369,7 @@ bool otaGetConfig(const JsonObject& settings)
Preferences preferences;
bool changed = false;
preferences.begin("ota", true);
nvs_user_begin(preferences,"ota", true);
settings["url"] = preferences.getString("url", HASP_OTA_URL);
settings["redirect"] = preferences.getUInt("redirect", 0);
preferences.end();
@ -393,7 +392,7 @@ bool otaGetConfig(const JsonObject& settings)
bool otaSetConfig(const JsonObject& settings)
{
Preferences preferences;
preferences.begin("ota", false);
nvs_user_begin(preferences,"ota", false);
configOutput(settings, TAG_OTA);
bool changed = false;

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2019-2021 Francis Van Roie
/* MIT License - Copyright (c) 2019-2023 Francis Van Roie
For full license information read the LICENSE file in the project folder */
#include "hasplib.h"
@ -9,7 +9,6 @@
#include <StreamUtils.h>
#include "hasp_debug.h"
#include "hasp_config.h"
#include "hasp_telnet.h"
#include "hasp_http.h"