mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 23:48:11 +01:00
Comments removed
This commit is contained in:
parent
a87ce5fb85
commit
8097f85632
3 changed files with 5 additions and 9 deletions
|
@ -28,7 +28,7 @@ CONFIG_SCHEMA = (
|
|||
}
|
||||
)
|
||||
.extend(cv.COMPONENT_SCHEMA)
|
||||
.extend(i2c.i2c_device_schema(0x58)) # GP8211 I2C-Adresse
|
||||
.extend(i2c.i2c_device_schema(0x58))
|
||||
)
|
||||
|
||||
async def to_code(config):
|
||||
|
|
|
@ -6,11 +6,10 @@ namespace gp8211 {
|
|||
|
||||
static const char *const TAG = "gp8211";
|
||||
|
||||
static const uint8_t RANGE_REGISTER = 0x01; // Register für die Spannungsrange
|
||||
static const uint8_t RANGE_REGISTER = 0x01;
|
||||
|
||||
void GP8211::setup() {
|
||||
// Wähle den Spannungsmodus basierend auf der YAML-Konfiguration
|
||||
uint8_t voltage_setting = (this->voltage_ == GP8211_VOLTAGE_10V) ? 0x77 : 0x55; // 0x77 für 0-10V, 0x55 für 0-5V
|
||||
uint8_t voltage_setting = (this->voltage_ == GP8211_VOLTAGE_10V) ? 0x77 : 0x55;
|
||||
this->write_register(RANGE_REGISTER, &voltage_setting, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,11 @@ void GP8211Output::dump_config() {
|
|||
}
|
||||
|
||||
void GP8211Output::write_state(float state) {
|
||||
// Ausgabe des ursprünglichen Helligkeitswerts von der Light-Komponente
|
||||
ESP_LOGD(TAG, "Original brightness state received from Light component: %.5f", state);
|
||||
|
||||
// Konvertiere den state (0.0 bis 1.0) in einen 15-Bit DAC-Wert (0 bis 32767)
|
||||
uint16_t value = static_cast<uint16_t>(state * 32767);
|
||||
ESP_LOGD(TAG, "Calculated DAC value: %u", value); // Ausgabe des berechneten Wertes zur Überprüfung
|
||||
|
||||
// Sende den Wert an den DAC (2 Bytes)
|
||||
ESP_LOGD(TAG, "Calculated DAC value: %u", value);
|
||||
|
||||
i2c::ErrorCode err = this->parent_->write_register(OUTPUT_REGISTER, (uint8_t *)&value, 2);
|
||||
|
||||
if (err != i2c::ERROR_OK) {
|
||||
|
|
Loading…
Reference in a new issue