From e44c02523a3c07779018683218c4a63ea6a9f935 Mon Sep 17 00:00:00 2001 From: Tomasz Duda Date: Mon, 22 Jul 2024 12:35:52 +0200 Subject: [PATCH] add this-> prefix --- esphome/components/logger/logger_zephyr.cpp | 10 +++++----- esphome/components/zephyr/core.cpp | 2 +- esphome/components/zephyr/gpio.cpp | 20 ++++++++++---------- esphome/components/zephyr/gpio.h | 10 +++++----- esphome/components/zephyr/preferences.cpp | 18 +++++++++--------- esphome/core/helpers.cpp | 4 ++-- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/esphome/components/logger/logger_zephyr.cpp b/esphome/components/logger/logger_zephyr.cpp index 523d23083f..c0e9eb142d 100644 --- a/esphome/components/logger/logger_zephyr.cpp +++ b/esphome/components/logger/logger_zephyr.cpp @@ -19,7 +19,7 @@ void Logger::loop() { } static bool opened = false; uint32_t dtr = 0; - uart_line_ctrl_get(uart_dev_, UART_LINE_CTRL_DTR, &dtr); + uart_line_ctrl_get(this->uart_dev_, UART_LINE_CTRL_DTR, &dtr); /* Poll if the DTR flag was set, optional */ if (opened == dtr) { @@ -52,7 +52,7 @@ void Logger::pre_setup() { if (!device_is_ready(uart_dev)) { ESP_LOGE(TAG, "%s is not ready.", get_uart_selection_()); } else { - uart_dev_ = uart_dev; + this->uart_dev_ = uart_dev; } } global_logger = this; @@ -63,14 +63,14 @@ void HOT Logger::write_msg_(const char *msg) { #ifdef CONFIG_PRINTK printk("%s\n", msg); #endif - if (nullptr == uart_dev_) { + if (nullptr == this->uart_dev_) { return; } while (*msg) { - uart_poll_out(uart_dev_, *msg); + uart_poll_out(this->uart_dev_, *msg); ++msg; } - uart_poll_out(uart_dev_, '\n'); + uart_poll_out(this->uart_dev_, '\n'); } const char *const UART_SELECTIONS[] = {"UART0", "UART1", "USB_CDC"}; diff --git a/esphome/components/zephyr/core.cpp b/esphome/components/zephyr/core.cpp index a2d185221e..c846680db2 100644 --- a/esphome/components/zephyr/core.cpp +++ b/esphome/components/zephyr/core.cpp @@ -1,4 +1,4 @@ -#if 1 +#ifdef USE_ZEPHYR #include #include diff --git a/esphome/components/zephyr/gpio.cpp b/esphome/components/zephyr/gpio.cpp index ea33d96236..c166628781 100644 --- a/esphome/components/zephyr/gpio.cpp +++ b/esphome/components/zephyr/gpio.cpp @@ -40,8 +40,8 @@ struct ISRPinArg { ISRInternalGPIOPin ZephyrGPIOPin::to_isr() const { auto *arg = new ISRPinArg{}; - arg->pin = pin_; - arg->inverted = inverted_; + arg->pin = this->pin_; + arg->inverted = this->inverted_; return ISRInternalGPIOPin((void *) arg); } @@ -76,33 +76,33 @@ void ZephyrGPIOPin::setup() { } void ZephyrGPIOPin::pin_mode(gpio::Flags flags) { - if (nullptr == gpio_) { + if (nullptr == this->gpio_) { return; } - gpio_pin_configure(gpio_, pin_ % 32, flags_to_mode(flags, inverted_, value_)); + gpio_pin_configure(this->gpio_, this->pin_ % 32, flags_to_mode(flags, this->inverted_, this->value_)); } std::string ZephyrGPIOPin::dump_summary() const { char buffer[32]; - snprintf(buffer, sizeof(buffer), "GPIO%u", pin_); + snprintf(buffer, sizeof(buffer), "GPIO%u", this->pin_); return buffer; } bool ZephyrGPIOPin::digital_read() { - if (nullptr == gpio_) { + if (nullptr == this->gpio_) { return false; } - return bool(gpio_pin_get(gpio_, pin_ % 32) != inverted_); + return bool(gpio_pin_get(this->gpio_, this->pin_ % 32) != this->inverted_); } void ZephyrGPIOPin::digital_write(bool value) { // make sure that value is not ignored since it can be inverted e.g. on switch side // that way init state should be correct - value_ = value; - if (nullptr == gpio_) { + this->value_ = value; + if (nullptr == this->gpio_) { return; } - gpio_pin_set(gpio_, pin_ % 32, value != inverted_ ? 1 : 0); + gpio_pin_set(this->gpio_, this->pin_ % 32, value != this->inverted_ ? 1 : 0); } void ZephyrGPIOPin::detach_interrupt() const { // TODO diff --git a/esphome/components/zephyr/gpio.h b/esphome/components/zephyr/gpio.h index 7af424f360..17a7e97b8f 100644 --- a/esphome/components/zephyr/gpio.h +++ b/esphome/components/zephyr/gpio.h @@ -8,9 +8,9 @@ namespace zephyr { class ZephyrGPIOPin : public InternalGPIOPin { public: - void set_pin(uint8_t pin) { pin_ = pin; } - void set_inverted(bool inverted) { inverted_ = inverted; } - void set_flags(gpio::Flags flags) { flags_ = flags; } + void set_pin(uint8_t pin) { this->pin_ = pin; } + void set_inverted(bool inverted) { this->inverted_ = inverted; } + void set_flags(gpio::Flags flags) { this->flags_ = flags; } void setup() override; void pin_mode(gpio::Flags flags) override; @@ -19,8 +19,8 @@ class ZephyrGPIOPin : public InternalGPIOPin { std::string dump_summary() const override; void detach_interrupt() const override; ISRInternalGPIOPin to_isr() const override; - uint8_t get_pin() const override { return pin_; } - bool is_inverted() const override { return inverted_; } + uint8_t get_pin() const override { return this->pin_; } + bool is_inverted() const override { return this->inverted_; } protected: void attach_interrupt(void (*func)(void *), void *arg, gpio::InterruptType type) const override; diff --git a/esphome/components/zephyr/preferences.cpp b/esphome/components/zephyr/preferences.cpp index b8c4be467c..b45a8375f0 100644 --- a/esphome/components/zephyr/preferences.cpp +++ b/esphome/components/zephyr/preferences.cpp @@ -19,7 +19,7 @@ class ZephyrPreferenceBackend : public ESPPreferenceBackend { bool save(const uint8_t *data, size_t len) override { this->data.resize(len); std::memcpy(this->data.data(), data, len); - ESP_LOGVV(TAG, "save key: %u, len: %d", type_, len); + ESP_LOGVV(TAG, "save key: %u, len: %d", this->type_, len); return true; } @@ -29,12 +29,12 @@ class ZephyrPreferenceBackend : public ESPPreferenceBackend { return false; } std::memcpy(data, this->data.data(), len); - ESP_LOGVV(TAG, "load key: %u, len: %d", type_, len); + ESP_LOGVV(TAG, "load key: %u, len: %d", this->type_, len); return true; } - const uint32_t get_type() const { return type_; } - const std::string get_key() const { return str_sprintf(ESPHOME_SETTINGS_KEY "/%" PRIx32, type_); } + const uint32_t get_type() const { return this->type_; } + const std::string get_key() const { return str_sprintf(ESPHOME_SETTINGS_KEY "/%" PRIx32, this->type_); } std::vector data; @@ -68,7 +68,7 @@ class ZephyrPreferences : public ESPPreferences { ESP_LOGE(TAG, "Cannot load settings, err: %d", err); return; } - ESP_LOGD(TAG, "Loaded %u settings.", backends_.size()); + ESP_LOGD(TAG, "Loaded %u settings.", this->backends_.size()); } ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash) override { @@ -76,15 +76,15 @@ class ZephyrPreferences : public ESPPreferences { } ESPPreferenceObject make_preference(size_t length, uint32_t type) override { - for (auto backend : backends_) { + for (auto backend : this->backends_) { if (backend->get_type() == type) { return ESPPreferenceObject(backend); } } - printf("type %u size %u\n", type, backends_.size()); + printf("type %u size %u\n", type, this->backends_.size()); auto *pref = new ZephyrPreferenceBackend(type); ESP_LOGD(TAG, "Add new setting %s.", pref->get_key().c_str()); - backends_.push_back(pref); + this->backends_.push_back(pref); return ESPPreferenceObject(pref); } @@ -100,7 +100,7 @@ class ZephyrPreferences : public ESPPreferences { bool reset() override { ESP_LOGD(TAG, "Reset settings"); - for (auto backend : backends_) { + for (auto backend : this->backends_) { // save empty delete data backend->data.clear(); } diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index cf1b1b9206..2a302056cb 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -57,7 +57,7 @@ #endif #ifdef USE_ZEPHYR -#include +#include #endif namespace esphome { @@ -635,7 +635,7 @@ void Mutex::lock() {} bool Mutex::try_lock() { return true; } void Mutex::unlock() {} #elif defined(USE_ZEPHYR) -Mutex::Mutex() { k_mutex_init(&handle_); } +Mutex::Mutex() { k_mutex_init(&this->handle_); } void Mutex::lock() { k_mutex_lock(&this->handle_, K_FOREVER); } bool Mutex::try_lock() { return k_mutex_lock(&this->handle_, K_NO_WAIT) == 0; } void Mutex::unlock() { k_mutex_unlock(&this->handle_); }