Skip to content

Commit

Permalink
Various lint/coding updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SenexCrenshaw committed Jun 19, 2021
1 parent 112c6de commit 2634ebc
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace esphome {
namespace nextion {

static const char *TAG = "nextion_binarysensor";
static const char *const TAG = "nextion_binarysensor";

void NextionBinarySensor::process_bool(const std::string &variable_name, bool state) {
if (!this->nextion_->is_setup())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NextionBinarySensor : public NextionComponent,
NextionQueueType get_queue_type() override { return NextionQueueType::BINARY_SENSOR; }
void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override {}
void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override {
this->set_state(state_value == 0 ? false : true, publish, send_to_nextion);
this->set_state(state_value != 0, publish, send_to_nextion);
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/nextion/nextion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ uint16_t Nextion::recv_ret_string_(std::string &response, uint32_t timeout, bool
uint16_t ret = 0;
uint8_t c = 0;
uint8_t nr_of_ff_bytes = 0;
long start;
uint64_t start;
bool exit_flag = false;
bool ff_flag = false;

Expand Down
2 changes: 1 addition & 1 deletion esphome/components/nextion/nextion.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
std::deque<NextionQueue *> nextion_queue_;
uint16_t recv_ret_string_(std::string &response, uint32_t timeout, bool recv_flag);
void all_components_send_state_(bool force_update = false);
long comok_sent_ = 0;
uint64_t comok_sent_ = 0;
bool remove_from_q_(bool report_empty = true);
/**
* @brief
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/nextion/nextion_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace esphome {
namespace nextion {
static const char *TAG = "nextion";
static const char *const TAG = "nextion";

// Sleep safe commands
void Nextion::soft_reset() { this->send_command_("rest"); }
Expand Down
11 changes: 6 additions & 5 deletions esphome/components/nextion/nextion_component_base.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <utility>
#include "esphome/core/defines.h"

namespace esphome {
Expand All @@ -13,8 +14,8 @@ enum NextionQueueType {
WAVEFORM_SENSOR = 5,
};

static const char *NextionQueueTypeStrings[] = {"NO_RESULT", "SENSOR", "BINARY_SENSOR",
"SWITCH", "TEXT_SENSOR", "WAVEFORM_SENSOR"};
static const char *const NEXTION_QUEUE_TYPE_STRINGS[] = {"NO_RESULT", "SENSOR", "BINARY_SENSOR",
"SWITCH", "TEXT_SENSOR", "WAVEFORM_SENSOR"};

class NextionComponentBase;

Expand All @@ -29,10 +30,10 @@ class NextionComponentBase {
public:
virtual ~NextionComponentBase() = default;

void set_variable_name(std::string variable_name, std::string variable_name_to_send = "") {
void set_variable_name(const std::string &variable_name, const std::string &variable_name_to_send = "") {
variable_name_ = variable_name;
if (variable_name_to_send.empty()) {
variable_name_to_send_ = variable_name_;
variable_name_to_send_ = variable_name;
} else {
variable_name_to_send_ = variable_name_to_send;
}
Expand Down Expand Up @@ -71,7 +72,7 @@ class NextionComponentBase {
std::string get_variable_name() { return this->variable_name_; }
std::string get_variable_name_to_send() { return this->variable_name_to_send_; }
virtual NextionQueueType get_queue_type() { return NextionQueueType::NO_RESULT; }
virtual std::string get_queue_type_string() { return NextionQueueTypeStrings[this->get_queue_type()]; }
virtual std::string get_queue_type_string() { return NEXTION_QUEUE_TYPE_STRINGS[this->get_queue_type()]; }
virtual void set_state_from_int(int state_value, bool publish, bool send_to_nextion){};
virtual void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion){};
virtual void send_state_to_nextion(){};
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/nextion/nextion_upload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace esphome {
namespace nextion {
static const char *TAG = "nextion_upload";
static const char *const TAG = "nextion_upload";

#if defined(USE_TFT_UPLOAD) && (defined(USE_ETHERNET) || defined(USE_WIFI))

Expand Down
2 changes: 1 addition & 1 deletion esphome/components/nextion/sensor/nextion_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace esphome {
namespace nextion {

static const char *TAG = "nextion_sensor";
static const char *const TAG = "nextion_sensor";

void NextionSensor::process_sensor(const std::string &variable_name, int state) {
if (!this->nextion_->is_setup())
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/nextion/switch/nextion_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace esphome {
namespace nextion {

static const char *TAG = "nextion_switch";
static const char *const TAG = "nextion_switch";

void NextionSwitch::process_bool(const std::string &variable_name, bool on) {
if (!this->nextion_->is_setup())
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/nextion/switch/nextion_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class NextionSwitch : public NextionComponent, public switch_::Switch, public Po
NextionQueueType get_queue_type() override { return NextionQueueType::SWITCH; }
void set_state_from_string(const std::string &state_value, bool publish, bool send_to_nextion) override {}
void set_state_from_int(int state_value, bool publish, bool send_to_nextion) override {
this->set_state(state_value == 0 ? false : true, publish, send_to_nextion);
this->set_state(state_value != 0, publish, send_to_nextion);
}

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace esphome {
namespace nextion {
static const char *TAG = "nextion_textsensor";
static const char *const TAG = "nextion_textsensor";

void NextionTextSensor::process_text(const std::string &variable_name, const std::string &text_value) {
if (!this->nextion_->is_setup())
Expand Down

0 comments on commit 2634ebc

Please sign in to comment.