1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-13 16:52:18 +01:00

Avoid non-const globals and enable clang-tidy check (#1892)

This commit is contained in:
Stefan Agner
2021-06-10 22:19:44 +02:00
committed by GitHub
parent 360effcb72
commit 501f88ca86
376 changed files with 466 additions and 468 deletions

View File

@@ -698,7 +698,7 @@ RC_SWITCH_TRANSMITTER = cv.Schema(
}
)
rc_switch_protocols = ns.rc_switch_protocols
rc_switch_protocols = ns.RC_SWITCH_PROTOCOLS
RCSwitchData = ns.struct("RCSwitchData")
RCSwitchBase = ns.class_("RCSwitchBase")
RCSwitchTrigger = ns.class_("RCSwitchTrigger", RemoteReceiverTrigger)

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.jvc";
static const char *const TAG = "remote.jvc";
static const uint8_t NBITS = 16;
static const uint32_t HEADER_HIGH_US = 8400;

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.lg";
static const char *const TAG = "remote.lg";
static const uint32_t HEADER_HIGH_US = 8000;
static const uint32_t HEADER_LOW_US = 4000;

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.nec";
static const char *const TAG = "remote.nec";
static const uint32_t HEADER_HIGH_US = 9000;
static const uint32_t HEADER_LOW_US = 4500;

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.panasonic";
static const char *const TAG = "remote.panasonic";
static const uint32_t HEADER_HIGH_US = 3502;
static const uint32_t HEADER_LOW_US = 1750;

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.pioneer";
static const char *const TAG = "remote.pioneer";
static const uint32_t HEADER_HIGH_US = 9000;
static const uint32_t HEADER_LOW_US = 4500;

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.raw";
static const char *const TAG = "remote.raw";
bool RawDumper::dump(RemoteReceiveData src) {
char buffer[256];

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.rc5";
static const char *const TAG = "remote.rc5";
static const uint32_t BIT_TIME_US = 889;
static const uint8_t NBITS = 14;

View File

@@ -4,17 +4,17 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.rc_switch";
static const char *const TAG = "remote.rc_switch";
RCSwitchBase rc_switch_protocols[9] = {RCSwitchBase(0, 0, 0, 0, 0, 0, false),
RCSwitchBase(350, 10850, 350, 1050, 1050, 350, false),
RCSwitchBase(650, 6500, 650, 1300, 1300, 650, false),
RCSwitchBase(3000, 7100, 400, 1100, 900, 600, false),
RCSwitchBase(380, 2280, 380, 1140, 1140, 380, false),
RCSwitchBase(3000, 7000, 500, 1000, 1000, 500, false),
RCSwitchBase(10350, 450, 450, 900, 900, 450, true),
RCSwitchBase(300, 9300, 150, 900, 900, 150, false),
RCSwitchBase(250, 2500, 250, 1250, 250, 250, false)};
const RCSwitchBase RC_SWITCH_PROTOCOLS[9] = {RCSwitchBase(0, 0, 0, 0, 0, 0, false),
RCSwitchBase(350, 10850, 350, 1050, 1050, 350, false),
RCSwitchBase(650, 6500, 650, 1300, 1300, 650, false),
RCSwitchBase(3000, 7100, 400, 1100, 900, 600, false),
RCSwitchBase(380, 2280, 380, 1140, 1140, 380, false),
RCSwitchBase(3000, 7000, 500, 1000, 1000, 500, false),
RCSwitchBase(10350, 450, 450, 900, 900, 450, true),
RCSwitchBase(300, 9300, 150, 900, 900, 150, false),
RCSwitchBase(250, 2500, 250, 1250, 250, 250, false)};
RCSwitchBase::RCSwitchBase(uint32_t sync_high, uint32_t sync_low, uint32_t zero_high, uint32_t zero_low,
uint32_t one_high, uint32_t one_low, bool inverted)
@@ -132,7 +132,7 @@ optional<RCSwitchData> RCSwitchBase::decode(RemoteReceiveData &src) const {
uint8_t out_nbits;
for (uint8_t i = 1; i <= 8; i++) {
src.reset();
RCSwitchBase *protocol = &rc_switch_protocols[i];
const RCSwitchBase *protocol = &RC_SWITCH_PROTOCOLS[i];
if (protocol->decode(src, &out.code, &out_nbits) && out_nbits >= 3) {
out.protocol = i;
return out;
@@ -246,7 +246,7 @@ bool RCSwitchDumper::dump(RemoteReceiveData src) {
src.reset();
uint64_t out_data;
uint8_t out_nbits;
RCSwitchBase *protocol = &rc_switch_protocols[i];
const RCSwitchBase *protocol = &RC_SWITCH_PROTOCOLS[i];
if (protocol->decode(src, &out_data, &out_nbits) && out_nbits >= 3) {
char buffer[65];
for (uint8_t j = 0; j < out_nbits; j++)

View File

@@ -60,7 +60,7 @@ class RCSwitchBase {
bool inverted_{};
};
extern RCSwitchBase rc_switch_protocols[9];
extern const RCSwitchBase RC_SWITCH_PROTOCOLS[9];
uint64_t decode_binary_string(const std::string &data);

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote_base";
static const char *const TAG = "remote_base";
#ifdef ARDUINO_ARCH_ESP32
RemoteRMTChannel::RemoteRMTChannel(uint8_t mem_block_num) : mem_block_num_(mem_block_num) {

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.samsung36";
static const char *const TAG = "remote.samsung36";
static const uint8_t NBITS = 78;

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.samsung";
static const char *const TAG = "remote.samsung";
static const uint8_t NBITS = 32;
static const uint32_t HEADER_HIGH_US = 4500;

View File

@@ -4,7 +4,7 @@
namespace esphome {
namespace remote_base {
static const char *TAG = "remote.sony";
static const char *const TAG = "remote.sony";
static const uint32_t HEADER_HIGH_US = 2400;
static const uint32_t HEADER_LOW_US = 600;