Subversion Repositories Projects

Rev

Rev 837 | Rev 932 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 837 Rev 902
Line 1... Line 1...
1
/****************************************************************************
1
/****************************************************************************
2
 *   Copyright (C) 2009-2010 by Claas Anders "CaScAdE" Rathje               *
2
 *   Copyright (C) 2009-2011 by Claas Anders "CaScAdE" Rathje               *
3
 *   admiralcascade@gmail.com                                               *
3
 *   admiralcascade@gmail.com                                               *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
5
 *                                                                          *
5
 *                                                                          *
6
 *   This program is free software; you can redistribute it and/or modify   *
6
 *   This program is free software; you can redistribute it and/or modify   *
7
 *   it under the terms of the GNU General Public License as published by   *
7
 *   it under the terms of the GNU General Public License as published by   *
Line 35... Line 35...
35
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
35
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
36
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
36
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
37
uint8_t EEMEM ee_COSD_FLAGS_MODES = 0;
37
uint8_t EEMEM ee_COSD_FLAGS_MODES = 0;
38
uint8_t EEMEM ee_COSD_FLAGS_CONFIG = 0;
38
uint8_t EEMEM ee_COSD_FLAGS_CONFIG = 0;
39
uint8_t EEMEM ee_COSD_DISPLAYMODE = 0;
39
uint8_t EEMEM ee_COSD_DISPLAYMODE = 0;
40
uint8_t EEMEM ee_COSD_SCOPE [8] = {
40
uint8_t EEMEM ee_COSD_SCOPE [12] = {
41
    5, 5,
41
    5, 5, 0,
42
    25, 5,
42
    25, 5, 0,
43
    5, 10,
43
    5, 10, 0,
44
    25, 10
44
    25, 10, 0
45
};
45
};
46
 
46
 
47
// video modes
47
// video modes
48
const char VM_PAL[] PROGMEM = "PAL ";
48
const char VM_PAL[] PROGMEM = "PAL ";
49
const char VM_NTSC[] PROGMEM = "NTSC";
49
const char VM_NTSC[] PROGMEM = "NTSC";
Line 62... Line 62...
62
        if (verbose) write_ascii_string_pgm(2, 2, ee_msg[0]); // Loading data
62
        if (verbose) write_ascii_string_pgm(2, 2, ee_msg[0]); // Loading data
63
        COSD_FLAGS_MODES = eeprom_read_byte(&ee_COSD_FLAGS_MODES);
63
        COSD_FLAGS_MODES = eeprom_read_byte(&ee_COSD_FLAGS_MODES);
64
        COSD_FLAGS_CONFIG = eeprom_read_byte(&ee_COSD_FLAGS_CONFIG);
64
        COSD_FLAGS_CONFIG = eeprom_read_byte(&ee_COSD_FLAGS_CONFIG);
65
        COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE);
65
        COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE);
66
        //if (verbose) write_ndigit_number_u(23, 11, COSD_DISPLAYMODE, 2, 0);
66
        //if (verbose) write_ndigit_number_u(23, 11, COSD_DISPLAYMODE, 2, 0);
67
        for (int i = 0; i < 8; i++) {
67
        for (int i = 0; i < 12; i++) {
68
            scope[i] = eeprom_read_byte(&ee_COSD_SCOPE[i]);
68
            scope[i] = eeprom_read_byte(&ee_COSD_SCOPE[i]);
69
        }
69
        }
70
    } else {
70
    } else {
71
        if (verbose) write_ascii_string_pgm(2, 2, ee_msg[1]); // Loading data
71
        if (verbose) write_ascii_string_pgm(2, 2, ee_msg[1]); // Loading data
72
    }
72
    }
Line 79... Line 79...
79
    eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
79
    eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
80
    eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
80
    eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
81
    eeprom_write_byte(&ee_COSD_FLAGS_MODES, COSD_FLAGS_MODES);
81
    eeprom_write_byte(&ee_COSD_FLAGS_MODES, COSD_FLAGS_MODES);
82
    eeprom_write_byte(&ee_COSD_FLAGS_CONFIG, COSD_FLAGS_CONFIG);
82
    eeprom_write_byte(&ee_COSD_FLAGS_CONFIG, COSD_FLAGS_CONFIG);
83
    eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE);
83
    eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE);
84
    for (int i = 0; i < 8; i++) {
84
    for (int i = 0; i < 12; i++) {
85
        eeprom_write_byte(&ee_COSD_SCOPE[i], scope[i]);
85
        eeprom_write_byte(&ee_COSD_SCOPE[i], scope[i]);
86
    }
86
    }
87
}
87
}
88
 
88
 
89
/**
89
/**
Line 225... Line 225...
225
 * helper function for menu updating
225
 * helper function for menu updating
226
 */
226
 */
227
void config_menu_drawings(uint8_t chosen) {
227
void config_menu_drawings(uint8_t chosen) {
228
    static uint8_t old_y = 0;
228
    static uint8_t old_y = 0;
229
    uint8_t x = MENU_LEFT, y = MENU_TOP, line = MENU_TOP;
229
    uint8_t x = MENU_LEFT, y = MENU_TOP, line = MENU_TOP;
230
 
-
 
-
 
230
    //************************************************* 13 to 14
231
    if (chosen > 5 && chosen < 13) { // right
231
    if (chosen > 6 && chosen < 15) { // right
232
        x = MENU_MIDDLE;
232
        x = MENU_MIDDLE;
233
        y = chosen - 6 + MENU_TOP;
233
        y = chosen - 7 + MENU_TOP;
234
    } else if (chosen < 7) {
234
    } else if (chosen < 8) {
235
        y = chosen + MENU_TOP;
235
        y = chosen + MENU_TOP;
236
    } else {
236
    } else {
237
        y = chosen - 6 + MENU_TOP;
237
        y = chosen - 7 + MENU_TOP;
238
    }
238
    }
239
 
239
 
240
    // clear prevoius _cursor_ and draw current
240
    // clear prevoius _cursor_ and draw current
241
    for (uint8_t myx = MENU_LEFT; myx < 29; myx++) {
241
    for (uint8_t myx = MENU_LEFT; myx < 29; myx++) {
242
        write_char_att_xy(myx, old_y, 0);
242
        write_char_att_xy(myx, old_y, 0);
Line 265... Line 265...
265
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STATS);
265
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STATS);
266
 
266
 
267
    write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("A by FC"));
267
    write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("A by FC"));
268
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT);
268
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT);
269
 
269
 
-
 
270
    write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("GPS Pos"));
-
 
271
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_SHOW_COORDS);
-
 
272
 
270
    // 2nd col
273
    // 2nd col
271
    line = 2;
274
    line = 2;
272
 
275
 
273
    write_ascii_string_pgm(MENU_MIDDLE, line, PSTR("V C-Strom"));
276
    write_ascii_string_pgm(MENU_MIDDLE, line, PSTR("V C-Strom"));
274
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT);
277
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT);
Line 284... Line 287...
284
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_FEET);
287
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_FEET);
285
 
288
 
286
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Big Vario"));
289
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Big Vario"));
287
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO);
290
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO);
288
 
291
 
-
 
292
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Big Speed"));
-
 
293
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_BIGSPEED);
-
 
294
 
289
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Passive"));
295
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Passive"));
290
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_PASSIVE);
296
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_PASSIVE);
291
 
297
 
292
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Cam Scope"));
298
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Cam Scope"));
293
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_SHOW_SCOPE);
299
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_SHOW_SCOPE);
294
 
300
 
295
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Move Scope"));
301
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Move Scope"));
296
 
302
 
297
 
303
 
298
    // bottom
304
    // bottom
299
    write_ascii_string_pgm(MENU_LEFT, 9, PSTR("Reset uptime"));
305
    write_ascii_string_pgm(MENU_LEFT, 10, PSTR("Reset uptime"));
300
 
306
 
301
    write_ascii_string_pgm(MENU_LEFT, 10, PSTR("Display Mode"));
307
    write_ascii_string_pgm(MENU_LEFT, 11, PSTR("Display Mode"));
302
    write_ascii_string_pgm(18, 10, (const char *)(pgm_read_word(&(mode->desc))));
308
    write_ascii_string_pgm(15, 11, (const char *)(pgm_read_word(&(mode->desc))));
303
 
309
 
304
    write_ascii_string_pgm(MENU_LEFT, 11, PSTR("Save config"));
310
    write_ascii_string_pgm(MENU_LEFT, 12, PSTR("Save config"));
305
    write_ascii_string_pgm(MENU_LEFT, 12, PSTR("EXIT"));
311
    write_ascii_string_pgm(MENU_LEFT, 13, PSTR("EXIT"));
306
 
312
 
307
    old_y = y;
313
    old_y = y;
308
}
314
}
309
 
315
 
310
/**
316
/**
Line 322... Line 328...
322
void move_scope() {
328
void move_scope() {
323
    uint8_t mode = 0;
329
    uint8_t mode = 0;
324
    clear();
330
    clear();
325
    draw_scope();
331
    draw_scope();
326
    _delay_ms(500);
332
    _delay_ms(500);
327
    while (mode < 8) {
333
    while (mode < 12) {
328
        if (s2_pressed()) { // next
334
        if (s2_pressed()) { // next
329
            mode++;
335
            mode++;
330
            _delay_ms(500);
336
            _delay_ms(500);
331
        } else if (s1_pressed()) {
337
        } else if (s1_pressed()) {
-
 
338
            if (mode % 3 == 2) {
-
 
339
                scope[mode] = (scope[mode] + 1) % 2;
-
 
340
            } else {
332
            scope[mode] = (scope[mode] + 1) % (mode % 2 == 0 ? 30 : bottom_line);
341
                scope[mode] = (scope[mode] + 1) % ((mode % 3) % 2 == 0 ? 30 : bottom_line);
-
 
342
            }
333
            clear();
343
            clear();
334
            draw_scope();
344
            draw_scope();
335
            _delay_ms(100);
345
            _delay_ms(100);
336
        }
346
        }
337
    }
347
    }
Line 357... Line 367...
357
 
367
 
358
    config_menu_drawings(chosen);
368
    config_menu_drawings(chosen);
359
 
369
 
360
    while (inmenu) {
370
    while (inmenu) {
361
        if (s2_pressed()) {
371
        if (s2_pressed()) {
362
            chosen = (chosen + 1) % 17;
372
            chosen = (chosen + 1) % 19;
363
            //if (chosen == 12) chosen = 13; // SKIP unused menu space for now
373
            //if (chosen == 12) chosen = 13; // SKIP unused menu space for now
364
            config_menu_drawings(chosen);
374
            config_menu_drawings(chosen);
365
            _delay_ms(500);
375
            _delay_ms(500);
366
        } else if (s1_pressed()) {
376
        } else if (s1_pressed()) {
367
            switch (chosen) {
377
            switch (chosen) {
Line 393... Line 403...
393
                    COSD_FLAGS_MODES ^= COSD_FLAG_STATS;
403
                    COSD_FLAGS_MODES ^= COSD_FLAG_STATS;
394
                    break;
404
                    break;
395
                case 5: // current by fc
405
                case 5: // current by fc
396
                    COSD_FLAGS_MODES ^= COSD_FLAG_FCCURRENT;
406
                    COSD_FLAGS_MODES ^= COSD_FLAG_FCCURRENT;
397
                    break;
407
                    break;
-
 
408
                case 6: // GPS coordinates while flying
-
 
409
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_SHOW_COORDS;
-
 
410
                    break;
398
                case 6: // 2nd voltage by c-strom
411
                case 7: // 2nd voltage by c-strom
399
                    COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT;
412
                    COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT;
400
                    break;
413
                    break;
401
                case 7: // GPS or BARO height
414
                case 8: // GPS or BARO height
402
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT;
415
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT;
403
                    break;
416
                    break;
404
                case 8: // Feet and mph?
417
                case 9: // Feet and mph?
405
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_FEET;
418
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_FEET;
406
                    break;
419
                    break;
407
                case 9: // big vario
420
                case 10: // big vario
408
                    COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO;
421
                    COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO;
409
                    break;
422
                    break;
-
 
423
                case 11: // big Speed
-
 
424
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_BIGSPEED;
-
 
425
                    break;
410
                case 10: // passive
426
                case 12: // passive
411
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_PASSIVE;
427
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_PASSIVE;
412
                    break;
428
                    break;
413
                case 11: // scope
429
                case 13: // scope
414
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_SHOW_SCOPE;
430
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_SHOW_SCOPE;
415
                    break;
431
                    break;
416
                case 12: // move scope
432
                case 14: // move scope
417
                    move_scope();
433
                    move_scope();
418
                    break;
434
                    break;
419
                case 13: // reset uptime
435
                case 15: // reset uptime
420
                    uptime = 0;
436
                    uptime = 0;
421
                    config_menu_doclick(chosen);
437
                    config_menu_doclick(chosen);
422
                    break;
438
                    break;
423
                case 14: // change mode
439
                case 16: // change mode
424
#if FCONLY
440
#if FCONLY
425
                    COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof (fcdisplaymodes) / sizeof (displaymode_t));
441
                    COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof (fcdisplaymodes) / sizeof (displaymode_t));
426
                    mode = fcdisplaymodes;
442
                    mode = fcdisplaymodes;
427
                    mode += COSD_DISPLAYMODE;
443
                    mode += COSD_DISPLAYMODE;
428
                    osd_fcmode = (int(*)(void)) pgm_read_word(&mode->dfun);
444
                    osd_fcmode = (int(*)(void)) pgm_read_word(&mode->dfun);
Line 431... Line 447...
431
                    mode = ncdisplaymodes;
447
                    mode = ncdisplaymodes;
432
                    mode += COSD_DISPLAYMODE;
448
                    mode += COSD_DISPLAYMODE;
433
                    osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun);
449
                    osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun);
434
#endif
450
#endif
435
                    break;
451
                    break;
436
                case 15: // save
452
                case 17: // save
437
                    save_eeprom();
453
                    save_eeprom();
438
                    config_menu_doclick(chosen);
454
                    config_menu_doclick(chosen);
439
                    break;
455
                    break;
440
                case 16: // exit
456
                case 18: // exit
441
                    inmenu = 0;
457
                    inmenu = 0;
442
                    config_menu_doclick(chosen);
458
                    config_menu_doclick(chosen);
443
                    break;
459
                    break;
444
            }
460
            }
445
            config_menu_drawings(chosen);
461
            config_menu_drawings(chosen);