From 45a451c830add0415fbf13bfbbae735eb805a712 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Fri, 8 Oct 2021 18:59:41 +0200 Subject: [PATCH] Change HASP_USE_CUSTOM > 0 to defined(HASP_USE_CUSTOM) --- include/hasp_conf.h | 6 +++--- src/custom/my_custom_fan_template.cpp | 2 +- src/custom/my_custom_template.cpp | 2 +- src/custom/my_custom_template.h | 2 +- src/hasp/hasp_dispatch.cpp | 6 +++--- src/main_arduino.cpp | 10 +++++----- src/main_sdl2.cpp | 10 +++++----- src/mqtt/hasp_mqtt_paho_single.cpp | 2 +- src/mqtt/hasp_mqtt_pubsubclient.cpp | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/hasp_conf.h b/include/hasp_conf.h index 2c728161..138d57ce 100644 --- a/include/hasp_conf.h +++ b/include/hasp_conf.h @@ -145,9 +145,9 @@ #define HASP_NUM_GPIO_CONFIG 8 #endif -#ifndef HASP_USE_CUSTOM -#define HASP_USE_CUSTOM 0 -#endif +// #ifndef HASP_USE_CUSTOM +// #define HASP_USE_CUSTOM 0 +// #endif // #ifndef HASP_NUM_OUTPUTS // #define HASP_NUM_OUTPUTS 3 diff --git a/src/custom/my_custom_fan_template.cpp b/src/custom/my_custom_fan_template.cpp index 60f007a5..8fce2f9f 100644 --- a/src/custom/my_custom_fan_template.cpp +++ b/src/custom/my_custom_fan_template.cpp @@ -3,7 +3,7 @@ #include "hasplib.h" -#if HASP_USE_CUSTOM > 0 && false // <-- set this to true in your code +#if defined(HASP_USE_CUSTOM) && false // <-- set this to true in your code #include "custom/my_custom.h" diff --git a/src/custom/my_custom_template.cpp b/src/custom/my_custom_template.cpp index fdb5b38b..1bfd6503 100644 --- a/src/custom/my_custom_template.cpp +++ b/src/custom/my_custom_template.cpp @@ -3,7 +3,7 @@ #include "hasplib.h" -#if HASP_USE_CUSTOM > 0 && false // <-- set this to true in your code +#if defined(HASP_USE_CUSTOM) && false // <-- set this to true in your code #include "custom/my_custom.h" diff --git a/src/custom/my_custom_template.h b/src/custom/my_custom_template.h index c7511791..3538c4ad 100644 --- a/src/custom/my_custom_template.h +++ b/src/custom/my_custom_template.h @@ -5,7 +5,7 @@ #define HASP_CUSTOM_H #include "hasplib.h" -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) /* This function is called at boot */ void custom_setup(); diff --git a/src/hasp/hasp_dispatch.cpp b/src/hasp/hasp_dispatch.cpp index 28792d52..bd329b43 100644 --- a/src/hasp/hasp_dispatch.cpp +++ b/src/hasp/hasp_dispatch.cpp @@ -40,7 +40,7 @@ #include "hasp_config.h" #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) #include "custom/my_custom.h" #endif @@ -340,7 +340,7 @@ void dispatch_topic_payload(const char* topic, const char* payload, bool update, } #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) if(topic == strstr_P(topic, PSTR(MQTT_TOPIC_CUSTOM "/"))) { // startsWith custom topic += 7u; custom_topic_payload(topic, (char*)payload, source); @@ -1001,7 +1001,7 @@ void dispatch_send_sensordata(const char*, const char*, uint8_t source) haspDevice.get_sensors(doc); -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_get_sensors(doc); #endif diff --git a/src/main_arduino.cpp b/src/main_arduino.cpp index 44a6633d..441d66d5 100644 --- a/src/main_arduino.cpp +++ b/src/main_arduino.cpp @@ -20,7 +20,7 @@ #include "hasp_gui.h" #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) #include "custom/my_custom.h" #endif @@ -110,7 +110,7 @@ void setup() slaveSetup(); #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_setup(); #endif @@ -145,7 +145,7 @@ IRAM_ATTR void loop() consoleLoop(); #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_loop(); #endif @@ -164,7 +164,7 @@ IRAM_ATTR void loop() telnetEverySecond(); #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_every_second(); #endif // debugEverySecond(); @@ -185,7 +185,7 @@ IRAM_ATTR void loop() // gpioEvery5Seconds(); #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_every_5seconds(); #endif break; diff --git a/src/main_sdl2.cpp b/src/main_sdl2.cpp index 6c13c973..1d3456ae 100644 --- a/src/main_sdl2.cpp +++ b/src/main_sdl2.cpp @@ -36,7 +36,7 @@ #include "dev/device.h" -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) #include "custom/my_custom.h" #endif @@ -142,7 +142,7 @@ void setup() gpioSetup(); #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_setup(); #endif @@ -164,7 +164,7 @@ void loop() gpioLoop(); #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_loop(); #endif @@ -178,7 +178,7 @@ void loop() otaEverySecond(); // progressbar #endif -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_every_second(); #endif @@ -188,7 +188,7 @@ void loop() haspDevice.loop_5s(); gpioEvery5Seconds(); -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) custom_every_5seconds(); #endif } diff --git a/src/mqtt/hasp_mqtt_paho_single.cpp b/src/mqtt/hasp_mqtt_paho_single.cpp index 6f55dc7f..f2fc0c3a 100644 --- a/src/mqtt/hasp_mqtt_paho_single.cpp +++ b/src/mqtt/hasp_mqtt_paho_single.cpp @@ -264,7 +264,7 @@ static void onConnect(void* context) topic = mqttNodeTopic + "config/#"; mqtt_subscribe(mqtt_client, topic.c_str()); -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) topic = mqttGroupTopic + MQTT_TOPIC_CUSTOM "/#"; mqtt_subscribe(mqtt_client, topic.c_str()); diff --git a/src/mqtt/hasp_mqtt_pubsubclient.cpp b/src/mqtt/hasp_mqtt_pubsubclient.cpp index a2f964fd..69f3759d 100644 --- a/src/mqtt/hasp_mqtt_pubsubclient.cpp +++ b/src/mqtt/hasp_mqtt_pubsubclient.cpp @@ -300,7 +300,7 @@ void mqttStart() snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CONFIG "/#"), mqttNodeTopic); mqttSubscribeTo(topic); -#if HASP_USE_CUSTOM > 0 +#if defined(HASP_USE_CUSTOM) snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CUSTOM "/#"), mqttGroupTopic); mqttSubscribeTo(topic); snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CUSTOM "/#"), mqttNodeTopic);