From ed3ba7d55c975c6cb7e2f70adae18767f6d51f40 Mon Sep 17 00:00:00 2001
From: arovak
Date: Mon, 5 Apr 2021 21:31:51 +0200
Subject: [PATCH 1/7] Add user_override_sample.h with example settings
---
include/hasp_conf.h | 4 ++
src/lang/lang.h | 9 ++-
src/lang/nl_NL.h | 5 +-
src/log/hasp_debug.cpp | 6 +-
src/mqtt/hasp_mqtt_pubsubclient.cpp | 6 +-
src/sys/net/hasp_network.cpp | 6 +-
src/sys/net/hasp_wifi.cpp | 6 +-
src/sys/svc/hasp_http.cpp | 6 +-
src/user_config_override_sample.h | 85 +++++++++++++++++++++++++++++
9 files changed, 114 insertions(+), 19 deletions(-)
create mode 100644 src/user_config_override_sample.h
diff --git a/include/hasp_conf.h b/include/hasp_conf.h
index 52d2e081..fe34ab5d 100644
--- a/include/hasp_conf.h
+++ b/include/hasp_conf.h
@@ -1,6 +1,10 @@
#ifndef HASP_CONF_H
#define HASP_CONF_H
+#ifdef USE_CONFIG_OVERRIDE
+#include "user_config_override.h"
+#endif
+
// language specific defines
#include "lang/lang.h"
diff --git a/src/lang/lang.h b/src/lang/lang.h
index 1b40b78f..74b95923 100644
--- a/src/lang/lang.h
+++ b/src/lang/lang.h
@@ -1,7 +1,14 @@
#ifndef HASP_LANG_H
#define HASP_LANG_H
-#include "en_US.h"
+#ifndef HASP_LANGUAGE
+ #include "en_US.h"
+#else
+ #define QUOTEME(x) QUOTEME_1(x)
+ #define QUOTEME_1(x) #x
+ #define INCLUDE_FILE(x) QUOTEME(x.h)
+ #include INCLUDE_FILE(HASP_LANGUAGE)
+#endif
// language independent defines
#define D_PASSWORD_MASK "********"
diff --git a/src/lang/nl_NL.h b/src/lang/nl_NL.h
index e2b26fc7..514b2029 100644
--- a/src/lang/nl_NL.h
+++ b/src/lang/nl_NL.h
@@ -6,7 +6,7 @@
#define D_SSID "Ssid:"
#define D_ERROR_OUT_OF_MEMORY "Geen geheugen bechikbaar"
-#define D_ERROR_UNKNOWN "Unbekende fout"
+#define D_ERROR_UNKNOWN "Onbekende fout"
#define D_CONFIG_NOT_CHANGED "Instellingen ongewijzigd"
#define D_CONFIG_CHANGED "Instellingen gewijzigd"
@@ -51,7 +51,6 @@
#define D_TELNET_CLOSING_CONNECTION "Sessie sluiten van %s"
#define D_TELNET_CLIENT_LOGIN_FROM "Client aangemeld van %s"
#define D_TELNET_CLIENT_CONNECT_FROM "Client verbonden van %s"
-#define D_TELNET_CLIENT_NOT_CONNECTED "Client NIET vzebonden"
#define D_TELNET_AUTHENTICATION_FAILED "Autorisatie mislukt!"
#define D_TELNET_INCORRECT_LOGIN_ATTEMPT "Aanmelding van %s mislukt"
#define D_TELNET_STARTED "Telnet console gestart"
@@ -125,7 +124,7 @@
#define D_HTTP_REBOOT "Herstarten"
#define D_HTTP_CONFIGURATION "Configuratie"
-#define D_OOBE_MSB "Raak het scherm aan om WiFi in te stellen of meld je aan op AP:"
+#define D_OOBE_MSG "Raak het scherm aan om WiFi in te stellen of meld je aan op AP:"
#define D_OOBE_SCAN_TO_CONNECT "Scan code"
#endif
\ No newline at end of file
diff --git a/src/log/hasp_debug.cpp b/src/log/hasp_debug.cpp
index f30989fc..a2c7071f 100644
--- a/src/log/hasp_debug.cpp
+++ b/src/log/hasp_debug.cpp
@@ -39,9 +39,9 @@
#include "hasp/hasp_dispatch.h"
#include "hasp/hasp.h"
-#ifdef USE_CONFIG_OVERRIDE
-#include "user_config_override.h"
-#endif
+// #ifdef USE_CONFIG_OVERRIDE
+// #include "user_config_override.h"
+// #endif
#ifndef SERIAL_SPEED
#define SERIAL_SPEED 115200
diff --git a/src/mqtt/hasp_mqtt_pubsubclient.cpp b/src/mqtt/hasp_mqtt_pubsubclient.cpp
index fd681b42..791387de 100644
--- a/src/mqtt/hasp_mqtt_pubsubclient.cpp
+++ b/src/mqtt/hasp_mqtt_pubsubclient.cpp
@@ -42,9 +42,9 @@ EthernetClient mqttNetworkClient;
#include "../hasp/hasp_dispatch.h"
-#ifdef USE_CONFIG_OVERRIDE
-#include "user_config_override.h"
-#endif
+// #ifdef USE_CONFIG_OVERRIDE
+// #include "user_config_override.h"
+// #endif
char mqttNodeTopic[24];
char mqttGroupTopic[24];
diff --git a/src/sys/net/hasp_network.cpp b/src/sys/net/hasp_network.cpp
index ba6dd8b0..1001a5d6 100644
--- a/src/sys/net/hasp_network.cpp
+++ b/src/sys/net/hasp_network.cpp
@@ -3,9 +3,9 @@
#include
#include
-#ifdef USE_CONFIG_OVERRIDE
-#include "user_config_override.h"
-#endif
+// #ifdef USE_CONFIG_OVERRIDE
+// #include "user_config_override.h"
+// #endif
#ifndef MYTZ
#define MYTZ "EST5EDT,M3.2.0/2,M11.1.0"
#endif
diff --git a/src/sys/net/hasp_wifi.cpp b/src/sys/net/hasp_wifi.cpp
index 5746a0a2..c5317871 100644
--- a/src/sys/net/hasp_wifi.cpp
+++ b/src/sys/net/hasp_wifi.cpp
@@ -34,9 +34,9 @@ SPIClass espSPI(ESPSPI_MOSI, ESPSPI_MISO, ESPSPI_SCLK); // SPI port where esp is
#endif
//#include "DNSserver.h"
-#ifdef USE_CONFIG_OVERRIDE
-#include "user_config_override.h"
-#endif
+// #ifdef USE_CONFIG_OVERRIDE
+// #include "user_config_override.h"
+// #endif
#ifdef WIFI_SSID
char wifiSsid[32] = WIFI_SSID;
diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp
index 37689bca..ca90ff14 100644
--- a/src/sys/svc/hasp_http.cpp
+++ b/src/sys/svc/hasp_http.cpp
@@ -26,9 +26,9 @@
#if HASP_USE_HTTP > 0
-#ifdef USE_CONFIG_OVERRIDE
-#include "user_config_override.h"
-#endif
+// #ifdef USE_CONFIG_OVERRIDE
+// #include "user_config_override.h"
+// #endif
//default theme
#ifndef D_HTTP_COLOR_TEXT
diff --git a/src/user_config_override_sample.h b/src/user_config_override_sample.h
new file mode 100644
index 00000000..25429883
--- /dev/null
+++ b/src/user_config_override_sample.h
@@ -0,0 +1,85 @@
+#ifndef HASP_USER_CONFIG_OVERRIDE_H
+#define HASP_USER_CONFIG_OVERRIDE_H
+/***************************************************
+ Setup WiFi Settings
+ **************************************************/
+// #define WIFI_SSID "" // WiFi SSID
+// #define WIFI_PASSW "" // WiFi Password
+
+/***************************************************
+ MQTT Settings
+ **************************************************/
+// #define MQTT_HOST "" // MQTT server Address
+// #define MQTT_PORT 1883 // MQTT server Port
+// #define MQTT_USER "" // Optional Username
+// #define MQTT_PASSW "" // Optional Password
+// #define MQTT_GROUPNAME "plates" // MQTT Group topic for all plates to listen on, default: plates
+// #define MQTT_PREFIX "hasp" // Prefix for all MQTT topics, default: hasp
+
+/***************************************************
+ SYSLOG Settings
+ **************************************************/
+// #define SYSLOG_SERVER "" // Syslog server Address
+// #define SYSLOG_PORT 514 // Syslog server Port
+
+/***************************************************
+ Timezone Settings
+ **************************************************/
+// #define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3" // A full list with possible timezones can be found here https://gist.github.com/alwynallan/24d96091655391107939
+
+/***************************************************
+ Interface Language Settings
+ **************************************************/
+// #define HASP_LANGUAGE en_US // English
+// #define HASP_LANGUAGE nl_NL // Dutch
+// #define HASP_LANGUAGE hu_HU // Hungarian
+// #define HASP_LANGUAGE ro_RO // Romanian
+
+/***************************************************
+ Web Interface Templates
+ **************************************************/
+/*
+//default theme
+#define D_HTTP_COLOR_TEXT "#000" // Global text color - Black
+#define D_HTTP_COLOR_BACKGROUND "#fff" // Global background color - White
+#define D_HTTP_COLOR_INPUT_TEXT "#000" // Input text color - Black
+#define D_HTTP_COLOR_INPUT "#fff" // Input background color - White
+#define D_HTTP_COLOR_INPUT_WARNING "#f00" // Warning text color - Red
+#define D_HTTP_COLOR_BUTTON_TEXT "#fff" // Button text color - White
+#define D_HTTP_COLOR_BUTTON "#1fa3ec" // Button color - Vivid blue
+#define D_HTTP_COLOR_BUTTON_RESET "#f00" // Restart/Reset/Delete button color - red
+*/
+/*
+// Dark theme
+#define D_HTTP_COLOR_TEXT "#eaeaea" // Global text color - Very light gray
+#define D_HTTP_COLOR_BACKGROUND "#252525" // Global background color - Very dark gray (mostly black)
+#define D_HTTP_COLOR_INPUT_TEXT "#000" // Input text color - Black
+#define D_HTTP_COLOR_INPUT "#ddd" // Input background color - Very light gray
+#define D_HTTP_COLOR_INPUT_WARNING "#ff5661" // Warning text color - Brick Red
+#define D_HTTP_COLOR_BUTTON_TEXT "#faffff" // Button text color - Very pale (mostly white) cyan
+#define D_HTTP_COLOR_BUTTON "#1fa3ec" // Button color - Vivid blue
+#define D_HTTP_COLOR_BUTTON_RESET "#d43535" // Restart/Reset/Delete button color - Strong red
+*/
+/*
+// Purple theme
+#define D_HTTP_COLOR_TEXT "#eaeaea"
+#define D_HTTP_COLOR_BACKGROUND "#252525"
+#define D_HTTP_COLOR_INPUT_TEXT "#eaeaea"
+#define D_HTTP_COLOR_INPUT "#282531"
+#define D_HTTP_COLOR_INPUT_WARNING "#ff5661"
+#define D_HTTP_COLOR_BUTTON_TEXT "#faffff"
+#define D_HTTP_COLOR_BUTTON "#694fa8"
+#define D_HTTP_COLOR_BUTTON_RESET "#b73d5d"
+*/
+/*
+// Green theme
+#define D_HTTP_COLOR_TEXT "#edddd4"
+#define D_HTTP_COLOR_BACKGROUND "#283d3b"
+#define D_HTTP_COLOR_INPUT_TEXT "#edddd4"
+#define D_HTTP_COLOR_INPUT "#197278"
+#define D_HTTP_COLOR_INPUT_WARNING "#772e25"
+#define D_HTTP_COLOR_BUTTON_TEXT "#edddd4"
+#define D_HTTP_COLOR_BUTTON "#197278"
+#define D_HTTP_COLOR_BUTTON_RESET "#c44536"
+*/
+#endif
\ No newline at end of file
From c818ad86800626f28544cd467efb7087ed84c78f Mon Sep 17 00:00:00 2001
From: arovak
Date: Mon, 5 Apr 2021 23:32:31 +0200
Subject: [PATCH 2/7] combine user_override files
---
include/user_config_override-template.h | 17 +++++
src/user_config_override_sample.h | 85 -------------------------
2 files changed, 17 insertions(+), 85 deletions(-)
delete mode 100644 src/user_config_override_sample.h
diff --git a/include/user_config_override-template.h b/include/user_config_override-template.h
index 2f1fd4a7..fd01a783 100644
--- a/include/user_config_override-template.h
+++ b/include/user_config_override-template.h
@@ -9,6 +9,8 @@
//
// To use: Save a copy as user_config_override.h
***************************************************/
+#ifndef HASP_USER_CONFIG_OVERRIDE_H
+#define HASP_USER_CONFIG_OVERRIDE_H
#define SERIAL_SPEED 115200
@@ -48,6 +50,19 @@
#define SYSLOG_PORT 514
#define APP_NAME "HASP"
+/***************************************************
+ * Timezone Settings
+ **************************************************/
+#define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3" // A full list with possible timezones can be found here https://gist.github.com/alwynallan/24d96091655391107939
+
+/***************************************************
+ * Interface Language Settings
+ **************************************************/
+#define HASP_LANGUAGE en_US // English
+// #define HASP_LANGUAGE nl_NL // Dutch
+// #define HASP_LANGUAGE hu_HU // Hungarian
+// #define HASP_LANGUAGE ro_RO // Romanian
+
/***************************************************
* Web interface coloring
**************************************************/
@@ -77,3 +92,5 @@
* Other Settings
**************************************************/
//#define HASP_USE_HA // Enable Home Assistant auto-discovery
+
+#endif
\ No newline at end of file
diff --git a/src/user_config_override_sample.h b/src/user_config_override_sample.h
deleted file mode 100644
index 25429883..00000000
--- a/src/user_config_override_sample.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef HASP_USER_CONFIG_OVERRIDE_H
-#define HASP_USER_CONFIG_OVERRIDE_H
-/***************************************************
- Setup WiFi Settings
- **************************************************/
-// #define WIFI_SSID "" // WiFi SSID
-// #define WIFI_PASSW "" // WiFi Password
-
-/***************************************************
- MQTT Settings
- **************************************************/
-// #define MQTT_HOST "" // MQTT server Address
-// #define MQTT_PORT 1883 // MQTT server Port
-// #define MQTT_USER "" // Optional Username
-// #define MQTT_PASSW "" // Optional Password
-// #define MQTT_GROUPNAME "plates" // MQTT Group topic for all plates to listen on, default: plates
-// #define MQTT_PREFIX "hasp" // Prefix for all MQTT topics, default: hasp
-
-/***************************************************
- SYSLOG Settings
- **************************************************/
-// #define SYSLOG_SERVER "" // Syslog server Address
-// #define SYSLOG_PORT 514 // Syslog server Port
-
-/***************************************************
- Timezone Settings
- **************************************************/
-// #define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3" // A full list with possible timezones can be found here https://gist.github.com/alwynallan/24d96091655391107939
-
-/***************************************************
- Interface Language Settings
- **************************************************/
-// #define HASP_LANGUAGE en_US // English
-// #define HASP_LANGUAGE nl_NL // Dutch
-// #define HASP_LANGUAGE hu_HU // Hungarian
-// #define HASP_LANGUAGE ro_RO // Romanian
-
-/***************************************************
- Web Interface Templates
- **************************************************/
-/*
-//default theme
-#define D_HTTP_COLOR_TEXT "#000" // Global text color - Black
-#define D_HTTP_COLOR_BACKGROUND "#fff" // Global background color - White
-#define D_HTTP_COLOR_INPUT_TEXT "#000" // Input text color - Black
-#define D_HTTP_COLOR_INPUT "#fff" // Input background color - White
-#define D_HTTP_COLOR_INPUT_WARNING "#f00" // Warning text color - Red
-#define D_HTTP_COLOR_BUTTON_TEXT "#fff" // Button text color - White
-#define D_HTTP_COLOR_BUTTON "#1fa3ec" // Button color - Vivid blue
-#define D_HTTP_COLOR_BUTTON_RESET "#f00" // Restart/Reset/Delete button color - red
-*/
-/*
-// Dark theme
-#define D_HTTP_COLOR_TEXT "#eaeaea" // Global text color - Very light gray
-#define D_HTTP_COLOR_BACKGROUND "#252525" // Global background color - Very dark gray (mostly black)
-#define D_HTTP_COLOR_INPUT_TEXT "#000" // Input text color - Black
-#define D_HTTP_COLOR_INPUT "#ddd" // Input background color - Very light gray
-#define D_HTTP_COLOR_INPUT_WARNING "#ff5661" // Warning text color - Brick Red
-#define D_HTTP_COLOR_BUTTON_TEXT "#faffff" // Button text color - Very pale (mostly white) cyan
-#define D_HTTP_COLOR_BUTTON "#1fa3ec" // Button color - Vivid blue
-#define D_HTTP_COLOR_BUTTON_RESET "#d43535" // Restart/Reset/Delete button color - Strong red
-*/
-/*
-// Purple theme
-#define D_HTTP_COLOR_TEXT "#eaeaea"
-#define D_HTTP_COLOR_BACKGROUND "#252525"
-#define D_HTTP_COLOR_INPUT_TEXT "#eaeaea"
-#define D_HTTP_COLOR_INPUT "#282531"
-#define D_HTTP_COLOR_INPUT_WARNING "#ff5661"
-#define D_HTTP_COLOR_BUTTON_TEXT "#faffff"
-#define D_HTTP_COLOR_BUTTON "#694fa8"
-#define D_HTTP_COLOR_BUTTON_RESET "#b73d5d"
-*/
-/*
-// Green theme
-#define D_HTTP_COLOR_TEXT "#edddd4"
-#define D_HTTP_COLOR_BACKGROUND "#283d3b"
-#define D_HTTP_COLOR_INPUT_TEXT "#edddd4"
-#define D_HTTP_COLOR_INPUT "#197278"
-#define D_HTTP_COLOR_INPUT_WARNING "#772e25"
-#define D_HTTP_COLOR_BUTTON_TEXT "#edddd4"
-#define D_HTTP_COLOR_BUTTON "#197278"
-#define D_HTTP_COLOR_BUTTON_RESET "#c44536"
-*/
-#endif
\ No newline at end of file
From b95e2d78f1387d1fc4b88853e40e9ee84d0a8149 Mon Sep 17 00:00:00 2001
From: arovak
Date: Mon, 5 Apr 2021 23:34:54 +0200
Subject: [PATCH 3/7] rearrange some includes and defines
---
src/dev/esp32/esp32.cpp | 3 ++-
src/sys/net/hasp_network.cpp | 7 ++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/dev/esp32/esp32.cpp b/src/dev/esp32/esp32.cpp
index 837a6bad..d591a407 100644
--- a/src/dev/esp32/esp32.cpp
+++ b/src/dev/esp32/esp32.cpp
@@ -7,13 +7,14 @@
#include
#include "esp_system.h"
+#include "hasp_conf.h"
+
#include "../device.h"
#include "esp32.h"
#include "driver/adc.h"
#include "esp_adc_cal.h"
-#include "hasp_conf.h"
#include "hasp_debug.h"
#include "hasp/hasp_utilities.h"
diff --git a/src/sys/net/hasp_network.cpp b/src/sys/net/hasp_network.cpp
index 1001a5d6..bdbc49c0 100644
--- a/src/sys/net/hasp_network.cpp
+++ b/src/sys/net/hasp_network.cpp
@@ -6,9 +6,6 @@
// #ifdef USE_CONFIG_OVERRIDE
// #include "user_config_override.h"
// #endif
-#ifndef MYTZ
-#define MYTZ "EST5EDT,M3.2.0/2,M11.1.0"
-#endif
#include
#include "ArduinoLog.h"
@@ -20,6 +17,10 @@
#include "hasp/hasp.h"
#include "sys/svc/hasp_mdns.h"
+#ifndef MYTZ
+#define MYTZ "EST5EDT,M3.2.0/2,M11.1.0"
+#endif
+
#if HASP_USE_ETHERNET > 0 || HASP_USE_WIFI > 0
void networkStart(void)
{
From 6abf19b1df41bdea4a6006ecf04b59bc758879df Mon Sep 17 00:00:00 2001
From: arovak
Date: Mon, 5 Apr 2021 23:35:20 +0200
Subject: [PATCH 4/7] allow MQTT_NODENAME override
---
src/dev/esp32/esp32.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/dev/esp32/esp32.h b/src/dev/esp32/esp32.h
index 7c2b6797..72dde072 100644
--- a/src/dev/esp32/esp32.h
+++ b/src/dev/esp32/esp32.h
@@ -15,7 +15,11 @@ class Esp32Device : public BaseDevice {
public:
Esp32Device()
{
+#ifdef MQTT_NODENAME
+ _hostname = MQTT_NODENAME;
+#else
_hostname = "plate";
+#endif
_backlight_power = 1;
_backlight_level = 100;
#ifdef TFT_BCKL
From 8022b03ae6269e530b52e57b88f6262d63d5fb70 Mon Sep 17 00:00:00 2001
From: fvanroie
Date: Tue, 6 Apr 2021 02:27:14 +0200
Subject: [PATCH 5/7] Fix HASwitchPlate/openHASP-custom-component#37
---
platformio.ini | 6 +++---
src/dev/esp32/esp32.cpp | 6 ++----
src/dev/esp8266/esp8266.cpp | 6 ++----
src/dev/posix/hasp_posix.cpp | 5 ++---
src/dev/stm32f4/stm32f4.cpp | 4 +---
src/dev/win32/hasp_win32.cpp | 5 ++---
src/hasp/hasp.cpp | 2 +-
src/hasp_oobe.cpp | 6 +++---
8 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/platformio.ini b/platformio.ini
index 04bf24c7..d58e177b 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -73,9 +73,9 @@ lib_deps =
git+https://github.com/fvanroie/ConsoleInput.git
;git+https://github.com/andrethomas/TasmotaSlave.git
;git+https://github.com/lvgl/lvgl.git
- lvgl/lvgl @^7.11.0 ; from PIO library
- ;bodmer/TFT_eSPI @ 2.3.4 ; Tft SPI drivers EXACT version 2.3.5 has compile error
- git+https://github.com/Bodmer/TFT_eSPI.git
+ lvgl/lvgl@^7.11.0 ; from PIO library
+ bodmer/TFT_eSPI^2.3.61 ; Tft SPI drivers EXACT version 2.3.5 has compile error
+ ;git+https://github.com/Bodmer/TFT_eSPI.git
; ------ Unused / Test libraries
;https://github.com/netwizeBE/TFT_eSPI.git
;Syslog@^2.0.0 ; Obsoleted
diff --git a/src/dev/esp32/esp32.cpp b/src/dev/esp32/esp32.cpp
index d591a407..8835cb9f 100644
--- a/src/dev/esp32/esp32.cpp
+++ b/src/dev/esp32/esp32.cpp
@@ -91,9 +91,7 @@ void Esp32Device::set_backlight_pin(uint8_t pin)
void Esp32Device::set_backlight_level(uint8_t level)
{
- _backlight_level = level >= 0 ? level : 0;
- _backlight_level = _backlight_level <= 100 ? _backlight_level : 100;
-
+ _backlight_level = level;
update_backlight();
}
@@ -116,7 +114,7 @@ bool Esp32Device::get_backlight_power()
void Esp32Device::update_backlight()
{
if(_backlight_pin < GPIO_NUM_MAX) {
- uint32_t duty = _backlight_power ? map(_backlight_level, 0, 100, 0, 4095) : 0;
+ uint32_t duty = _backlight_power ? map(_backlight_level, 0, 255, 0, 4095) : 0;
ledcWrite(BACKLIGHT_CHANNEL, duty); // ledChannel and value
}
}
diff --git a/src/dev/esp8266/esp8266.cpp b/src/dev/esp8266/esp8266.cpp
index 9b8c5ec3..b3e53837 100644
--- a/src/dev/esp8266/esp8266.cpp
+++ b/src/dev/esp8266/esp8266.cpp
@@ -60,9 +60,7 @@ void Esp8266Device::set_backlight_pin(uint8_t pin)
void Esp8266Device::set_backlight_level(uint8_t level)
{
- _backlight_level = level >= 0 ? level : 0;
- _backlight_level = _backlight_level <= 100 ? _backlight_level : 100;
-
+ _backlight_level = level;
update_backlight();
}
@@ -86,7 +84,7 @@ void Esp8266Device::update_backlight()
{
if(_backlight_pin == -1) return;
- analogWrite(_backlight_pin, _backlight_power ? map(_backlight_level, 0, 100, 0, 1023) : 0);
+ analogWrite(_backlight_pin, _backlight_power ? map(_backlight_level, 0, 255, 0, 1023) : 0);
}
size_t Esp8266Device::get_free_max_block()
diff --git a/src/dev/posix/hasp_posix.cpp b/src/dev/posix/hasp_posix.cpp
index 8884861a..01c7397b 100644
--- a/src/dev/posix/hasp_posix.cpp
+++ b/src/dev/posix/hasp_posix.cpp
@@ -88,8 +88,7 @@ void PosixDevice::set_backlight_pin(uint8_t pin)
void PosixDevice::set_backlight_level(uint8_t level)
{
- uint8_t new_level = level >= 0 ? level : 0;
- new_level = new_level <= 100 ? new_level : 100;
+ uint8_t new_level = level;
if(_backlight_level != new_level) {
_backlight_level = new_level;
@@ -115,7 +114,7 @@ bool PosixDevice::get_backlight_power()
void PosixDevice::update_backlight()
{
- uint8_t level = _backlight_power ? map(_backlight_level, 0, 100, 0, 255) : 0;
+ uint8_t level = _backlight_power ? _backlight_level : 0;
monitor_backlight(level);
// SDL_SetTextureColorMod(monitor.texture, level, level, level);
// window_update(&monitor);
diff --git a/src/dev/stm32f4/stm32f4.cpp b/src/dev/stm32f4/stm32f4.cpp
index 41df3ad3..f9bb220e 100644
--- a/src/dev/stm32f4/stm32f4.cpp
+++ b/src/dev/stm32f4/stm32f4.cpp
@@ -71,9 +71,7 @@ const char* Stm32f4Device::get_chip_model()
void Stm32f4Device::set_backlight_level(uint8_t level)
{
- _backlight_level = level >= 0 ? level : 0;
- _backlight_level = _backlight_level <= 100 ? _backlight_level : 100;
-
+ _backlight_level = level;
update_backlight();
}
diff --git a/src/dev/win32/hasp_win32.cpp b/src/dev/win32/hasp_win32.cpp
index be465952..47733d63 100644
--- a/src/dev/win32/hasp_win32.cpp
+++ b/src/dev/win32/hasp_win32.cpp
@@ -68,8 +68,7 @@ void Win32Device::set_backlight_pin(uint8_t pin)
void Win32Device::set_backlight_level(uint8_t level)
{
- uint8_t new_level = level >= 0 ? level : 0;
- new_level = new_level <= 100 ? new_level : 100;
+ uint8_t new_level = level;
if(_backlight_level != new_level) {
_backlight_level = new_level;
@@ -95,7 +94,7 @@ bool Win32Device::get_backlight_power()
void Win32Device::update_backlight()
{
- uint8_t level = _backlight_power ? map(_backlight_level, 0, 100, 0, 255) : 0;
+ uint8_t level = _backlight_power ? _backlight_level : 0;
monitor_backlight(level);
}
diff --git a/src/hasp/hasp.cpp b/src/hasp/hasp.cpp
index d2be0930..f4d1f368 100644
--- a/src/hasp/hasp.cpp
+++ b/src/hasp/hasp.cpp
@@ -81,7 +81,7 @@ uint8_t hasp_sleep_state = HASP_SLEEP_OFF; // Used in hasp_drv_touch.cpp
static uint16_t sleepTimeShort = 60; // 1 second resolution
static uint16_t sleepTimeLong = 120; // 1 second resolution
-uint8_t haspStartDim = 100;
+uint8_t haspStartDim = 255;
uint8_t haspStartPage = 1;
uint8_t haspThemeId = 2;
uint16_t haspThemeHue = 200;
diff --git a/src/hasp_oobe.cpp b/src/hasp_oobe.cpp
index 562753a0..b8cb1b8e 100644
--- a/src/hasp_oobe.cpp
+++ b/src/hasp_oobe.cpp
@@ -288,7 +288,7 @@ static void oobe_calibrate_cb(lv_obj_t* ta, lv_event_t event)
{
if(event == LV_EVENT_CLICKED) {
if(oobeAutoCalibrate) {
- haspDevice.set_backlight_level(100);
+ haspDevice.set_backlight_level(255);
guiCalibrate();
oobeAutoCalibrate = false;
lv_obj_set_click(lv_disp_get_layer_sys(NULL), true);
@@ -316,7 +316,7 @@ bool oobeSetup()
char pass[32];
if(wifiShowAP(ssid, pass)) {
- haspDevice.set_backlight_level(100);
+ haspDevice.set_backlight_level(255);
oobeSetupQR(ssid, pass);
oobeSetupSsid();
@@ -344,7 +344,7 @@ void oobeFakeSetup(const char*, const char*)
char ssid[32] = "HASP-ABCDEF";
char pass[32] = "haspadmin";
- haspDevice.set_backlight_level(100);
+ haspDevice.set_backlight_level(255);
oobeSetupQR(ssid, pass);
oobeSetupSsid();
oobeSetPage(0);
From e83d6c6ba622b225a3adc0c64c0a832e51d3331b Mon Sep 17 00:00:00 2001
From: fvanroie
Date: Tue, 6 Apr 2021 02:30:07 +0200
Subject: [PATCH 6/7] Allow startDim 0-255 and startPage 1-12
---
src/sys/svc/hasp_http.cpp | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp
index ca90ff14..a263f6a7 100644
--- a/src/sys/svc/hasp_http.cpp
+++ b/src/sys/svc/hasp_http.cpp
@@ -30,6 +30,7 @@
// #include "user_config_override.h"
// #endif
+/* clang-format off */
//default theme
#ifndef D_HTTP_COLOR_TEXT
#define D_HTTP_COLOR_TEXT "#000" // Global text color - Black
@@ -55,6 +56,7 @@
#ifndef D_HTTP_COLOR_BUTTON_RESET
#define D_HTTP_COLOR_BUTTON_RESET "#f00" // Restart/Reset button color - red
#endif
+/* clang-format on */
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
File fsUploadFile;
@@ -119,8 +121,10 @@ const char HTTP_STYLE[] PROGMEM =
"select{background-color:" D_HTTP_COLOR_INPUT ";color:" D_HTTP_COLOR_INPUT_TEXT ";}"
"input:invalid{border:1px solid " D_HTTP_COLOR_INPUT_WARNING ";}"
//"#hue{width:100%;}"
- "body{font-family:verdana;width:60%;margin:auto;background:" D_HTTP_COLOR_BACKGROUND ";color:" D_HTTP_COLOR_TEXT ";}"
- "button{border:0;border-radius:0.6rem;background-color:" D_HTTP_COLOR_BUTTON ";color:" D_HTTP_COLOR_BUTTON_TEXT ";line-height:2.4rem;font-size:1.2rem;"
+ "body{font-family:verdana;width:60%;margin:auto;background:" D_HTTP_COLOR_BACKGROUND ";color:" D_HTTP_COLOR_TEXT
+ ";}"
+ "button{border:0;border-radius:0.6rem;background-color:" D_HTTP_COLOR_BUTTON ";color:" D_HTTP_COLOR_BUTTON_TEXT
+ ";line-height:2.4rem;font-size:1.2rem;"
"width:100%;}"
//".q{float:right;width:64px;text-align:right;}"
".red{background-color:" D_HTTP_COLOR_BUTTON_RESET ";}"
@@ -1757,11 +1761,11 @@ void webHandleHaspConfig()
httpMessage += settings[FPSTR(FP_CONFIG_PAGES)].as();
httpMessage += F("'>Startup Page (required)
Startup Brightness (required)
");
From f41625894eb369f9e53eee65451d969ea8aebbc1 Mon Sep 17 00:00:00 2001
From: fvanroie
Date: Tue, 6 Apr 2021 02:40:53 +0200
Subject: [PATCH 7/7] Bump tft_espi library version
---
platformio.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/platformio.ini b/platformio.ini
index d58e177b..375b434e 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -74,7 +74,7 @@ lib_deps =
;git+https://github.com/andrethomas/TasmotaSlave.git
;git+https://github.com/lvgl/lvgl.git
lvgl/lvgl@^7.11.0 ; from PIO library
- bodmer/TFT_eSPI^2.3.61 ; Tft SPI drivers EXACT version 2.3.5 has compile error
+ bodmer/TFT_eSPI@^2.3.62 ; Tft SPI drivers EXACT version 2.3.5 has compile error
;git+https://github.com/Bodmer/TFT_eSPI.git
; ------ Unused / Test libraries
;https://github.com/netwizeBE/TFT_eSPI.git