.
This commit is contained in:
@@ -14,6 +14,21 @@ void ShowcaseComponent::loop() {
|
|||||||
uint8_t data = 10;
|
uint8_t data = 10;
|
||||||
this->read_register(0x0, &data, 0x1);
|
this->read_register(0x0, &data, 0x1);
|
||||||
/* ESP_LOGI(TAG, "READ value: %d", data); */
|
/* 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(){
|
void ShowcaseComponent::dump_config(){
|
||||||
|
|||||||
@@ -3,14 +3,18 @@
|
|||||||
#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/monochromatic/monochromatic_light_output.h" */
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace showcase_component {
|
namespace showcase_component {
|
||||||
|
|
||||||
/* enum state{ Off, Auto, On }; */
|
enum state{ Off, Auto, On };
|
||||||
|
|
||||||
class ShowcaseComponent : public i2c::I2CDevice, public Component {
|
class ShowcaseComponent : public i2c::I2CDevice, public Component {
|
||||||
public:
|
public:
|
||||||
|
state s;
|
||||||
|
|
||||||
void setup() override;
|
void setup() override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
@@ -21,11 +25,15 @@ class ShowcaseComponent : public i2c::I2CDevice, public Component {
|
|||||||
/* void write_state(float upper, float lower){ */
|
/* void write_state(float upper, float lower){ */
|
||||||
/* this->upper_->set_level(upper); */
|
/* this->upper_->set_level(upper); */
|
||||||
/* this->lower_->set_level(lower); */
|
/* this->lower_->set_level(lower); */
|
||||||
|
/* /\* this->upper_->write_state(upper); *\/ */
|
||||||
|
/* /\* this->lower_->write_state(lower); *\/ */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
/* protected: */
|
protected:
|
||||||
/* output::FloatOutput *upper_; */
|
/* output::FloatOutput *upper_; */
|
||||||
/* output::FloatOutput *lower_; */
|
/* output::FloatOutput *lower_; */
|
||||||
|
/* monochromatic::MonochromaticLightOutput *upper_; */
|
||||||
|
/* monochromatic::MonochromaticLightOutput *lower_; */
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace empty_i2c_component
|
} // namespace empty_i2c_component
|
||||||
|
|||||||
Reference in New Issue
Block a user