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.

36 lines
792 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. protected:
  25. FrontPanelHAL *front_panel_;
  26. };
  27. } // namespace bslamp2
  28. } // namespace xiaomi
  29. } // namespace esphome