Update display.cpp

Add strftime variant with background color (useful for antialiased fonts with non black background)
This commit is contained in:
mikosoft83 2024-11-02 22:42:35 +01:00 committed by GitHub
parent 77bb46ff3b
commit d36e0b3b80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -662,20 +662,23 @@ void DisplayOnPageChangeTrigger::process(DisplayPage *from, DisplayPage *to) {
if ((this->from_ == nullptr || this->from_ == from) && (this->to_ == nullptr || this->to_ == to)) if ((this->from_ == nullptr || this->from_ == from) && (this->to_ == nullptr || this->to_ == to))
this->trigger(from, to); this->trigger(from, to);
} }
void Display::strftime(int x, int y, BaseFont *font, Color color, TextAlign align, const char *format, ESPTime time) { void Display::strftime(int x, int y, BaseFont *font, Color color, Color background, TextAlign align, const char *format, ESPTime time) {
char buffer[64]; char buffer[64];
size_t ret = time.strftime(buffer, sizeof(buffer), format); size_t ret = time.strftime(buffer, sizeof(buffer), format);
if (ret > 0) if (ret > 0)
this->print(x, y, font, color, align, buffer); this->print(x, y, font, color, align, buffer, background);
}
void Display::strftime(int x, int y, BaseFont *font, Color color, TextAlign align, const char *format, ESPTime time) {
this->strftime(x, y, font, color, COLOR_OFF, TextAlign::TOP_LEFT, format, time);
} }
void Display::strftime(int x, int y, BaseFont *font, Color color, const char *format, ESPTime time) { void Display::strftime(int x, int y, BaseFont *font, Color color, const char *format, ESPTime time) {
this->strftime(x, y, font, color, TextAlign::TOP_LEFT, format, time); this->strftime(x, y, font, color, COLOR_OFF, TextAlign::TOP_LEFT, format, time);
} }
void Display::strftime(int x, int y, BaseFont *font, TextAlign align, const char *format, ESPTime time) { void Display::strftime(int x, int y, BaseFont *font, TextAlign align, const char *format, ESPTime time) {
this->strftime(x, y, font, COLOR_ON, align, format, time); this->strftime(x, y, font, COLOR_ON, COLOR_OFF, align, format, time);
} }
void Display::strftime(int x, int y, BaseFont *font, const char *format, ESPTime time) { void Display::strftime(int x, int y, BaseFont *font, const char *format, ESPTime time) {
this->strftime(x, y, font, COLOR_ON, TextAlign::TOP_LEFT, format, time); this->strftime(x, y, font, COLOR_ON, COLOR_OFF, TextAlign::TOP_LEFT, format, time);
} }
void Display::start_clipping(Rect rect) { void Display::start_clipping(Rect rect) {