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.

73 lines
2.1 KiB

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