mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 18:18:43 +00:00
[multiple] Fix minor bugs in 8 components (#14650)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
7c1b9f0cb4
commit
9902447834
@@ -138,23 +138,24 @@ void BL0906::read_data_(const uint8_t address, const float reference, sensor::Se
|
||||
|
||||
this->write_byte(BL0906_READ_COMMAND);
|
||||
this->write_byte(address);
|
||||
if (this->read_array((uint8_t *) &buffer, sizeof(buffer) - 1)) {
|
||||
if (bl0906_checksum(address, &buffer) == buffer.checksum) {
|
||||
if (signed_result) {
|
||||
data_s24.l = buffer.l;
|
||||
data_s24.m = buffer.m;
|
||||
data_s24.h = buffer.h;
|
||||
} else {
|
||||
data_u24.l = buffer.l;
|
||||
data_u24.m = buffer.m;
|
||||
data_u24.h = buffer.h;
|
||||
}
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Junk on wire. Throwing away partial message");
|
||||
while (read() >= 0)
|
||||
;
|
||||
return;
|
||||
}
|
||||
if (!this->read_array((uint8_t *) &buffer, sizeof(buffer) - 1)) {
|
||||
ESP_LOGW(TAG, "Read failed");
|
||||
return;
|
||||
}
|
||||
if (bl0906_checksum(address, &buffer) != buffer.checksum) {
|
||||
ESP_LOGW(TAG, "Junk on wire. Throwing away partial message");
|
||||
while (read() >= 0)
|
||||
;
|
||||
return;
|
||||
}
|
||||
if (signed_result) {
|
||||
data_s24.l = buffer.l;
|
||||
data_s24.m = buffer.m;
|
||||
data_s24.h = buffer.h;
|
||||
} else {
|
||||
data_u24.l = buffer.l;
|
||||
data_u24.m = buffer.m;
|
||||
data_u24.h = buffer.h;
|
||||
}
|
||||
// Power
|
||||
if (reference == BL0906_PREF) {
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace esphome {
|
||||
namespace bmi160 {
|
||||
|
||||
static const char *const TAG = "bmi160";
|
||||
static constexpr uint32_t GYRO_WAKEUP_TIMEOUT_MS = 100;
|
||||
|
||||
const uint8_t BMI160_REGISTER_CHIPID = 0x00;
|
||||
|
||||
@@ -144,7 +145,7 @@ void BMI160Component::internal_setup_(int stage) {
|
||||
}
|
||||
ESP_LOGV(TAG, " Waiting for gyroscope to wake up");
|
||||
// wait between 51 & 81ms, doing 100 to be safe
|
||||
this->set_timeout(10, [this]() { this->internal_setup_(2); });
|
||||
this->set_timeout(GYRO_WAKEUP_TIMEOUT_MS, [this]() { this->internal_setup_(2); });
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
@@ -146,6 +146,10 @@ void ESP32Camera::dump_config() {
|
||||
}
|
||||
|
||||
sensor_t *s = esp_camera_sensor_get();
|
||||
if (s == nullptr) {
|
||||
ESP_LOGE(TAG, " Camera sensor not available");
|
||||
return;
|
||||
}
|
||||
auto st = s->status;
|
||||
ESP_LOGCONFIG(TAG,
|
||||
" JPEG Quality: %u\n"
|
||||
@@ -483,6 +487,9 @@ void ESP32Camera::request_image(camera::CameraRequester requester) { this->singl
|
||||
camera::CameraImageReader *ESP32Camera::create_image_reader() { return new ESP32CameraImageReader; }
|
||||
void ESP32Camera::update_camera_parameters() {
|
||||
sensor_t *s = esp_camera_sensor_get();
|
||||
if (s == nullptr) {
|
||||
return;
|
||||
}
|
||||
/* update image */
|
||||
s->set_vflip(s, this->vertical_flip_);
|
||||
s->set_hmirror(s, this->horizontal_mirror_);
|
||||
|
||||
@@ -133,7 +133,7 @@ static constexpr uint8_t DATA_FRAME_FOOTER[2] = {0x55, 0xCC};
|
||||
// MAC address the module uses when Bluetooth is disabled
|
||||
static constexpr uint8_t NO_MAC[] = {0x08, 0x05, 0x04, 0x03, 0x02, 0x01};
|
||||
|
||||
static inline uint16_t convert_seconds_to_ms(uint16_t value) { return value * 1000; };
|
||||
static inline uint32_t convert_seconds_to_ms(uint16_t value) { return (uint32_t) value * 1000; };
|
||||
|
||||
static inline void convert_int_values_to_hex(const int *values, uint8_t *bytes) {
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
|
||||
@@ -168,7 +168,7 @@ class LD2450Component : public Component, public uart::UARTDevice {
|
||||
uint32_t presence_millis_ = 0;
|
||||
uint32_t still_presence_millis_ = 0;
|
||||
uint32_t moving_presence_millis_ = 0;
|
||||
uint16_t timeout_ = 5;
|
||||
uint32_t timeout_ = 5;
|
||||
uint8_t buffer_data_[MAX_LINE_LENGTH];
|
||||
uint8_t mac_address_[6] = {0, 0, 0, 0, 0, 0};
|
||||
uint8_t version_[6] = {0, 0, 0, 0, 0, 0};
|
||||
|
||||
@@ -324,6 +324,8 @@ class AddressableFireworksEffect : public AddressableLightEffect {
|
||||
target *= 170;
|
||||
view = target;
|
||||
}
|
||||
if (it.size() < 2)
|
||||
return;
|
||||
int last = it.size() - 1;
|
||||
it[0].set(it[0].get() + (it[1].get() * 128));
|
||||
for (int i = 1; i < last; i++) {
|
||||
|
||||
@@ -126,18 +126,18 @@ bool MopekaStdCheck::parse_device(const esp32_ble_tracker::ESPBTDevice &device)
|
||||
// Copy measurements over into my array.
|
||||
{
|
||||
u_int8_t measurements_index = 0;
|
||||
for (u_int8_t i = 0; i < 3; i++) {
|
||||
measurements_time[measurements_index] = mopeka_data->val[i].time_0 + 1;
|
||||
measurements_value[measurements_index] = mopeka_data->val[i].value_0;
|
||||
for (const auto &val : mopeka_data->val) {
|
||||
measurements_time[measurements_index] = val.time_0 + 1;
|
||||
measurements_value[measurements_index] = val.value_0;
|
||||
measurements_index++;
|
||||
measurements_time[measurements_index] = mopeka_data->val[i].time_1 + 1;
|
||||
measurements_value[measurements_index] = mopeka_data->val[i].value_1;
|
||||
measurements_time[measurements_index] = val.time_1 + 1;
|
||||
measurements_value[measurements_index] = val.value_1;
|
||||
measurements_index++;
|
||||
measurements_time[measurements_index] = mopeka_data->val[i].time_2 + 1;
|
||||
measurements_value[measurements_index] = mopeka_data->val[i].value_2;
|
||||
measurements_time[measurements_index] = val.time_2 + 1;
|
||||
measurements_value[measurements_index] = val.value_2;
|
||||
measurements_index++;
|
||||
measurements_time[measurements_index] = mopeka_data->val[i].time_3 + 1;
|
||||
measurements_value[measurements_index] = mopeka_data->val[i].value_3;
|
||||
measurements_time[measurements_index] = val.time_3 + 1;
|
||||
measurements_value[measurements_index] = val.value_3;
|
||||
measurements_index++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ struct mopeka_std_package { // NOLINT(readability-identifier-naming,altera-stru
|
||||
bool slow_update_rate : 1;
|
||||
bool sync_pressed : 1;
|
||||
|
||||
mopeka_std_values val[4];
|
||||
mopeka_std_values val[3];
|
||||
} __attribute__((packed));
|
||||
|
||||
class MopekaStdCheck : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
|
||||
|
||||
@@ -146,16 +146,19 @@ void Rtttl::loop() {
|
||||
}
|
||||
#endif // USE_SPEAKER
|
||||
|
||||
// Align to note: most rtttl's out there does not add any space after the ',' separator but just in case
|
||||
while (this->position_ < this->rtttl_.length()) {
|
||||
char c = this->rtttl_[this->position_];
|
||||
if (c != ',' && c != ' ')
|
||||
break;
|
||||
this->position_++;
|
||||
}
|
||||
|
||||
if (this->position_ >= this->rtttl_.length()) {
|
||||
this->finish_();
|
||||
return;
|
||||
}
|
||||
|
||||
// Align to note: most rtttl's out there does not add any space after the ',' separator but just in case
|
||||
while (this->rtttl_[this->position_] == ',' || this->rtttl_[this->position_] == ' ') {
|
||||
this->position_++;
|
||||
}
|
||||
|
||||
// First, get note duration, if available
|
||||
uint8_t note_denominator = this->get_integer_();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user