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.

75 lines
2.1 KiB

  1. /*
  2. RELAY MODULE
  3. */
  4. #pragma once
  5. #include "espurna.h"
  6. constexpr const unsigned long _relayDelayOn(unsigned char index) {
  7. return (
  8. (index == 0) ? RELAY1_DELAY_ON :
  9. (index == 1) ? RELAY2_DELAY_ON :
  10. (index == 2) ? RELAY3_DELAY_ON :
  11. (index == 3) ? RELAY4_DELAY_ON :
  12. (index == 4) ? RELAY5_DELAY_ON :
  13. (index == 5) ? RELAY6_DELAY_ON :
  14. (index == 6) ? RELAY7_DELAY_ON :
  15. (index == 7) ? RELAY8_DELAY_ON : 0
  16. );
  17. }
  18. constexpr const unsigned long _relayDelayOff(unsigned char index) {
  19. return (
  20. (index == 0) ? RELAY1_DELAY_OFF :
  21. (index == 1) ? RELAY2_DELAY_OFF :
  22. (index == 2) ? RELAY3_DELAY_OFF :
  23. (index == 3) ? RELAY4_DELAY_OFF :
  24. (index == 4) ? RELAY5_DELAY_OFF :
  25. (index == 5) ? RELAY6_DELAY_OFF :
  26. (index == 6) ? RELAY7_DELAY_OFF :
  27. (index == 7) ? RELAY8_DELAY_OFF : 0
  28. );
  29. }
  30. constexpr const unsigned char _relayPin(unsigned char index) {
  31. return (
  32. (index == 0) ? RELAY1_PIN :
  33. (index == 1) ? RELAY2_PIN :
  34. (index == 2) ? RELAY3_PIN :
  35. (index == 3) ? RELAY4_PIN :
  36. (index == 4) ? RELAY5_PIN :
  37. (index == 5) ? RELAY6_PIN :
  38. (index == 6) ? RELAY7_PIN :
  39. (index == 7) ? RELAY8_PIN : GPIO_NONE
  40. );
  41. }
  42. constexpr const unsigned char _relayType(unsigned char index) {
  43. return (
  44. (index == 0) ? RELAY1_TYPE :
  45. (index == 1) ? RELAY2_TYPE :
  46. (index == 2) ? RELAY3_TYPE :
  47. (index == 3) ? RELAY4_TYPE :
  48. (index == 4) ? RELAY5_TYPE :
  49. (index == 5) ? RELAY6_TYPE :
  50. (index == 6) ? RELAY7_TYPE :
  51. (index == 7) ? RELAY8_TYPE : RELAY_TYPE_NORMAL
  52. );
  53. }
  54. constexpr const unsigned char _relayResetPin(unsigned char index) {
  55. return (
  56. (index == 0) ? RELAY1_RESET_PIN :
  57. (index == 1) ? RELAY2_RESET_PIN :
  58. (index == 2) ? RELAY3_RESET_PIN :
  59. (index == 3) ? RELAY4_RESET_PIN :
  60. (index == 4) ? RELAY5_RESET_PIN :
  61. (index == 5) ? RELAY6_RESET_PIN :
  62. (index == 6) ? RELAY7_RESET_PIN :
  63. (index == 7) ? RELAY8_RESET_PIN : GPIO_NONE
  64. );
  65. }