xnrg_interface.ino 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. xnrg_interface.ino - Energy driver interface support for Sonoff-Tasmota
  3. Copyright (C) 2018 Theo Arends inspired by ESPEasy
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifdef XFUNC_PTR_IN_ROM
  16. int (* const xnrg_func_ptr[])(byte) PROGMEM = { // Energy driver Function Pointers
  17. #else
  18. int (* const xnrg_func_ptr[])(byte) = { // Energy driver Function Pointers
  19. #endif
  20. #ifdef XNRG_01
  21. &Xnrg01,
  22. #endif
  23. #ifdef XNRG_02
  24. &Xnrg02,
  25. #endif
  26. #ifdef XNRG_03
  27. &Xnrg03,
  28. #endif
  29. #ifdef XNRG_04
  30. &Xnrg04,
  31. #endif
  32. #ifdef XNRG_05
  33. &Xnrg05,
  34. #endif
  35. #ifdef XNRG_06
  36. &Xnrg06,
  37. #endif
  38. #ifdef XNRG_07
  39. &Xnrg07,
  40. #endif
  41. #ifdef XNRG_08
  42. &Xnrg08,
  43. #endif
  44. #ifdef XNRG_09
  45. &Xnrg09,
  46. #endif
  47. #ifdef XNRG_10
  48. &Xnrg10,
  49. #endif
  50. #ifdef XNRG_11
  51. &Xnrg11,
  52. #endif
  53. #ifdef XNRG_12
  54. &Xnrg12,
  55. #endif
  56. #ifdef XNRG_13
  57. &Xnrg13,
  58. #endif
  59. #ifdef XNRG_14
  60. &Xnrg14,
  61. #endif
  62. #ifdef XNRG_15
  63. &Xnrg15,
  64. #endif
  65. #ifdef XNRG_16
  66. &Xnrg16
  67. #endif
  68. };
  69. const uint8_t xnrg_present = sizeof(xnrg_func_ptr) / sizeof(xnrg_func_ptr[0]); // Number of drivers found
  70. int XnrgCall(byte Function)
  71. {
  72. int result = 0;
  73. for (byte x = 0; x < xnrg_present; x++) {
  74. result = xnrg_func_ptr[x](Function);
  75. if (result) break;
  76. }
  77. return result;
  78. }