mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 11:56:25 +01:00
commit
8f7ff25624
@ -1,6 +1,10 @@
|
|||||||
# Source https://github.com/letscontrolit/ESPEasy/pull/3845#issuecomment-1005864664
|
# Source https://github.com/letscontrolit/ESPEasy/pull/3845#issuecomment-1005864664
|
||||||
|
|
||||||
import esptool
|
import os
|
||||||
|
if os.environ.get("ESPHOME_USE_SUBPROCESS") is None:
|
||||||
|
import esptool
|
||||||
|
else:
|
||||||
|
import subprocess
|
||||||
from SCons.Script import ARGUMENTS
|
from SCons.Script import ARGUMENTS
|
||||||
|
|
||||||
# pylint: disable=E0602
|
# pylint: disable=E0602
|
||||||
@ -42,8 +46,11 @@ def esp32_create_combined_bin(source, target, env):
|
|||||||
print()
|
print()
|
||||||
print(f"Using esptool.py arguments: {' '.join(cmd)}")
|
print(f"Using esptool.py arguments: {' '.join(cmd)}")
|
||||||
print()
|
print()
|
||||||
esptool.main(cmd)
|
|
||||||
|
|
||||||
|
if os.environ.get("ESPHOME_USE_SUBPROCESS") is None:
|
||||||
|
esptool.main(cmd)
|
||||||
|
else:
|
||||||
|
subprocess.run(["esptool.py", *cmd])
|
||||||
|
|
||||||
# pylint: disable=E0602
|
# pylint: disable=E0602
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa
|
||||||
|
@ -43,16 +43,34 @@ void TSL2591Component::disable_if_power_saving_() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TSL2591Component::setup() {
|
void TSL2591Component::setup() {
|
||||||
if (this->component_gain_ == TSL2591_CGAIN_AUTO)
|
switch (this->component_gain_) {
|
||||||
this->gain_ = TSL2591_GAIN_MED;
|
case TSL2591_CGAIN_LOW:
|
||||||
|
this->gain_ = TSL2591_GAIN_LOW;
|
||||||
|
break;
|
||||||
|
case TSL2591_CGAIN_MED:
|
||||||
|
this->gain_ = TSL2591_GAIN_MED;
|
||||||
|
break;
|
||||||
|
case TSL2591_CGAIN_HIGH:
|
||||||
|
this->gain_ = TSL2591_GAIN_HIGH;
|
||||||
|
break;
|
||||||
|
case TSL2591_CGAIN_MAX:
|
||||||
|
this->gain_ = TSL2591_GAIN_MAX;
|
||||||
|
break;
|
||||||
|
case TSL2591_CGAIN_AUTO:
|
||||||
|
this->gain_ = TSL2591_GAIN_MED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t address = this->address_;
|
uint8_t address = this->address_;
|
||||||
ESP_LOGI(TAG, "Setting up TSL2591 sensor at I2C address 0x%02X", address);
|
ESP_LOGI(TAG, "Setting up TSL2591 sensor at I2C address 0x%02X", address);
|
||||||
|
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
if (!this->read_byte(TSL2591_COMMAND_BIT | TSL2591_REGISTER_DEVICE_ID, &id)) {
|
if (!this->read_byte(TSL2591_COMMAND_BIT | TSL2591_REGISTER_DEVICE_ID, &id)) {
|
||||||
ESP_LOGE(TAG, "Failed I2C read during setup()");
|
ESP_LOGE(TAG, "Failed I2C read during setup()");
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id != 0x50) {
|
if (id != 0x50) {
|
||||||
ESP_LOGE(TAG,
|
ESP_LOGE(TAG,
|
||||||
"Could not find the TSL2591 sensor. The ID register of the device at address 0x%02X reported 0x%02X "
|
"Could not find the TSL2591 sensor. The ID register of the device at address 0x%02X reported 0x%02X "
|
||||||
@ -61,6 +79,7 @@ void TSL2591Component::setup() {
|
|||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->set_integration_time_and_gain(this->integration_time_, this->gain_);
|
this->set_integration_time_and_gain(this->integration_time_, this->gain_);
|
||||||
this->disable_if_power_saving_();
|
this->disable_if_power_saving_();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2022.2.4"
|
__version__ = "2022.2.5"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user