cleanups (coding style...)
This commit is contained in:
parent
6599378981
commit
4d4acdd9d1
2 changed files with 45 additions and 49 deletions
24
glcd.c
24
glcd.c
|
@ -4,13 +4,10 @@
|
|||
#include <math.h>
|
||||
|
||||
uint16_t lcd_width, lcd_height;
|
||||
|
||||
uint16_t bgcolor=White, fgcolor=Black;
|
||||
uint16_t cx, cy;
|
||||
|
||||
static uint8_t tpText=0;
|
||||
|
||||
const uint8_t* font;
|
||||
uint8_t* font;
|
||||
|
||||
void lcdInit(void) {
|
||||
lld_lcdInit();
|
||||
|
@ -128,17 +125,15 @@ void lcdEnableTransparentText(uint8_t en) {
|
|||
|
||||
void lcdDrawChar(char c) {
|
||||
const uint8_t* ptr;
|
||||
|
||||
uint8_t fontHeight = lcdGetCurFontHeight();
|
||||
uint8_t sps = font[FONT_TABLE_PAD_AFTER_CHAR_IDX];
|
||||
|
||||
uint16_t chi;
|
||||
|
||||
uint16_t x,y;
|
||||
|
||||
// No support for nongraphic characters, so just ignore them
|
||||
if(c < 0x20 || c > 0x7F) {
|
||||
if (c=='\n') lcdLineBreak();
|
||||
if(c=='\n')
|
||||
lcdLineBreak();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -148,13 +143,12 @@ void lcdDrawChar(char c) {
|
|||
|
||||
uint8_t fontWidth = *(ptr++);
|
||||
|
||||
if (cx+fontWidth>lcdGetWidth()) lcdLineBreak();
|
||||
if(cx + fontWidth > lcdGetWidth())
|
||||
lcdLineBreak();
|
||||
|
||||
for(x = 0; x < fontWidth; x++) {
|
||||
chi = *(uint16_t*)ptr;
|
||||
|
||||
for(y = 0; y < fontHeight; y++) {
|
||||
|
||||
if(chi & 0x01)
|
||||
lcdDrawPixel(cx+x, cy+y, fgcolor);
|
||||
else if(!tpText)
|
||||
|
@ -167,7 +161,8 @@ void lcdDrawChar(char c) {
|
|||
|
||||
cx += fontWidth;
|
||||
if(sps != 0) {
|
||||
if (!tpText) lcdFillArea(cx,cy,sps,fontHeight,fgcolor);
|
||||
if(!tpText)
|
||||
lcdFillArea(cx, cy, sps, fontHeight, fgcolor);
|
||||
cx += sps;
|
||||
}
|
||||
}
|
||||
|
@ -195,9 +190,8 @@ uint16_t lcdMeasureChar(char c) {
|
|||
|
||||
uint16_t chi;
|
||||
|
||||
if (c<0x20||c>0x7F) {
|
||||
if(c < 0x20 || c > 0x7F)
|
||||
return 0;
|
||||
}
|
||||
|
||||
chi = *(uint16_t*)(&font[FONT_TABLE_CHAR_LOOKUP_IDX + (c-0x20)*2]);
|
||||
|
||||
|
@ -210,7 +204,9 @@ uint16_t lcdMeasureChar(char c) {
|
|||
|
||||
uint16_t lcdMeasureString(const char *str) {
|
||||
uint16_t result = 0;
|
||||
|
||||
while (*str)result += lcdMeasureChar(*str++);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
2
glcd.h
2
glcd.h
|
@ -34,7 +34,7 @@ enum filled {frame, filled};
|
|||
// For text rendering only
|
||||
extern uint16_t bgcolor, fgcolor;
|
||||
extern uint16_t cx, cy;
|
||||
extern const uint8_t* font;
|
||||
extern uint8_t* font;
|
||||
|
||||
// A few macros
|
||||
#define lcdGotoXY(x,y) { cx=x; cy=y; }
|
||||
|
|
Loading…
Add table
Reference in a new issue