stat bar for tft display
This commit is contained in:
parent
bf4870c091
commit
250ead8f86
|
|
@ -56,6 +56,12 @@ static unsigned char stattiles[5][4] = {
|
|||
0x1F, 0x15, 0x15, 0x00 , // E == decode error
|
||||
0x00, 0x00, 0x00, 0x00 , // ' ' == unknown/unassigned
|
||||
0x07, 0x05, 0x07, 0x00 }; // ° = rx ok, but no valid position
|
||||
static unsigned char stattilesXL[5][5] = {
|
||||
0x00, 0x7F, 0x00, 0x00, 0x00, // | == ok
|
||||
0x00, 0x40, 0x40, 0x00, 0x00, // . == no header found
|
||||
0x7F, 0x49, 0x49, 0x49, 0x00, // E == decode error
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, // ' ' == unknown/unassigned
|
||||
0x07, 0x05, 0x07, 0x00, 0x00 }; // ° = rx ok, but no valid position (not yet used?)
|
||||
|
||||
|
||||
//static uint8_t halfdb_tile[8]={0x80, 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, 0x00};
|
||||
|
|
@ -290,6 +296,16 @@ void U8x8Display::drawIP(uint8_t x, uint8_t y, int16_t width, uint16_t fg, uint1
|
|||
u8x8->drawTile(x, y, 11, myIP_tiles);
|
||||
}
|
||||
|
||||
// len must be multiple of 2, size is fixed for u8x8 display
|
||||
void U8x8Display::drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t /*size*/, uint8_t *stat) {
|
||||
for(int i=0; i<len; i+=2) {
|
||||
uint8_t tile[8];
|
||||
*(uint32_t *)(&tile[0]) = *(uint32_t *)(&(stattiles[stat[i]]));
|
||||
*(uint32_t *)(&tile[4]) = *(uint32_t *)(&(stattiles[stat[i+1]]));
|
||||
drawTile(x+i/2, y, 1, tile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const GFXfont *gfl[] = {
|
||||
&FreeMono9pt7b, // 3
|
||||
|
|
@ -447,6 +463,27 @@ void ILI9225Display::drawIP(uint8_t x, uint8_t y, int16_t width, uint16_t fg, ui
|
|||
drawString(x, y, buf, width, fg, bg);
|
||||
}
|
||||
|
||||
// size: 3=> 3x5 symbols; 4=> 4x7 symbols
|
||||
void ILI9225Display::drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t size, uint8_t *stat) {
|
||||
if(size<3) size=3;
|
||||
if(size>4) size=4;
|
||||
const uint16_t width = len*(size+1);
|
||||
const uint16_t height = (size+3);
|
||||
uint16_t bitmap[width*height];
|
||||
for(int i=0; i<len; i++) {
|
||||
for(int xx=0; xx<size+1; xx++) {
|
||||
for(int yy=0; yy<size+3; yy++) {
|
||||
if(size==3) {
|
||||
bitmap[ yy*width + i*(size+1) + xx ] = ((stattiles[stat[i]][xx]>>yy)&0x01) ?0xffff:0x0000;
|
||||
} else {
|
||||
bitmap[ yy*width + i*(size+1) + xx ] = ((stattilesXL[stat[i]][xx]>>yy)&0x01) ?0xffff:0x0000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
drawBitmap(x, y, bitmap, len*(size+1), (size+3));
|
||||
}
|
||||
|
||||
#include <pgmspace.h>
|
||||
#define pgm_read_pointer(addr) ((void *)pgm_read_dword(addr))
|
||||
|
||||
|
|
@ -614,7 +651,17 @@ void Display::parseDispElement(char *text, DispEntry *de)
|
|||
de->extra = strdup(text+1);
|
||||
break;
|
||||
case 'q':
|
||||
de->func = disp.drawQS; break;
|
||||
{
|
||||
struct StatInfo *statinfo = (struct StatInfo *)malloc(sizeof(struct StatInfo));
|
||||
// maybe enable more flexible configuration?
|
||||
statinfo->size=3;
|
||||
statinfo->len=18;
|
||||
if(text[1]=='4') statinfo->size = 4;
|
||||
|
||||
de->extra = (const char *)statinfo;
|
||||
de->func = disp.drawQS;
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
de->func = disp.drawType; break;
|
||||
case 'c':
|
||||
|
|
@ -986,13 +1033,10 @@ void Display::drawRSSI(DispEntry *de) {
|
|||
}
|
||||
void Display::drawQS(DispEntry *de) {
|
||||
uint8_t *stat = sonde.si()->rxStat;
|
||||
for(int i=0; i<18; i+=2) {
|
||||
uint8_t tile[8];
|
||||
*(uint32_t *)(&tile[0]) = *(uint32_t *)(&(stattiles[stat[i]]));
|
||||
*(uint32_t *)(&tile[4]) = *(uint32_t *)(&(stattiles[stat[i+1]]));
|
||||
rdis->drawTile(de->x+i/2, de->y, 1, tile);
|
||||
}
|
||||
struct StatInfo *statinfo = (struct StatInfo *)de->extra;
|
||||
rdis->drawQS(de->x, de->y, statinfo->len, statinfo->size, stat);
|
||||
}
|
||||
|
||||
void Display::drawType(DispEntry *de) {
|
||||
rdis->setFont(de->fmt);
|
||||
drawString(de, sondeTypeStr[sonde.si()->type]);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ struct DispInfo {
|
|||
uint8_t usegps;
|
||||
};
|
||||
|
||||
struct StatInfo {
|
||||
uint8_t len;
|
||||
uint8_t size;
|
||||
};
|
||||
|
||||
struct CircleInfo { // 3,5=g0NCS,50,ff0000,000033,5,ffff00,4,ffffff
|
||||
char type;
|
||||
char top,bul,arr; // what to point to with top, bullet, array
|
||||
|
|
@ -55,7 +60,7 @@ public:
|
|||
virtual void drawBitmap(uint16_t x1, uint16_t y1, const uint16_t* bitmap, int16_t w, int16_t h) = 0;
|
||||
virtual void welcome() = 0;
|
||||
virtual void drawIP(uint8_t x, uint8_t y, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0 ) = 0;
|
||||
|
||||
virtual void drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t size, uint8_t *stat) = 0;
|
||||
};
|
||||
|
||||
class U8x8Display : public RawDisplay {
|
||||
|
|
@ -77,6 +82,7 @@ public:
|
|||
void drawBitmap(uint16_t x1, uint16_t y1, const uint16_t* bitmap, int16_t w, int16_t h);
|
||||
void welcome();
|
||||
void drawIP(uint8_t x, uint8_t y, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0);
|
||||
void drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t size, uint8_t *stat);
|
||||
};
|
||||
|
||||
class MY_ILI9225 : public TFT22_ILI9225 {
|
||||
|
|
@ -103,6 +109,7 @@ public:
|
|||
void drawBitmap(uint16_t x1, uint16_t y1, const uint16_t* bitmap, int16_t w, int16_t h);
|
||||
void welcome();
|
||||
void drawIP(uint8_t x, uint8_t y, int16_t width=WIDTH_AUTO, uint16_t fg=0xffff, uint16_t bg=0);
|
||||
void drawQS(uint8_t x, uint8_t y, uint8_t len, uint8_t size, uint8_t *stat);
|
||||
};
|
||||
|
||||
class Display {
|
||||
|
|
|
|||
Loading…
Reference in New Issue