Sensor types are defined in platformio.ini

This commit is contained in:
Ollo 2022-03-06 14:25:14 +01:00
parent 9a172c269e
commit 6c475a2ade
4 changed files with 48 additions and 7 deletions

View File

@ -27,6 +27,8 @@
#define NUMBER_TYPE "Float" /**< numberic information, published or read in Homie */ #define NUMBER_TYPE "Float" /**< numberic information, published or read in Homie */
/** /**
* @}
*
* @name Temperatur Node * @name Temperatur Node
* @{ * @{
**/ **/

View File

@ -13,12 +13,22 @@
#include <Homie.h> #include <Homie.h>
/**
* @name Sensor types
* possible sensors:
* @{
**/
#define FOREACH_SENSOR(SENSOR) \ #define FOREACH_SENSOR(SENSOR) \
SENSOR(NONE) \ SENSOR(NONE) \
SENSOR(CAPACITIVE_FREQUENCY) \ SENSOR(CAPACITIVE_FREQUENCY) \
SENSOR(ANALOG_RESISTANCE_PROBE) \ SENSOR(ANALOG_RESISTANCE_PROBE) \
SENSOR(SHT20) SENSOR(SHT20)
/**
* @}
*/
#define GENERATE_ENUM(ENUM) ENUM, #define GENERATE_ENUM(ENUM) ENUM,
#define GENERATE_STRING(STRING) #STRING, #define GENERATE_STRING(STRING) #STRING,

View File

@ -13,6 +13,13 @@ platform = espressif32
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1
framework = arduino framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY 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 board_build.partitions = defaultWithSmallerSpiffs.csv

View File

@ -92,14 +92,36 @@ DallasTemperature sensors(&oneWire);
DS2438 battery(&oneWire, 0.0333333f, AMOUNT_SENOR_QUERYS); DS2438 battery(&oneWire, 0.0333333f, AMOUNT_SENOR_QUERYS);
VL53L0X tankSensor; 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 mPlants[MAX_PLANTS] = {
Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0, SHT20), Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0, PLANT0_SENSORTYPE),
Plant(SENSOR_PLANT1, OUTPUT_PUMP1, 1, &plant1, &mSetting1, ANALOG_RESISTANCE_PROBE), Plant(SENSOR_PLANT1, OUTPUT_PUMP1, 1, &plant1, &mSetting1, PLANT1_SENSORTYPE),
Plant(SENSOR_PLANT2, OUTPUT_PUMP2, 2, &plant2, &mSetting2, CAPACITIVE_FREQUENCY), Plant(SENSOR_PLANT2, OUTPUT_PUMP2, 2, &plant2, &mSetting2, PLANT2_SENSORTYPE),
Plant(SENSOR_PLANT3, OUTPUT_PUMP3, 3, &plant3, &mSetting3, CAPACITIVE_FREQUENCY), Plant(SENSOR_PLANT3, OUTPUT_PUMP3, 3, &plant3, &mSetting3, PLANT3_SENSORTYPE),
Plant(SENSOR_PLANT4, OUTPUT_PUMP4, 4, &plant4, &mSetting4, CAPACITIVE_FREQUENCY), Plant(SENSOR_PLANT4, OUTPUT_PUMP4, 4, &plant4, &mSetting4, PLANT4_SENSORTYPE),
Plant(SENSOR_PLANT5, OUTPUT_PUMP5, 5, &plant5, &mSetting5, CAPACITIVE_FREQUENCY), Plant(SENSOR_PLANT5, OUTPUT_PUMP5, 5, &plant5, &mSetting5, PLANT5_SENSORTYPE),
Plant(SENSOR_PLANT6, OUTPUT_PUMP6, 6, &plant6, &mSetting6, CAPACITIVE_FREQUENCY)}; Plant(SENSOR_PLANT6, OUTPUT_PUMP6, 6, &plant6, &mSetting6, PLANT6_SENSORTYPE)};
/****************************************************************************** /******************************************************************************
* LOCAL FUNCTIONS * LOCAL FUNCTIONS