--- a/src/display.cpp Sat Nov 07 19:20:39 2020 +0100 +++ b/src/display.cpp Sat Nov 07 19:22:04 2020 +0100 @@ -42,42 +42,42 @@ // dimm the char number of the currently displayed string of the main area; // do this by printing a modifed version of the last displayed string // but only alphanumeric chars should be counted (not the punctuation) - static char txt[64]; char c; uint8_t len, i, j; // for which we need to look for the entry in the table for (i=0; i<sizeof(table)/sizeof(table[0]); ++i) { if (table[i].cmd == 0x00) { - ::printf("DIMM CHAR %d\n", n); - ::printf("repl '%s'\n", table[i].buffer); + + background(table[i].bgcolor); + foreground(table[i].color / 2); // dimmed + set_font((unsigned char*) table[i].font); + locate(table[i].x0, table[i].y0); + len = strlen(table[i].buffer); if (n >= len) break; // nothing to do - strncpy(txt, table[i].buffer, table[i].maxsize); - // look for the actual position of the char in the string (only alphanum) - // XXX very poor implementation... - for (j=0; (j<len)&&(j<=n); j++) + //::printf("DIMM CHAR %d\n", n); + //::printf(" in (len=%d) '%s'\n", len, table[i].buffer); + + for (j=0; (j<len); j++) { - c = txt[j]; - if ((c == ',') || (c == '.') || (c == ';') || (c == ':') || (c == ' ')) + // advae the location up to the char to dimm + c = table[i].buffer[j]; + if ((c == ',') || (c == '.') || (c == ';') || (c == ':')) + // it's a "zero" width char, skip it n++; + if (n == 0) + { + //::printf(" Found at pos %d char '%c'\n", j, c); + // found it + character(c); + break; + } + // otherwise, just advance the char_x + //::printf(" move %d for '%c' [%X]\n", , c, c); + char_width(c, true); + n--; } - // now move the end of the string for char n to steps on the right - // so we can insert our 2 '\t' characters before and after the - // character to dimm - for (j=len; j>n; j--) - { - txt[j+2] = txt[j]; - } - txt[n+2] = '\t'; - txt[n+1] = txt[n]; - txt[n] = '\t'; - txt[len+2] = 0x00; // make sure the string will be terminated - - ::printf("with '%s'\n", txt); - // now display this string - show(0x00, txt, 0); - break; } } } @@ -103,6 +103,7 @@ } else { + pixel_buffer_mutex.lock(); for (i=0; i<sizeof(table)/sizeof(table[0]); ++i) { if (table[i].cmd == cmd) { strcpy(txt, intxt); @@ -120,7 +121,7 @@ if (table[i].fmt & FMT_ASCII) // ASCII text { // check if the string has changed since last time - if (strncmp(oldv, txt, table[i].maxsize) != 0) + if (true) //(strncmp(oldv, txt, table[i].maxsize) != 0) { // clear the text area if (table[i].width > 0) @@ -173,6 +174,7 @@ { uint8_t nbyte; uint8_t nbit; + uint16_t color; // flags for (uint8_t l=0; l<(sizeof(flags)/sizeof(flags[0])); ++l) { @@ -203,8 +205,9 @@ // draw frames (Alarm and Channel) for (uint8_t l=0; l<(sizeof(frames)/sizeof(frames[0])); ++l) { - uint16_t color; - if (intxt[0] & (1 << frames[l].flag)) // frame flags are on the 1st byte only + nbyte = frames[l].flag / 8; + nbit = frames[l].flag % 8; + if (intxt[nbyte] & (1 << nbit)) color = fgcolor/6; else color = bgcolor; @@ -223,6 +226,8 @@ break; } } + pixel_buffer_mutex.unlock(); + //free(txt); //this->copy_to_lcd(); }