Changed names back to name without underscore

This commit is contained in:
KoenBreeman 2024-08-16 11:58:58 +02:00
parent 5e530970a5
commit 7a9a8e3eb6
4 changed files with 14 additions and 14 deletions

View File

@ -6,20 +6,20 @@ namespace m5stack_4relay {
static const char *const TAG = "m5stack_4_relay";
void M5Stack_4Relay::dump_config() {
void M5Stack4Relay::dump_config() {
ESP_LOGCONFIG(TAG, "M5Stack 4 Relays:");
LOG_I2C_DEVICE(this);
}
/*! @brief Setting the mode of the device, and turn off all relays, restore the switches with restore mode.
* @param mode Async = 0, Sync = 1. */
void M5Stack_4Relay::init_(bool mode) {
void M5Stack4Relay::init_(bool mode) {
this->write1_byte_(UNIT_4RELAY_REG, mode);
this->write1_byte_(UNIT_4RELAY_RELAY_REG, 0);
}
/*! @brief Read a certain length of data to the specified register address. */
uint8_t M5Stack_4Relay::read1_byte_(uint8_t register_address) {
uint8_t M5Stack4Relay::read1_byte_(uint8_t register_address) {
uint8_t data;
if (!this->read_byte(register_address, &data)) {
ESP_LOGW(TAG, "Read from relay failed!");
@ -32,7 +32,7 @@ uint8_t M5Stack_4Relay::read1_byte_(uint8_t register_address) {
/*! @brief Control the on/off of the specified relay.
* @param number Bit number of relay (0~3).
@param state OFF = 0, ON = 1 . */
void M5Stack_4Relay::relay_write(uint8_t number, bool state) {
void M5Stack4Relay::relay_write(uint8_t number, bool state) {
uint8_t state_from_device = this->read1_byte_(UNIT_4RELAY_RELAY_REG);
if (state == 0) {
state_from_device &= ~(0x01 << number);
@ -42,7 +42,7 @@ void M5Stack_4Relay::relay_write(uint8_t number, bool state) {
this->write1_byte_(UNIT_4RELAY_RELAY_REG, state_from_device);
}
void M5Stack_4Relay::setup() {
void M5Stack4Relay::setup() {
ESP_LOGCONFIG(TAG, "Setting up M5Stack_4_Relays...");
uint8_t setupmode = 1;
this->init_(setupmode);
@ -50,10 +50,10 @@ void M5Stack_4Relay::setup() {
/*! @brief Setting the mode of the device.
* @param mode Async = 0, Sync = 1. */
void M5Stack_4Relay::set_switch_mode(bool mode) { this->write1_byte_(UNIT_4RELAY_REG, mode); }
void M5Stack4Relay::set_switch_mode(bool mode) { this->write1_byte_(UNIT_4RELAY_REG, mode); }
/*! @brief Write a certain length of data to the specified register address. */
void M5Stack_4Relay::write1_byte_(uint8_t register_address, uint8_t data) {
void M5Stack4Relay::write1_byte_(uint8_t register_address, uint8_t data) {
if (!this->write_byte(register_address, data)) {
ESP_LOGW(TAG, "Write to relay failed!");
this->status_set_warning();

View File

@ -9,7 +9,7 @@ namespace m5stack_4relay {
static constexpr uint8_t UNIT_4RELAY_REG = 0X10;
static constexpr uint8_t UNIT_4RELAY_RELAY_REG = 0X11;
class M5Stack_4Relay : public Component, public i2c::I2CDevice {
class M5Stack4Relay : public Component, public i2c::I2CDevice {
public:
void set_switch_mode(bool mode);

View File

@ -6,9 +6,9 @@ namespace m5stack_4relay {
static const char *const TAG = "switch.M5Stack_4_Relay";
float M5Stack_4RelaySwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
float M5Stack4RelaySwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
void M5Stack_4RelaySwitch::setup() {
void M5Stack4RelaySwitch::setup() {
ESP_LOGCONFIG(TAG, "Setting up M5Stack_4_relay Switch '%s'...", this->name_.c_str());
bool initial_state = this->get_initial_state_with_restore_mode().value_or(false);
@ -21,7 +21,7 @@ void M5Stack_4RelaySwitch::setup() {
}
}
void M5Stack_4RelaySwitch::dump_config() {
void M5Stack4RelaySwitch::dump_config() {
LOG_SWITCH("", "M5Stack_4Relay Switch", this);
ESP_LOGCONFIG(TAG, " Channel: %u", this->channel_);
@ -35,7 +35,7 @@ void M5Stack_4RelaySwitch::dump_config() {
}
}
void M5Stack_4RelaySwitch::write_state(bool state) {
void M5Stack4RelaySwitch::write_state(bool state) {
if (state != this->inverted_) {
// Turning ON, check interlocking
@ -70,7 +70,7 @@ void M5Stack_4RelaySwitch::write_state(bool state) {
this->publish_state(state);
}
void M5Stack_4RelaySwitch::set_interlock(const std::vector<Switch *> &interlock) { this->interlock_ = interlock; }
void M5Stack4RelaySwitch::set_interlock(const std::vector<Switch *> &interlock) { this->interlock_ = interlock; }
} // namespace m5stack_4relay
} // namespace esphome

View File

@ -8,7 +8,7 @@
namespace esphome {
namespace m5stack_4relay {
class M5Stack_4RelaySwitch : public Component, public switch_::Switch, public Parented<M5Stack_4Relay> {
class M5Stack4RelaySwitch : public Component, public switch_::Switch, public Parented<M5Stack4Relay> {
public:
float get_setup_priority() const override;