2018-09-04 15:22:34 +01:00
|
|
|
/*
|
|
|
|
xnrg_interface.ino - Energy driver interface support for Sonoff-Tasmota
|
|
|
|
|
|
|
|
Copyright (C) 2018 Theo Arends inspired by ESPEasy
|
|
|
|
|
|
|
|
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-11-07 10:57:28 +00:00
|
|
|
#ifdef XFUNC_PTR_IN_ROM
|
2018-09-04 15:22:34 +01:00
|
|
|
int (* const xnrg_func_ptr[])(byte) PROGMEM = { // Energy driver Function Pointers
|
2018-11-07 10:57:28 +00:00
|
|
|
#else
|
|
|
|
int (* const xnrg_func_ptr[])(byte) = { // Energy driver Function Pointers
|
|
|
|
#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
|
|
|
|
&Xnrg16
|
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
|
|
|
|
|
|
|
|
int XnrgCall(byte Function)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
for (byte x = 0; x < xnrg_present; x++) {
|
|
|
|
result = xnrg_func_ptr[x](Function);
|
|
|
|
if (result) break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|