mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 03:36:42 +00:00
Merge pull request #9627 from tichris0/development
Cleanup the EZO devices
This commit is contained in:
commit
05b19062d6
@ -567,7 +567,7 @@
|
|||||||
// #define USE_EZORTD // [I2cDriver55] Enable support for EZO's RTD sensor (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
|
// #define USE_EZORTD // [I2cDriver55] Enable support for EZO's RTD sensor (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||||
// #define USE_EZOHUM // [I2cDriver55] Enable support for EZO's HUM sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
// #define USE_EZOHUM // [I2cDriver55] Enable support for EZO's HUM sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||||
// #define USE_EZOEC // [I2cDriver55] Enable support for EZO's EC sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
// #define USE_EZOEC // [I2cDriver55] Enable support for EZO's EC sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||||
// #define USE_EZOCO2 // [I2cDriver55] Enable support for EZO's CO2 sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
// #define USE_EZOCO2 // [I2cDriver55] Enable support for EZO's CO2 sensor (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||||
|
|
||||||
// #define USE_DISPLAY // Add I2C Display Support (+2k code)
|
// #define USE_DISPLAY // Add I2C Display Support (+2k code)
|
||||||
#define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0
|
#define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
//#define USE_EZORTD // [I2cDriver55] Enable support for EZO's RTD sensor (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
|
//#define USE_EZORTD // [I2cDriver55] Enable support for EZO's RTD sensor (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||||
//#define USE_EZOHUM // [I2cDriver55] Enable support for EZO's HUM sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
//#define USE_EZOHUM // [I2cDriver55] Enable support for EZO's HUM sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||||
//#define USE_EZOEC // [I2cDriver55] Enable support for EZO's EC sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
//#define USE_EZOEC // [I2cDriver55] Enable support for EZO's EC sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||||
//#define USE_EZOCO2 // [I2cDriver55] Enable support for EZO's CO2 sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code)
|
//#define USE_EZOCO2 // [I2cDriver55] Enable support for EZO's CO2 sensor (+0k2 code) - Shared EZO code required for any EZO device (+1k2 code)
|
||||||
|
|
||||||
#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code)
|
#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code)
|
||||||
#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code)
|
#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code)
|
||||||
|
@ -80,6 +80,8 @@ struct EZOStruct {
|
|||||||
virtual void ProcessMeasurement(void);
|
virtual void ProcessMeasurement(void);
|
||||||
virtual void Show(bool json, const char *name);
|
virtual void Show(bool json, const char *name);
|
||||||
|
|
||||||
|
static const char id[] PROGMEM;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMeasurement(char *const data, const uint32_t len, const uint32_t latency)
|
void ProcessMeasurement(char *const data, const uint32_t len, const uint32_t latency)
|
||||||
{
|
{
|
||||||
@ -108,7 +110,7 @@ protected:
|
|||||||
uint32_t lastRead;
|
uint32_t lastRead;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char EZOStruct::id[] PROGMEM = "";
|
||||||
|
|
||||||
#endif // USE_EZO
|
#endif // USE_EZO
|
||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
@ -49,9 +49,13 @@ struct EZOCO2 : public EZOStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char id[] PROGMEM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t CO2;
|
uint16_t CO2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char EZOCO2::id[] PROGMEM = "CO2";
|
||||||
|
|
||||||
#endif // USE_EZOCO2
|
#endif // USE_EZOCO2
|
||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
xsns_78_ezoph.ino - EZO EC I2C EC sensor support for Tasmota
|
xsns_78_ezoec.ino - EZO EC I2C EC sensor support for Tasmota
|
||||||
|
|
||||||
Copyright (C) 2020 Christopher Tremblay
|
Copyright (C) 2020 Christopher Tremblay
|
||||||
|
|
||||||
@ -35,8 +35,8 @@ struct EZOEC : public EZOStruct {
|
|||||||
|
|
||||||
virtual void Show(bool json, const char *name)
|
virtual void Show(bool json, const char *name)
|
||||||
{
|
{
|
||||||
char str[6];
|
char str[10];
|
||||||
dtostrfd(EC, 2, str);
|
dtostrfd(EC, 3, str);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_EC "\":%s}" ), name, str);
|
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_EC "\":%s}" ), name, str);
|
||||||
@ -48,9 +48,13 @@ struct EZOEC : public EZOStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char id[] PROGMEM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float EC;
|
float EC;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char EZOEC::id[] PROGMEM = "EC";
|
||||||
|
|
||||||
#endif // USE_EZOEC
|
#endif // USE_EZOEC
|
||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
@ -52,10 +52,14 @@ struct EZOHUM : public EZOStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char id[] PROGMEM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float humidity;
|
float humidity;
|
||||||
float temperature;
|
float temperature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char EZOHUM::id[] PROGMEM = "HUM";
|
||||||
|
|
||||||
#endif // USE_EZOHUM
|
#endif // USE_EZOHUM
|
||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
@ -35,8 +35,8 @@ struct EZOORP : public EZOStruct {
|
|||||||
|
|
||||||
virtual void Show(bool json, const char *name)
|
virtual void Show(bool json, const char *name)
|
||||||
{
|
{
|
||||||
char str[6];
|
char str[8];
|
||||||
dtostrfd(ORP, 0, str);
|
dtostrfd(ORP, 2, str);
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_ORP "\":%s}" ), name, str);
|
ResponseAppend_P(PSTR(",\"%s\":{\"" D_JSON_ORP "\":%s}" ), name, str);
|
||||||
@ -48,11 +48,13 @@ struct EZOORP : public EZOStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char id[] PROGMEM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float ORP;
|
float ORP;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char EZOORP::id[] PROGMEM = "ORP";
|
||||||
|
|
||||||
#endif // USE_EZOORP
|
#endif // USE_EZOORP
|
||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
#define EZO_PH_READ_LATENCY 900
|
#define EZO_PH_READ_LATENCY 900
|
||||||
|
|
||||||
struct EZOpH : public EZOStruct {
|
struct EZOPH : public EZOStruct {
|
||||||
EZOpH(uint32_t addr) : EZOStruct(addr), pH(NAN) {}
|
EZOPH(uint32_t addr) : EZOStruct(addr), pH(NAN) {}
|
||||||
|
|
||||||
virtual void ProcessMeasurement(void)
|
virtual void ProcessMeasurement(void)
|
||||||
{
|
{
|
||||||
@ -48,9 +48,13 @@ struct EZOpH : public EZOStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char id[] PROGMEM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float pH;
|
float pH;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char EZOPH::id[] PROGMEM = "pH";
|
||||||
|
|
||||||
#endif // USE_EZOPH
|
#endif // USE_EZOPH
|
||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
@ -34,7 +34,7 @@ struct EZORTD : public EZOStruct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void Show(bool json, const char *name)
|
virtual void Show(bool json, const char *name)
|
||||||
{
|
{
|
||||||
char str[10];
|
char str[10];
|
||||||
dtostrfd(ConvertTemp(temperature), Settings.flag2.temperature_resolution, str);
|
dtostrfd(ConvertTemp(temperature), Settings.flag2.temperature_resolution, str);
|
||||||
|
|
||||||
@ -46,11 +46,15 @@ struct EZORTD : public EZOStruct {
|
|||||||
WSContentSend_PD(HTTP_SNS_TEMP, name, str, TempUnit());
|
WSContentSend_PD(HTTP_SNS_TEMP, name, str, TempUnit());
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char id[] PROGMEM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float temperature;
|
float temperature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char EZORTD::id[] PROGMEM = "RTD";
|
||||||
|
|
||||||
#endif // USE_EZORTD
|
#endif // USE_EZORTD
|
||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
|
|
||||||
// List of known EZO devices and their default address
|
// List of known EZO devices and their default address
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
EZO_DO = 0x61, // D.O.
|
EZO_DO = 0x61, // D.O.
|
||||||
EZO_ORP = 0x62, // ORP
|
EZO_ORP = 0x62, // ORP
|
||||||
@ -49,83 +48,37 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const char EZO_EMPTY[] PROGMEM = "";
|
|
||||||
//const char EZO_DO_NAME[] PROGMEM = "DO";
|
|
||||||
#ifdef USE_EZOORP
|
|
||||||
const char EZO_ORP_NAME[] PROGMEM = "ORP";
|
|
||||||
#endif
|
|
||||||
#ifdef USE_EZOPH
|
|
||||||
const char EZO_PH_NAME[] PROGMEM = "pH";
|
|
||||||
#endif
|
|
||||||
#ifdef USE_EZOEC
|
|
||||||
const char EZO_EC_NAME[] PROGMEM = "EC";
|
|
||||||
#endif
|
|
||||||
#ifdef USE_EZORTD
|
|
||||||
const char EZO_RTD_NAME[] PROGMEM = "RTD";
|
|
||||||
#endif
|
|
||||||
//const char EZO_PMP_NAME[] PROGMEM = "PMP";
|
|
||||||
//const char EZO_FLO_NAME[] PROGMEM = "FLO";
|
|
||||||
const char EZO_CO2_NAME[] PROGMEM = "CO2";
|
|
||||||
//const char EZO_PRS_NAME[] PROGMEM = "PRS";
|
|
||||||
//const char EZO_O2_NAME[] PROGMEM = "O2";
|
|
||||||
#ifdef USE_EZOHUM
|
|
||||||
const char EZO_HUM_NAME[] PROGMEM = "HUM";
|
|
||||||
#endif
|
|
||||||
//const char EZO_RGB_NAME[] PROGMEM = "RGB";
|
|
||||||
|
|
||||||
|
// Creates a complex preprocessor macro to fetch a specified class OR EZOStruct if it wasn't defined
|
||||||
|
template <class T, class = void> struct IsComplete : std::false_type {};
|
||||||
|
template <class T> struct IsComplete< T, decltype(void(sizeof(T))) > : std::true_type {};
|
||||||
|
|
||||||
|
#define GET_EZO_CLASS(CLASS) std::conditional<IsComplete<CLASS>::value, CLASS, EZOStruct>::type
|
||||||
|
|
||||||
|
// The order of the EZO devices must map with the enum declared above
|
||||||
const char *const EZOSupport[EZO_ADDR_n] PROGMEM = {
|
const char *const EZOSupport[EZO_ADDR_n] PROGMEM = {
|
||||||
EZO_EMPTY,
|
EZOStruct::id, // "DO"
|
||||||
|
GET_EZO_CLASS(EZOORP)::id,
|
||||||
#ifdef USE_EZOORP
|
GET_EZO_CLASS(EZOPH)::id,
|
||||||
EZO_ORP_NAME,
|
GET_EZO_CLASS(EZOEC)::id,
|
||||||
#else
|
EZOStruct::id,
|
||||||
EZO_EMPTY,
|
GET_EZO_CLASS(EZORTD)::id,
|
||||||
#endif
|
EZOStruct::id, // "PMP"
|
||||||
|
EZOStruct::id, // "FLO"
|
||||||
#ifdef USE_EZOPH
|
GET_EZO_CLASS(EZOCO2)::id,
|
||||||
EZO_PH_NAME,
|
EZOStruct::id, // "PRS"
|
||||||
#else
|
EZOStruct::id,
|
||||||
EZO_EMPTY,
|
EZOStruct::id, // "O2"
|
||||||
#endif
|
EZOStruct::id,
|
||||||
|
EZOStruct::id,
|
||||||
#ifdef USE_EZOEC
|
GET_EZO_CLASS(EZOHUM)::id,
|
||||||
EZO_EC_NAME,
|
EZOStruct::id, // "RGB"
|
||||||
#else
|
|
||||||
EZO_EMPTY,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EZO_EMPTY,
|
|
||||||
|
|
||||||
#ifdef USE_EZORTD
|
|
||||||
EZO_RTD_NAME,
|
|
||||||
#else
|
|
||||||
EZO_EMPTY,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EZO_EMPTY,
|
|
||||||
EZO_EMPTY,
|
|
||||||
|
|
||||||
#ifdef USE_EZOCO2
|
|
||||||
EZO_CO2_NAME,
|
|
||||||
#else
|
|
||||||
EZO_EMPTY,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EZO_EMPTY,
|
|
||||||
EZO_EMPTY,
|
|
||||||
EZO_EMPTY,
|
|
||||||
EZO_EMPTY,
|
|
||||||
EZO_EMPTY,
|
|
||||||
|
|
||||||
#ifdef USE_EZOHUM
|
|
||||||
EZO_HUM_NAME,
|
|
||||||
#else
|
|
||||||
EZO_EMPTY,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EZO_EMPTY,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define CREATE_EZO_CLASS(CLASS) \
|
||||||
|
case EZO_ ## CLASS: \
|
||||||
|
sensor[count] = new EZO ## CLASS(addr); \
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
struct EZOManager {
|
struct EZOManager {
|
||||||
@ -252,34 +205,22 @@ private:
|
|||||||
// We use switch intead of virtual function to save RAM
|
// We use switch intead of virtual function to save RAM
|
||||||
switch (j + EZO_ADDR_0) {
|
switch (j + EZO_ADDR_0) {
|
||||||
#ifdef USE_EZOORP
|
#ifdef USE_EZOORP
|
||||||
case EZO_ORP:
|
CREATE_EZO_CLASS(ORP)
|
||||||
sensor[count] = new EZOORP(addr);
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_EZOPH
|
#ifdef USE_EZOPH
|
||||||
case EZO_PH:
|
CREATE_EZO_CLASS(PH)
|
||||||
sensor[count] = new EZOpH(addr);
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_EZOEC
|
#ifdef USE_EZOEC
|
||||||
case EZO_EC:
|
CREATE_EZO_CLASS(EC)
|
||||||
sensor[count] = new EZOEC(addr);
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_EZORTD
|
#ifdef USE_EZORTD
|
||||||
case EZO_RTD:
|
CREATE_EZO_CLASS(RTD)
|
||||||
sensor[count] = new EZORTD(addr);
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_EZOCO2
|
#ifdef USE_EZOCO2
|
||||||
case EZO_CO2:
|
CREATE_EZO_CLASS(CO2)
|
||||||
sensor[count] = new EZOCO2(addr);
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_EZOHUM
|
#ifdef USE_EZOHUM
|
||||||
case EZO_HUM:
|
CREATE_EZO_CLASS(HUM)
|
||||||
sensor[count] = new EZOHUM(addr);
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user