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.
38 lines
1.0 KiB
38 lines
1.0 KiB
#pragma once
|
|
|
|
#include "esphome/components/i2c/i2c.h"
|
|
#include "esphome/components/light/light_output.h"
|
|
#include "esphome/components/output/float_output.h"
|
|
#include "esphome/core/component.h"
|
|
|
|
namespace esphome {
|
|
namespace c_monochromatic {
|
|
|
|
class MonochromaticLightOutput : public light::LightOutput,
|
|
public i2c::I2CDevice,
|
|
public Component {
|
|
public:
|
|
void set_output(output::FloatOutput *upper, output::FloatOutput *lower) {
|
|
upper_ = upper;
|
|
lower_ = lower;
|
|
}
|
|
light::LightTraits get_traits() override {
|
|
auto traits = light::LightTraits();
|
|
traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS});
|
|
return traits;
|
|
}
|
|
void write_state(light::LightState *state) override {
|
|
float bright;
|
|
state->current_values_as_brightness(&bright);
|
|
this->upper_->set_level(bright);
|
|
this->lower_->set_level(bright);
|
|
}
|
|
|
|
protected:
|
|
output::FloatOutput *upper_;
|
|
output::FloatOutput *lower_;
|
|
};
|
|
|
|
} // namespace c_monochromatic
|
|
} // namespace esphome
|