From 04d970f529f297482bd715c2d5fc72e7155246d3 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Thu, 15 Apr 2021 17:15:47 +0200 Subject: [PATCH] Move defines to hasp_conf.h --- include/hasp_conf.h | 13 +++++++++++++ src/dev/esp32/esp32.h | 13 +------------ src/dev/esp8266/esp8266.h | 10 +++------- src/dev/stm32f4/stm32f4.h | 8 ++------ 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/include/hasp_conf.h b/include/hasp_conf.h index d6f82f2f..8e2d833e 100644 --- a/include/hasp_conf.h +++ b/include/hasp_conf.h @@ -8,6 +8,15 @@ // language specific defines #include "lang/lang.h" +// TFT defines +#ifndef TFT_BACKLIGHT_ON +#define TFT_BACKLIGHT_ON LOW +#endif + +#ifndef TFT_BCKL +#define TFT_BCKL -1 +#endif + #define HASP_USE_APP 1 #ifndef HASP_USE_DEBUG @@ -34,6 +43,10 @@ #define HASP_USE_MQTT (HASP_HAS_NETWORK) #endif +#ifndef MQTT_NODENAME +#define MQTT_NODENAME "plate" +#endif + #ifndef HASP_USE_HTTP #define HASP_USE_HTTP (HASP_HAS_NETWORK) #endif diff --git a/src/dev/esp32/esp32.h b/src/dev/esp32/esp32.h index 8633748a..4eaff04f 100644 --- a/src/dev/esp32/esp32.h +++ b/src/dev/esp32/esp32.h @@ -4,22 +4,11 @@ #ifndef HASP_DEVICE_ESP32_H #define HASP_DEVICE_ESP32_H +#include "hasp_conf.h" #include "../device.h" #if defined(ESP32) -#ifndef TFT_BACKLIGHT_ON -#define TFT_BACKLIGHT_ON LOW -#endif - -#ifndef MQTT_NODENAME -#define MQTT_NODENAME "plate" -#endif - -#ifndef TFT_BCKL -#define TFT_BCKL -1 -#endif - namespace dev { class Esp32Device : public BaseDevice { diff --git a/src/dev/esp8266/esp8266.h b/src/dev/esp8266/esp8266.h index bd1502ae..8980bd43 100644 --- a/src/dev/esp8266/esp8266.h +++ b/src/dev/esp8266/esp8266.h @@ -16,16 +16,12 @@ class Esp8266Device : public BaseDevice { public: Esp8266Device() { - _hostname = "plate"; + _hostname = MQTT_NODENAME; + _backlight_invert = (TFT_BACKLIGHT_ON == LOW); _backlight_power = 1; - _backlight_invert = 0; _backlight_level = 100; _core_version = ESP.getCoreVersion().c_str(); -#ifdef TFT_BCKL - _backlight_pin = TFT_BCKL; -#else - _backlight_pin = -1; -#endif + _backlight_pin = TFT_BCKL; } void reboot() override; diff --git a/src/dev/stm32f4/stm32f4.h b/src/dev/stm32f4/stm32f4.h index d9903f17..007b4eeb 100644 --- a/src/dev/stm32f4/stm32f4.h +++ b/src/dev/stm32f4/stm32f4.h @@ -16,15 +16,11 @@ class Stm32f4Device : public BaseDevice { public: Stm32f4Device() { - _hostname = "plate"; + _hostname = MQTT_NODENAME; _backlight_power = 1; _backlight_invert = 0; _backlight_level = 100; -#ifdef TFT_BCKL - _backlight_pin = TFT_BCKL; -#else - _backlight_pin = -1; -#endif + _backlight_pin = TFT_BCKL; } void reboot() override;