mirror of
https://github.com/nacabaro/nacapet.git
synced 2026-06-05 14:02:53 +00:00
Enhance tft_drawText function to support background color
This commit is contained in:
parent
e158f50970
commit
60c1659875
@ -2,6 +2,8 @@
|
||||
#include "defs/screen_defs.h"
|
||||
#include "defs/defs.h"
|
||||
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
int xPos = 0;
|
||||
int yPos = 0;
|
||||
|
||||
@ -59,9 +61,15 @@ void tft_drawCenteredText(const char* text, int size, int yGlobal) {
|
||||
composite.drawString(text, x, yGlobal);
|
||||
}
|
||||
|
||||
void tft_drawText(const char* text, int size, int x, int y, uint16_t color) {
|
||||
void tft_drawText(const char* text, int size, int x, int y, uint16_t color, uint16_t bgColor = TFT_TRANSPARENT) {
|
||||
composite.setTextSize(size);
|
||||
composite.setTextColor(color);
|
||||
|
||||
if (bgColor != TFT_TRANSPARENT) {
|
||||
composite.setTextColor(color, bgColor);
|
||||
} else {
|
||||
composite.setTextColor(color);
|
||||
}
|
||||
|
||||
composite.drawString(text, x, y);
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ void tft_drawBuffer();
|
||||
void tft_clearBuffer(TFT_eSprite &buffer, uint16_t color = TFT_WHITE);
|
||||
void tft_clearBuffer(uint16_t color = TFT_WHITE);
|
||||
void tft_drawCenteredText(const char* text, int factor, int y);
|
||||
void tft_drawText(const char* text, int size, int x, int y, uint16_t color = TFT_BLACK);
|
||||
void tft_drawText(const char* text, int size, int x, int y, uint16_t color = TFT_BLACK, uint16_t bgColor = TFT_TRANSPARENT);
|
||||
void tft_drawRectangle(int x, int y, int w, int h, uint16_t color = TFT_BLACK);
|
||||
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user