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.

91 lines
1.9 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. #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX
  30. constexpr my92xx_cmd_t my92xxCommand() {
  31. return MY92XX_COMMAND;
  32. }
  33. constexpr unsigned char my92xxChannels() {
  34. return MY92XX_CHANNELS;
  35. }
  36. constexpr my92xx_model_t my92xxModel() {
  37. return MY92XX_MODEL;
  38. }
  39. constexpr int my92xxChips() {
  40. return MY92XX_CHIPS;
  41. }
  42. constexpr int my92xxDiPin() {
  43. return MY92XX_DI_PIN;
  44. }
  45. constexpr int my92xxDckiPin() {
  46. return MY92XX_DCKI_PIN;
  47. }
  48. #ifdef MY92XX_MAPPING
  49. constexpr unsigned char _my92xx_mapping[MY92XX_CHANNELS] {
  50. MY92XX_MAPPING
  51. };
  52. constexpr unsigned char my92xxChannel(unsigned char)
  53. __attribute__((deprecated("MY92XX_CH# flags should be used instead of MY92XX_MAPPING")));
  54. constexpr unsigned char my92xxChannel(unsigned char channel) {
  55. return _my92xx_mapping[channel];
  56. }
  57. #else
  58. constexpr unsigned char my92xxChannel(unsigned char channel) {
  59. return (channel == 0) ? MY92XX_CH1 :
  60. (channel == 1) ? MY92XX_CH2 :
  61. (channel == 2) ? MY92XX_CH3 :
  62. (channel == 3) ? MY92XX_CH4 :
  63. (channel == 4) ? MY92XX_CH5 : Light::ChannelsMax;
  64. }
  65. #endif
  66. #endif
  67. } // namespace build
  68. } // namespace Light