Subversion Repositories Projects

Rev

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

Rev 489 Rev 497
Line 38... Line 38...
38
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
38
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
39
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
39
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
40
uint16_t EEMEM ee_cal_ampere = 512;
40
uint16_t EEMEM ee_cal_ampere = 512;
41
uint8_t EEMEM ee_sensor = 50;
41
uint8_t EEMEM ee_sensor = 50;
42
uint8_t EEMEM ee_COSD_FLAGS;
42
uint8_t EEMEM ee_COSD_FLAGS;
-
 
43
uint8_t EEMEM ee_COSD_DISPLAYMODE = 0;
43
 
44
 
44
// store init strings in progmem
45
// store init strings in progmem
45
const char init_0[] PROGMEM = "C-OSD Initialisation";
46
const char init_0[] PROGMEM = "C-OSD Initialisation";
46
const char init_1[] PROGMEM = "FC only Mode";
47
const char init_1[] PROGMEM = "FC only Mode";
47
const char init_2[] PROGMEM = "NaviCtrl Mode";
48
const char init_2[] PROGMEM = "NaviCtrl Mode";
Line 66... Line 67...
66
const char menu_item3[] PROGMEM = "Big Vario bar";
67
const char menu_item3[] PROGMEM = "Big Vario bar";
67
const char menu_item4[] PROGMEM = "Statistics";
68
const char menu_item4[] PROGMEM = "Statistics";
68
const char menu_item5[] PROGMEM = "Warnings"; // TODO: do it!
69
const char menu_item5[] PROGMEM = "Warnings"; // TODO: do it!
69
const char menu_item6[] PROGMEM = "Reset uptime";
70
const char menu_item6[] PROGMEM = "Reset uptime";
70
const char menu_item7[] PROGMEM = "Request OSD-data";
71
const char menu_item7[] PROGMEM = "Request OSD-data";
71
const char menu_item8[] PROGMEM = "Disable Debug-data";
72
const char menu_item8[] PROGMEM = "Display Mode";
72
const char menu_item9[] PROGMEM = "Save config";
73
const char menu_item9[] PROGMEM = "Save config";
73
const char menu_item10[] PROGMEM = "EXIT";
74
const char menu_item10[] PROGMEM = "EXIT";
74
const char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4,
75
const char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4,
75
        menu_item5, menu_item6, menu_item7, menu_item8, menu_item9, menu_item10};
76
        menu_item5, menu_item6, menu_item7, menu_item8, menu_item9, menu_item10};
76
 
77
 
-
 
78
const displaymode_t * mode;
-
 
79
 
77
/**
80
/**
78
 * read data saved in eeprom, print out message if <verbose> is set
81
 * read data saved in eeprom, print out message if <verbose> is set
79
 */
82
 */
80
void get_eeprom(uint8_t verbose) {
83
void get_eeprom(uint8_t verbose) {
81
        if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
84
        if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
82
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data
85
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data
83
                COSD_FLAGS = eeprom_read_byte(&ee_COSD_FLAGS);
86
                COSD_FLAGS = eeprom_read_byte(&ee_COSD_FLAGS);
-
 
87
                COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE);
-
 
88
                //if (verbose) write_ndigit_number_u(23, 11, COSD_DISPLAYMODE, 10, 0);
84
        } else {
89
        } else {
85
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // No data found
90
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // No data found
86
        }
91
        }
87
}
92
}
88
 
93
 
Line 91... Line 96...
91
 */
96
 */
92
void save_eeprom() {
97
void save_eeprom() {
93
        eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
98
        eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
94
        eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
99
        eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
95
        eeprom_write_byte(&ee_COSD_FLAGS, COSD_FLAGS);
100
        eeprom_write_byte(&ee_COSD_FLAGS, COSD_FLAGS);
-
 
101
        eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE);
96
}
102
}
97
 
103
 
98
/**
104
/**
99
 * auto config some stuff on startup, currently only battery cells
105
 * auto config some stuff on startup, currently only battery cells
100
 * TODO: this is testing stuff, strings should go progmem and so on...
106
 * TODO: this is testing stuff, strings should go progmem and so on...
Line 140... Line 146...
140
                write_ascii_string_pgm(23, 2, VM_NTSC);
146
                write_ascii_string_pgm(23, 2, VM_NTSC);
141
        } else {
147
        } else {
142
                write_ascii_string_pgm(23, 2, VM_PAL);
148
                write_ascii_string_pgm(23, 2, VM_PAL);
143
        }
149
        }
144
 
150
 
-
 
151
 
-
 
152
        #if FCONLY
-
 
153
        COSD_DISPLAYMODE %= (sizeof(fcdisplaymodes) / sizeof(displaymode_t));
-
 
154
        mode = fcdisplaymodes;
-
 
155
        mode += COSD_DISPLAYMODE;
-
 
156
        osd_fcmode = (int(*)(void)) pgm_read_word(&mode->dfun);
-
 
157
        #else
-
 
158
        COSD_DISPLAYMODE %= (sizeof(ncdisplaymodes) / sizeof(displaymode_t));
-
 
159
        mode = ncdisplaymodes;
-
 
160
        mode += COSD_DISPLAYMODE;
-
 
161
        osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun);
-
 
162
        #endif
-
 
163
 
145
    _delay_ms(200);
164
    _delay_ms(200);
146
    clear();
165
    clear();
147
    // update flags to paint display again because of clear
166
    // update flags to paint display again because of clear
148
    COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN;
167
    COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN;
149
}
168
}
Line 190... Line 209...
190
    if (COSD_FLAGS & COSD_FLAG_WARNINGS) {
209
    if (COSD_FLAGS & COSD_FLAG_WARNINGS) {
191
        write_ascii_string_pgm(23, 7, ON);
210
        write_ascii_string_pgm(23, 7, ON);
192
    } else {
211
    } else {
193
        write_ascii_string_pgm(23, 7, OFF);
212
        write_ascii_string_pgm(23, 7, OFF);
194
    }
213
    }
-
 
214
        //write_ndigit_number_u(23, 10, COSD_DISPLAYMODE, 10, 0);
-
 
215
        write_ascii_string_pgm(18, 10, (const char *) (pgm_read_word(&(mode->desc))));
-
 
216
       
195
}
217
}
196
 
218
 
197
/**
219
/**
198
 * some sort of clicking response in the menu
220
 * some sort of clicking response in the menu
199
 */
221
 */
Line 293... Line 315...
293
                    // and disable debug...
315
                    // and disable debug...
294
                    usart1_request_mk_data(0, 'd', 0);
316
                    usart1_request_mk_data(0, 'd', 0);
295
#endif
317
#endif
296
                    config_menu_doclick(chosen, menu);
318
                    config_menu_doclick(chosen, menu);
297
                    break;
319
                    break;
298
                case 8: // disable debug data
320
                case 8: // change mode
-
 
321
                                        #if FCONLY
-
 
322
                                        COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(fcdisplaymodes) / sizeof(displaymode_t));
-
 
323
                                        mode = fcdisplaymodes;
-
 
324
                                        mode += COSD_DISPLAYMODE;
299
                    // disable sending of debug data
325
                                        osd_fcmode = (int(*)(void)) pgm_read_word(&mode->dfun);
-
 
326
                                        #else
300
                    // may result in smoother ddata display
327
                                        COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(ncdisplaymodes) / sizeof(displaymode_t));
-
 
328
                                        mode = ncdisplaymodes;
-
 
329
                                        mode += COSD_DISPLAYMODE;
301
                    usart1_request_mk_data(0, 'd', 0);
330
                                        osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun);
-
 
331
                                        #endif
302
                    config_menu_doclick(chosen, menu);
332
                                        config_menu_drawings(chosen);
303
                    break;
333
                    break;
304
                case 9: // save
334
                case 9: // save
305
                    save_eeprom();
335
                    save_eeprom();
306
                    config_menu_doclick(chosen, menu);
336
                    config_menu_doclick(chosen, menu);
307
                    break;
337
                    break;