mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 00:48:19 +01:00
Add null GPIO pin (#6611)
This commit is contained in:
parent
8027921ba3
commit
b8f0182fc5
3 changed files with 26 additions and 12 deletions
|
@ -5,17 +5,13 @@ namespace cst226 {
|
||||||
|
|
||||||
void CST226Touchscreen::setup() {
|
void CST226Touchscreen::setup() {
|
||||||
esph_log_config(TAG, "Setting up CST226 Touchscreen...");
|
esph_log_config(TAG, "Setting up CST226 Touchscreen...");
|
||||||
if (this->reset_pin_ != nullptr) {
|
this->reset_pin_->setup();
|
||||||
this->reset_pin_->setup();
|
this->reset_pin_->digital_write(true);
|
||||||
this->reset_pin_->digital_write(true);
|
delay(5);
|
||||||
delay(5);
|
this->reset_pin_->digital_write(false);
|
||||||
this->reset_pin_->digital_write(false);
|
delay(5);
|
||||||
delay(5);
|
this->reset_pin_->digital_write(true);
|
||||||
this->reset_pin_->digital_write(true);
|
this->set_timeout(30, [this] { this->continue_setup_(); });
|
||||||
this->set_timeout(30, [this] { this->continue_setup_(); });
|
|
||||||
} else {
|
|
||||||
this->continue_setup_();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CST226Touchscreen::update_touches() {
|
void CST226Touchscreen::update_touches() {
|
||||||
|
|
|
@ -35,7 +35,7 @@ class CST226Touchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice
|
||||||
void continue_setup_();
|
void continue_setup_();
|
||||||
|
|
||||||
InternalGPIOPin *interrupt_pin_{};
|
InternalGPIOPin *interrupt_pin_{};
|
||||||
GPIOPin *reset_pin_{};
|
GPIOPin *reset_pin_{NULL_PIN};
|
||||||
uint8_t chip_id_{};
|
uint8_t chip_id_{};
|
||||||
bool setup_complete_{};
|
bool setup_complete_{};
|
||||||
};
|
};
|
||||||
|
|
|
@ -62,6 +62,24 @@ class GPIOPin {
|
||||||
virtual bool is_internal() { return false; }
|
virtual bool is_internal() { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pin to replace those that don't exist.
|
||||||
|
*/
|
||||||
|
class NullPin : public GPIOPin {
|
||||||
|
public:
|
||||||
|
void setup() override {}
|
||||||
|
|
||||||
|
void pin_mode(gpio::Flags _) override {}
|
||||||
|
|
||||||
|
bool digital_read() override { return false; }
|
||||||
|
|
||||||
|
void digital_write(bool _) override {}
|
||||||
|
|
||||||
|
std::string dump_summary() const override { return {"Not used"}; }
|
||||||
|
};
|
||||||
|
|
||||||
|
static GPIOPin *const NULL_PIN = new NullPin();
|
||||||
|
|
||||||
/// Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
|
/// Copy of GPIOPin that is safe to use from ISRs (with no virtual functions)
|
||||||
class ISRInternalGPIOPin {
|
class ISRInternalGPIOPin {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue