Rev 519 | Rev 567 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 519 | Rev 523 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | 31 | ||
32 | uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1; |
32 | uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1; |
33 | uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2; |
33 | uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2; |
34 | uint16_t EEMEM ee_cal_ampere = 512; |
34 | uint16_t EEMEM ee_cal_ampere = 512; |
35 | uint8_t EEMEM ee_sensor = 50; |
35 | uint8_t EEMEM ee_sensor = 50; |
- | 36 | uint8_t EEMEM ee_COSD_FLAGS_MODES = 0; |
|
36 | uint8_t EEMEM ee_COSD_FLAGS; |
37 | uint8_t EEMEM ee_COSD_FLAGS_CONFIG = 0; |
Line 37... | Line 38... | ||
37 | uint8_t EEMEM ee_COSD_DISPLAYMODE = 0; |
38 | uint8_t EEMEM ee_COSD_DISPLAYMODE = 0; |
Line 38... | Line 39... | ||
38 | 39 | ||
Line 64... | Line 65... | ||
64 | const char menu_item4[] PROGMEM = "Statistics"; |
65 | const char menu_item4[] PROGMEM = "Statistics"; |
65 | const char menu_item5[] PROGMEM = "Warnings"; // TODO: do it! |
66 | const char menu_item5[] PROGMEM = "Warnings"; // TODO: do it! |
66 | const char menu_item6[] PROGMEM = "Voltage by C-Strom"; |
67 | const char menu_item6[] PROGMEM = "Voltage by C-Strom"; |
67 | const char menu_item7[] PROGMEM = "Reset uptime"; |
68 | const char menu_item7[] PROGMEM = "Reset uptime"; |
68 | const char menu_item8[] PROGMEM = "Display Mode"; |
69 | const char menu_item8[] PROGMEM = "Display Mode"; |
- | 70 | const char menu_item9[] PROGMEM = "Height by"; |
|
69 | const char menu_item9[] PROGMEM = "Save config"; |
71 | const char menu_item10[] PROGMEM = "Save config"; |
70 | const char menu_item10[] PROGMEM = "EXIT"; |
72 | const char menu_item11[] PROGMEM = "EXIT"; |
71 | const char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4, |
73 | const char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4, |
72 | menu_item5, menu_item6, menu_item7, menu_item8, menu_item9, menu_item10}; |
74 | menu_item5, menu_item6, menu_item7, menu_item8, menu_item9, menu_item10, menu_item11}; |
Line 73... | Line 75... | ||
73 | 75 | ||
Line 74... | Line 76... | ||
74 | const displaymode_t * mode; |
76 | const displaymode_t * mode; |
Line 85... | Line 87... | ||
85 | void get_eeprom(uint8_t verbose) { |
87 | void get_eeprom(uint8_t verbose) { |
86 | if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) { |
88 | if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) { |
87 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
89 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
88 | if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data |
90 | if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data |
89 | #endif |
91 | #endif |
90 | COSD_FLAGS = eeprom_read_byte(&ee_COSD_FLAGS); |
92 | COSD_FLAGS_MODES = eeprom_read_byte(&ee_COSD_FLAGS_MODES); |
- | 93 | COSD_FLAGS_CONFIG = eeprom_read_byte(&ee_COSD_FLAGS_CONFIG); |
|
91 | COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE); |
94 | COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE); |
92 | //if (verbose) write_ndigit_number_u(23, 11, COSD_DISPLAYMODE, 2, 0); |
95 | //if (verbose) write_ndigit_number_u(23, 11, COSD_DISPLAYMODE, 2, 0); |
93 | } else { |
96 | } else { |
94 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
97 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
95 | if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // Loading data |
98 | if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // Loading data |
Line 103... | Line 106... | ||
103 | * save data to eeprom |
106 | * save data to eeprom |
104 | */ |
107 | */ |
105 | void save_eeprom() { |
108 | void save_eeprom() { |
106 | eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1); |
109 | eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1); |
107 | eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2); |
110 | eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2); |
108 | eeprom_write_byte(&ee_COSD_FLAGS, COSD_FLAGS); |
111 | eeprom_write_byte(&ee_COSD_FLAGS_MODES, COSD_FLAGS_MODES); |
- | 112 | eeprom_write_byte(&ee_COSD_FLAGS_CONFIG, COSD_FLAGS_CONFIG); |
|
109 | eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE); |
113 | eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE); |
110 | } |
114 | } |
Line 111... | Line 115... | ||
111 | 115 | ||
112 | /** |
116 | /** |
Line 122... | Line 126... | ||
122 | //write_ascii_string(2, 2, "FC only Mode"); |
126 | //write_ascii_string(2, 2, "FC only Mode"); |
123 | #else |
127 | #else |
124 | write_ascii_string_pgm(2, 2, init_point[2]); // NaviCtrl Mode |
128 | write_ascii_string_pgm(2, 2, init_point[2]); // NaviCtrl Mode |
125 | //write_ascii_string(2, 2, "NaviCtrl Mode"); |
129 | //write_ascii_string(2, 2, "NaviCtrl Mode"); |
126 | #endif |
130 | #endif |
127 | write_ascii_string(2, 3, BUILDDATE); |
131 | write_ascii_string_pgm(2, 3, PSTR(BUILDDATE)); |
128 | uint8_t cellnum = 0; |
132 | uint8_t cellnum = 0; |
129 | if (CELL_NUM == -1) { |
133 | if (CELL_NUM == -1) { |
130 | write_ascii_string_pgm(2, 4, init_point[3]); // Guessing Number of Cells |
134 | write_ascii_string_pgm(2, 4, init_point[3]); // Guessing Number of Cells |
131 | //write_ascii_string(2, 6, "Guessing Number of Cells"); |
135 | //write_ascii_string(2, 6, "Guessing Number of Cells"); |
132 | do { |
136 | do { |
Line 148... | Line 152... | ||
148 | write_ndigit_number_s_10th(20, 7, max_voltage, 3, 0); |
152 | write_ndigit_number_s_10th(20, 7, max_voltage, 3, 0); |
Line 149... | Line 153... | ||
149 | 153 | ||
Line 150... | Line 154... | ||
150 | get_eeprom(1); |
154 | get_eeprom(1); |
151 | 155 | ||
152 | //write_ascii_string_pgm(23, 2, vm[COSD_FLAGS & COSD_FLAG_NTSC]); |
156 | //write_ascii_string_pgm(23, 2, vm[COSD_FLAGS & COSD_FLAG_NTSC]); |
153 | if (COSD_FLAGS & COSD_FLAG_NTSC) { |
157 | if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) { |
154 | write_ascii_string_pgm(23, 2, VM_NTSC); |
158 | write_ascii_string_pgm(23, 2, VM_NTSC); |
155 | } else { |
159 | } else { |
Line 170... | Line 174... | ||
170 | #endif |
174 | #endif |
Line 171... | Line 175... | ||
171 | 175 | ||
172 | _delay_ms(200); |
176 | _delay_ms(200); |
173 | clear(); |
177 | clear(); |
174 | // update flags to paint display again because of clear |
178 | // update flags to paint display again because of clear |
175 | COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN; |
179 | COSD_FLAGS_RUNTIME &= ~COSD_ICONS_WRITTEN; |
Line 176... | Line 180... | ||
176 | } |
180 | } |
177 | 181 | ||
178 | /* ########################################################################## |
182 | /* ########################################################################## |
Line 186... | Line 190... | ||
186 | // clear prevoius _cursor_ |
190 | // clear prevoius _cursor_ |
187 | write_ascii_string(3, (chosen + 2) % 10, " "); |
191 | write_ascii_string(3, (chosen + 2) % 10, " "); |
188 | // draw current _cursor_ |
192 | // draw current _cursor_ |
189 | write_ascii_string(3, chosen + 2, ">"); |
193 | write_ascii_string(3, chosen + 2, ">"); |
Line 190... | Line 194... | ||
190 | 194 | ||
191 | if (COSD_FLAGS & COSD_FLAG_NTSC) { |
195 | if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) { |
192 | write_ascii_string_pgm(23, 2, VM_NTSC); |
196 | write_ascii_string_pgm(23, 2, VM_NTSC); |
193 | } else { |
197 | } else { |
194 | write_ascii_string_pgm(23, 2, VM_PAL); |
198 | write_ascii_string_pgm(23, 2, VM_PAL); |
Line 195... | Line 199... | ||
195 | } |
199 | } |
196 | 200 | ||
197 | if (COSD_FLAGS & COSD_FLAG_HUD) { |
201 | if (COSD_FLAGS_MODES & COSD_FLAG_HUD) { |
198 | write_ascii_string_pgm(23, 3, ON); |
202 | write_ascii_string_pgm(23, 3, ON); |
199 | } else { |
203 | } else { |
200 | write_ascii_string_pgm(23, 3, OFF); |
204 | write_ascii_string_pgm(23, 3, OFF); |
201 | } |
205 | } |
202 | if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { |
206 | if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { |
203 | write_ascii_string_pgm(23, 4, ON); |
207 | write_ascii_string_pgm(23, 4, ON); |
204 | } else { |
208 | } else { |
205 | write_ascii_string_pgm(23, 4, OFF); |
209 | write_ascii_string_pgm(23, 4, OFF); |
206 | } |
210 | } |
207 | if (COSD_FLAGS & COSD_FLAG_BIGVARIO) { |
211 | if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) { |
208 | write_ascii_string_pgm(23, 5, ON); |
212 | write_ascii_string_pgm(23, 5, ON); |
209 | } else { |
213 | } else { |
210 | write_ascii_string_pgm(23, 5, OFF); |
214 | write_ascii_string_pgm(23, 5, OFF); |
211 | } |
215 | } |
212 | if (COSD_FLAGS & COSD_FLAG_STATS) { |
216 | if (COSD_FLAGS_MODES & COSD_FLAG_STATS) { |
213 | write_ascii_string_pgm(23, 6, ON); |
217 | write_ascii_string_pgm(23, 6, ON); |
214 | } else { |
218 | } else { |
215 | write_ascii_string_pgm(23, 6, OFF); |
219 | write_ascii_string_pgm(23, 6, OFF); |
216 | } |
220 | } |
217 | if (COSD_FLAGS & COSD_FLAG_WARNINGS) { |
221 | if (COSD_FLAGS_MODES & COSD_FLAG_WARNINGS) { |
218 | write_ascii_string_pgm(23, 7, ON); |
222 | write_ascii_string_pgm(23, 7, ON); |
219 | } else { |
223 | } else { |
220 | write_ascii_string_pgm(23, 7, OFF); |
224 | write_ascii_string_pgm(23, 7, OFF); |
221 | } |
225 | } |
222 | if (COSD_FLAGS & COSD_FLAG_STROMVOLT) { |
226 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
223 | write_ascii_string_pgm(23, 8, ON); |
227 | write_ascii_string_pgm(23, 8, ON); |
224 | } else { |
228 | } else { |
225 | write_ascii_string_pgm(23, 8, OFF); |
229 | write_ascii_string_pgm(23, 8, OFF); |
226 | } |
230 | } |
Line -... | Line 231... | ||
- | 231 | //write_ndigit_number_u(23, 10, COSD_DISPLAYMODE, 2, 0); |
|
- | 232 | write_ascii_string_pgm(18, 10, (const char *) (pgm_read_word(&(mode->desc)))); |
|
- | 233 | ||
- | 234 | if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) { |
|
- | 235 | write_ascii_string_pgm(20, 11, PSTR(" GPS")); |
|
227 | //write_ndigit_number_u(23, 10, COSD_DISPLAYMODE, 2, 0); |
236 | } else { |
Line 228... | Line 237... | ||
228 | write_ascii_string_pgm(18, 10, (const char *) (pgm_read_word(&(mode->desc)))); |
237 | write_ascii_string_pgm(20, 11, PSTR("BARO")); |
229 | 238 | } |
|
230 | } |
239 | } |
231 | 240 | ||
232 | /** |
241 | /** |
233 | * some sort of clicking response in the menu |
242 | * some sort of clicking response in the menu |
234 | */ |
243 | */ |
235 | void config_menu_doclick(uint8_t chosen, const char* menu[]) { |
244 | void config_menu_doclick(uint8_t chosen, const char* menu[]) { |
Line 236... | Line 245... | ||
236 | write_ascii_string(4, chosen + 2, "DONE "); |
245 | write_ascii_string_pgm(4, chosen + 2, PSTR("DONE ")); |
Line 248... | Line 257... | ||
248 | // clear screen |
257 | // clear screen |
249 | clear(); |
258 | clear(); |
Line 250... | Line 259... | ||
250 | 259 | ||
251 | uint8_t inmenu = 1; |
260 | uint8_t inmenu = 1; |
252 | uint8_t chosen = 0; |
261 | uint8_t chosen = 0; |
Line 253... | Line 262... | ||
253 | write_ascii_string(6, 1, "C-OSD Config Menu"); |
262 | write_ascii_string_pgm(6, 1, PSTR("C-OSD Config Menu")); |
254 | 263 | ||
Line 255... | Line 264... | ||
255 | // wait a bit before doing stuff so user has chance to release button |
264 | // wait a bit before doing stuff so user has chance to release button |
Line 264... | Line 273... | ||
264 | write_ascii_string_pgm(4, 8, menu[6]); |
273 | write_ascii_string_pgm(4, 8, menu[6]); |
265 | write_ascii_string_pgm(4, 9, menu[7]); |
274 | write_ascii_string_pgm(4, 9, menu[7]); |
266 | write_ascii_string_pgm(4, 10, menu[8]); |
275 | write_ascii_string_pgm(4, 10, menu[8]); |
267 | write_ascii_string_pgm(4, 11, menu[9]); |
276 | write_ascii_string_pgm(4, 11, menu[9]); |
268 | write_ascii_string_pgm(4, 12, menu[10]); |
277 | write_ascii_string_pgm(4, 12, menu[10]); |
- | 278 | write_ascii_string_pgm(4, 13, menu[11]); |
|
Line 269... | Line 279... | ||
269 | 279 | ||
Line 270... | Line 280... | ||
270 | config_menu_drawings(chosen); |
280 | config_menu_drawings(chosen); |
271 | 281 | ||
272 | while (inmenu) { |
282 | while (inmenu) { |
273 | if (s2_pressed()) { |
283 | if (s2_pressed()) { |
274 | write_ascii_string(3, chosen + 2, " "); |
284 | write_ascii_string(3, chosen + 2, " "); |
275 | chosen = (chosen + 1) % 11; |
285 | chosen = (chosen + 1) % 12; |
276 | write_ascii_string(3, chosen + 2, ">"); |
286 | write_ascii_string(3, chosen + 2, ">"); |
277 | _delay_ms(500); |
287 | _delay_ms(500); |
278 | } else if (s1_pressed()) { |
288 | } else if (s1_pressed()) { |
279 | switch (chosen) { |
289 | switch (chosen) { |
280 | case 0: // full HUD |
290 | case 0: // NTSC or PAL |
281 | COSD_FLAGS ^= COSD_FLAG_NTSC; |
291 | COSD_FLAGS_CONFIG ^= COSD_FLAG_NTSC; |
282 | // Setup Video Mode |
292 | // Setup Video Mode |
283 | if (COSD_FLAGS & COSD_FLAG_NTSC) { |
293 | if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) { |
Line 284... | Line 294... | ||
284 | // NTSC + enable display immediately (VM0) |
294 | // NTSC + enable display immediately (VM0) |
285 | spi_send_byte(0x00, 0b00001000); |
295 | spi_send_byte(0x00, 0b00001000); |
Line 292... | Line 302... | ||
292 | bottom_line = 14; |
302 | bottom_line = 14; |
293 | } |
303 | } |
294 | config_menu_drawings(chosen); |
304 | config_menu_drawings(chosen); |
295 | break; |
305 | break; |
296 | case 1: // full HUD |
306 | case 1: // full HUD |
297 | COSD_FLAGS ^= COSD_FLAG_HUD; |
307 | COSD_FLAGS_MODES ^= COSD_FLAG_HUD; |
298 | config_menu_drawings(chosen); |
308 | config_menu_drawings(chosen); |
299 | break; |
309 | break; |
300 | case 2: // art horizon |
310 | case 2: // art horizon |
301 | COSD_FLAGS ^= COSD_FLAG_ARTHORIZON; |
311 | COSD_FLAGS_MODES ^= COSD_FLAG_ARTHORIZON; |
302 | config_menu_drawings(chosen); |
312 | config_menu_drawings(chosen); |
303 | break; |
313 | break; |
304 | case 3: // big vario |
314 | case 3: // big vario |
305 | COSD_FLAGS ^= COSD_FLAG_BIGVARIO; |
315 | COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO; |
306 | config_menu_drawings(chosen); |
316 | config_menu_drawings(chosen); |
307 | break; |
317 | break; |
308 | case 4: // statistics |
318 | case 4: // statistics |
309 | COSD_FLAGS ^= COSD_FLAG_STATS; |
319 | COSD_FLAGS_MODES ^= COSD_FLAG_STATS; |
310 | config_menu_drawings(chosen); |
320 | config_menu_drawings(chosen); |
311 | break; |
321 | break; |
312 | case 5: // warnings |
322 | case 5: // warnings |
313 | COSD_FLAGS ^= COSD_FLAG_WARNINGS; |
323 | COSD_FLAGS_MODES ^= COSD_FLAG_WARNINGS; |
314 | config_menu_drawings(chosen); |
324 | config_menu_drawings(chosen); |
315 | break; |
325 | break; |
316 | case 6: // 2nd voltage by c-strom |
326 | case 6: // 2nd voltage by c-strom |
317 | COSD_FLAGS ^= COSD_FLAG_STROMVOLT; |
327 | COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT; |
318 | config_menu_drawings(chosen); |
328 | config_menu_drawings(chosen); |
319 | break; |
329 | break; |
320 | case 7: // reset uptime |
330 | case 7: // reset uptime |
321 | uptime = 0; |
331 | uptime = 0; |
322 | config_menu_doclick(chosen, menu); |
332 | config_menu_doclick(chosen, menu); |
Line 333... | Line 343... | ||
333 | mode += COSD_DISPLAYMODE; |
343 | mode += COSD_DISPLAYMODE; |
334 | osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun); |
344 | osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun); |
335 | #endif |
345 | #endif |
336 | config_menu_drawings(chosen); |
346 | config_menu_drawings(chosen); |
337 | break; |
347 | break; |
- | 348 | case 9: // GPS or BARO height |
|
- | 349 | COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT; |
|
- | 350 | config_menu_drawings(chosen); |
|
- | 351 | break; |
|
338 | case 9: // save |
352 | case 10: // save |
339 | save_eeprom(); |
353 | save_eeprom(); |
340 | config_menu_doclick(chosen, menu); |
354 | config_menu_doclick(chosen, menu); |
341 | break; |
355 | break; |
342 | case 10: // exit |
356 | case 11: // exit |
343 | inmenu = 0; |
357 | inmenu = 0; |
344 | break; |
358 | break; |
345 | } |
359 | } |
346 | _delay_ms(250); |
360 | _delay_ms(250); |
347 | } |
361 | } |
Line 349... | Line 363... | ||
349 | 363 | ||
350 | // clear screen up again |
364 | // clear screen up again |
Line 351... | Line 365... | ||
351 | clear(); |
365 | clear(); |
352 | 366 | ||
Line 353... | Line 367... | ||
353 | // update flags to paint display again if needed |
367 | // update flags to paint display again if needed |
354 | COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN; |
368 | COSD_FLAGS_RUNTIME &= ~COSD_ICONS_WRITTEN; |
355 | 369 |