mirror of
https://github.com/esphome/esphome.git
synced 2024-12-27 07:51:43 +01:00
add this-> prefix
This commit is contained in:
parent
487cf39101
commit
e44c02523a
6 changed files with 32 additions and 32 deletions
|
@ -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"};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#if 1
|
||||
#ifdef USE_ZEPHYR
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/drivers/watchdog.h>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<uint8_t> 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();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef USE_ZEPHYR
|
||||
#include <zephyr/random/rand32.h>
|
||||
#include <zephyr/random/random.h>
|
||||
#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_); }
|
||||
|
|
Loading…
Reference in a new issue