2018-09-04 15:22:34 +01:00
|
|
|
/*
|
2019-10-27 10:13:24 +00:00
|
|
|
xnrg_interface.ino - Energy driver interface support for Tasmota
|
2018-09-04 15:22:34 +01:00
|
|
|
|
2021-01-01 12:44:04 +00:00
|
|
|
Copyright (C) 2021 Theo Arends inspired by ESPEasy
|
2018-09-04 15:22:34 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-12-30 14:32:53 +00:00
|
|
|
#ifdef USE_ENERGY_SENSOR
|
|
|
|
|
2018-11-07 10:57:28 +00:00
|
|
|
#ifdef XFUNC_PTR_IN_ROM
|
2022-11-11 09:44:56 +00:00
|
|
|
bool (* const xnrg_func_ptr[])(uint32_t) PROGMEM = { // Energy driver Function Pointers
|
2018-11-07 10:57:28 +00:00
|
|
|
#else
|
2022-11-11 09:44:56 +00:00
|
|
|
bool (* const xnrg_func_ptr[])(uint32_t) = { // Energy driver Function Pointers
|
2018-11-07 10:57:28 +00:00
|
|
|
#endif
|
|
|
|
|
2018-09-04 15:22:34 +01:00
|
|
|
#ifdef XNRG_01
|
|
|
|
&Xnrg01,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_02
|
|
|
|
&Xnrg02,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_03
|
|
|
|
&Xnrg03,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_04
|
|
|
|
&Xnrg04,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_05
|
|
|
|
&Xnrg05,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_06
|
2018-10-17 11:27:05 +01:00
|
|
|
&Xnrg06,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_07
|
|
|
|
&Xnrg07,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_08
|
2018-10-23 15:03:57 +01:00
|
|
|
&Xnrg08,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_09
|
|
|
|
&Xnrg09,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_10
|
|
|
|
&Xnrg10,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_11
|
|
|
|
&Xnrg11,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_12
|
|
|
|
&Xnrg12,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_13
|
|
|
|
&Xnrg13,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_14
|
|
|
|
&Xnrg14,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_15
|
|
|
|
&Xnrg15,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_16
|
2020-07-12 16:52:24 +01:00
|
|
|
&Xnrg16,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_17
|
2020-07-14 10:57:10 +01:00
|
|
|
&Xnrg17,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_18
|
|
|
|
&Xnrg18,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_19
|
|
|
|
&Xnrg19,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_20
|
|
|
|
&Xnrg20,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_21
|
|
|
|
&Xnrg21,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_22
|
|
|
|
&Xnrg22,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_23
|
|
|
|
&Xnrg23,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_24
|
|
|
|
&Xnrg24,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_25
|
|
|
|
&Xnrg25,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_26
|
|
|
|
&Xnrg26,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_27
|
|
|
|
&Xnrg27,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_28
|
|
|
|
&Xnrg28,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_29
|
|
|
|
&Xnrg29,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_30
|
|
|
|
&Xnrg30,
|
|
|
|
#endif
|
|
|
|
|
2020-11-14 15:43:32 +00:00
|
|
|
#ifdef XNRG_31 // Reserved for use by xdrv_45_shelly_dimmer.ino
|
2020-07-14 10:57:10 +01:00
|
|
|
&Xnrg31,
|
|
|
|
#endif
|
|
|
|
|
2020-07-14 16:37:14 +01:00
|
|
|
#ifdef XNRG_32 // Reserved for use by xdrv_16_tuyamcu.ino
|
2024-07-27 16:11:25 +01:00
|
|
|
&Xnrg32,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XNRG_33 // Reserved for use by xsns_02_analog.ino
|
|
|
|
&Xnrg33
|
2018-09-04 15:22:34 +01:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
const uint8_t xnrg_present = sizeof(xnrg_func_ptr) / sizeof(xnrg_func_ptr[0]); // Number of drivers found
|
|
|
|
|
2019-09-08 16:21:26 +01:00
|
|
|
uint8_t xnrg_active = 0;
|
|
|
|
|
2022-11-11 09:44:56 +00:00
|
|
|
bool XnrgCall(uint32_t function) {
|
2019-11-06 16:48:38 +00:00
|
|
|
DEBUG_TRACE_LOG(PSTR("NRG: %d"), function);
|
|
|
|
|
2019-09-08 15:57:56 +01:00
|
|
|
if (FUNC_PRE_INIT == function) {
|
|
|
|
for (uint32_t x = 0; x < xnrg_present; x++) {
|
|
|
|
xnrg_func_ptr[x](function);
|
2020-10-30 11:29:48 +00:00
|
|
|
if (TasmotaGlobal.energy_driver) {
|
2019-09-08 16:21:26 +01:00
|
|
|
xnrg_active = x;
|
|
|
|
return true; // Stop further driver investigation
|
2019-09-08 15:57:56 +01:00
|
|
|
}
|
2018-12-30 14:32:53 +00:00
|
|
|
}
|
2018-09-04 15:22:34 +01:00
|
|
|
}
|
2020-10-30 11:29:48 +00:00
|
|
|
else if (TasmotaGlobal.energy_driver) {
|
2019-09-08 16:21:26 +01:00
|
|
|
return xnrg_func_ptr[xnrg_active](function);
|
2019-09-08 15:57:56 +01:00
|
|
|
}
|
|
|
|
return false;
|
2018-09-04 15:22:34 +01:00
|
|
|
}
|
2018-12-30 14:32:53 +00:00
|
|
|
|
|
|
|
#endif // USE_ENERGY_SENSOR
|