Add text_align_to_string

Used for debugging ESP_LOGCONFIG purposes
This commit is contained in:
Michael Davidson 2023-12-29 18:31:01 +11:00
parent d663e453a1
commit 982942a512
No known key found for this signature in database
GPG key ID: B8D1A99712B8B0EB
2 changed files with 34 additions and 0 deletions

View file

@ -416,5 +416,36 @@ void DisplayPage::set_prev(DisplayPage *prev) { this->prev_ = prev; }
void DisplayPage::set_next(DisplayPage *next) { this->next_ = next; } void DisplayPage::set_next(DisplayPage *next) { this->next_ = next; }
const display_writer_t &DisplayPage::get_writer() const { return this->writer_; } const display_writer_t &DisplayPage::get_writer() const { return this->writer_; }
const LogString *text_align_to_string(TextAlign textalign) {
switch (textalign) {
case TextAlign::TOP_LEFT:
return LOG_STR("TOP_LEFT");
case TextAlign::TOP_CENTER:
return LOG_STR("TOP_CENTER");
case TextAlign::TOP_RIGHT:
return LOG_STR("TOP_RIGHT");
case TextAlign::CENTER_LEFT:
return LOG_STR("CENTER_LEFT");
case TextAlign::CENTER:
return LOG_STR("CENTER");
case TextAlign::CENTER_RIGHT:
return LOG_STR("CENTER_RIGHT");
case TextAlign::BASELINE_LEFT:
return LOG_STR("BASELINE_LEFT");
case TextAlign::BASELINE_CENTER:
return LOG_STR("BASELINE_CENTER");
case TextAlign::BASELINE_RIGHT:
return LOG_STR("BASELINE_RIGHT");
case TextAlign::BOTTOM_LEFT:
return LOG_STR("BOTTOM_LEFT");
case TextAlign::BOTTOM_CENTER:
return LOG_STR("BOTTOM_CENTER");
case TextAlign::BOTTOM_RIGHT:
return LOG_STR("BOTTOM_RIGHT");
default:
return LOG_STR("UNKNOWN");
}
}
} // namespace display } // namespace display
} // namespace esphome } // namespace esphome

View file

@ -9,6 +9,7 @@
#include "esphome/core/color.h" #include "esphome/core/color.h"
#include "esphome/core/automation.h" #include "esphome/core/automation.h"
#include "esphome/core/time.h" #include "esphome/core/time.h"
#include "esphome/core/log.h"
#ifdef USE_GRAPH #ifdef USE_GRAPH
#include "esphome/components/graph/graph.h" #include "esphome/components/graph/graph.h"
@ -631,5 +632,7 @@ class DisplayOnPageChangeTrigger : public Trigger<DisplayPage *, DisplayPage *>
DisplayPage *to_{nullptr}; DisplayPage *to_{nullptr};
}; };
const LogString *text_align_to_string(TextAlign textalign);
} // namespace display } // namespace display
} // namespace esphome } // namespace esphome