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.

48 lines
1015 B

  1. #pragma once
  2. #include "../common.h"
  3. #include "../front_panel_hal.h"
  4. #include "esphome/components/output/float_output.h"
  5. #include <cmath>
  6. namespace esphome {
  7. namespace xiaomi {
  8. namespace bslamp2 {
  9. /**
  10. * An output, used for controlling the front panel illumination and
  11. * level indicator on the Xiaomi Mijia Bedside Lamp 2 front panel.
  12. */
  13. class XiaomiBslamp2FrontPanelOutput : public output::FloatOutput, public Component {
  14. public:
  15. void set_parent(FrontPanelHAL *front_panel) {
  16. front_panel_ = front_panel;
  17. }
  18. void write_state(float level) {
  19. front_panel_->set_light_level(level);
  20. }
  21. void set_leds(uint16_t leds) {
  22. front_panel_->set_leds(leds);
  23. }
  24. void turn_on_leds(uint16_t leds) {
  25. front_panel_->turn_on_leds(leds);
  26. }
  27. void turn_off_leds(uint16_t leds) {
  28. front_panel_->turn_off_leds(leds);
  29. }
  30. void update_leds() {
  31. front_panel_->update_leds();
  32. }
  33. protected:
  34. FrontPanelHAL *front_panel_;
  35. };
  36. } // namespace bslamp2
  37. } // namespace xiaomi
  38. } // namespace esphome