Wed, 07 Nov 2018 20:00:52 +0100
more stuff
src/main.cpp | file | annotate | diff | comparison | revisions |
--- a/src/main.cpp Mon Nov 05 23:18:37 2018 +0100 +++ b/src/main.cpp Wed Nov 07 20:00:52 2018 +0100 @@ -89,7 +89,7 @@ #define KP_C0 PB_0 // I-4 #define KP_C1 PA_6 // I-2 #define KP_C2 PA_7 // I-3 -#define KP_C3 PA_5 // I-1 +#define KP_C3 PA_10 // I-1 #define KP_C4 PD_2 // II-1 // misc @@ -192,7 +192,7 @@ { 0x0C, 0xF, 0x0,204, 38, 0x01, 3, 45, Mono15x22}, // channels display // { 0x01, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, // { 0x02, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, - { 0x0A, 0xF, 0x0, 0, 57, 0x0C, 4, 0, Terminal6x8}, // flags + bits + { 0x0A, 0xF, 0x0, 0, 57, 0x08, 4, 0, Terminal6x8}, // flags + bits // { 0xFF, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, }; @@ -250,6 +250,9 @@ // right-side icons area { 0x00, 0x02, 0, 0, NULL, icon_alarm}, // F1.0 { 0x01, 0x02, 0, 11, NULL, icon_curve}, // F1.1 + //{ 0x14, 0x02, 0, 0, "4W"}, // F2.4 + //{ 0x15, 0x02, 0, 8, "OC"}, // F2.5 + // F1.2 == Channel frame { 0x03, 0x04, 1, 2, "Channel"}, // F1.3 // F1.7 == Alarm frame @@ -261,8 +264,8 @@ //col 2 { 0x32, 0x20, 0, 0, "*"}, // F4.2 - { 0x36, 0x20, 0, 8, "CFG"}, // F4.6 - { 0x27, 0x20, 0, 16, "ERR"}, // F3.7 + { 0x36, 0x20, 0, 8, "CONFIG"}, // F4.6 + { 0x27, 0x20, 0, 16, "ERROR"}, // F3.7 // col 3 { 0x41, 0x040, 0, 0, "ADRS"}, // F4.1 @@ -278,7 +281,7 @@ // col 5 { 0x14, 0x100, 0, 0, "4W"}, // F2.4 { 0x15, 0x100, 0, 8, "OC"}, // F2.5 - { 0x22, 0x100, 0, 16, "LST"}, // F3.2 + { 0x22, 0x100, 0, 16, "LAST"}, // F3.2 { 0x21, 0x100, 0, 16, "MIN"}, // F3.1 { 0x20, 0x100, 0, 16, "MAX"}, // F3.0 { 0x17, 0x100, 0, 16, "AVG"}, // F2.7 @@ -294,7 +297,7 @@ }; static const FRAME zones[] = - { +{ // flag, x0, y0, x1, y1 { 0x001, 0, 0, 245, 27}, // main display area { 0x002, 246, 0, 255, 27}, // right notif area { 0x004, 203, 28, 255, 54}, // channels display area @@ -305,7 +308,7 @@ { 0x080, 104, 28, 128, 54}, // flags col4 { 0x100, 129, 28, 159, 54}, // flags col5 - { 0x8000, 0, 55, 255, 63}, // flags bits display area +// { 0x8000, 0, 55, 255, 63}, // flags bits display area }; static const FRAME frames[] = @@ -345,6 +348,7 @@ void reset_irq(void); void qei_cb(int dir); void end_splashscreen(void); +void show(uint8_t, const char*, uint8_t); @@ -361,6 +365,10 @@ //blinker.attach(callback(timeout_h), 0.5f); hp = NULL; + printf("Serial communication pins\r\n"); + printf(" USBRX=%d\r\n", USBRX); + printf(" USBTX=%d\r\n", USBTX); + printf("Setup HP communication pins\r\n"); printf(" HP_RX=%d\r\n", HP_RX); DigitalIn(HP_RX).mode(PullDown); @@ -388,7 +396,6 @@ kpad->start(); printf("Setup OLED display\r\n"); - splashscreen = true; // init the LCD printf(" DSP_MOSI=%d\r\n", DSP_MOSI); printf(" DSP_MISO=%d\r\n", DSP_MISO); @@ -426,10 +433,16 @@ printf("Starting LCD thread\r\n"); tdsp.start(©_to_lcd); - //printf("Starting Event thread\r\n"); - //tloop.start(&loop); + printf("Starting Event thread\r\n"); + tloop.start(&loop); + + dsp->clrbuff(); + show(0x00, "HH:MM:\tSS\t:mmmm", 15); // main dsp + show(0x0C, "888", 3); // channel dsp + show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags printf("Attaching timers\r\n"); + splashscreen = true; splashscreen_timer.attach(callback(&end_splashscreen), 2); rst.fall(&reset_irq); @@ -438,7 +451,8 @@ void end_splashscreen(void) { - printf("End of splash screen\r\n"); + printf("End of splash screen CB\r\n"); + //dsp->cls(); splashscreen = false; } @@ -497,11 +511,19 @@ uint8_t i, len; uint16_t bgcolor, fgcolor; char *oldv; - char *txt; + char *txt, *txtp; + if (cmd == 0xFF) // cls + { + dsp->clrbuff(); + } + else + { txt = (char *)malloc(strlen(intxt)+1); strcpy(txt, intxt); + txtp = txt; + pulse(1, true); len = MAX_BUFF; @@ -517,35 +539,43 @@ dsp->locate(table[i].x0, table[i].y0); - if (table[i].fmt & 0x01 ) { - if (strncmp(oldv, txt, table[i].maxsize) != 0) { - // ascii - if (table[i].width > 0) - dsp->fillrect(table[i].x0, table[i].y0, table[i].x0 + table[i].width, table[i].y0 + table[i].font[2], bgcolor); - for (uint8_t k=0; ;k++) { - if (txt[k] == 0x00) - { - dsp->printf(txt); - break; - } - if (txt[k] == 0x09) { // \t is a special char for 'unselected' display value - txt[k] = 0x00; - dsp->printf(txt); + if (table[i].fmt & 0x01 ) + { + if (strncmp(oldv, txt, table[i].maxsize) != 0) + { + // ascii + if (table[i].width > 0) + dsp->fillrect(table[i].x0, + table[i].y0, + table[i].x0 + table[i].width, + table[i].y0 + table[i].font[2], + bgcolor); + for (uint8_t k=0; ;k++) + { + if (txtp[k] == 0x00) + { + dsp->printf(txtp); + break; + } + if (txtp[k] == 0x09) + { // \t is a special char for 'unselected' display value + txtp[k] = 0x00; + dsp->printf(txtp); - if (fgcolor == table[i].color) - fgcolor /= 2; - else - fgcolor = table[i].color; - dsp->foreground(fgcolor); - txt = &(txt[k+1]); - k = 0; - } - } - if (cmd == 0x00) // main area - must_refresh |= 0x01; - if (cmd == 0x0C) // channels area - must_refresh |= 0x04; - } + if (fgcolor == table[i].color) + fgcolor /= 2; + else + fgcolor = table[i].color; + dsp->foreground(fgcolor); + txtp = &(txtp[k+1]); + k = 0; + } + } + if (cmd == 0x00) // main area + must_refresh |= 0x01; + if (cmd == 0x0C) // channels area + must_refresh |= 0x04; + } } /* if (table[i].fmt & 0x02 ) { @@ -559,38 +589,19 @@ dsp->printf(" "); } */ - if (table[i].fmt & 0x04 ) { - // binary - dsp->foreground(fgcolor); - dsp->printf(" ["); - for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) { - if (j>0) { - dsp->foreground(fgcolor); - dsp->printf(" | "); - } - for (uint8_t k=0; k<8; k++) { - if (txt[j] & (1 << (7-k))) - dsp->foreground(fgcolor); - else - dsp->foreground(bgcolor); - dsp->printf("%d", (8-k)); - } - } - dsp->foreground(fgcolor); - dsp->printf("]"); - must_refresh |= 0x8000; - } - - if (table[i].fmt & 0x08 ) { - // flags - for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) { - for (uint8_t k=0; k<8; k++) { - if (1) {//(txt[j] & (1 << k) ) != (oldv[j] & (1 << k))) { - - if (txt[j] & (1 << k)) - dsp->foreground(fgcolor); - else - dsp->foreground(bgcolor); + if (table[i].fmt & 0x08 ) + { + // flags + for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) + { + for (uint8_t k=0; k<8; k++) + { + if (1) + { //(txt[j] & (1 << k) ) != (oldv[j] & (1 << k))) { + if (txtp[j] & (1 << k)) + dsp->foreground(fgcolor); + else + dsp->foreground(bgcolor); /* for (uint8_t l=0; @@ -607,53 +618,61 @@ } */ - for (uint8_t l=0; - l<(sizeof(flags)/sizeof(flags[0])); ++l) { - if (flags[l].flag == ((j<<4) + k)) { - for (uint8_t m=0; m<(sizeof(zones)/sizeof(zones[0])); m++) { - if (flags[l].zone == zones[m].flag) { - if (flags[l].msg != NULL) { // a string - dsp->locate(flags[l].x + zones[m].x0, - flags[l].y + zones[m].y0); - dsp->printf(flags[l].msg);} - else { // an icon - Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; - dsp->Bitmap_BW(pic, - flags[l].x + zones[m].x0, - flags[l].y + zones[m].y0); - } - must_refresh |= zones[m].flag; - break; - } + for (uint8_t l=0; + l<(sizeof(flags)/sizeof(flags[0])); ++l) + { + if (flags[l].flag == ((j<<4) + k)) { + for (uint8_t m=0; m<(sizeof(zones)/sizeof(zones[0])); m++) + { + if (flags[l].zone == zones[m].flag) { + if (flags[l].msg != NULL) + { // a string + dsp->locate(flags[l].x + zones[m].x0, + flags[l].y + zones[m].y0); + dsp->printf(flags[l].msg);} + else + { // an icon + Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; + dsp->Bitmap_BW(pic, + flags[l].x + zones[m].x0, + flags[l].y + zones[m].y0); + } + must_refresh |= zones[m].flag; + break; + } + } + break; + } + } + } } - break; } - } - } - } - } } for(uint8_t j=0; j<table[i].maxsize; j++) - oldv[j] = txt[j]; + oldv[j] = txt[j]; break; } } free(txt); //dsp->copy_to_lcd(); pulse(1, false); + } } void test_dsp() { const FRAME *z; + printf("TEST DSP\r\n"); + dsp->cls(); + printf("TEST DSP #2\r\n"); show(0x00, "8g8g8g8g8g8g8", 13); // main dsp show(0x0C, "888", 3); // channel dsp show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags dsp->copy_to_lcd(); wait(3); dsp->cls(); - + printf("TEST DSP #3\r\n"); for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) { @@ -679,6 +698,7 @@ */ wait(2); dsp->cls(); + printf("TEST DSP DONE\r\n"); } @@ -785,5 +805,8 @@ setup(); printf("Main loop (noop)\r\n"); while(1) - wait(.1); + { + timeout_h(); + wait(1); + } }