Roman Kretschmer 2 years ago
parent a35709a233
commit 5effe60dd7

@ -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(){

@ -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

Loading…
Cancel
Save