fix ascii check
This commit is contained in:
parent
51549151c6
commit
af8aedd1f6
33
main.c
33
main.c
@ -239,14 +239,16 @@ static void vfd_digit(uint8_t nb, char c)
|
||||
if (false) { // add the comma (not encoded)
|
||||
vfd_data[1] |= (1<<(16));
|
||||
}
|
||||
|
||||
if (((c&0x7f)<' ') || ((c&0x7f)>' '+LENGTH(ascii_7segments)-1)) { // unknown ASCII character
|
||||
vfd_data[1] = 0; // add empty segments to memory
|
||||
} else {
|
||||
vfd_data[1] |= (ascii_7segments[c-' ']<<(17)); // add encoded segments to memory
|
||||
}
|
||||
|
||||
vfd_data[2] = 0;
|
||||
c &= 0x7f; // only take the ASCII part
|
||||
if (c>=' ') { // only take printable characters
|
||||
uint8_t i = c-' '; // get index for character
|
||||
if (i<LENGTH(ascii_7segments)) {
|
||||
vfd_data[1] |= (ascii_7segments[i]<<(17)); // add encoded segments to memory
|
||||
}
|
||||
}
|
||||
|
||||
vfd_data[2] = 0; // last part is not used
|
||||
}
|
||||
|
||||
/* font for the 5x7 dot matrix display
|
||||
@ -374,9 +376,9 @@ static void vfd_matrix(uint8_t nb, char c)
|
||||
vfd_data[1] = 0;
|
||||
}
|
||||
|
||||
if (c<0x80) {
|
||||
uint8_t i = c-' ';
|
||||
vfd_data[2] = 0;
|
||||
vfd_data[2] = 0;
|
||||
if ((c<0x80) && (c>=' ')) { // only take printable characters
|
||||
uint8_t i = c-' '; // get index for character
|
||||
if (i<LENGTH(ascii_font5x7)) {
|
||||
vfd_data[1] |= ascii_font5x7[i][0]<<24;
|
||||
vfd_data[2] |= ascii_font5x7[i][1]<<0;
|
||||
@ -384,18 +386,14 @@ static void vfd_matrix(uint8_t nb, char c)
|
||||
vfd_data[2] |= ascii_font5x7[i][3]<<16;
|
||||
vfd_data[2] |= ascii_font5x7[i][4]<<24;
|
||||
}
|
||||
} else {
|
||||
uint8_t i = c-0x80;
|
||||
vfd_data[2] = 0;
|
||||
} else if (c>0x7f) { // the non ASCII character are used for pictures
|
||||
uint8_t i = c-0x80; // get index for character
|
||||
if (i<LENGTH(ascii_pict5x7)) {
|
||||
vfd_data[2] = 0;
|
||||
vfd_data[1] |= ascii_pict5x7[i][0]<<24;
|
||||
vfd_data[2] |= ascii_pict5x7[i][1]<<0;
|
||||
vfd_data[2] |= ascii_pict5x7[i][2]<<8;
|
||||
vfd_data[2] |= ascii_pict5x7[i][3]<<16;
|
||||
vfd_data[2] |= ascii_pict5x7[i][4]<<24;
|
||||
} else {
|
||||
vfd_data[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -423,9 +421,8 @@ int main(void)
|
||||
uint8_t matrix = 0;
|
||||
char c = ' ';
|
||||
|
||||
vfd_digit(digit,c);
|
||||
vfd_digit(digit,'0');
|
||||
vfd_shift();
|
||||
digit = (digit+1)%10;
|
||||
// let the fluorescence glow up a bit
|
||||
for (uint32_t i = 0; i < 0x2000; i++) {
|
||||
__asm__("nop");
|
||||
|
Loading…
Reference in New Issue
Block a user