From 6c475a2adef7dbe4b17d19d6c28ac829ec6f4b9d Mon Sep 17 00:00:00 2001 From: Ollo Date: Sun, 6 Mar 2022 14:25:14 +0100 Subject: [PATCH] Sensor types are defined in platformio.ini --- esp32/include/HomieConfiguration.h | 2 ++ esp32/include/HomieTypes.h | 10 +++++++++ esp32/platformio.ini | 7 ++++++ esp32/src/main.cpp | 36 ++++++++++++++++++++++++------ 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/esp32/include/HomieConfiguration.h b/esp32/include/HomieConfiguration.h index 124d166..23dc690 100644 --- a/esp32/include/HomieConfiguration.h +++ b/esp32/include/HomieConfiguration.h @@ -27,6 +27,8 @@ #define NUMBER_TYPE "Float" /**< numberic information, published or read in Homie */ /** + * @} + * * @name Temperatur Node * @{ **/ diff --git a/esp32/include/HomieTypes.h b/esp32/include/HomieTypes.h index 4fae0cc..3105f2d 100644 --- a/esp32/include/HomieTypes.h +++ b/esp32/include/HomieTypes.h @@ -13,12 +13,22 @@ #include +/** + * @name Sensor types + * possible sensors: + * @{ + **/ + #define FOREACH_SENSOR(SENSOR) \ SENSOR(NONE) \ SENSOR(CAPACITIVE_FREQUENCY) \ SENSOR(ANALOG_RESISTANCE_PROBE) \ SENSOR(SHT20) +/** + * @} + */ + #define GENERATE_ENUM(ENUM) ENUM, #define GENERATE_STRING(STRING) #STRING, diff --git a/esp32/platformio.ini b/esp32/platformio.ini index 28cdfff..39ddff5 100644 --- a/esp32/platformio.ini +++ b/esp32/platformio.ini @@ -13,6 +13,13 @@ platform = espressif32 board = esp32doit-devkit-v1 framework = arduino build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY + -DPLANT0_SENSORTYPE=SHT20 + -DPLANT1_SENSORTYPE=ANALOG_RESISTANCE_PROBE + -DPLANT2_SENSORTYPE=CAPACITIVE_FREQUENCY + -DPLANT3_SENSORTYPE=CAPACITIVE_FREQUENCY + -DPLANT4_SENSORTYPE=CAPACITIVE_FREQUENCY + -DPLANT5_SENSORTYPE=CAPACITIVE_FREQUENCY + -DPLANT6_SENSORTYPE=CAPACITIVE_FREQUENCY board_build.partitions = defaultWithSmallerSpiffs.csv diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index be66d78..80df651 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -92,14 +92,36 @@ DallasTemperature sensors(&oneWire); DS2438 battery(&oneWire, 0.0333333f, AMOUNT_SENOR_QUERYS); VL53L0X tankSensor; +#ifndef PLANT0_SENSORTYPE +#error "Sensor type must be specified, see HomieTypes.h - Sensor types" +#endif +#ifndef PLANT1_SENSORTYPE +#error "Sensor type must be specified, see HomieTypes.h - Sensor types" +#endif +#ifndef PLANT2_SENSORTYPE +#error "Sensor type must be specified, see HomieTypes.h - Sensor types" +#endif +#ifndef PLANT3_SENSORTYPE +#error "Sensor type must be specified, see HomieTypes.h - Sensor types" +#endif +#ifndef PLANT4_SENSORTYPE +#error "Sensor type must be specified, see HomieTypes.h - Sensor types" +#endif +#ifndef PLANT5_SENSORTYPE +#error "Sensor type must be specified, see HomieTypes.h - Sensor types" +#endif +#ifndef PLANT6_SENSORTYPE +#error "Sensor type must be specified, see HomieTypes.h - Sensor types" +#endif + Plant mPlants[MAX_PLANTS] = { - Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0, SHT20), - Plant(SENSOR_PLANT1, OUTPUT_PUMP1, 1, &plant1, &mSetting1, ANALOG_RESISTANCE_PROBE), - Plant(SENSOR_PLANT2, OUTPUT_PUMP2, 2, &plant2, &mSetting2, CAPACITIVE_FREQUENCY), - Plant(SENSOR_PLANT3, OUTPUT_PUMP3, 3, &plant3, &mSetting3, CAPACITIVE_FREQUENCY), - Plant(SENSOR_PLANT4, OUTPUT_PUMP4, 4, &plant4, &mSetting4, CAPACITIVE_FREQUENCY), - Plant(SENSOR_PLANT5, OUTPUT_PUMP5, 5, &plant5, &mSetting5, CAPACITIVE_FREQUENCY), - Plant(SENSOR_PLANT6, OUTPUT_PUMP6, 6, &plant6, &mSetting6, CAPACITIVE_FREQUENCY)}; + Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0, PLANT0_SENSORTYPE), + Plant(SENSOR_PLANT1, OUTPUT_PUMP1, 1, &plant1, &mSetting1, PLANT1_SENSORTYPE), + Plant(SENSOR_PLANT2, OUTPUT_PUMP2, 2, &plant2, &mSetting2, PLANT2_SENSORTYPE), + Plant(SENSOR_PLANT3, OUTPUT_PUMP3, 3, &plant3, &mSetting3, PLANT3_SENSORTYPE), + Plant(SENSOR_PLANT4, OUTPUT_PUMP4, 4, &plant4, &mSetting4, PLANT4_SENSORTYPE), + Plant(SENSOR_PLANT5, OUTPUT_PUMP5, 5, &plant5, &mSetting5, PLANT5_SENSORTYPE), + Plant(SENSOR_PLANT6, OUTPUT_PUMP6, 6, &plant6, &mSetting6, PLANT6_SENSORTYPE)}; /****************************************************************************** * LOCAL FUNCTIONS