mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-07 13:24:56 +02:00
🏗 Merge C++ into python codebase (#504)
## Description: Move esphome-core codebase into esphome (and a bunch of other refactors). See https://github.com/esphome/feature-requests/issues/97 Yes this is a shit ton of work and no there's no way to automate it :( But it will be worth it 👍 Progress: - Core support (file copy etc): 80% - Base Abstractions (light, switch): ~50% - Integrations: ~10% - Working? Yes, (but only with ported components). Other refactors: - Moves all codegen related stuff into a single class: `esphome.codegen` (imported as `cg`) - Rework coroutine syntax - Move from `component/platform.py` to `domain/component.py` structure as with HA - Move all defaults out of C++ and into config validation. - Remove `make_...` helpers from Application class. Reason: Merge conflicts with every single new integration. - Pointer Variables are stored globally instead of locally in setup(). Reason: stack size limit. Future work: - Rework const.py - Move all `CONF_...` into a conf class (usage `conf.UPDATE_INTERVAL` vs `CONF_UPDATE_INTERVAL`). Reason: Less convoluted import block - Enable loading from `custom_components` folder. **Related issue (if applicable):** https://github.com/esphome/feature-requests/issues/97 **Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#<esphome-docs PR number goes here> ## Checklist: - [ ] The code change is tested and works locally. - [ ] Tests have been added to verify that the new code works (under `tests/` folder). If user exposed functionality or configuration variables are added/changed: - [ ] Documentation added/updated in [esphomedocs](https://github.com/OttoWinter/esphomedocs).
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/i2c/i2c.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace tcs34725 {
|
||||
|
||||
enum TCS34725IntegrationTime {
|
||||
TCS34725_INTEGRATION_TIME_2_4MS = 0xFF,
|
||||
TCS34725_INTEGRATION_TIME_24MS = 0xF6,
|
||||
TCS34725_INTEGRATION_TIME_50MS = 0xEB,
|
||||
TCS34725_INTEGRATION_TIME_101MS = 0xD5,
|
||||
TCS34725_INTEGRATION_TIME_154MS = 0xC0,
|
||||
TCS34725_INTEGRATION_TIME_700MS = 0x00,
|
||||
};
|
||||
|
||||
enum TCS34725Gain {
|
||||
TCS34725_GAIN_1X = 0x00,
|
||||
TCS34725_GAIN_4X = 0x01,
|
||||
TCS34725_GAIN_16X = 0x02,
|
||||
TCS34725_GAIN_60X = 0x03,
|
||||
};
|
||||
|
||||
class TCS34725Component : public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
TCS34725Component(uint32_t update_interval) : PollingComponent(update_interval) {}
|
||||
|
||||
void set_integration_time(TCS34725IntegrationTime integration_time);
|
||||
void set_gain(TCS34725Gain gain);
|
||||
|
||||
void set_clear_sensor(sensor::Sensor *clear_sensor) { clear_sensor_ = clear_sensor; }
|
||||
void set_red_sensor(sensor::Sensor *red_sensor) { red_sensor_ = red_sensor; }
|
||||
void set_green_sensor(sensor::Sensor *green_sensor) { green_sensor_ = green_sensor; }
|
||||
void set_blue_sensor(sensor::Sensor *blue_sensor) { blue_sensor_ = blue_sensor; }
|
||||
void set_illuminance_sensor(sensor::Sensor *illuminance_sensor) { illuminance_sensor_ = illuminance_sensor; }
|
||||
void set_color_temperature_sensor(sensor::Sensor *color_temperature_sensor) {
|
||||
color_temperature_sensor_ = color_temperature_sensor;
|
||||
}
|
||||
|
||||
void setup() override;
|
||||
float get_setup_priority() const override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *clear_sensor_{nullptr};
|
||||
sensor::Sensor *red_sensor_{nullptr};
|
||||
sensor::Sensor *green_sensor_{nullptr};
|
||||
sensor::Sensor *blue_sensor_{nullptr};
|
||||
sensor::Sensor *illuminance_sensor_{nullptr};
|
||||
sensor::Sensor *color_temperature_sensor_{nullptr};
|
||||
TCS34725IntegrationTime integration_time_{TCS34725_INTEGRATION_TIME_2_4MS};
|
||||
TCS34725Gain gain_{TCS34725_GAIN_1X};
|
||||
};
|
||||
|
||||
} // namespace tcs34725
|
||||
} // namespace esphome
|
||||
Reference in New Issue
Block a user