Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.2 KiB

  1. /*
  2. LED MODULE
  3. */
  4. #pragma once
  5. #include "espurna.h"
  6. namespace led {
  7. namespace build {
  8. constexpr size_t preconfiguredLeds() {
  9. return 0ul
  10. #if LED1_PIN != GPIO_NONE
  11. + 1ul
  12. #endif
  13. #if LED2_PIN != GPIO_NONE
  14. + 1ul
  15. #endif
  16. #if LED3_PIN != GPIO_NONE
  17. + 1ul
  18. #endif
  19. #if LED4_PIN != GPIO_NONE
  20. + 1ul
  21. #endif
  22. #if LED5_PIN != GPIO_NONE
  23. + 1ul
  24. #endif
  25. #if LED6_PIN != GPIO_NONE
  26. + 1ul
  27. #endif
  28. #if LED7_PIN != GPIO_NONE
  29. + 1ul
  30. #endif
  31. #if LED8_PIN != GPIO_NONE
  32. + 1ul
  33. #endif
  34. ;
  35. }
  36. constexpr unsigned char pin(size_t index) {
  37. return (
  38. (index == 0) ? LED1_PIN :
  39. (index == 1) ? LED2_PIN :
  40. (index == 2) ? LED3_PIN :
  41. (index == 3) ? LED4_PIN :
  42. (index == 4) ? LED5_PIN :
  43. (index == 5) ? LED6_PIN :
  44. (index == 6) ? LED7_PIN :
  45. (index == 7) ? LED8_PIN : GPIO_NONE
  46. );
  47. }
  48. constexpr LedMode mode(size_t index) {
  49. return (
  50. (index == 0) ? LED1_MODE :
  51. (index == 1) ? LED2_MODE :
  52. (index == 2) ? LED3_MODE :
  53. (index == 3) ? LED4_MODE :
  54. (index == 4) ? LED5_MODE :
  55. (index == 5) ? LED6_MODE :
  56. (index == 6) ? LED7_MODE :
  57. (index == 7) ? LED8_MODE : LedMode::Manual
  58. );
  59. }
  60. constexpr unsigned char relay(size_t index) {
  61. return (
  62. (index == 0) ? (LED1_RELAY - 1) :
  63. (index == 1) ? (LED2_RELAY - 1) :
  64. (index == 2) ? (LED3_RELAY - 1) :
  65. (index == 3) ? (LED4_RELAY - 1) :
  66. (index == 4) ? (LED5_RELAY - 1) :
  67. (index == 5) ? (LED6_RELAY - 1) :
  68. (index == 6) ? (LED7_RELAY - 1) :
  69. (index == 7) ? (LED8_RELAY - 1) : RELAY_NONE
  70. );
  71. }
  72. constexpr bool inverse(size_t index) {
  73. return (
  74. (index == 0) ? (1 == LED1_PIN_INVERSE) :
  75. (index == 1) ? (1 == LED2_PIN_INVERSE) :
  76. (index == 2) ? (1 == LED3_PIN_INVERSE) :
  77. (index == 3) ? (1 == LED4_PIN_INVERSE) :
  78. (index == 4) ? (1 == LED5_PIN_INVERSE) :
  79. (index == 5) ? (1 == LED6_PIN_INVERSE) :
  80. (index == 6) ? (1 == LED7_PIN_INVERSE) :
  81. (index == 7) ? (1 == LED8_PIN_INVERSE) : false
  82. );
  83. }
  84. } // namespace build
  85. } // namespace led