Roman Kretschmer 2 years ago
parent 6191889745
commit 1f733d2887

@ -1,24 +0,0 @@
#include "esphome/core/log.h"
#include "showcase_component.h"
#include <Arduino.h>
namespace esphome {
namespace showcase_component {
static const char *TAG = "empty_i2c_component.component";
void ShowcaseComponent::setup() {
}
void ShowcaseComponent::loop() {
uint8_t data = 10;
this->read_register(0x0, &data, 0x1);
/* ESP_LOGI(TAG, "READ value: %d", data); */
}
void ShowcaseComponent::dump_config(){
ESP_LOGCONFIG(TAG, "Empty I2C component");
}
} // namespace empty_i2c_component
} // namespace esphome

@ -1,30 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/i2c/i2c.h"
#include "esphome/components/output/float_output.h"
namespace esphome {
namespace showcase_component {
class ShowcaseComponent : public i2c::I2CDevice, public Component {
public:
void setup() override;
void loop() override;
void dump_config() override;
void set_upper(output::FloatOutput *upper) {upper_ = upper;}
void set_lower(output::FloatOutput *lower) {lower_ = lower;}
void write_state(float upper, float lower){
this->upper_->set_level(upper);
this->lower_->set_level(lower);
}
protected:
output::FloatOutput *upper_;
output::FloatOutput *lower_;
};
} // namespace empty_i2c_component
} // namespace esphome

@ -1,25 +1,24 @@
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "empty_i2c_component.h" #include "showcase_component.h"
#include <Arduino.h> #include <Arduino.h>
namespace esphome { namespace esphome {
namespace empty_i2c_component { namespace showcase_component {
static const char *TAG = "empty_i2c_component.component"; static const char *TAG = "empty_i2c_component.component";
void EmptyI2CComponent::setup() { void ShowcaseComponent::setup() {
} }
void EmptyI2CComponent::loop() { 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); */
} }
void EmptyI2CComponent::dump_config(){ void ShowcaseComponent::dump_config(){
ESP_LOGCONFIG(TAG, "Empty I2C component"); ESP_LOGCONFIG(TAG, "Empty I2C component");
} }
} // namespace empty_i2c_component } // namespace empty_i2c_component
} // namespace esphome } // namespace esphome

@ -2,17 +2,31 @@
#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"
namespace esphome { namespace esphome {
namespace empty_i2c_component { namespace showcase_component {
class EmptyI2CComponent : public i2c::I2CDevice, public Component { enum state{ Off, Auto, On };
class ShowcaseComponent : public i2c::I2CDevice, public Component {
public: public:
void setup() override; void setup() override;
void loop() override; void loop() override;
void dump_config() override; void dump_config() override;
};
void set_upper(output::FloatOutput *upper) {upper_ = upper;}
void set_lower(output::FloatOutput *lower) {lower_ = lower;}
void write_state(float upper, float lower){
this->upper_->set_level(upper);
this->lower_->set_level(lower);
}
protected:
output::FloatOutput *upper_;
output::FloatOutput *lower_;
};
} // namespace empty_i2c_component } // namespace empty_i2c_component
} // namespace esphome } // namespace esphome
Loading…
Cancel
Save