Clang tidy

This commit is contained in:
Tristan Groléat 2023-12-03 23:47:35 +01:00
parent 232e36300a
commit b0f6eb9828
2 changed files with 36 additions and 36 deletions

View File

@ -3034,51 +3034,51 @@ void WaveshareEPaper13P3InK::dump_config() {
void WaveshareEPaperPolled::update() { void WaveshareEPaperPolled::update() {
this->do_update_(); this->do_update_();
if (this->state_ == State::sleeping) { if (this->state_ == State::SLEEPING) {
this->set_state_(State::update_requested); this->set_state_(State::UPDATE_REQUESTED);
} }
} }
void WaveshareEPaperPolled::loop() { void WaveshareEPaperPolled::loop() {
switch (this->state_) { switch (this->state_) {
case State::sleeping: case State::SLEEPING:
break; break;
case State::update_requested: case State::UPDATE_REQUESTED:
this->reset_pin_->digital_write(false); this->reset_pin_->digital_write(false);
this->set_state_(State::resetting); this->set_state_(State::RESETTING);
break; break;
case State::resetting: case State::RESETTING:
if (millis() - this->last_state_change_ >= this->reset_duration_) { if (millis() - this->last_state_change_ >= this->reset_duration_) {
this->reset_pin_->digital_write(true); this->reset_pin_->digital_write(true);
this->set_state_(State::initializing); this->set_state_(State::INITIALIZING);
} }
break; break;
case State::initializing: case State::INITIALIZING:
if (millis() - this->last_state_change_ >= 200) { if (millis() - this->last_state_change_ >= 200) {
this->power_on(); this->power_on();
this->set_state_(State::powering_on); this->set_state_(State::POWERING_ON);
} }
break; break;
case State::powering_on: case State::POWERING_ON:
if (millis() - this->last_state_change_ >= 100 && (!this->busy_pin_ || !this->busy_pin_->digital_read())) { if (millis() - this->last_state_change_ >= 100 && (!this->busy_pin_ || !this->busy_pin_->digital_read())) {
this->configure(); this->configure();
this->set_state_(State::configuring); this->set_state_(State::CONFIGURING);
} }
break; break;
case State::configuring: case State::CONFIGURING:
this->display(); this->display();
this->set_state_(State::displaying); this->set_state_(State::DISPLAYING);
break; break;
case State::displaying: case State::DISPLAYING:
if (millis() - this->last_state_change_ >= 200 && (!this->busy_pin_ || !this->busy_pin_->digital_read())) { if (millis() - this->last_state_change_ >= 200 && (!this->busy_pin_ || !this->busy_pin_->digital_read())) {
this->power_off(); this->power_off();
this->set_state_(State::powering_off); this->set_state_(State::POWERING_OFF);
} }
break; break;
case State::powering_off: case State::POWERING_OFF:
if (!this->busy_pin_ || !this->busy_pin_->digital_read()) { if (!this->busy_pin_ || !this->busy_pin_->digital_read()) {
this->deep_sleep(); this->deep_sleep();
this->set_state_(State::sleeping); this->set_state_(State::SLEEPING);
} }
break; break;
} }
@ -3088,28 +3088,28 @@ void WaveshareEPaperPolled::set_state_(State state) {
this->state_ = state; this->state_ = state;
this->last_state_change_ = millis(); this->last_state_change_ = millis();
switch (this->state_) { switch (this->state_) {
case State::sleeping: case State::SLEEPING:
ESP_LOGD(TAG, "sleeping"); ESP_LOGD(TAG, "sleeping");
break; break;
case State::update_requested: case State::UPDATE_REQUESTED:
ESP_LOGD(TAG, "update_requested"); ESP_LOGD(TAG, "update_requested");
break; break;
case State::resetting: case State::RESETTING:
ESP_LOGD(TAG, "resetting"); ESP_LOGD(TAG, "resetting");
break; break;
case State::initializing: case State::INITIALIZING:
ESP_LOGD(TAG, "initializing"); ESP_LOGD(TAG, "initializing");
break; break;
case State::powering_on: case State::POWERING_ON:
ESP_LOGD(TAG, "powering_on"); ESP_LOGD(TAG, "powering_on");
break; break;
case State::configuring: case State::CONFIGURING:
ESP_LOGD(TAG, "configuring"); ESP_LOGD(TAG, "configuring");
break; break;
case State::displaying: case State::DISPLAYING:
ESP_LOGD(TAG, "displaying"); ESP_LOGD(TAG, "displaying");
break; break;
case State::powering_off: case State::POWERING_OFF:
ESP_LOGD(TAG, "powering_off"); ESP_LOGD(TAG, "powering_off");
break; break;
} }

View File

@ -813,7 +813,7 @@ class WaveshareEPaperPolled : public WaveshareEPaper {
virtual void configure() = 0; virtual void configure() = 0;
// Send image data and refresh the display // Send image data and refresh the display
virtual void display() = 0; void display() override = 0;
// Power off the driver // Power off the driver
virtual void power_off() = 0; virtual void power_off() = 0;
@ -823,21 +823,21 @@ class WaveshareEPaperPolled : public WaveshareEPaper {
private: private:
enum class State : uint8_t { enum class State : uint8_t {
sleeping, SLEEPING,
update_requested, UPDATE_REQUESTED,
resetting, RESETTING,
initializing, INITIALIZING,
powering_on, POWERING_ON,
configuring, CONFIGURING,
displaying, DISPLAYING,
powering_off, POWERING_OFF,
}; };
// Set the current state of the display // Set the current state of the display
void set_state_(State state); void set_state_(State state);
// Current state of the display // Current state of the display
State state_{State::sleeping}; State state_{State::SLEEPING};
// Timestamp of last state changed, used to wait between states // Timestamp of last state changed, used to wait between states
uint32_t last_state_change_{0}; uint32_t last_state_change_{0};
}; };
@ -854,7 +854,7 @@ class WaveshareEPaper7In5BV2 : public WaveshareEPaperPolled {
void power_off() override; void power_off() override;
void deep_sleep() override; void deep_sleep() override;
virtual std::vector<Color> get_supported_colors() override { return {display::COLOR_ON, Color(255, 0, 0, 0)}; } std::vector<Color> get_supported_colors() override { return {display::COLOR_ON, Color(255, 0, 0, 0)}; }
protected: protected:
int get_width_internal() override { return 800; } int get_width_internal() override { return 800; }