xdsp_interface.ino 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. xdsp_interface.ino - Display interface support for Sonoff-Tasmota
  3. Copyright (C) 2018 Theo Arends
  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. boolean (* const xdsp_func_ptr[])(byte) PROGMEM = { // Display Function Pointers
  17. #else
  18. boolean (* const xdsp_func_ptr[])(byte) = { // Display Function Pointers
  19. #endif
  20. #ifdef XDSP_01
  21. &Xdsp01,
  22. #endif
  23. #ifdef XDSP_02
  24. &Xdsp02,
  25. #endif
  26. #ifdef XDSP_03
  27. &Xdsp03,
  28. #endif
  29. #ifdef XDSP_04
  30. &Xdsp04,
  31. #endif
  32. #ifdef XDSP_05
  33. &Xdsp05,
  34. #endif
  35. #ifdef XDSP_06
  36. &Xdsp06,
  37. #endif
  38. #ifdef XDSP_07
  39. &Xdsp07,
  40. #endif
  41. #ifdef XDSP_08
  42. &Xdsp08,
  43. #endif
  44. #ifdef XDSP_09
  45. &Xdsp09,
  46. #endif
  47. #ifdef XDSP_10
  48. &Xdsp10,
  49. #endif
  50. #ifdef XDSP_11
  51. &Xdsp11,
  52. #endif
  53. #ifdef XDSP_12
  54. &Xdsp12,
  55. #endif
  56. #ifdef XDSP_13
  57. &Xdsp13,
  58. #endif
  59. #ifdef XDSP_14
  60. &Xdsp14,
  61. #endif
  62. #ifdef XDSP_15
  63. &Xdsp15,
  64. #endif
  65. #ifdef XDSP_16
  66. &Xdsp16
  67. #endif
  68. };
  69. const uint8_t xdsp_present = sizeof(xdsp_func_ptr) / sizeof(xdsp_func_ptr[0]); // Number of drivers found
  70. /*********************************************************************************************\
  71. * Function call to all xdsp
  72. *
  73. * FUNC_DISPLAY_INIT_DRIVER
  74. * FUNC_DISPLAY_INIT
  75. * FUNC_DISPLAY_EVERY_50_MSECOND
  76. * FUNC_DISPLAY_EVERY_SECOND
  77. * FUNC_DISPLAY_POWER
  78. * FUNC_DISPLAY_CLEAR
  79. * FUNC_DISPLAY_DRAW_FRAME
  80. * FUNC_DISPLAY_DRAW_HLINE
  81. * FUNC_DISPLAY_DRAW_VLINE
  82. * FUNC_DISPLAY_DRAW_CIRCLE
  83. * FUNC_DISPLAY_FILL_CIRCLE
  84. * FUNC_DISPLAY_DRAW_RECTANGLE
  85. * FUNC_DISPLAY_FILL_RECTANGLE
  86. * FUNC_DISPLAY_FONT_SIZE
  87. * FUNC_DISPLAY_ROTATION
  88. * FUNC_DISPLAY_DRAW_STRING
  89. * FUNC_DISPLAY_ONOFF
  90. \*********************************************************************************************/
  91. uint8_t XdspPresent(void)
  92. {
  93. return xdsp_present;
  94. }
  95. boolean XdspCall(byte Function)
  96. {
  97. boolean result = false;
  98. for (byte x = 0; x < xdsp_present; x++) {
  99. result = xdsp_func_ptr[x](Function);
  100. if (result) break;
  101. }
  102. return result;
  103. }