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.

63 lines
1.4 KiB

  1. /*
  2. LIGHT MODULE
  3. */
  4. #pragma once
  5. #include "espurna.h"
  6. namespace Light {
  7. namespace build {
  8. constexpr unsigned char enablePin() {
  9. return LIGHT_ENABLE_PIN;
  10. }
  11. constexpr unsigned char channelPin(unsigned char index) {
  12. return (
  13. (index == 0) ? LIGHT_CH1_PIN :
  14. (index == 1) ? LIGHT_CH2_PIN :
  15. (index == 2) ? LIGHT_CH3_PIN :
  16. (index == 3) ? LIGHT_CH4_PIN :
  17. (index == 4) ? LIGHT_CH5_PIN : GPIO_NONE
  18. );
  19. }
  20. constexpr bool inverse(unsigned char index) {
  21. return (
  22. (index == 0) ? (1 == LIGHT_CH1_INVERSE) :
  23. (index == 1) ? (1 == LIGHT_CH2_INVERSE) :
  24. (index == 2) ? (1 == LIGHT_CH3_INVERSE) :
  25. (index == 3) ? (1 == LIGHT_CH4_INVERSE) :
  26. (index == 4) ? (1 == LIGHT_CH5_INVERSE) : false
  27. );
  28. }
  29. #ifdef MY92XX_MAPPING
  30. constexpr unsigned char _my92xx_mapping[LIGHT_CHANNELS] {
  31. MY92XX_MAPPING
  32. };
  33. constexpr unsigned char my92xxChannel(unsigned char)
  34. __attribute__((deprecated("MY92XX_CH# flags should be used instead of MY92XX_MAPPING")));
  35. constexpr unsigned char _lightMy92xxChannel(unsigned char channel) {
  36. return _my92xx_mapping[channel];
  37. }
  38. #else
  39. constexpr unsigned char my92xxChannel(unsigned char channel) {
  40. return (channel == 0) ? MY92XX_CH1 :
  41. (channel == 1) ? MY92XX_CH2 :
  42. (channel == 2) ? MY92XX_CH3 :
  43. (channel == 3) ? MY92XX_CH4 :
  44. (channel == 4) ? MY92XX_CH5 : 255u;
  45. }
  46. } // namespace build
  47. } // namespace Light
  48. #endif