mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
Merge branch 'dev' into dev
This commit is contained in:
commit
de3661586f
5 changed files with 44 additions and 29 deletions
|
@ -76,16 +76,9 @@ void QMC5883LComponent::dump_config() {
|
|||
float QMC5883LComponent::get_setup_priority() const { return setup_priority::DATA; }
|
||||
void QMC5883LComponent::update() {
|
||||
uint8_t status = false;
|
||||
if (ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG)
|
||||
this->read_byte(QMC5883L_REGISTER_STATUS, &status);
|
||||
|
||||
uint16_t raw_x, raw_y, raw_z;
|
||||
if (!this->read_byte_16_(QMC5883L_REGISTER_DATA_X_LSB, &raw_x) ||
|
||||
!this->read_byte_16_(QMC5883L_REGISTER_DATA_Y_LSB, &raw_y) ||
|
||||
!this->read_byte_16_(QMC5883L_REGISTER_DATA_Z_LSB, &raw_z)) {
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
|
||||
float mg_per_bit;
|
||||
switch (this->range_) {
|
||||
case QMC5883L_RANGE_200_UT:
|
||||
|
@ -99,11 +92,37 @@ void QMC5883LComponent::update() {
|
|||
}
|
||||
|
||||
// in µT
|
||||
const float x = int16_t(raw_x) * mg_per_bit * 0.1f;
|
||||
const float y = int16_t(raw_y) * mg_per_bit * 0.1f;
|
||||
const float z = int16_t(raw_z) * mg_per_bit * 0.1f;
|
||||
float x = NAN, y = NAN, z = NAN;
|
||||
if (this->x_sensor_ != nullptr || this->heading_sensor_ != nullptr) {
|
||||
uint16_t raw_x;
|
||||
if (!this->read_byte_16_(QMC5883L_REGISTER_DATA_X_LSB, &raw_x)) {
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
x = int16_t(raw_x) * mg_per_bit * 0.1f;
|
||||
}
|
||||
if (this->y_sensor_ != nullptr || this->heading_sensor_ != nullptr) {
|
||||
uint16_t raw_y;
|
||||
if (!this->read_byte_16_(QMC5883L_REGISTER_DATA_Y_LSB, &raw_y)) {
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
y = int16_t(raw_y) * mg_per_bit * 0.1f;
|
||||
}
|
||||
if (this->z_sensor_ != nullptr) {
|
||||
uint16_t raw_z;
|
||||
if (!this->read_byte_16_(QMC5883L_REGISTER_DATA_Z_LSB, &raw_z)) {
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
z = int16_t(raw_z) * mg_per_bit * 0.1f;
|
||||
}
|
||||
|
||||
float heading = NAN;
|
||||
if (this->heading_sensor_ != nullptr) {
|
||||
heading = atan2f(0.0f - x, y) * 180.0f / M_PI;
|
||||
}
|
||||
|
||||
float heading = atan2f(0.0f - x, y) * 180.0f / M_PI;
|
||||
ESP_LOGD(TAG, "Got x=%0.02fµT y=%0.02fµT z=%0.02fµT heading=%0.01f° status=%u", x, y, z, heading, status);
|
||||
|
||||
if (this->x_sensor_ != nullptr)
|
||||
|
|
|
@ -74,12 +74,12 @@ def _format_framework_arduino_version(ver: cv.Version) -> str:
|
|||
# The default/recommended arduino framework version
|
||||
# - https://github.com/earlephilhower/arduino-pico/releases
|
||||
# - https://api.registry.platformio.org/v3/packages/earlephilhower/tool/framework-arduinopico
|
||||
RECOMMENDED_ARDUINO_FRAMEWORK_VERSION = cv.Version(3, 6, 0)
|
||||
RECOMMENDED_ARDUINO_FRAMEWORK_VERSION = cv.Version(3, 7, 2)
|
||||
|
||||
# The platformio/raspberrypi version to use for arduino frameworks
|
||||
# - https://github.com/platformio/platform-raspberrypi/releases
|
||||
# - https://api.registry.platformio.org/v3/packages/platformio/platform/raspberrypi
|
||||
ARDUINO_PLATFORM_VERSION = cv.Version(1, 10, 0)
|
||||
ARDUINO_PLATFORM_VERSION = cv.Version(1, 12, 0)
|
||||
|
||||
|
||||
def _arduino_check_versions(value):
|
||||
|
|
|
@ -30,37 +30,37 @@ CONFIG_SCHEMA = cv.All(
|
|||
|
||||
|
||||
def determine_config_register(polling_period):
|
||||
if polling_period >= 16.0:
|
||||
if polling_period >= 16000:
|
||||
# 64 averaged conversions, max conversion time
|
||||
# 0000 00 111 11 00000
|
||||
# 0000 0011 1110 0000
|
||||
return 0x03E0
|
||||
if polling_period >= 8.0:
|
||||
if polling_period >= 8000:
|
||||
# 64 averaged conversions, high conversion time
|
||||
# 0000 00 110 11 00000
|
||||
# 0000 0011 0110 0000
|
||||
return 0x0360
|
||||
if polling_period >= 4.0:
|
||||
if polling_period >= 4000:
|
||||
# 64 averaged conversions, mid conversion time
|
||||
# 0000 00 101 11 00000
|
||||
# 0000 0010 1110 0000
|
||||
return 0x02E0
|
||||
if polling_period >= 1.0:
|
||||
if polling_period >= 1000:
|
||||
# 64 averaged conversions, min conversion time
|
||||
# 0000 00 000 11 00000
|
||||
# 0000 0000 0110 0000
|
||||
return 0x0060
|
||||
if polling_period >= 0.5:
|
||||
if polling_period >= 500:
|
||||
# 32 averaged conversions, min conversion time
|
||||
# 0000 00 000 10 00000
|
||||
# 0000 0000 0100 0000
|
||||
return 0x0040
|
||||
if polling_period >= 0.25:
|
||||
if polling_period >= 250:
|
||||
# 8 averaged conversions, mid conversion time
|
||||
# 0000 00 010 01 00000
|
||||
# 0000 0001 0010 0000
|
||||
return 0x0120
|
||||
if polling_period >= 0.125:
|
||||
if polling_period >= 125:
|
||||
# 8 averaged conversions, min conversion time
|
||||
# 0000 00 000 01 00000
|
||||
# 0000 0000 0010 0000
|
||||
|
@ -76,5 +76,5 @@ async def to_code(config):
|
|||
await cg.register_component(var, config)
|
||||
await i2c.register_i2c_device(var, config)
|
||||
|
||||
update_period = config[CONF_UPDATE_INTERVAL].total_seconds
|
||||
update_period = config[CONF_UPDATE_INTERVAL].total_milliseconds
|
||||
cg.add(var.set_config(determine_config_register(update_period)))
|
||||
|
|
|
@ -59,17 +59,14 @@ def clone_or_update(
|
|||
)
|
||||
|
||||
repo_dir = _compute_destination_path(key, domain)
|
||||
fetch_pr_branch = ref is not None and ref.startswith("pull/")
|
||||
if not repo_dir.is_dir():
|
||||
_LOGGER.info("Cloning %s", key)
|
||||
_LOGGER.debug("Location: %s", repo_dir)
|
||||
cmd = ["git", "clone", "--depth=1"]
|
||||
if ref is not None and not fetch_pr_branch:
|
||||
cmd += ["--branch", ref]
|
||||
cmd += ["--", url, str(repo_dir)]
|
||||
run_git_command(cmd)
|
||||
|
||||
if fetch_pr_branch:
|
||||
if ref is not None:
|
||||
# We need to fetch the PR branch first, otherwise git will complain
|
||||
# about missing objects
|
||||
_LOGGER.info("Fetching %s", ref)
|
||||
|
|
|
@ -154,13 +154,12 @@ extra_scripts = post:esphome/components/esp32/post_build.py.script
|
|||
; These are common settings for the RP2040 using Arduino.
|
||||
[common:rp2040-arduino]
|
||||
extends = common:arduino
|
||||
board_build.core = earlephilhower
|
||||
board_build.filesystem_size = 0.5m
|
||||
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
||||
platform_packages =
|
||||
; earlephilhower/framework-arduinopico@~1.20602.0 ; Cannot use the platformio package until old releases stop getting deleted
|
||||
earlephilhower/framework-arduinopico@https://github.com/earlephilhower/arduino-pico/releases/download/3.6.0/rp2040-3.6.0.zip
|
||||
earlephilhower/framework-arduinopico@https://github.com/earlephilhower/arduino-pico/releases/download/3.7.2/rp2040-3.7.2.zip
|
||||
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
|
|
Loading…
Reference in a new issue