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.

61 lines
1.7 KiB

  1. /*
  2. LED MODULE
  3. */
  4. #pragma once
  5. #include "espurna.h"
  6. constexpr const unsigned char _ledPin(unsigned char index) {
  7. return (
  8. (index == 0) ? LED1_PIN :
  9. (index == 1) ? LED2_PIN :
  10. (index == 2) ? LED3_PIN :
  11. (index == 3) ? LED4_PIN :
  12. (index == 4) ? LED5_PIN :
  13. (index == 5) ? LED6_PIN :
  14. (index == 6) ? LED7_PIN :
  15. (index == 7) ? LED8_PIN : GPIO_NONE
  16. );
  17. }
  18. constexpr const unsigned char _ledMode(unsigned char index) {
  19. return (
  20. (index == 0) ? LED1_MODE :
  21. (index == 1) ? LED2_MODE :
  22. (index == 2) ? LED3_MODE :
  23. (index == 3) ? LED4_MODE :
  24. (index == 4) ? LED5_MODE :
  25. (index == 5) ? LED6_MODE :
  26. (index == 6) ? LED7_MODE :
  27. (index == 7) ? LED8_MODE : LED_MODE_WIFI
  28. );
  29. }
  30. constexpr const unsigned char _ledRelay(unsigned char index) {
  31. return (
  32. (index == 0) ? (LED1_RELAY - 1) :
  33. (index == 1) ? (LED2_RELAY - 1) :
  34. (index == 2) ? (LED3_RELAY - 1) :
  35. (index == 3) ? (LED4_RELAY - 1) :
  36. (index == 4) ? (LED5_RELAY - 1) :
  37. (index == 5) ? (LED6_RELAY - 1) :
  38. (index == 6) ? (LED7_RELAY - 1) :
  39. (index == 7) ? (LED8_RELAY - 1) : RELAY_NONE
  40. );
  41. }
  42. constexpr const bool _ledInverse(unsigned char index) {
  43. return (
  44. (index == 0) ? (1 == LED1_PIN_INVERSE) :
  45. (index == 1) ? (1 == LED2_PIN_INVERSE) :
  46. (index == 2) ? (1 == LED3_PIN_INVERSE) :
  47. (index == 3) ? (1 == LED4_PIN_INVERSE) :
  48. (index == 4) ? (1 == LED5_PIN_INVERSE) :
  49. (index == 5) ? (1 == LED6_PIN_INVERSE) :
  50. (index == 6) ? (1 == LED7_PIN_INVERSE) :
  51. (index == 7) ? (1 == LED8_PIN_INVERSE) : false
  52. );
  53. }