Rev 471 | Rev 489 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 471 | Rev 474 | ||
---|---|---|---|
Line 53... | Line 53... | ||
53 | 53 | ||
54 | char ee_message0[] PROGMEM = "Loading Data from EEPROM"; |
54 | char ee_message0[] PROGMEM = "Loading Data from EEPROM"; |
55 | char ee_message1[] PROGMEM = "No saved Data in EEPROM"; |
55 | char ee_message1[] PROGMEM = "No saved Data in EEPROM"; |
Line -... | Line 56... | ||
- | 56 | char* ee_msg[] PROGMEM = {ee_message0, ee_message1}; |
|
- | 57 | ||
- | 58 | // video modes |
|
- | 59 | char VM_PAL[] PROGMEM = "PAL "; |
|
56 | char* ee_msg[] PROGMEM = {ee_message0, ee_message1}; |
60 | char VM_NTSC[] PROGMEM = "NTSC"; |
- | 61 | ||
57 | 62 | // menu strings to progmem |
|
58 | // menu strings to progmem |
63 | char menu_item0[] PROGMEM = "Video Mode"; |
59 | char menu_item0[] PROGMEM = "Full HUD"; |
64 | char menu_item1[] PROGMEM = "Full HUD"; |
60 | char menu_item1[] PROGMEM = "Art.Horizon in HUD"; |
65 | char menu_item2[] PROGMEM = "Art.Horizon in HUD"; |
61 | char menu_item2[] PROGMEM = "Big Vario bar"; |
66 | char menu_item3[] PROGMEM = "Big Vario bar"; |
62 | char menu_item3[] PROGMEM = "Statistics"; |
67 | char menu_item4[] PROGMEM = "Statistics"; |
63 | char menu_item4[] PROGMEM = "Warnings"; // TODO: do it! |
68 | char menu_item5[] PROGMEM = "Warnings"; // TODO: do it! |
64 | char menu_item5[] PROGMEM = "Reset uptime"; |
69 | char menu_item6[] PROGMEM = "Reset uptime"; |
65 | char menu_item6[] PROGMEM = "Request OSD-data"; |
70 | char menu_item7[] PROGMEM = "Request OSD-data"; |
66 | char menu_item7[] PROGMEM = "Disable Debug-data"; |
71 | char menu_item8[] PROGMEM = "Disable Debug-data"; |
67 | char menu_item8[] PROGMEM = "Save config"; |
72 | char menu_item9[] PROGMEM = "Save config"; |
68 | char menu_item9[] PROGMEM = "EXIT"; |
73 | char menu_item10[] PROGMEM = "EXIT"; |
Line 69... | Line 74... | ||
69 | char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4, |
74 | char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4, |
70 | menu_item5, menu_item6, menu_item7, menu_item8, menu_item9}; |
75 | menu_item5, menu_item6, menu_item7, menu_item8, menu_item9, menu_item10}; |
71 | 76 | ||
72 | /** |
77 | /** |
73 | * read data saved in eeprom |
78 | * read data saved in eeprom, print out message if <verbose> is set |
74 | */ |
79 | */ |
75 | void get_eeprom() { |
80 | void get_eeprom(uint8_t verbose) { |
76 | if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) { |
81 | if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) { |
77 | write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data |
82 | if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data |
78 | COSD_FLAGS = eeprom_read_byte(&ee_COSD_FLAGS); |
83 | COSD_FLAGS = eeprom_read_byte(&ee_COSD_FLAGS); |
79 | } else { |
84 | } else { |
Line 80... | Line 85... | ||
80 | write_ascii_string_pgm(2, 9, ee_msg[1]); // No data found |
85 | if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // No data found |
81 | } |
86 | } |
Line 126... | Line 131... | ||
126 | write_ndigit_number_s_10th(20, 6, min_voltage, 100, 0); |
131 | write_ndigit_number_s_10th(20, 6, min_voltage, 100, 0); |
127 | write_ascii_string_pgm(2, 7, init_point[6]); // Max Voltage |
132 | write_ascii_string_pgm(2, 7, init_point[6]); // Max Voltage |
128 | //write_ascii_string(2, 7, "Max Voltage :"); |
133 | //write_ascii_string(2, 7, "Max Voltage :"); |
129 | write_ndigit_number_s_10th(20, 7, max_voltage, 100, 0); |
134 | write_ndigit_number_s_10th(20, 7, max_voltage, 100, 0); |
Line 130... | Line 135... | ||
130 | 135 | ||
- | 136 | get_eeprom(1); |
|
- | 137 | ||
- | 138 | //write_ascii_string_pgm(23, 2, vm[COSD_FLAGS & COSD_FLAG_NTSC]); |
|
- | 139 | if (COSD_FLAGS & COSD_FLAG_NTSC) { |
|
- | 140 | write_ascii_string_pgm(23, 2, VM_NTSC); |
|
- | 141 | } else { |
|
- | 142 | write_ascii_string_pgm(23, 2, VM_PAL); |
|
Line 131... | Line 143... | ||
131 | get_eeprom(); |
143 | } |
132 | 144 | ||
133 | _delay_ms(200); |
145 | _delay_ms(200); |
134 | clear(); |
146 | clear(); |
Line 143... | Line 155... | ||
143 | /** |
155 | /** |
144 | * helper function for menu updating |
156 | * helper function for menu updating |
145 | */ |
157 | */ |
146 | void config_menu_drawings(uint8_t chosen) { |
158 | void config_menu_drawings(uint8_t chosen) { |
147 | // clear prevoius _cursor_ |
159 | // clear prevoius _cursor_ |
148 | write_ascii_string(3, (chosen + 3) % 9, " "); |
160 | write_ascii_string(3, (chosen + 2) % 10, " "); |
149 | // draw current _cursor_ |
161 | // draw current _cursor_ |
150 | write_ascii_string(3, chosen + 3, ">"); |
162 | write_ascii_string(3, chosen + 2, ">"); |
- | 163 | ||
- | 164 | if (COSD_FLAGS & COSD_FLAG_NTSC) { |
|
- | 165 | write_ascii_string_pgm(23, 2, VM_NTSC); |
|
- | 166 | } else { |
|
- | 167 | write_ascii_string_pgm(23, 2, VM_PAL); |
|
- | 168 | } |
|
- | 169 | ||
151 | if (COSD_FLAGS & COSD_FLAG_HUD) { |
170 | if (COSD_FLAGS & COSD_FLAG_HUD) { |
152 | write_ascii_string_pgm(23, 3, ON); |
171 | write_ascii_string_pgm(23, 3, ON); |
153 | } else { |
172 | } else { |
154 | write_ascii_string_pgm(23, 3, OFF); |
173 | write_ascii_string_pgm(23, 3, OFF); |
155 | } |
174 | } |
Line 177... | Line 196... | ||
177 | 196 | ||
178 | /** |
197 | /** |
179 | * some sort of clicking response in the menu |
198 | * some sort of clicking response in the menu |
180 | */ |
199 | */ |
181 | void config_menu_doclick(uint8_t chosen, char** menu) { |
200 | void config_menu_doclick(uint8_t chosen, char** menu) { |
182 | write_ascii_string(4, chosen + 3, "DONE "); |
201 | write_ascii_string(4, chosen + 2, "DONE "); |
183 | _delay_ms(500); |
202 | _delay_ms(500); |
184 | write_ascii_string_pgm(4, chosen + 3, menu[chosen]); |
203 | write_ascii_string_pgm(4, chosen + 2, menu[chosen]); |
Line 185... | Line 204... | ||
185 | } |
204 | } |
186 | 205 | ||
187 | /** |
206 | /** |
Line 194... | Line 213... | ||
194 | // clear screen |
213 | // clear screen |
195 | clear(); |
214 | clear(); |
Line 196... | Line 215... | ||
196 | 215 | ||
197 | uint8_t inmenu = 1; |
216 | uint8_t inmenu = 1; |
198 | uint8_t chosen = 0; |
217 | uint8_t chosen = 0; |
Line 199... | Line 218... | ||
199 | write_ascii_string(6, 2, "C-OSD Config Menu"); |
218 | write_ascii_string(6, 1, "C-OSD Config Menu"); |
200 | 219 | ||
Line -... | Line 220... | ||
- | 220 | // wait a bit before doing stuff so user has chance to release button |
|
201 | // wait a bit before doing stuff so user has chance to release button |
221 | _delay_ms(250); |
202 | _delay_ms(250); |
222 | |
203 | 223 | write_ascii_string_pgm(4, 2, menu[0]); |
|
204 | write_ascii_string_pgm(4, 3, menu[0]); |
224 | write_ascii_string_pgm(4, 3, menu[1]); |
205 | write_ascii_string_pgm(4, 4, menu[1]); |
225 | write_ascii_string_pgm(4, 4, menu[2]); |
206 | write_ascii_string_pgm(4, 5, menu[2]); |
226 | write_ascii_string_pgm(4, 5, menu[3]); |
207 | write_ascii_string_pgm(4, 6, menu[3]); |
227 | write_ascii_string_pgm(4, 6, menu[4]); |
208 | write_ascii_string_pgm(4, 7, menu[4]); |
228 | write_ascii_string_pgm(4, 7, menu[5]); |
209 | write_ascii_string_pgm(4, 8, menu[5]); |
229 | write_ascii_string_pgm(4, 8, menu[6]); |
210 | write_ascii_string_pgm(4, 9, menu[6]); |
230 | write_ascii_string_pgm(4, 9, menu[7]); |
Line 211... | Line 231... | ||
211 | write_ascii_string_pgm(4, 10, menu[7]); |
231 | write_ascii_string_pgm(4, 10, menu[8]); |
Line 212... | Line 232... | ||
212 | write_ascii_string_pgm(4, 11, menu[8]); |
232 | write_ascii_string_pgm(4, 11, menu[9]); |
213 | write_ascii_string_pgm(4, 12, menu[9]); |
233 | write_ascii_string_pgm(4, 12, menu[10]); |
214 | 234 | ||
215 | config_menu_drawings(chosen); |
235 | config_menu_drawings(chosen); |
216 | 236 | ||
217 | while (inmenu) { |
237 | while (inmenu) { |
218 | if (s2_pressed()) { |
238 | if (s2_pressed()) { |
219 | write_ascii_string(3, chosen + 3, " "); |
239 | write_ascii_string(3, chosen + 2, " "); |
220 | chosen = (chosen + 1) % 10; |
240 | chosen = (chosen + 1) % 11; |
- | 241 | write_ascii_string(3, chosen + 2, ">"); |
|
- | 242 | _delay_ms(500); |
|
- | 243 | } else if (s1_pressed()) { |
|
- | 244 | switch (chosen) { |
|
- | 245 | case 0: // full HUD |
|
- | 246 | COSD_FLAGS ^= COSD_FLAG_NTSC; |
|
- | 247 | // Setup Video Mode |
|
- | 248 | if (COSD_FLAGS & COSD_FLAG_NTSC) { |
|
- | 249 | // NTSC + enable display immediately (VM0) |
|
- | 250 | spi_send_byte(0x00, 0b00001000); |
|
- | 251 | ||
- | 252 | bottom_line = 12; |
|
- | 253 | } else { |
|
- | 254 | // PAL + enable display immediately (VM0) |
|
- | 255 | spi_send_byte(0x00, 0b01001000); |
|
- | 256 | ||
221 | write_ascii_string(3, chosen + 3, ">"); |
257 | bottom_line = 14; |
222 | _delay_ms(500); |
258 | } |
223 | } else if (s1_pressed()) { |
259 | config_menu_drawings(chosen); |
224 | switch (chosen) { |
260 | break; |
225 | case 0: // full HUD |
261 | case 1: // full HUD |
226 | COSD_FLAGS ^= COSD_FLAG_HUD; |
262 | COSD_FLAGS ^= COSD_FLAG_HUD; |
227 | config_menu_drawings(chosen); |
263 | config_menu_drawings(chosen); |
228 | break; |
264 | break; |
229 | case 1: // art horizon |
265 | case 2: // art horizon |
230 | COSD_FLAGS ^= COSD_FLAG_ARTHORIZON; |
266 | COSD_FLAGS ^= COSD_FLAG_ARTHORIZON; |
231 | config_menu_drawings(chosen); |
267 | config_menu_drawings(chosen); |
232 | break; |
268 | break; |
233 | case 2: // big vario |
269 | case 3: // big vario |
234 | COSD_FLAGS ^= COSD_FLAG_BIGVARIO; |
270 | COSD_FLAGS ^= COSD_FLAG_BIGVARIO; |
235 | config_menu_drawings(chosen); |
271 | config_menu_drawings(chosen); |
236 | break; |
272 | break; |
237 | case 3: // statistics |
273 | case 4: // statistics |
238 | COSD_FLAGS ^= COSD_FLAG_STATS; |
274 | COSD_FLAGS ^= COSD_FLAG_STATS; |
239 | config_menu_drawings(chosen); |
275 | config_menu_drawings(chosen); |
240 | break; |
276 | break; |
241 | case 4: // warnings |
277 | case 5: // warnings |
242 | COSD_FLAGS ^= COSD_FLAG_WARNINGS; |
278 | COSD_FLAGS ^= COSD_FLAG_WARNINGS; |
243 | config_menu_drawings(chosen); |
279 | config_menu_drawings(chosen); |
244 | break; |
280 | break; |
245 | case 5: // reset uptime |
281 | case 6: // reset uptime |
246 | uptime = 0; |
282 | uptime = 0; |
247 | config_menu_doclick(chosen, menu); |
283 | config_menu_doclick(chosen, menu); |
248 | break; |
284 | break; |
249 | case 6: // re-request OSD data |
285 | case 7: // re-request OSD data |
Line 257... | Line 293... | ||
257 | // and disable debug... |
293 | // and disable debug... |
258 | usart1_request_mk_data(0, 'd', 0); |
294 | usart1_request_mk_data(0, 'd', 0); |
259 | #endif |
295 | #endif |
260 | config_menu_doclick(chosen, menu); |
296 | config_menu_doclick(chosen, menu); |
261 | break; |
297 | break; |
262 | case 7: // disable debug data |
298 | case 8: // disable debug data |
263 | // disable sending of debug data |
299 | // disable sending of debug data |
264 | // may result in smoother ddata display |
300 | // may result in smoother ddata display |
265 | usart1_request_mk_data(0, 'd', 0); |
301 | usart1_request_mk_data(0, 'd', 0); |
266 | config_menu_doclick(chosen, menu); |
302 | config_menu_doclick(chosen, menu); |
267 | break; |
303 | break; |
268 | case 8: // save |
304 | case 9: // save |
269 | save_eeprom(); |
305 | save_eeprom(); |
270 | config_menu_doclick(chosen, menu); |
306 | config_menu_doclick(chosen, menu); |
271 | break; |
307 | break; |
272 | case 9: // exit |
308 | case 10: // exit |
273 | inmenu = 0; |
309 | inmenu = 0; |
274 | break; |
310 | break; |
275 | } |
311 | } |
276 | _delay_ms(250); |
312 | _delay_ms(250); |
277 | } |
313 | } |