Restored prev implementation of lcdDrawString()

Support for transparent/non-transparent text rendering via
lcdEnableTransparentText(). It is disabled by default.
This commit is contained in:
Kumar Abhishek 2012-06-13 19:14:38 +05:30
parent bd573fbef1
commit 2f157e29de
3 changed files with 22 additions and 10 deletions

26
glcd.c
View File

@ -8,7 +8,7 @@ uint16_t lcd_width, lcd_height;
uint16_t bgcolor=White, fgcolor=Black;
uint16_t cx, cy;
static uint8_t tpText=1;
static uint8_t tpText=0;
const uint8_t* font;
@ -118,6 +118,10 @@ void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t co
}
}
void lcdEnableTransparentText(uint8_t en) {
tpText=en;
}
void lcdDrawChar(char c) {
const uint8_t* ptr;
@ -164,10 +168,21 @@ void lcdDrawChar(char c) {
}
}
void lcdDrawString(const char *str) {
void lcdPutString(const char *str) {
while (*str) lcdDrawChar(*str++);
}
void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor) {
uint16_t _bg=bgcolor, _fg=fgcolor;
cx=x;
cy=y;
bgcolor=bkcolor;
fgcolor=color;
lcdPutString(str);
bgcolor=_bg;
fgcolor=_fg;
}
uint16_t lcdMeasureChar(char c) {
const uint8_t* ptr;
@ -257,18 +272,13 @@ void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t fil
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char *str, uint16_t fontColor, uint16_t bkColor) {
uint16_t off_left, off_up;
uint16_t _fontClr=fgcolor;
off_left = ((x1-x0)-lcdMeasureString(str))/2;
off_up = ((y1-y0) - lcdGetCurFontHeight()) / 2;
lcdDrawRect(x0, y0, x1, y1, 1, bkColor);
cx=x0+off_left;
cy=y0+off_up;
fgcolor=fontColor;
lcdDrawString(str);
fgcolor=_fontClr;
lcdDrawString(x0+off_left, y0+off_up, str, fontColor, bkColor);
}
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color) {

4
glcd.h
View File

@ -53,8 +53,10 @@ void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t fil
void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char* str, uint16_t fontColor, uint16_t bkColor);
void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color);
void lcdEnableTransparentText(uint8_t en);
void lcdDrawChar(char c);
void lcdDrawString(const char *str);
void lcdPutString(const char *str);
void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor);
void lcdLineBreak(void);
uint16_t lcdMeasureChar(char c);

View File

@ -123,7 +123,7 @@ void tpCalibrate(void) {
lcdSetOrientation(portrait);
lcdClear(Red);
cx=40; cy=10;
lcdDrawString("Touchpad Calibration");
lcdDrawString(40, 10, "Touchpad Calibration", White, Red);
for(i=0; i<2; i++) {
tpDrawCross(cross[i][0], cross[i][1]);