Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
 
2
void uploadFont()
3
{
4
  uint16_t byte_count = 0;
5
  byte bit_count;
6
  byte ascii_binary[0x08];
7
 
8
  // move these local to prevent ram usage
9
  uint8_t character_bitmap[0x40];
10
  int font_count = 0;
11
 
12
     osd.clear();
13
     osd.setPanel(6,9);
14
     osd.openPanel();
15
     osd.printf_P(PSTR("Update CharSet"));
16
     osd.closePanel();
17
 
18
 
19
  Serial.printf_P(PSTR("Ready for Font\n"));
20
 
21
                while(font_count < 256) {
22
                int8_t incomingByte = Serial.read();
23
    switch(incomingByte) // parse and decode mcm file
24
    {
25
      case 0x0d: // carridge return, end of line
26
        //Serial.println("cr");
27
       if (bit_count == 8 && (ascii_binary[0] == 0x30 || ascii_binary[0] == 0x31))
28
       {
29
          // turn 8 ascii binary bytes to single byte '01010101' = 0x55
30
          // fill in 64 bytes of character data
31
// made this local to prevent needing a global
32
  byte ascii_byte;
33
 
34
  ascii_byte = 0;
35
 
36
  if (ascii_binary[0] == 0x31) // ascii '1'
37
    ascii_byte = ascii_byte + 128;
38
 
39
  if (ascii_binary[1] == 0x31)
40
    ascii_byte = ascii_byte + 64;
41
 
42
  if (ascii_binary[2] == 0x31)
43
    ascii_byte = ascii_byte + 32;
44
 
45
  if (ascii_binary[3] == 0x31)
46
    ascii_byte = ascii_byte + 16;
47
 
48
  if (ascii_binary[4] == 0x31)
49
    ascii_byte = ascii_byte + 8;
50
 
51
  if (ascii_binary[5] == 0x31)
52
    ascii_byte = ascii_byte + 4;
53
 
54
  if (ascii_binary[6] == 0x31)
55
    ascii_byte = ascii_byte + 2;
56
 
57
  if (ascii_binary[7] == 0x31)
58
    ascii_byte = ascii_byte + 1;
59
 
60
         character_bitmap[byte_count] = ascii_byte;
61
         byte_count++;
62
         bit_count = 0;
63
       }
64
       else
65
         bit_count = 0;
66
      break;
67
      case 0x0a: // line feed, ignore
68
        //Serial.println("ln");
69
      break;
70
      case 0x30: // ascii '0'
71
      case 0x31: // ascii '1'
72
        ascii_binary[bit_count] = incomingByte;
73
        bit_count++;
74
      break;
75
      default:
76
      break;
77
    }
78
 
79
      // we have one completed character
80
  // write the character to NVM
81
  if(byte_count == 64)
82
  {
83
    osd.write_NVM(font_count, character_bitmap);
84
    byte_count = 0;
85
    font_count++;
86
    Serial.printf_P(PSTR("Char Done\n"));
87
  }
88
              }
89
 
90
//  character_bitmap[]
91
}
92
 
93