This commit is contained in:
fvanroie 2021-04-06 03:31:47 +02:00
commit 5759c1b51a
18 changed files with 80 additions and 51 deletions

View File

@ -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"

View File

@ -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

View File

@ -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.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
;Syslog@^2.0.0 ; Obsoleted

View File

@ -7,13 +7,14 @@
#include <Esp.h>
#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"
@ -90,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();
}
@ -115,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
}
}

View File

@ -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

View File

@ -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()

View File

@ -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);

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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 "********"

View File

@ -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

View File

@ -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

View File

@ -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];

View File

@ -3,12 +3,9 @@
#include <time.h>
#include <sys/time.h>
#ifdef USE_CONFIG_OVERRIDE
#include "user_config_override.h"
#endif
#ifndef MYTZ
#define MYTZ "EST5EDT,M3.2.0/2,M11.1.0"
#endif
// #ifdef USE_CONFIG_OVERRIDE
// #include "user_config_override.h"
// #endif
#include <Arduino.h>
#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)
{

View File

@ -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;

View File

@ -26,10 +26,11 @@
#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
/* 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<String>();
httpMessage += F("'></br><b>Startup Page</b> <i><small>(required)</small></i><input id='startpage' required "
"name='startpage' type='number' min='1' max='4' value='");
"name='startpage' type='number' min='1' max='12' value='");
httpMessage += settings[FPSTR(FP_CONFIG_STARTPAGE)].as<String>();
httpMessage +=
F("'></p><p><b>Startup Brightness</b> <i><small>(required)</small></i><input id='startpage' required "
"name='startdim' type='number' min='0' max='100' value='");
"name='startdim' type='number' min='0' max='255' value='");
httpMessage += settings[FPSTR(FP_CONFIG_STARTDIM)].as<String>();
httpMessage += F("'></p>");