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.7 KiB

  1. // -----------------------------------------------------------------------------
  2. // Lights
  3. // -----------------------------------------------------------------------------
  4. #pragma once
  5. namespace Light {
  6. constexpr const size_t ChannelsMax = 5;
  7. constexpr const long VALUE_MIN = LIGHT_MIN_VALUE;
  8. constexpr const long VALUE_MAX = LIGHT_MAX_VALUE;
  9. constexpr const long BRIGHTNESS_MIN = LIGHT_MIN_BRIGHTNESS;
  10. constexpr const long BRIGHTNESS_MAX = LIGHT_MAX_BRIGHTNESS;
  11. constexpr const long PWM_MIN = LIGHT_MIN_PWM;
  12. constexpr const long PWM_MAX = LIGHT_MAX_PWM;
  13. constexpr const long PWM_LIMIT = LIGHT_LIMIT_PWM;
  14. enum Communications : unsigned char {
  15. COMMS_NONE = 0,
  16. COMMS_NORMAL = 1 << 0,
  17. COMMS_GROUP = 1 << 1
  18. };
  19. }
  20. struct channel_t {
  21. channel_t();
  22. channel_t(unsigned char pin, bool inverse);
  23. unsigned char pin; // real GPIO pin
  24. bool inverse; // whether we should invert the value before using it
  25. bool state; // is the channel ON
  26. unsigned char inputValue; // raw value, without the brightness
  27. unsigned char value; // normalized value, including brightness
  28. unsigned char target; // target value
  29. double current; // transition value
  30. };
  31. size_t lightChannels();
  32. void lightState(unsigned char i, bool state);
  33. bool lightState(unsigned char i);
  34. void lightState(bool state);
  35. bool lightState();
  36. void lightBrightness(long brightness);
  37. long lightBrightness();
  38. long lightChannel(unsigned char id);
  39. void lightChannel(unsigned char id, long value);
  40. void lightBrightnessStep(long steps, long multiplier = LIGHT_STEP);
  41. void lightChannelStep(unsigned char id, long steps, long multiplier = LIGHT_STEP);