mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 14:43:51 +00:00
use `encode_uintXX` (#8847)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/uart/uart.h"
|
||||
|
||||
@@ -28,8 +29,13 @@ class GCJA5Component : public Component, public uart::UARTDevice {
|
||||
void parse_data_();
|
||||
bool calculate_checksum_();
|
||||
|
||||
uint32_t get_32_bit_uint_(uint8_t start_index);
|
||||
uint16_t get_16_bit_uint_(uint8_t start_index);
|
||||
uint16_t get_16_bit_uint_(uint8_t start_index) const {
|
||||
return encode_uint16(this->rx_message_[start_index + 1], this->rx_message_[start_index]);
|
||||
}
|
||||
uint32_t get_32_bit_uint_(uint8_t start_index) const {
|
||||
return encode_uint32(this->rx_message_[start_index + 3], this->rx_message_[start_index + 2],
|
||||
this->rx_message_[start_index + 1], this->rx_message_[start_index]);
|
||||
}
|
||||
uint32_t last_transmission_{0};
|
||||
std::vector<uint8_t> rx_message_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user