mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
STD and STDV2 fonts defined in lcd.cpp
This commit is contained in:
parent
d840c8acd4
commit
7e567fdb15
1 changed files with 236 additions and 2 deletions
|
@ -85,6 +85,8 @@ void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags
|
|||
}
|
||||
|
||||
uint8_t lcdLastPos;
|
||||
|
||||
#if defined(PWFONT)
|
||||
uint8_t lcdLastFW;
|
||||
|
||||
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
||||
|
@ -332,6 +334,198 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
|||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
|
||||
{
|
||||
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
|
||||
|
||||
#if defined(CPUARM)
|
||||
const pm_uchar *q = (c < 0xC0) ? &font_5x7[(c-0x20)*5+4] : &font_5x7_extra[(c-0xC0)*5+4];
|
||||
#else
|
||||
const pm_uchar *q = &font_5x7[(c-0x20)*5+4];
|
||||
#endif
|
||||
|
||||
bool inv = false;
|
||||
if (flags & BLINK) {
|
||||
if (BLINK_ON_PHASE) {
|
||||
if (flags & INVERS)
|
||||
inv = true;
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (flags & INVERS) {
|
||||
inv = true;
|
||||
}
|
||||
|
||||
if (flags & DBLSIZE) {
|
||||
// To save space only some DBLSIZE chars are available
|
||||
// c has to be remapped. All non existing chars mapped to 0 (space)
|
||||
unsigned char c_remapped;
|
||||
|
||||
if (c>=',' && c<=':')
|
||||
c_remapped = c - ',' + 1;
|
||||
else if (c>='A' && c<='Z')
|
||||
c_remapped = c - 'A' + 16;
|
||||
else if (c>='a' && c<='z')
|
||||
c_remapped = c - 'a' + 42;
|
||||
else if (c=='_')
|
||||
c_remapped = 4;
|
||||
#if defined(CPUARM)
|
||||
else if (c>= 128 )
|
||||
c_remapped = c - 60;
|
||||
#endif
|
||||
else
|
||||
c_remapped = 0;
|
||||
|
||||
/* each letter consists of ten top bytes followed by
|
||||
* by ten bottom bytes (20 bytes per * char) */
|
||||
q = &font_10x14[((uint16_t)c_remapped)*20];
|
||||
for (int8_t i=11; i>=0; i--) {
|
||||
if ((flags & CONDENSED) && i<=1) break;
|
||||
uint8_t b1=0, b2=0;
|
||||
if (i>1) {
|
||||
b1 = pgm_read_byte(q++); /*top byte*/
|
||||
b2 = pgm_read_byte(q++); /*top byte*/
|
||||
}
|
||||
if (inv) {
|
||||
b1 = ~b1;
|
||||
b2 = ~b2;
|
||||
}
|
||||
if(&p[LCD_W+1] < DISPLAY_END) {
|
||||
ASSERT_IN_DISPLAY(p);
|
||||
ASSERT_IN_DISPLAY(p+LCD_W);
|
||||
LCD_BYTE_FILTER(p, 0, b1);
|
||||
LCD_BYTE_FILTER(p+LCD_W, 0, b2);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined(CPUARM)
|
||||
else if (flags & MIDSIZE) {
|
||||
/* each letter consists of ten top bytes followed by
|
||||
* by ten bottom bytes (20 bytes per * char) */
|
||||
q = &font_8x10[((uint16_t)c-0x20)*16];
|
||||
for (int8_t i=9; i>=0; i--) {
|
||||
uint8_t b1=0, b2=0;
|
||||
if ((flags & CONDENSED) && i<=1) break;
|
||||
if (i!=0 && i!=9) {
|
||||
b1 = pgm_read_byte(q++); /*top byte*/
|
||||
b2 = pgm_read_byte(q++); /*top byte*/
|
||||
}
|
||||
if (inv) {
|
||||
b1 = ~b1;
|
||||
b2 = ~b2;
|
||||
}
|
||||
uint8_t ym8 = (y & 0x07);
|
||||
if (&p[LCD_W+1] < DISPLAY_END) {
|
||||
LCD_BYTE_FILTER(p, ~(0xff << ym8), b1 << ym8);
|
||||
uint8_t *r = p + LCD_W;
|
||||
if (r<DISPLAY_END) {
|
||||
if (ym8)
|
||||
LCD_BYTE_FILTER(r, ~(0xff >> (8-ym8)), b1 >> (8-ym8));
|
||||
LCD_BYTE_FILTER(r, ~(0x0f << ym8), (b2&0x0f) << ym8);
|
||||
if (ym8) {
|
||||
r = r + LCD_W;
|
||||
if (r<DISPLAY_END)
|
||||
LCD_BYTE_FILTER(r, ~(0x0f >> (8-ym8)), (b2&0x0f) >> (8-ym8));
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flags & SMLSIZE) {
|
||||
q = (c < 0xC0) ? &font_4x6[(c-0x20)*5+4] : &font_4x6_extra[(c-0xC0)*5+4];
|
||||
uint8_t ym8 = (y & 0x07);
|
||||
p += 4;
|
||||
for (int8_t i=4; i>=0; i--) {
|
||||
uint8_t b = pgm_read_byte(q--);
|
||||
if (inv) b = ~b & 0x7f;
|
||||
if (p<DISPLAY_END) {
|
||||
LCD_BYTE_FILTER(p, ~(0x7f << ym8), b << ym8);
|
||||
if (ym8) {
|
||||
uint8_t *r = p + LCD_W;
|
||||
if (r<DISPLAY_END)
|
||||
LCD_BYTE_FILTER(r, ~(0x7f >> (8-ym8)), b >> (8-ym8));
|
||||
}
|
||||
}
|
||||
p--;
|
||||
}
|
||||
}
|
||||
else if (flags & TINSIZE) {
|
||||
q = &font_3x5[((uint16_t)c-0x2D)*3+2];
|
||||
uint8_t ym8 = (y & 0x07);
|
||||
p += 3;
|
||||
for (int8_t i=3; i>=0; i--) {
|
||||
uint8_t b = (i!=3 ? pgm_read_byte(q--) : 0);
|
||||
if (inv) b = ~b & 0x3f;
|
||||
if (p<DISPLAY_END) {
|
||||
LCD_BYTE_FILTER(p, ~(0x3f << ym8), b << ym8);
|
||||
if (ym8) {
|
||||
uint8_t *r = p + LCD_W;
|
||||
if (r<DISPLAY_END)
|
||||
LCD_BYTE_FILTER(r, ~(0x3f >> (8-ym8)), b >> (8-ym8));
|
||||
}
|
||||
}
|
||||
p--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
uint8_t condense=0;
|
||||
|
||||
if (flags & CONDENSED) {
|
||||
*p = inv ? ~0 : 0;
|
||||
condense=1;
|
||||
}
|
||||
|
||||
uint8_t ym8 = (y & 0x07);
|
||||
p += 5;
|
||||
for (uint8_t i=6, b=0; i>0; i--, b=pgm_read_byte(q--)) {
|
||||
if (inv) b = ~b;
|
||||
|
||||
if (condense && i==2) {
|
||||
/*condense the letter by skipping column 4 */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p<DISPLAY_END) {
|
||||
LCD_BYTE_FILTER(p, ~(0xff << ym8), b << ym8);
|
||||
if (ym8) {
|
||||
uint8_t *r = p + LCD_W;
|
||||
if (r<DISPLAY_END)
|
||||
LCD_BYTE_FILTER(r, ~(0xff >> (8-ym8)), b >> (8-ym8));
|
||||
}
|
||||
#if defined(BOLD_FONT)
|
||||
if (flags & BOLD) {
|
||||
ASSERT_IN_DISPLAY(p+1);
|
||||
if (inv)
|
||||
LCD_BYTE_FILTER(p+1, b << ym8, 0);
|
||||
else
|
||||
LCD_BYTE_FILTER(p+1, 0xff, b << ym8);
|
||||
#if defined(CPUARM)
|
||||
if (ym8) {
|
||||
uint8_t *r = p+1 + LCD_W;
|
||||
if (r<DISPLAY_END) {
|
||||
if (inv)
|
||||
LCD_BYTE_FILTER(r, b >> (8-ym8), 0);
|
||||
else
|
||||
LCD_BYTE_FILTER(r, 0xff, b >> (8-ym8));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
p--;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void lcd_putc(xcoord_t x, uint8_t y, const unsigned char c)
|
||||
{
|
||||
lcd_putcAtt(x, y, c, 0);
|
||||
|
@ -363,8 +557,24 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag
|
|||
|
||||
if (!c || x>LCD_W-6) break;
|
||||
if (c >= 0x20) {
|
||||
#if defined(PWFONT)
|
||||
lcd_putcAtt(x, y, c, mode);
|
||||
x += lcdLastFW;
|
||||
x += lcdLastFW;
|
||||
#else
|
||||
#if defined(CPUARM)
|
||||
if ((mode & MIDSIZE) && ((c>='a'&&c<='z')||(c>='0'&&c<='9'))) {
|
||||
lcd_putcAtt(x, y, c, mode);
|
||||
x-=1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
lcd_putcAtt(x, y, c, mode);
|
||||
x += FW;
|
||||
if (c == '|') x -= 4;
|
||||
if (mode&DBLSIZE) x += FW-1;
|
||||
else if (mode&MIDSIZE) x += FW-3;
|
||||
else if (mode&SMLSIZE) x -= 1;
|
||||
#endif
|
||||
}
|
||||
else if (setx) {
|
||||
x = c;
|
||||
|
@ -408,7 +618,11 @@ void lcd_putsLeft(uint8_t y, const pm_char * s)
|
|||
|
||||
void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val)
|
||||
{
|
||||
#if defined(PWFONT)
|
||||
x+=FWNUM*4+1;
|
||||
#else
|
||||
x+=FWNUM*4;
|
||||
#endif
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
x-=FWNUM;
|
||||
|
@ -489,8 +703,12 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
|
|||
}
|
||||
|
||||
lcdLastPos = x;
|
||||
#if defined(PWFONT)
|
||||
x -= fw;
|
||||
if (dblsize) x++;
|
||||
#else
|
||||
x -= fw + 1;
|
||||
#endif
|
||||
|
||||
for (uint8_t i=1; i<=len; i++) {
|
||||
div_t qr = div((uint16_t)val, 10);
|
||||
|
@ -498,7 +716,11 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
|
|||
LcdFlags f = flags;
|
||||
#if !defined(PCBTARANIS)
|
||||
if (dblsize) {
|
||||
#if defined(PWFONT)
|
||||
if (c=='1' && i==len && xn>x+10) { x+=1; }
|
||||
#else
|
||||
if (c=='1' && i==len && xn>x+10) { x+=2; f|=CONDENSED; }
|
||||
#endif
|
||||
if ((uint16_t)val >= 1000) { x+=FWNUM; f&=~DBLSIZE; }
|
||||
}
|
||||
#endif
|
||||
|
@ -506,7 +728,11 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
|
|||
if (mode==i) {
|
||||
flags &= ~PREC2; // TODO not needed but removes 20bytes, could be improved for sure, check asm
|
||||
if (dblsize) {
|
||||
#if defined(PWFONT)
|
||||
xn = x - 2;
|
||||
#else
|
||||
xn = x;
|
||||
#endif
|
||||
if (c>='1' && c<='3') ln++;
|
||||
uint8_t tn = (qr.quot) % 10;
|
||||
if (tn==2 || tn==4) {
|
||||
|
@ -528,12 +754,18 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
|
|||
x--;
|
||||
}
|
||||
else {
|
||||
#if defined(PWFONT)
|
||||
x -= 2;
|
||||
#else
|
||||
x--;
|
||||
#endif
|
||||
lcd_plot(x, y+6);
|
||||
if ((flags&INVERS) && ((~flags & BLINK) || BLINK_ON_PHASE)) {
|
||||
lcd_vline(x, y, 8);
|
||||
}
|
||||
// x--;
|
||||
#if !defined(PWFONT)
|
||||
x--;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if !defined(PCBTARANIS)
|
||||
|
@ -558,7 +790,9 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t
|
|||
lcd_hline(xn, y+2*FH-2, ln);
|
||||
}
|
||||
}
|
||||
#if defined(PWFONT)
|
||||
x--;
|
||||
#endif
|
||||
if (neg) lcd_putcAtt(x, y, '-', flags);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue