new configurable display code, finetuning

This commit is contained in:
Hansi, dl9rdz 2019-05-22 22:13:14 +02:00
parent d6236b75d2
commit e84a5872b5
3 changed files with 55 additions and 34 deletions

View File

@ -8,6 +8,24 @@ extern Sonde sonde;
extern U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8; extern U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8;
const char *sondeTypeStr[5] = { "DFM6", "DFM9", "RS41" };
byte myIP_tiles[8*11];
static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00};
static const uint8_t font[10][5]={
0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
0x00, 0x42, 0x7F, 0x40, 0x00, // 1
0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x21, 0x41, 0x45, 0x4B, 0x31, // 3
0x18, 0x14, 0x12, 0x7F, 0x10, // 4
0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x3C, 0x4A, 0x49, 0x49, 0x30, // 6
0x01, 0x01, 0x79, 0x05, 0x03, // 7
0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x06, 0x49, 0x39, 0x29, 0x1E }; // 9; .=0x40
static unsigned char kmh_tiles[] U8X8_PROGMEM = { static unsigned char kmh_tiles[] U8X8_PROGMEM = {
0x1F, 0x04, 0x0A, 0x11, 0x00, 0x1F, 0x02, 0x04, 0x42, 0x3F, 0x10, 0x08, 0xFC, 0x22, 0x20, 0xF8 0x1F, 0x04, 0x0A, 0x11, 0x00, 0x1F, 0x02, 0x04, 0x42, 0x3F, 0x10, 0x08, 0xFC, 0x22, 0x20, 0xF8
}; };
@ -39,7 +57,7 @@ DispEntry searchLayout[] = {
{0, 8, FONT_LARGE, disp.drawType}, {0, 8, FONT_LARGE, disp.drawType},
{3, 0, FONT_LARGE, disp.drawFreq, " MHz"}, {3, 0, FONT_LARGE, disp.drawFreq, " MHz"},
{5, 0, FONT_LARGE, disp.drawSite}, {5, 0, FONT_LARGE, disp.drawSite},
{7, 8, 0, disp.drawIP}, {7, 5, 0, disp.drawIP},
{-1, -1, -1, NULL}, {-1, -1, -1, NULL},
}; };
DispEntry legacyLayout[] = { DispEntry legacyLayout[] = {
@ -185,6 +203,8 @@ void Display::drawAFC(DispEntry *de) {
u8x8->drawString(de->x, de->y, buf+strlen(buf)-8); u8x8->drawString(de->x, de->y, buf+strlen(buf)-8);
} }
void Display::drawIP(DispEntry *de) { void Display::drawIP(DispEntry *de) {
u8x8->drawTile(de->x, de->y, 11, myIP_tiles);
} }
void Display::drawSite(DispEntry *de) { void Display::drawSite(DispEntry *de) {
SETFONT(de->fmt); SETFONT(de->fmt);
@ -199,6 +219,30 @@ void Display::drawText(DispEntry *de) {
u8x8->drawString(de->x, de->y, de->extra); u8x8->drawString(de->x, de->y, de->extra);
} }
void Display::clearIP() {
memset(myIP_tiles, 0, 11*8);
}
void Display::setIP(const char *ip, bool AP) {
memset(myIP_tiles, 0, 11*8);
int len = strlen(ip);
int pix = (len-3)*6+6;
int tp = 80-pix+8;
if(AP) memcpy(myIP_tiles+(tp<16?0:8), ap_tile, 8);
for(int i=0; i<len; i++) {
if(ip[i]=='.') { myIP_tiles[tp++]=0x40; myIP_tiles[tp++]=0x00; }
else {
int idx = ip[i]-'0';
memcpy(myIP_tiles+tp, &font[idx], 5);
myIP_tiles[tp+5] = 0;
tp+=6;
}
}
while(tp<8*10) { myIP_tiles[tp++]=0; }
}
void Display::updateDisplayPos() { void Display::updateDisplayPos() {
for(DispEntry *di=layout; di->func != NULL; di++) { for(DispEntry *di=layout; di->func != NULL; di++) {
if(di->func != disp.drawLat && di->func != disp.drawLon) continue; if(di->func != disp.drawLat && di->func != disp.drawLon) continue;
@ -237,6 +281,11 @@ void Display::updateDisplayRXConfig() {
} }
} }
void Display::updateDisplayIP() { void Display::updateDisplayIP() {
for(DispEntry *di=layout; di->func != NULL; di++) {
if(di->func != disp.drawIP) continue;
Serial.printf("updateDisplayIP: %d %d\n",di->x, di->y);
di->func(di);
}
} }
void Display::updateDisplay() { void Display::updateDisplay() {

View File

@ -38,6 +38,8 @@ public:
static void drawTelemetry(DispEntry *de); static void drawTelemetry(DispEntry *de);
static void drawGPSdist(DispEntry *de); static void drawGPSdist(DispEntry *de);
static void drawText(DispEntry *de); static void drawText(DispEntry *de);
void clearIP();
void setIP(const char *ip, bool AP);
void updateDisplayPos(); void updateDisplayPos();
void updateDisplayPos2(); void updateDisplayPos2();
void updateDisplayID(); void updateDisplayID();

View File

@ -11,22 +11,6 @@ extern U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8;
extern SX1278FSK sx1278; extern SX1278FSK sx1278;
//SondeInfo si = { STYPE_RS41, 403.450, "P1234567", true, 48.1234, 14.9876, 543, 3.97, -0.5, true, 120 }; //SondeInfo si = { STYPE_RS41, 403.450, "P1234567", true, 48.1234, 14.9876, 543, 3.97, -0.5, true, 120 };
const char *sondeTypeStr[5] = { "DFM6", "DFM9", "RS41" };
byte myIP_tiles[8*11];
static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00};
static const uint8_t font[10][5]={
0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
0x00, 0x42, 0x7F, 0x40, 0x00, // 1
0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x21, 0x41, 0x45, 0x4B, 0x31, // 3
0x18, 0x14, 0x12, 0x7F, 0x10, // 4
0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x3C, 0x4A, 0x49, 0x49, 0x30, // 6
0x01, 0x01, 0x79, 0x05, 0x03, // 7
0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x06, 0x49, 0x39, 0x29, 0x1E }; // 9; .=0x40
Sonde::Sonde() { Sonde::Sonde() {
config.button_pin = 0; config.button_pin = 0;
@ -165,25 +149,11 @@ void Sonde::setConfig(const char *cfg) {
} }
void Sonde::clearIP() { void Sonde::clearIP() {
memset(myIP_tiles, 0, 11*8); disp.clearIP();
} }
void Sonde::setIP(const char *ip, bool AP) { void Sonde::setIP(const char *ip, bool AP) {
memset(myIP_tiles, 0, 11*8); disp.setIP(ip, AP);
int len = strlen(ip);
int pix = (len-3)*6+6;
int tp = 80-pix+8;
if(AP) memcpy(myIP_tiles+(tp<16?0:8), ap_tile, 8);
for(int i=0; i<len; i++) {
if(ip[i]=='.') { myIP_tiles[tp++]=0x40; myIP_tiles[tp++]=0x00; }
else {
int idx = ip[i]-'0';
memcpy(myIP_tiles+tp, &font[idx], 5);
myIP_tiles[tp+5] = 0;
tp+=6;
}
}
while(tp<8*10) { myIP_tiles[tp++]=0; }
} }
void Sonde::clearSonde() { void Sonde::clearSonde() {
@ -278,7 +248,7 @@ void Sonde::updateDisplayRXConfig() {
} }
void Sonde::updateDisplayIP() { void Sonde::updateDisplayIP() {
u8x8->drawTile(5, 7, 11, myIP_tiles); disp.updateDisplayIP();
} }
// Probing RS41 // Probing RS41