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.
58 lines
1.4 KiB
58 lines
1.4 KiB
#include "esphome/core/log.h"
|
|
#include "showcase_component.h"
|
|
#include <Arduino.h>
|
|
|
|
namespace esphome {
|
|
namespace showcase_component {
|
|
|
|
/* static const char *TAG = "showcase_component.component"; */
|
|
|
|
void ShowcaseComponent::setup() {
|
|
}
|
|
|
|
void ShowcaseComponent::turn_on(){
|
|
this->write_state(On);
|
|
}
|
|
|
|
void ShowcaseComponent::turn_off(){
|
|
this->write_state(Off);
|
|
}
|
|
|
|
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->write_state(Off);
|
|
/* ESP_LOGI(TAG, "Set to Off", data); */
|
|
} else if ( data & 2 ){
|
|
this->write_state(Auto);
|
|
/* ESP_LOGI(TAG, "Set to Auto", data); */
|
|
} else if ( data & 4 ){
|
|
this->write_state(On);
|
|
/* ESP_LOGI(TAG, "Set to On", data); */
|
|
}
|
|
}
|
|
if(this->s_ == Auto) {
|
|
if(data & 8){
|
|
// TODO: turn on led
|
|
/* ESP_LOGI(TAG, "Auto On"); */
|
|
this->upper_->set_level(this->b_upper_);
|
|
this->lower_->set_level(this->b_lower_);
|
|
}
|
|
else{
|
|
/* ESP_LOGI(TAG, "Auto Off"); */
|
|
this->upper_->set_level(0.0);
|
|
this->lower_->set_level(0.0);
|
|
}
|
|
}
|
|
}
|
|
|
|
void ShowcaseComponent::dump_config(){
|
|
ESP_LOGCONFIG(TAG, "showcase component");
|
|
}
|
|
|
|
} // namespace empty_i2c_component
|
|
} // namespace esphome
|