Rev 738 | Rev 758 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 738 | Rev 757 | ||
---|---|---|---|
Line 82... | Line 82... | ||
82 | eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE); |
82 | eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE); |
83 | } |
83 | } |
Line 84... | Line 84... | ||
84 | 84 | ||
85 | /** |
85 | /** |
86 | * auto config some stuff on startup, currently only battery cells |
- | |
87 | * TODO: this is testing stuff, strings should go progmem and so on... |
86 | * auto config some stuff on startup, currently only battery cells |
88 | */ |
87 | */ |
89 | void init_cosd(uint8_t UBat) { |
88 | void init_cosd(uint8_t UBat) { |
90 | clear(); |
89 | clear(); |
91 | write_ascii_string_pgm(2, 1, PSTR("C-OSD Initialisation")); // C-OSD Initialisation |
90 | write_ascii_string_pgm(2, 1, PSTR("C-OSD Initialisation")); // C-OSD Initialisation |
Line 176... | Line 175... | ||
176 | * ##########################################################################*/ |
175 | * ##########################################################################*/ |
Line 177... | Line 176... | ||
177 | 176 | ||
178 | /** |
177 | /** |
179 | * helper function for flag display |
178 | * helper function for flag display |
180 | */ |
179 | */ |
181 | void onoff(uint8_t line, uint8_t onoff) { |
180 | void onoff(uint8_t col, uint8_t line, uint8_t onoff) { |
182 | if (onoff) { |
181 | if (onoff) { |
183 | write_ascii_string_pgm(23, line, PSTR("ON ")); |
182 | write_ascii_string_pgm(col, line, PSTR("ON ")); |
184 | } else { |
183 | } else { |
185 | write_ascii_string_pgm(23, line, PSTR("OFF")); |
184 | write_ascii_string_pgm(col, line, PSTR("OFF")); |
186 | } |
185 | } |
Line -... | Line 186... | ||
- | 186 | } |
|
187 | } |
187 | |
188 | 188 | ||
189 | /** |
189 | /** |
190 | * helper function for menu updating |
190 | * helper function for menu updating |
191 | */ |
191 | */ |
- | 192 | void config_menu_drawings(uint8_t chosen) { |
|
- | 193 | static uint8_t old_y = 0; |
|
- | 194 | uint8_t x = MENU_LEFT, y = MENU_TOP, line = MENU_TOP; |
|
- | 195 | ||
- | 196 | if (chosen > 5 && chosen < 12) { // right |
|
- | 197 | x = MENU_MIDDLE; |
|
- | 198 | y = chosen - 6 + MENU_TOP; |
|
- | 199 | } else if (chosen < 7) { |
|
- | 200 | y = chosen + MENU_TOP; |
|
- | 201 | } else { |
|
Line 192... | Line 202... | ||
192 | void config_menu_drawings(uint8_t chosen) { |
202 | y = chosen - 6 + MENU_TOP; |
193 | uint8_t line = 2; |
203 | } |
194 | 204 | ||
195 | // clear prevoius _cursor_ |
205 | // clear prevoius _cursor_ and draw current |
196 | //write_char_xy(3, line + ((chosen + 11) % 12), 0x00); |
206 | for (uint8_t myx = MENU_LEFT; myx < 29; myx++) { |
- | 207 | write_char_att_xy(myx, old_y, 0); |
|
197 | for (uint8_t x = 2; x < 28; x++) { |
208 | if (myx > x - 1 && myx < x + 14) { |
198 | write_char_att_xy(x, line + ((chosen + 11) % 12), 0); |
- | |
199 | write_char_att_xy(x, line + chosen, BLACKBG | INVERT); |
- | |
200 | }; |
- | |
Line 201... | Line 209... | ||
201 | // draw current _cursor_ |
209 | write_char_att_xy(myx, y, BLACKBG | INVERT); |
202 | //write_char_xy(3, line + chosen, 0xD9); |
210 | } |
203 | 211 | }; |
|
204 | 212 | ||
205 | write_ascii_string_pgm(4, line, PSTR("Video Mode")); |
213 | write_ascii_string_pgm(MENU_LEFT, line, PSTR("Video")); |
206 | if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) { |
214 | if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) { |
Line 207... | Line 215... | ||
207 | write_ascii_string_pgm(23, line, VM_NTSC); |
215 | write_ascii_string_pgm(MENU_LEFT + 10, line, VM_NTSC); |
208 | } else { |
216 | } else { |
209 | write_ascii_string_pgm(23, line, VM_PAL); |
- | |
210 | } |
- | |
211 | - | ||
Line 212... | Line 217... | ||
212 | write_ascii_string_pgm(4, ++line, PSTR("Full HUD")); |
217 | write_ascii_string_pgm(MENU_LEFT + 10, line, VM_PAL); |
213 | onoff(line, COSD_FLAGS_MODES & COSD_FLAG_HUD); |
218 | } |
Line -... | Line 219... | ||
- | 219 | ||
- | 220 | write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Full HUD")); |
|
- | 221 | onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_HUD); |
|
214 | 222 | ||
215 | write_ascii_string_pgm(4, ++line, PSTR("Art Horizon in HUD")); |
223 | write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Horizon")); |
Line 216... | Line 224... | ||
216 | onoff(line, COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON); |
224 | onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON); |
217 | 225 | ||
Line 218... | Line 226... | ||
218 | write_ascii_string_pgm(4, ++line, PSTR("Big Vario bar")); |
226 | write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Aggr.Hor.")); |
219 | onoff(line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO); |
227 | onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_AGGRHORIZON); |
Line 220... | Line 228... | ||
220 | 228 | ||
- | 229 | write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Stats")); |
|
Line 221... | Line -... | ||
221 | write_ascii_string_pgm(4, ++line, PSTR("Statistics")); |
- | |
222 | onoff(line, COSD_FLAGS_MODES & COSD_FLAG_STATS); |
- | |
223 | - | ||
224 | write_ascii_string_pgm(4, ++line, PSTR("Current by FC")); |
230 | onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STATS); |
225 | onoff(line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT); |
231 | |
226 | 232 | write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("A by FC")); |
|
227 | write_ascii_string_pgm(4, ++line, PSTR("Voltage by C-Strom")); |
233 | onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT); |
228 | onoff(line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT); |
234 | |
229 | 235 | // 2nd col |
|
Line -... | Line 236... | ||
- | 236 | line = 2; |
|
- | 237 | ||
- | 238 | write_ascii_string_pgm(MENU_MIDDLE, line, PSTR("V C-Strom")); |
|
- | 239 | onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT); |
|
- | 240 | ||
- | 241 | write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Height by")); |
|
- | 242 | if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) { |
|
- | 243 | write_ascii_string_pgm(MENU_MIDDLE + 10, line, PSTR(" GPS")); |
|
- | 244 | } else { |
|
- | 245 | write_ascii_string_pgm(MENU_MIDDLE + 10, line, PSTR("BARO")); |
|
- | 246 | } |
|
- | 247 | ||
- | 248 | write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Feet/mph")); |
|
230 | write_ascii_string_pgm(4, ++line, PSTR("Reset uptime")); |
249 | onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_FEET); |
231 | 250 | ||
- | 251 | write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Big Vario")); |
|
- | 252 | onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO); |
|
232 | write_ascii_string_pgm(4, ++line, PSTR("Display Mode")); |
253 | |
Line 233... | Line 254... | ||
233 | write_ascii_string_pgm(18, line, (const char *) (pgm_read_word(&(mode->desc)))); |
254 | |
234 | 255 | // bottom |
|
235 | write_ascii_string_pgm(4, ++line, PSTR("Height by")); |
256 | write_ascii_string_pgm(MENU_LEFT, 9, PSTR("Reset uptime")); |
236 | if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) { |
257 | |
237 | write_ascii_string_pgm(20, line, PSTR(" GPS")); |
258 | write_ascii_string_pgm(MENU_LEFT, 10, PSTR("Display Mode")); |
238 | } else { |
259 | write_ascii_string_pgm(18, 10, (const char *) (pgm_read_word(&(mode->desc)))); |
239 | write_ascii_string_pgm(20, line, PSTR("BARO")); |
260 | |
240 | } |
261 | write_ascii_string_pgm(MENU_LEFT, 11, PSTR("Save config")); |
Line 241... | Line 262... | ||
241 | 262 | write_ascii_string_pgm(MENU_LEFT, 12, PSTR("EXIT")); |
|
Line 271... | Line 292... | ||
271 | 292 | ||
Line 272... | Line 293... | ||
272 | config_menu_drawings(chosen); |
293 | config_menu_drawings(chosen); |
273 | 294 | ||
274 | while (inmenu) { |
295 | while (inmenu) { |
- | 296 | if (s2_pressed()) { |
|
275 | if (s2_pressed()) { |
297 | chosen = (chosen + 1) % 17; |
276 | chosen = (chosen + 1) % 12; |
298 | if (chosen == 10) chosen = 13; // SKIP unused menu space for now |
277 | config_menu_drawings(chosen); |
299 | config_menu_drawings(chosen); |
278 | _delay_ms(500); |
300 | _delay_ms(500); |
279 | } else if (s1_pressed()) { |
301 | } else if (s1_pressed()) { |
Line 290... | Line 312... | ||
290 | // PAL + enable display immediately (VM0) |
312 | // PAL + enable display immediately (VM0) |
291 | spi_send_byte(0x00, 0b01001000); |
313 | spi_send_byte(0x00, 0b01001000); |
Line 292... | Line 314... | ||
292 | 314 | ||
293 | bottom_line = 14; |
315 | bottom_line = 14; |
294 | } |
- | |
295 | config_menu_drawings(chosen); |
316 | } |
296 | break; |
317 | break; |
297 | case 1: // full HUD |
318 | case 1: // full HUD |
298 | COSD_FLAGS_MODES ^= COSD_FLAG_HUD; |
- | |
299 | config_menu_drawings(chosen); |
319 | COSD_FLAGS_MODES ^= COSD_FLAG_HUD; |
300 | break; |
320 | break; |
301 | case 2: // art horizon |
321 | case 2: // art horizon |
302 | COSD_FLAGS_MODES ^= COSD_FLAG_ARTHORIZON; |
- | |
303 | config_menu_drawings(chosen); |
322 | COSD_FLAGS_MODES ^= COSD_FLAG_ARTHORIZON; |
304 | break; |
323 | break; |
305 | case 3: // big vario |
324 | case 3: // aggressiva horizon |
306 | COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO; |
- | |
307 | config_menu_drawings(chosen); |
325 | COSD_FLAGS_MODES ^= COSD_FLAG_AGGRHORIZON; |
308 | break; |
326 | break; |
309 | case 4: // statistics |
327 | case 4: // statistics |
310 | COSD_FLAGS_MODES ^= COSD_FLAG_STATS; |
- | |
311 | config_menu_drawings(chosen); |
328 | COSD_FLAGS_MODES ^= COSD_FLAG_STATS; |
312 | break; |
- | |
313 | /*case 5: // warnings |
- | |
314 | COSD_FLAGS_MODES ^= COSD_FLAG_WARNINGS; |
- | |
315 | config_menu_drawings(chosen); |
- | |
316 | break;*/ |
329 | break; |
317 | case 5: // current by fc |
330 | case 5: // current by fc |
318 | COSD_FLAGS_MODES ^= COSD_FLAG_FCCURRENT; |
- | |
319 | config_menu_drawings(chosen); |
331 | COSD_FLAGS_MODES ^= COSD_FLAG_FCCURRENT; |
320 | break; |
332 | break; |
321 | case 6: // 2nd voltage by c-strom |
333 | case 6: // 2nd voltage by c-strom |
322 | COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT; |
- | |
323 | config_menu_drawings(chosen); |
334 | COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT; |
- | 335 | break; |
|
- | 336 | case 7: // GPS or BARO height |
|
- | 337 | COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT; |
|
- | 338 | break; |
|
- | 339 | case 8: // Feet and mph? |
|
- | 340 | COSD_FLAGS_CONFIG ^= COSD_FLAG_FEET; |
|
- | 341 | break; |
|
- | 342 | case 9: // big vario |
|
- | 343 | COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO; |
|
324 | break; |
344 | break; |
325 | case 7: // reset uptime |
345 | case 13: // reset uptime |
326 | uptime = 0; |
346 | uptime = 0; |
327 | config_menu_doclick(chosen); |
347 | config_menu_doclick(chosen); |
328 | break; |
348 | break; |
329 | case 8: // change mode |
349 | case 14: // change mode |
330 | #if FCONLY |
350 | #if FCONLY |
331 | COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(fcdisplaymodes) / sizeof(displaymode_t)); |
351 | COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(fcdisplaymodes) / sizeof(displaymode_t)); |
332 | mode = fcdisplaymodes; |
352 | mode = fcdisplaymodes; |
333 | mode += COSD_DISPLAYMODE; |
353 | mode += COSD_DISPLAYMODE; |
Line 336... | Line 356... | ||
336 | COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(ncdisplaymodes) / sizeof(displaymode_t)); |
356 | COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(ncdisplaymodes) / sizeof(displaymode_t)); |
337 | mode = ncdisplaymodes; |
357 | mode = ncdisplaymodes; |
338 | mode += COSD_DISPLAYMODE; |
358 | mode += COSD_DISPLAYMODE; |
339 | osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun); |
359 | osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun); |
340 | #endif |
360 | #endif |
341 | config_menu_drawings(chosen); |
- | |
342 | break; |
361 | break; |
343 | case 9: // GPS or BARO height |
- | |
344 | COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT; |
- | |
345 | config_menu_drawings(chosen); |
- | |
346 | break; |
- | |
347 | case 10: // save |
362 | case 15: // save |
348 | save_eeprom(); |
363 | save_eeprom(); |
349 | config_menu_doclick(chosen); |
364 | config_menu_doclick(chosen); |
350 | break; |
365 | break; |
351 | case 11: // exit |
366 | case 16: // exit |
352 | inmenu = 0; |
367 | inmenu = 0; |
- | 368 | config_menu_doclick(chosen); |
|
353 | break; |
369 | break; |
354 | } |
370 | } |
- | 371 | config_menu_drawings(chosen); |
|
355 | _delay_ms(250); |
372 | _delay_ms(250); |
356 | } |
373 | } |
357 | } |
374 | } |
Line 358... | Line 375... | ||
358 | 375 |