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.

57 lines
1.4 KiB

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