mirror of
https://github.com/esphome/esphome.git
synced 2024-11-29 12:55:46 +01:00
Fix compile errors on ESP32-C6 with latest ESP-IDF (#6822)
* Use <cinttypes> PRI macros to fix ESP32-C6 compile * Fix compile error on latest ESP-IDF framework & platform
This commit is contained in:
parent
497cf8742f
commit
db6f6f0cb7
@ -10,6 +10,7 @@
|
|||||||
#include "ade7880.h"
|
#include "ade7880.h"
|
||||||
#include "ade7880_registers.h"
|
#include "ade7880_registers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ade7880 {
|
namespace ade7880 {
|
||||||
@ -156,7 +157,7 @@ void ADE7880::update() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "update took %u ms", millis() - start);
|
ESP_LOGD(TAG, "update took %" PRIu32 " ms", millis() - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ADE7880::dump_config() {
|
void ADE7880::dump_config() {
|
||||||
@ -176,9 +177,9 @@ void ADE7880::dump_config() {
|
|||||||
LOG_SENSOR(" ", "Forward Active Energy", this->channel_a_->forward_active_energy);
|
LOG_SENSOR(" ", "Forward Active Energy", this->channel_a_->forward_active_energy);
|
||||||
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_a_->reverse_active_energy);
|
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_a_->reverse_active_energy);
|
||||||
ESP_LOGCONFIG(TAG, " Calibration:");
|
ESP_LOGCONFIG(TAG, " Calibration:");
|
||||||
ESP_LOGCONFIG(TAG, " Current: %u", this->channel_a_->current_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Current: %" PRId32, this->channel_a_->current_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Voltage: %d", this->channel_a_->voltage_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Voltage: %" PRId32, this->channel_a_->voltage_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Power: %d", this->channel_a_->power_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Power: %" PRId32, this->channel_a_->power_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_a_->phase_angle_calibration);
|
ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_a_->phase_angle_calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,9 +193,9 @@ void ADE7880::dump_config() {
|
|||||||
LOG_SENSOR(" ", "Forward Active Energy", this->channel_b_->forward_active_energy);
|
LOG_SENSOR(" ", "Forward Active Energy", this->channel_b_->forward_active_energy);
|
||||||
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_b_->reverse_active_energy);
|
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_b_->reverse_active_energy);
|
||||||
ESP_LOGCONFIG(TAG, " Calibration:");
|
ESP_LOGCONFIG(TAG, " Calibration:");
|
||||||
ESP_LOGCONFIG(TAG, " Current: %u", this->channel_b_->current_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Current: %" PRId32, this->channel_b_->current_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Voltage: %d", this->channel_b_->voltage_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Voltage: %" PRId32, this->channel_b_->voltage_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Power: %d", this->channel_b_->power_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Power: %" PRId32, this->channel_b_->power_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_b_->phase_angle_calibration);
|
ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_b_->phase_angle_calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,9 +209,9 @@ void ADE7880::dump_config() {
|
|||||||
LOG_SENSOR(" ", "Forward Active Energy", this->channel_c_->forward_active_energy);
|
LOG_SENSOR(" ", "Forward Active Energy", this->channel_c_->forward_active_energy);
|
||||||
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_c_->reverse_active_energy);
|
LOG_SENSOR(" ", "Reverse Active Energy", this->channel_c_->reverse_active_energy);
|
||||||
ESP_LOGCONFIG(TAG, " Calibration:");
|
ESP_LOGCONFIG(TAG, " Calibration:");
|
||||||
ESP_LOGCONFIG(TAG, " Current: %u", this->channel_c_->current_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Current: %" PRId32, this->channel_c_->current_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Voltage: %d", this->channel_c_->voltage_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Voltage: %" PRId32, this->channel_c_->voltage_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Power: %d", this->channel_c_->power_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Power: %" PRId32, this->channel_c_->power_gain_calibration);
|
||||||
ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_c_->phase_angle_calibration);
|
ESP_LOGCONFIG(TAG, " Phase Angle: %u", this->channel_c_->phase_angle_calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +219,7 @@ void ADE7880::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, " Neutral:");
|
ESP_LOGCONFIG(TAG, " Neutral:");
|
||||||
LOG_SENSOR(" ", "Current", this->channel_n_->current);
|
LOG_SENSOR(" ", "Current", this->channel_n_->current);
|
||||||
ESP_LOGCONFIG(TAG, " Calibration:");
|
ESP_LOGCONFIG(TAG, " Calibration:");
|
||||||
ESP_LOGCONFIG(TAG, " Current: %u", this->channel_n_->current_gain_calibration);
|
ESP_LOGCONFIG(TAG, " Current: %" PRId32, this->channel_n_->current_gain_calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_I2C_DEVICE(this);
|
LOG_I2C_DEVICE(this);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "ade7953_base.h"
|
#include "ade7953_base.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ade7953_base {
|
namespace ade7953_base {
|
||||||
@ -105,7 +106,7 @@ void ADE7953::update() {
|
|||||||
this->last_update_ = now;
|
this->last_update_ = now;
|
||||||
// prevent DIV/0
|
// prevent DIV/0
|
||||||
pf = ADE_WATTSEC_POWER_FACTOR * (diff < 10 ? 10 : diff) / 1000;
|
pf = ADE_WATTSEC_POWER_FACTOR * (diff < 10 ? 10 : diff) / 1000;
|
||||||
ESP_LOGVV(TAG, "ADE7953::update() diff=%d pf=%f", diff, pf);
|
ESP_LOGVV(TAG, "ADE7953::update() diff=%" PRIu32 " pf=%f", diff, pf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apparent power
|
// Apparent power
|
||||||
|
@ -541,34 +541,34 @@ void FingerprintGrowComponent::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, " Sensor Power Pin: %s",
|
ESP_LOGCONFIG(TAG, " Sensor Power Pin: %s",
|
||||||
this->has_power_pin_ ? this->sensor_power_pin_->dump_summary().c_str() : "None");
|
this->has_power_pin_ ? this->sensor_power_pin_->dump_summary().c_str() : "None");
|
||||||
if (this->idle_period_to_sleep_ms_ < UINT32_MAX) {
|
if (this->idle_period_to_sleep_ms_ < UINT32_MAX) {
|
||||||
ESP_LOGCONFIG(TAG, " Idle Period to Sleep: %u ms", this->idle_period_to_sleep_ms_);
|
ESP_LOGCONFIG(TAG, " Idle Period to Sleep: %" PRIu32 " ms", this->idle_period_to_sleep_ms_);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGCONFIG(TAG, " Idle Period to Sleep: Never");
|
ESP_LOGCONFIG(TAG, " Idle Period to Sleep: Never");
|
||||||
}
|
}
|
||||||
LOG_UPDATE_INTERVAL(this);
|
LOG_UPDATE_INTERVAL(this);
|
||||||
if (this->fingerprint_count_sensor_) {
|
if (this->fingerprint_count_sensor_) {
|
||||||
LOG_SENSOR(" ", "Fingerprint Count", this->fingerprint_count_sensor_);
|
LOG_SENSOR(" ", "Fingerprint Count", this->fingerprint_count_sensor_);
|
||||||
ESP_LOGCONFIG(TAG, " Current Value: %d", (uint16_t) this->fingerprint_count_sensor_->get_state());
|
ESP_LOGCONFIG(TAG, " Current Value: %u", (uint16_t) this->fingerprint_count_sensor_->get_state());
|
||||||
}
|
}
|
||||||
if (this->status_sensor_) {
|
if (this->status_sensor_) {
|
||||||
LOG_SENSOR(" ", "Status", this->status_sensor_);
|
LOG_SENSOR(" ", "Status", this->status_sensor_);
|
||||||
ESP_LOGCONFIG(TAG, " Current Value: %d", (uint8_t) this->status_sensor_->get_state());
|
ESP_LOGCONFIG(TAG, " Current Value: %u", (uint8_t) this->status_sensor_->get_state());
|
||||||
}
|
}
|
||||||
if (this->capacity_sensor_) {
|
if (this->capacity_sensor_) {
|
||||||
LOG_SENSOR(" ", "Capacity", this->capacity_sensor_);
|
LOG_SENSOR(" ", "Capacity", this->capacity_sensor_);
|
||||||
ESP_LOGCONFIG(TAG, " Current Value: %d", (uint16_t) this->capacity_sensor_->get_state());
|
ESP_LOGCONFIG(TAG, " Current Value: %u", (uint16_t) this->capacity_sensor_->get_state());
|
||||||
}
|
}
|
||||||
if (this->security_level_sensor_) {
|
if (this->security_level_sensor_) {
|
||||||
LOG_SENSOR(" ", "Security Level", this->security_level_sensor_);
|
LOG_SENSOR(" ", "Security Level", this->security_level_sensor_);
|
||||||
ESP_LOGCONFIG(TAG, " Current Value: %d", (uint8_t) this->security_level_sensor_->get_state());
|
ESP_LOGCONFIG(TAG, " Current Value: %u", (uint8_t) this->security_level_sensor_->get_state());
|
||||||
}
|
}
|
||||||
if (this->last_finger_id_sensor_) {
|
if (this->last_finger_id_sensor_) {
|
||||||
LOG_SENSOR(" ", "Last Finger ID", this->last_finger_id_sensor_);
|
LOG_SENSOR(" ", "Last Finger ID", this->last_finger_id_sensor_);
|
||||||
ESP_LOGCONFIG(TAG, " Current Value: %d", (uint32_t) this->last_finger_id_sensor_->get_state());
|
ESP_LOGCONFIG(TAG, " Current Value: %" PRIu32, (uint32_t) this->last_finger_id_sensor_->get_state());
|
||||||
}
|
}
|
||||||
if (this->last_confidence_sensor_) {
|
if (this->last_confidence_sensor_) {
|
||||||
LOG_SENSOR(" ", "Last Confidence", this->last_confidence_sensor_);
|
LOG_SENSOR(" ", "Last Confidence", this->last_confidence_sensor_);
|
||||||
ESP_LOGCONFIG(TAG, " Current Value: %d", (uint32_t) this->last_confidence_sensor_->get_state());
|
ESP_LOGCONFIG(TAG, " Current Value: %" PRIu32, (uint32_t) this->last_confidence_sensor_->get_state());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "he60r.h"
|
#include "he60r.h"
|
||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace he60r {
|
namespace he60r {
|
||||||
@ -127,7 +128,7 @@ void HE60rCover::update_() {
|
|||||||
if (toggles_needed_ != 0) {
|
if (toggles_needed_ != 0) {
|
||||||
if ((this->counter_++ & 0x3) == 0) {
|
if ((this->counter_++ & 0x3) == 0) {
|
||||||
toggles_needed_--;
|
toggles_needed_--;
|
||||||
ESP_LOGD(TAG, "Writing byte 0x30, still needed=%d", toggles_needed_);
|
ESP_LOGD(TAG, "Writing byte 0x30, still needed=%" PRIu32, toggles_needed_);
|
||||||
this->write_byte(TOGGLE_BYTE);
|
this->write_byte(TOGGLE_BYTE);
|
||||||
} else {
|
} else {
|
||||||
this->write_byte(QUERY_BYTE);
|
this->write_byte(QUERY_BYTE);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "mhz19.h"
|
#include "mhz19.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace mhz19 {
|
namespace mhz19 {
|
||||||
@ -32,7 +33,7 @@ void MHZ19Component::update() {
|
|||||||
uint32_t now_ms = millis();
|
uint32_t now_ms = millis();
|
||||||
uint32_t warmup_ms = this->warmup_seconds_ * 1000;
|
uint32_t warmup_ms = this->warmup_seconds_ * 1000;
|
||||||
if (now_ms < warmup_ms) {
|
if (now_ms < warmup_ms) {
|
||||||
ESP_LOGW(TAG, "MHZ19 warming up, %ds left", (warmup_ms - now_ms) / 1000);
|
ESP_LOGW(TAG, "MHZ19 warming up, %" PRIu32 " s left", (warmup_ms - now_ms) / 1000);
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -110,7 +111,7 @@ void MHZ19Component::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, " Automatic baseline calibration disabled on boot");
|
ESP_LOGCONFIG(TAG, " Automatic baseline calibration disabled on boot");
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGCONFIG(TAG, " Warmup seconds: %ds", this->warmup_seconds_);
|
ESP_LOGCONFIG(TAG, " Warmup time: %" PRIu32 " s", this->warmup_seconds_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mhz19
|
} // namespace mhz19
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "remote_base.h"
|
#include "remote_base.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cinttypes>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -144,7 +145,8 @@ class ABBWelcomeData {
|
|||||||
std::string to_string(uint8_t max_print_bytes = 255) const {
|
std::string to_string(uint8_t max_print_bytes = 255) const {
|
||||||
std::string info;
|
std::string info;
|
||||||
if (this->is_valid()) {
|
if (this->is_valid()) {
|
||||||
info = str_sprintf(this->get_three_byte_address() ? "[%06X %s %06X] Type: %02X" : "[%04X %s %04X] Type: %02X",
|
info = str_sprintf(this->get_three_byte_address() ? "[%06" PRIX32 " %s %06" PRIX32 "] Type: %02X"
|
||||||
|
: "[%04" PRIX32 " %s %04" PRIX32 "] Type: %02X",
|
||||||
this->get_source_address(), this->get_retransmission() ? "»" : ">",
|
this->get_source_address(), this->get_retransmission() ? "»" : ">",
|
||||||
this->get_destination_address(), this->get_message_type());
|
this->get_destination_address(), this->get_message_type());
|
||||||
if (this->get_data_size())
|
if (this->get_data_size())
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "byronsx_protocol.h"
|
#include "byronsx_protocol.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace remote_base {
|
namespace remote_base {
|
||||||
@ -57,7 +58,7 @@ void ByronSXProtocol::encode(RemoteTransmitData *dst, const ByronSXData &data) {
|
|||||||
out_data <<= NBITS_COMMAND;
|
out_data <<= NBITS_COMMAND;
|
||||||
out_data |= data.command;
|
out_data |= data.command;
|
||||||
|
|
||||||
ESP_LOGV(TAG, "Send ByronSX: out_data %03x", out_data);
|
ESP_LOGV(TAG, "Send ByronSX: out_data %03" PRIx32, out_data);
|
||||||
|
|
||||||
// Initial Mark start bit
|
// Initial Mark start bit
|
||||||
dst->mark(1 * BIT_TIME_US);
|
dst->mark(1 * BIT_TIME_US);
|
||||||
@ -90,13 +91,16 @@ optional<ByronSXData> ByronSXProtocol::decode(RemoteReceiveData src) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGVV(TAG, "%3d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", src.size(), src.peek(0),
|
ESP_LOGVV(TAG,
|
||||||
src.peek(1), src.peek(2), src.peek(3), src.peek(4), src.peek(5), src.peek(6), src.peek(7), src.peek(8),
|
"%3" PRId32 ": %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32
|
||||||
src.peek(9), src.peek(10), src.peek(11), src.peek(12), src.peek(13), src.peek(14), src.peek(15),
|
" %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32
|
||||||
src.peek(16), src.peek(17), src.peek(18), src.peek(19));
|
" %" PRId32 " %" PRId32 " %" PRId32,
|
||||||
|
src.size(), src.peek(0), src.peek(1), src.peek(2), src.peek(3), src.peek(4), src.peek(5), src.peek(6),
|
||||||
|
src.peek(7), src.peek(8), src.peek(9), src.peek(10), src.peek(11), src.peek(12), src.peek(13), src.peek(14),
|
||||||
|
src.peek(15), src.peek(16), src.peek(17), src.peek(18), src.peek(19));
|
||||||
|
|
||||||
ESP_LOGVV(TAG, " %d %d %d %d %d %d", src.peek(20), src.peek(21), src.peek(22), src.peek(23), src.peek(24),
|
ESP_LOGVV(TAG, " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32, src.peek(20),
|
||||||
src.peek(25));
|
src.peek(21), src.peek(22), src.peek(23), src.peek(24), src.peek(25));
|
||||||
|
|
||||||
// Read data bits
|
// Read data bits
|
||||||
uint32_t out_data = 0;
|
uint32_t out_data = 0;
|
||||||
@ -107,10 +111,10 @@ optional<ByronSXData> ByronSXProtocol::decode(RemoteReceiveData src) {
|
|||||||
} else if (src.expect_space(BIT_TIME_US) && src.expect_mark(2 * BIT_TIME_US)) {
|
} else if (src.expect_space(BIT_TIME_US) && src.expect_mark(2 * BIT_TIME_US)) {
|
||||||
out_data |= 0 << bit;
|
out_data |= 0 << bit;
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGV(TAG, "Decode ByronSX: Fail 2, %2d %08x", bit, out_data);
|
ESP_LOGV(TAG, "Decode ByronSX: Fail 2, %2d %08" PRIx32, bit, out_data);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
ESP_LOGVV(TAG, "Decode ByronSX: Data, %2d %08x", bit, out_data);
|
ESP_LOGVV(TAG, "Decode ByronSX: Data, %2d %08" PRIx32, bit, out_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// last bit followed by a long space
|
// last bit followed by a long space
|
||||||
|
@ -151,12 +151,12 @@ optional<DraytonData> DraytonProtocol::decode(RemoteReceiveData src) {
|
|||||||
|
|
||||||
// Look for sync pulse, after. If sucessful index points to space of sync symbol
|
// Look for sync pulse, after. If sucessful index points to space of sync symbol
|
||||||
while (src.size() - src.get_index() >= MIN_RX_SRC) {
|
while (src.size() - src.get_index() >= MIN_RX_SRC) {
|
||||||
ESP_LOGVV(TAG, "Decode Drayton: sync search %d, %" PRId32 " %" PRId32, src.size() - src.get_index(), src.peek(),
|
ESP_LOGVV(TAG, "Decode Drayton: sync search %" PRIu32 ", %" PRId32 " %" PRId32, src.size() - src.get_index(),
|
||||||
src.peek(1));
|
src.peek(), src.peek(1));
|
||||||
if (src.peek_mark(2 * BIT_TIME_US) &&
|
if (src.peek_mark(2 * BIT_TIME_US) &&
|
||||||
(src.peek_space(2 * BIT_TIME_US, 1) || src.peek_space(3 * BIT_TIME_US, 1))) {
|
(src.peek_space(2 * BIT_TIME_US, 1) || src.peek_space(3 * BIT_TIME_US, 1))) {
|
||||||
src.advance(1);
|
src.advance(1);
|
||||||
ESP_LOGVV(TAG, "Decode Drayton: Found SYNC, - %d", src.get_index());
|
ESP_LOGVV(TAG, "Decode Drayton: Found SYNC, - %" PRIu32, src.get_index());
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
src.advance(2);
|
src.advance(2);
|
||||||
@ -174,14 +174,16 @@ optional<DraytonData> DraytonProtocol::decode(RemoteReceiveData src) {
|
|||||||
// Checks next bit to leave index pointing correctly
|
// Checks next bit to leave index pointing correctly
|
||||||
uint32_t out_data = 0;
|
uint32_t out_data = 0;
|
||||||
uint8_t bit = NDATABITS - 1;
|
uint8_t bit = NDATABITS - 1;
|
||||||
ESP_LOGVV(TAG, "Decode Drayton: first bit %d %" PRId32 ", %" PRId32, src.peek(0), src.peek(1), src.peek(2));
|
ESP_LOGVV(TAG, "Decode Drayton: first bit %" PRId32 " %" PRId32 ", %" PRId32, src.peek(0), src.peek(1),
|
||||||
|
src.peek(2));
|
||||||
if (src.expect_space(3 * BIT_TIME_US) && (src.expect_mark(BIT_TIME_US) || src.peek_mark(2 * BIT_TIME_US))) {
|
if (src.expect_space(3 * BIT_TIME_US) && (src.expect_mark(BIT_TIME_US) || src.peek_mark(2 * BIT_TIME_US))) {
|
||||||
out_data |= 0 << bit;
|
out_data |= 0 << bit;
|
||||||
} else if (src.expect_space(2 * BIT_TIME_US) && src.expect_mark(BIT_TIME_US) &&
|
} else if (src.expect_space(2 * BIT_TIME_US) && src.expect_mark(BIT_TIME_US) &&
|
||||||
(src.expect_space(BIT_TIME_US) || src.peek_space(2 * BIT_TIME_US))) {
|
(src.expect_space(BIT_TIME_US) || src.peek_space(2 * BIT_TIME_US))) {
|
||||||
out_data |= 1 << bit;
|
out_data |= 1 << bit;
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGV(TAG, "Decode Drayton: Fail 2, - %d %d %d", src.peek(-1), src.peek(0), src.peek(1));
|
ESP_LOGV(TAG, "Decode Drayton: Fail 2, - %" PRId32 " %" PRId32 " %" PRId32, src.peek(-1), src.peek(0),
|
||||||
|
src.peek(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +204,8 @@ optional<DraytonData> DraytonProtocol::decode(RemoteReceiveData src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bit > 0) {
|
if (bit > 0) {
|
||||||
ESP_LOGVV(TAG, "Decode Drayton: Fail 3, %d %" PRId32 " %" PRId32, src.peek(-1), src.peek(0), src.peek(1));
|
ESP_LOGVV(TAG, "Decode Drayton: Fail 3, %" PRId32 " %" PRId32 " %" PRId32, src.peek(-1), src.peek(0),
|
||||||
|
src.peek(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +217,7 @@ optional<DraytonData> DraytonProtocol::decode(RemoteReceiveData src) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGV(TAG, "Decode Drayton: Data, %2d %08x", bit, out_data);
|
ESP_LOGV(TAG, "Decode Drayton: Data, %2d %08" PRIx32, bit, out_data);
|
||||||
|
|
||||||
out.channel = (uint8_t) (out_data & 0x1F);
|
out.channel = (uint8_t) (out_data & 0x1F);
|
||||||
out_data >>= NBITS_CHANNEL;
|
out_data >>= NBITS_CHANNEL;
|
||||||
|
@ -52,7 +52,7 @@ void KeeloqProtocol::encode(RemoteTransmitData *dst, const KeeloqData &data) {
|
|||||||
// Encrypted field
|
// Encrypted field
|
||||||
out_data = data.encrypted;
|
out_data = data.encrypted;
|
||||||
|
|
||||||
ESP_LOGV(TAG, "Send Keeloq: Encrypted data %04x", out_data);
|
ESP_LOGV(TAG, "Send Keeloq: Encrypted data %04" PRIx32, out_data);
|
||||||
|
|
||||||
for (uint32_t mask = 1, cnt = 0; cnt < NBITS_ENCRYPTED_DATA; cnt++, mask <<= 1) {
|
for (uint32_t mask = 1, cnt = 0; cnt < NBITS_ENCRYPTED_DATA; cnt++, mask <<= 1) {
|
||||||
if (out_data & mask) {
|
if (out_data & mask) {
|
||||||
@ -68,7 +68,7 @@ void KeeloqProtocol::encode(RemoteTransmitData *dst, const KeeloqData &data) {
|
|||||||
out_data = (data.command & 0x0f);
|
out_data = (data.command & 0x0f);
|
||||||
out_data <<= NBITS_SERIAL;
|
out_data <<= NBITS_SERIAL;
|
||||||
out_data |= data.address;
|
out_data |= data.address;
|
||||||
ESP_LOGV(TAG, "Send Keeloq: Fixed data %04x", out_data);
|
ESP_LOGV(TAG, "Send Keeloq: Fixed data %04" PRIx32, out_data);
|
||||||
|
|
||||||
for (uint32_t mask = 1, cnt = 0; cnt < (NBITS_FIXED_DATA - 2); cnt++, mask <<= 1) {
|
for (uint32_t mask = 1, cnt = 0; cnt < (NBITS_FIXED_DATA - 2); cnt++, mask <<= 1) {
|
||||||
if (out_data & mask) {
|
if (out_data & mask) {
|
||||||
@ -111,21 +111,24 @@ optional<KeeloqData> KeeloqProtocol::decode(RemoteReceiveData src) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGVV(TAG, "%2d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", src.size(), src.peek(0),
|
ESP_LOGVV(TAG,
|
||||||
src.peek(1), src.peek(2), src.peek(3), src.peek(4), src.peek(5), src.peek(6), src.peek(7), src.peek(8),
|
"%2" PRId32 ": %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32
|
||||||
src.peek(9), src.peek(10), src.peek(11), src.peek(12), src.peek(13), src.peek(14), src.peek(15),
|
" %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32
|
||||||
src.peek(16), src.peek(17), src.peek(18), src.peek(19));
|
" %" PRId32 " %" PRId32 " %" PRId32,
|
||||||
|
src.size(), src.peek(0), src.peek(1), src.peek(2), src.peek(3), src.peek(4), src.peek(5), src.peek(6),
|
||||||
|
src.peek(7), src.peek(8), src.peek(9), src.peek(10), src.peek(11), src.peek(12), src.peek(13), src.peek(14),
|
||||||
|
src.peek(15), src.peek(16), src.peek(17), src.peek(18), src.peek(19));
|
||||||
|
|
||||||
// Check preamble bits
|
// Check preamble bits
|
||||||
int8_t bit = NBITS_PREAMBLE - 1;
|
int8_t bit = NBITS_PREAMBLE - 1;
|
||||||
while (--bit >= 0) {
|
while (--bit >= 0) {
|
||||||
if (!src.expect_mark(BIT_TIME_US) || !src.expect_space(BIT_TIME_US)) {
|
if (!src.expect_mark(BIT_TIME_US) || !src.expect_space(BIT_TIME_US)) {
|
||||||
ESP_LOGV(TAG, "Decode KeeLoq: Fail 1, %d %d", bit + 1, src.peek());
|
ESP_LOGV(TAG, "Decode KeeLoq: Fail 1, %d %" PRId32, bit + 1, src.peek());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!src.expect_mark(BIT_TIME_US) || !src.expect_space(10 * BIT_TIME_US)) {
|
if (!src.expect_mark(BIT_TIME_US) || !src.expect_space(10 * BIT_TIME_US)) {
|
||||||
ESP_LOGV(TAG, "Decode KeeLoq: Fail 1, %d %d", bit + 1, src.peek());
|
ESP_LOGV(TAG, "Decode KeeLoq: Fail 1, %d %" PRId32, bit + 1, src.peek());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,11 +140,11 @@ optional<KeeloqData> KeeloqProtocol::decode(RemoteReceiveData src) {
|
|||||||
} else if (src.expect_mark(BIT_TIME_US) && src.expect_space(2 * BIT_TIME_US)) {
|
} else if (src.expect_mark(BIT_TIME_US) && src.expect_space(2 * BIT_TIME_US)) {
|
||||||
out_data |= 1 << bit;
|
out_data |= 1 << bit;
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGV(TAG, "Decode KeeLoq: Fail 2, %d %d", src.get_index(), src.peek());
|
ESP_LOGV(TAG, "Decode KeeLoq: Fail 2, %" PRIu32 " %" PRId32, src.get_index(), src.peek());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGVV(TAG, "Decode KeeLoq: Data, %d %08x", bit, out_data);
|
ESP_LOGVV(TAG, "Decode KeeLoq: Data, %d %08" PRIx32, bit, out_data);
|
||||||
out.encrypted = out_data;
|
out.encrypted = out_data;
|
||||||
|
|
||||||
// Read Serial Number and Button Status
|
// Read Serial Number and Button Status
|
||||||
@ -152,11 +155,11 @@ optional<KeeloqData> KeeloqProtocol::decode(RemoteReceiveData src) {
|
|||||||
} else if (src.expect_mark(BIT_TIME_US) && src.expect_space(2 * BIT_TIME_US)) {
|
} else if (src.expect_mark(BIT_TIME_US) && src.expect_space(2 * BIT_TIME_US)) {
|
||||||
out_data |= 1 << bit;
|
out_data |= 1 << bit;
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGV(TAG, "Decode KeeLoq: Fail 3, %d %d", src.get_index(), src.peek());
|
ESP_LOGV(TAG, "Decode KeeLoq: Fail 3, %" PRIu32 " %" PRId32, src.get_index(), src.peek());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGVV(TAG, "Decode KeeLoq: Data, %2d %08x", bit, out_data);
|
ESP_LOGVV(TAG, "Decode KeeLoq: Data, %2d %08" PRIx32, bit, out_data);
|
||||||
out.command = (out_data >> 28) & 0xf;
|
out.command = (out_data >> 28) & 0xf;
|
||||||
out.address = out_data & 0xfffffff;
|
out.address = out_data & 0xfffffff;
|
||||||
|
|
||||||
@ -166,7 +169,7 @@ optional<KeeloqData> KeeloqProtocol::decode(RemoteReceiveData src) {
|
|||||||
} else if (src.expect_mark(BIT_TIME_US) && src.expect_space(2 * BIT_TIME_US)) {
|
} else if (src.expect_mark(BIT_TIME_US) && src.expect_space(2 * BIT_TIME_US)) {
|
||||||
out.vlow = true;
|
out.vlow = true;
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGV(TAG, "Decode KeeLoq: Fail 4, %08x", src.peek());
|
ESP_LOGV(TAG, "Decode KeeLoq: Fail 4, %" PRId32, src.peek());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +179,7 @@ optional<KeeloqData> KeeloqProtocol::decode(RemoteReceiveData src) {
|
|||||||
} else if (src.expect_mark(BIT_TIME_US) && src.peek_space_at_least(2 * BIT_TIME_US)) {
|
} else if (src.expect_mark(BIT_TIME_US) && src.peek_space_at_least(2 * BIT_TIME_US)) {
|
||||||
out.repeat = true;
|
out.repeat = true;
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGV(TAG, "Decode KeeLoq: Fail 5, %08x", src.peek());
|
ESP_LOGV(TAG, "Decode KeeLoq: Fail 5, %" PRId32, src.peek());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void IDFUARTComponent::setup() {
|
|||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->uart_num_ = next_uart_num++;
|
this->uart_num_ = static_cast<uart_port_t>(next_uart_num++);
|
||||||
ESP_LOGCONFIG(TAG, "Setting up UART %u...", this->uart_num_);
|
ESP_LOGCONFIG(TAG, "Setting up UART %u...", this->uart_num_);
|
||||||
|
|
||||||
this->lock_ = xSemaphoreCreateMutex();
|
this->lock_ = xSemaphoreCreateMutex();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/components/i2c/i2c.h"
|
#include "esphome/components/i2c/i2c.h"
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace xgzp68xx {
|
namespace xgzp68xx {
|
||||||
@ -37,8 +38,8 @@ void XGZP68XXComponent::update() {
|
|||||||
temperature_raw = encode_uint16(data[3], data[4]);
|
temperature_raw = encode_uint16(data[3], data[4]);
|
||||||
|
|
||||||
// Convert the pressure data to hPa
|
// Convert the pressure data to hPa
|
||||||
ESP_LOGV(TAG, "Got raw pressure=%d, raw temperature=%d ", pressure_raw, temperature_raw);
|
ESP_LOGV(TAG, "Got raw pressure=%" PRIu32 ", raw temperature=%u", pressure_raw, temperature_raw);
|
||||||
ESP_LOGV(TAG, "K value is %d ", this->k_value_);
|
ESP_LOGV(TAG, "K value is %u", this->k_value_);
|
||||||
|
|
||||||
// The most significant bit of both pressure and temperature will be 1 to indicate a negative value.
|
// The most significant bit of both pressure and temperature will be 1 to indicate a negative value.
|
||||||
// This is directly from the datasheet, and the calculations below will handle this.
|
// This is directly from the datasheet, and the calculations below will handle this.
|
||||||
|
Loading…
Reference in New Issue
Block a user