|
|
|
@ -5,17 +5,34 @@
|
|
|
|
#include "esphome/core/component.h"
|
|
|
|
#include "esphome/core/component.h"
|
|
|
|
#include "esphome/components/i2c/i2c.h"
|
|
|
|
#include "esphome/components/i2c/i2c.h"
|
|
|
|
#include "esphome/components/output/float_output.h"
|
|
|
|
#include "esphome/components/output/float_output.h"
|
|
|
|
// TODO: maybe use monochrome leds instead of floatoutput directly?:
|
|
|
|
#include "esphome/components/light/light_output.h"
|
|
|
|
#include "esphome/components/monochromatic/monochromatic_light_output.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace esphome {
|
|
|
|
namespace showcase_component {
|
|
|
|
namespace showcase_component {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* class Output: public light::LightOutput{ */
|
|
|
|
|
|
|
|
/* public: */
|
|
|
|
|
|
|
|
/* void set_output(output::FloatOutput *output) { output_ = output; } */
|
|
|
|
|
|
|
|
/* 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->output_->set_level(bright); */
|
|
|
|
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* protected: */
|
|
|
|
|
|
|
|
/* output::FloatOutput *output_; */
|
|
|
|
|
|
|
|
/* }; */
|
|
|
|
|
|
|
|
|
|
|
|
enum State{ Off, Auto, On };
|
|
|
|
enum State{ Off, Auto, On };
|
|
|
|
|
|
|
|
|
|
|
|
static const char *TAG = "showcase_component.component";
|
|
|
|
static const char *TAG = "showcase_component.component";
|
|
|
|
|
|
|
|
|
|
|
|
class ShowcaseComponent : public i2c::I2CDevice, public Component, public EntityBase {
|
|
|
|
class ShowcaseComponent : public i2c::I2CDevice, public Component, public EntityBase, public light::LightOutput {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
State s_{Off};
|
|
|
|
State s_{Off};
|
|
|
|
float b_upper_{1.0};
|
|
|
|
float b_upper_{1.0};
|
|
|
|
@ -36,8 +53,6 @@ class ShowcaseComponent : public i2c::I2CDevice, public Component, public Entity
|
|
|
|
|
|
|
|
|
|
|
|
void set_upper(output::FloatOutput *upper) {this->upper_ = upper;}
|
|
|
|
void set_upper(output::FloatOutput *upper) {this->upper_ = upper;}
|
|
|
|
void set_lower(output::FloatOutput *lower) {this->lower_ = lower;}
|
|
|
|
void set_lower(output::FloatOutput *lower) {this->lower_ = lower;}
|
|
|
|
/* void set_upper(monochromatic::MonochromaticLightOutput *upper) {this->upper_ = upper;} */
|
|
|
|
|
|
|
|
/* void set_lower(monochromatic::MonochromaticLightOutput *lower) {this->lower_ = lower;} */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void write_state(State s){
|
|
|
|
void write_state(State s){
|
|
|
|
ESP_LOGI(TAG, "Write_state");
|
|
|
|
ESP_LOGI(TAG, "Write_state");
|
|
|
|
@ -85,8 +100,6 @@ class ShowcaseComponent : public i2c::I2CDevice, public Component, public Entity
|
|
|
|
|
|
|
|
|
|
|
|
output::FloatOutput *upper_;
|
|
|
|
output::FloatOutput *upper_;
|
|
|
|
output::FloatOutput *lower_;
|
|
|
|
output::FloatOutput *lower_;
|
|
|
|
monochromatic::MonochromaticLightOutput *upper2_;
|
|
|
|
|
|
|
|
monochromatic::MonochromaticLightOutput *lower2_;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace empty_i2c_component
|
|
|
|
} // namespace empty_i2c_component
|
|
|
|
|