From 5effe60dd793f6cec2a54765f779d0fabc769514 Mon Sep 17 00:00:00 2001 From: gnxlxnxx Date: Wed, 3 Jan 2024 16:03:12 +0100 Subject: [PATCH] . --- .../showcase_component/showcase_component.cpp | 15 +++++++++++++++ .../showcase_component/showcase_component.h | 16 ++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/components/showcase_component/showcase_component.cpp b/components/showcase_component/showcase_component.cpp index e04ac4c..32dcc4a 100644 --- a/components/showcase_component/showcase_component.cpp +++ b/components/showcase_component/showcase_component.cpp @@ -14,6 +14,21 @@ void ShowcaseComponent::loop() { uint8_t data = 10; this->read_register(0x0, &data, 0x1); /* ESP_LOGI(TAG, "READ value: %d", data); */ + if(data != 0){ + if(data & 1){ + this->s = Off; + // TODO: turn off leds + } else if ( data & 2 ){ + this->s = Auto; + } else if ( data & 4 ){ + this->s = On; + // TODO: turn on led + } + + if(this->s == Auto && data & 8){ + // TODO: turn on led + } + } } void ShowcaseComponent::dump_config(){ diff --git a/components/showcase_component/showcase_component.h b/components/showcase_component/showcase_component.h index fff38ed..a18a5a9 100644 --- a/components/showcase_component/showcase_component.h +++ b/components/showcase_component/showcase_component.h @@ -3,14 +3,18 @@ #include "esphome/core/component.h" #include "esphome/components/i2c/i2c.h" /* #include "esphome/components/output/float_output.h" */ +// TODO: maybe use monochrome leds instead of floatoutput directly?: +/* #include "esphome/components/monochromatic/monochromatic_light_output.h" */ namespace esphome { namespace showcase_component { -/* enum state{ Off, Auto, On }; */ +enum state{ Off, Auto, On }; class ShowcaseComponent : public i2c::I2CDevice, public Component { public: + state s; + void setup() override; void loop() override; void dump_config() override; @@ -21,11 +25,15 @@ class ShowcaseComponent : public i2c::I2CDevice, public Component { /* void write_state(float upper, float lower){ */ /* this->upper_->set_level(upper); */ /* this->lower_->set_level(lower); */ + /* /\* this->upper_->write_state(upper); *\/ */ + /* /\* this->lower_->write_state(lower); *\/ */ /* } */ - /* protected: */ - /* output::FloatOutput *upper_; */ - /* output::FloatOutput *lower_; */ + protected: + /* output::FloatOutput *upper_; */ + /* output::FloatOutput *lower_; */ + /* monochromatic::MonochromaticLightOutput *upper_; */ + /* monochromatic::MonochromaticLightOutput *lower_; */ }; } // namespace empty_i2c_component