Subversion Repositories Projects

Rev

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

Rev 734 Rev 736
Line 35... Line 35...
35
uint8_t EEMEM ee_COSD_FLAGS_CONFIG = 0;
35
uint8_t EEMEM ee_COSD_FLAGS_CONFIG = 0;
36
uint8_t EEMEM ee_COSD_DISPLAYMODE = 0;
36
uint8_t EEMEM ee_COSD_DISPLAYMODE = 0;
Line 37... Line 37...
37
 
37
 
Line 38... Line -...
38
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
-
 
39
 
-
 
40
// store more fixed strings in progmen
-
 
41
char ON[] PROGMEM = "ON ";
-
 
42
char OFF[] PROGMEM = "OFF";
38
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
43
 
39
 
44
// video modes
40
// video modes
Line 45... Line -...
45
const char VM_PAL[] PROGMEM = "PAL ";
-
 
46
const char VM_NTSC[] PROGMEM = "NTSC";
-
 
47
 
-
 
48
// menu strings to progmem
-
 
49
const char menu_item0[] PROGMEM = "Video Mode";
-
 
50
const char menu_item1[] PROGMEM = "Full HUD";
-
 
51
const char menu_item2[] PROGMEM = "Art.Horizon in HUD";
-
 
52
const char menu_item3[] PROGMEM = "Big Vario bar";
-
 
53
const char menu_item4[] PROGMEM = "Statistics";
-
 
54
//const char menu_item5[] PROGMEM = "Warnings"; // TODO: do it!
-
 
55
const char menu_item5[] PROGMEM = "Current by FC";
-
 
56
const char menu_item6[] PROGMEM = "Voltage by C-Strom";
-
 
57
const char menu_item7[] PROGMEM = "Reset uptime";
-
 
58
const char menu_item8[] PROGMEM = "Display Mode";
-
 
59
const char menu_item9[] PROGMEM = "Height by";
-
 
60
const char menu_item10[] PROGMEM = "Save config";
-
 
Line 61... Line 41...
61
const char menu_item11[] PROGMEM = "EXIT";
41
const char VM_PAL[] PROGMEM = "PAL ";
Line 62... Line 42...
62
const char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4,
42
const char VM_NTSC[] PROGMEM = "NTSC";
Line 190... Line 170...
190
/* ##########################################################################
170
/* ##########################################################################
191
 * A simple config menu for the flags
171
 * A simple config menu for the flags
192
 * ##########################################################################*/
172
 * ##########################################################################*/
Line 193... Line 173...
193
 
173
 
-
 
174
/**
-
 
175
 * helper function for flag display
-
 
176
 */
-
 
177
void onoff(uint8_t line, uint8_t onoff) {      
-
 
178
        if (onoff) {             
-
 
179
                write_ascii_string_pgm(23, line, PSTR("ON "));
-
 
180
        } else {
-
 
181
                write_ascii_string_pgm(23, line, PSTR("OFF"));
-
 
182
        }
-
 
183
}
-
 
184
 
194
/**
185
/**
195
 * helper function for menu updating
186
 * helper function for menu updating
196
 */
187
 */
-
 
188
void config_menu_drawings(uint8_t chosen) {
-
 
189
        uint8_t line = 2;
197
void config_menu_drawings(uint8_t chosen) {
190
 
198
    // clear prevoius _cursor_
191
    // clear prevoius _cursor_
-
 
192
    //write_char_xy(3, line + ((chosen + 11) % 12), 0x00);
-
 
193
        for (uint8_t x = 2; x < 28; x++) {             
-
 
194
                write_char_att_xy(x, line + ((chosen + 11) % 12), 0);
-
 
195
                write_char_att_xy(x, line + chosen, BLACKBG);
199
    write_ascii_string(3, (chosen + 2) % 10, " ");
196
        };
200
    // draw current _cursor_
197
        // draw current _cursor_        
-
 
198
        //write_char_xy(3, line + chosen, 0xD9);
Line -... Line 199...
-
 
199
                       
201
    write_ascii_string(3, chosen + 2, ">");
200
 
202
 
201
        write_ascii_string_pgm(4, line, PSTR("Video Mode"));
203
        if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) {
202
        if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) {
204
                write_ascii_string_pgm(23, 2, VM_NTSC);
203
                write_ascii_string_pgm(23, line, VM_NTSC);
205
        } else {
204
        } else {
206
                write_ascii_string_pgm(23, 2, VM_PAL);
-
 
207
        }
-
 
208
         
-
 
209
    if (COSD_FLAGS_MODES & COSD_FLAG_HUD) {
-
 
210
        write_ascii_string_pgm(23, 3, ON);
-
 
211
    } else {
-
 
212
        write_ascii_string_pgm(23, 3, OFF);
-
 
213
    }
-
 
214
    if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) {
-
 
215
        write_ascii_string_pgm(23, 4, ON);
-
 
216
    } else {
-
 
217
        write_ascii_string_pgm(23, 4, OFF);
-
 
218
    }
-
 
219
    if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) {
-
 
220
        write_ascii_string_pgm(23, 5, ON);
-
 
221
    } else {
-
 
222
        write_ascii_string_pgm(23, 5, OFF);
-
 
223
    }
-
 
224
    if (COSD_FLAGS_MODES & COSD_FLAG_STATS) {
-
 
225
        write_ascii_string_pgm(23, 6, ON);
-
 
226
    } else {
-
 
227
        write_ascii_string_pgm(23, 6, OFF);
-
 
228
    }
-
 
229
    /*if (COSD_FLAGS_MODES & COSD_FLAG_WARNINGS) {
-
 
230
        write_ascii_string_pgm(23, 7, ON);
-
 
231
    } else {
-
 
232
        write_ascii_string_pgm(23, 7, OFF);
-
 
233
    }*/
-
 
234
        if (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT) {
-
 
235
        write_ascii_string_pgm(23, 7, ON);
-
 
236
    } else {
-
 
237
        write_ascii_string_pgm(23, 7, OFF);
-
 
238
    }
-
 
239
    if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) {
-
 
240
        write_ascii_string_pgm(23, 8, ON);
-
 
241
    } else {
-
 
242
        write_ascii_string_pgm(23, 8, OFF);
-
 
243
    }
-
 
Line -... Line 205...
-
 
205
                write_ascii_string_pgm(23, line, VM_PAL);
-
 
206
        }
-
 
207
       
-
 
208
        write_ascii_string_pgm(4, ++line, PSTR("Full HUD"));
-
 
209
        onoff(line, COSD_FLAGS_MODES & COSD_FLAG_HUD);
-
 
210
   
-
 
211
        write_ascii_string_pgm(4, ++line, PSTR("Art Horizon in HUD"));
-
 
212
        onoff(line, COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON);
-
 
213
   
-
 
214
        write_ascii_string_pgm(4, ++line, PSTR("Big Vario bar"));
-
 
215
        onoff(line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO);
-
 
216
 
-
 
217
        write_ascii_string_pgm(4, ++line, PSTR("Statistics"));
-
 
218
    onoff(line, COSD_FLAGS_MODES & COSD_FLAG_STATS);
-
 
219
 
-
 
220
        write_ascii_string_pgm(4, ++line, PSTR("Current by FC"));
-
 
221
        onoff(line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT);
-
 
222
 
-
 
223
        write_ascii_string_pgm(4, ++line, PSTR("Voltage by C-Strom"));
-
 
224
        onoff(line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT);
-
 
225
 
-
 
226
        write_ascii_string_pgm(4, ++line, PSTR("Reset uptime"));
-
 
227
   
-
 
228
        write_ascii_string_pgm(4, ++line, PSTR("Display Mode"));    
244
        //write_ndigit_number_u(23, 10, COSD_DISPLAYMODE, 2, 0);
229
        write_ascii_string_pgm(18, line, (const char *) (pgm_read_word(&(mode->desc))));
245
        write_ascii_string_pgm(18, 10, (const char *) (pgm_read_word(&(mode->desc))));
230
       
246
       
231
        write_ascii_string_pgm(4, ++line, PSTR("Height by"));
247
        if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) {
232
        if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) {
248
                write_ascii_string_pgm(20, 11, PSTR(" GPS"));
233
                write_ascii_string_pgm(20, line, PSTR(" GPS"));
-
 
234
        } else {
-
 
235
                write_ascii_string_pgm(20, line, PSTR("BARO"));
-
 
236
        }
249
        } else {
237
 
Line 250... Line 238...
250
                write_ascii_string_pgm(20, 11, PSTR("BARO"));
238
        write_ascii_string_pgm(4, ++line, PSTR("Save config"));
251
        }
239
        write_ascii_string_pgm(4, ++line, PSTR("EXIT"));
252
}
240
}
253
 
241
 
254
/**
242
/**
255
 * some sort of clicking response in the menu
243
 * some sort of clicking response in the menu
256
 */
244
 */
257
void config_menu_doclick(uint8_t chosen, const char* menu[]) {
245
void config_menu_doclick(uint8_t chosen) {
Line 258... Line 246...
258
    write_ascii_string_pgm(4, chosen + 2, PSTR("DONE              "));
246
    write_ascii_string_pgm(4, chosen + 2, PSTR("DONE              "));
259
    _delay_ms(500);
247
    _delay_ms(500);
260
    write_ascii_string_pgm(4, chosen + 2, menu[chosen]);
248
    config_menu_drawings(chosen);
Line 268... Line 256...
268
    cli();
256
    cli();
Line 269... Line 257...
269
 
257
 
270
    // clear screen
258
    // clear screen
Line 271... Line -...
271
    clear();
-
 
272
 
259
    clear();
-
 
260
 
273
    uint8_t inmenu = 1;
261
    uint8_t chosen = 0;
Line 274... Line 262...
274
    uint8_t chosen = 0;
262
        uint8_t inmenu = 1;
275
    write_ascii_string_pgm(6, 1, PSTR("C-OSD Config Menu"));
263
    write_ascii_string_pgm(6, 1, PSTR("C-OSD Config Menu"));
Line 276... Line -...
276
 
-
 
277
    // wait a bit before doing stuff so user has chance to release button
-
 
278
    _delay_ms(250);
-
 
279
 
-
 
280
        write_ascii_string_pgm(4, 2, menu[0]);
-
 
281
    write_ascii_string_pgm(4, 3, menu[1]);
-
 
282
    write_ascii_string_pgm(4, 4, menu[2]);
-
 
283
    write_ascii_string_pgm(4, 5, menu[3]);
-
 
284
    write_ascii_string_pgm(4, 6, menu[4]);
-
 
285
    write_ascii_string_pgm(4, 7, menu[5]);
-
 
286
    write_ascii_string_pgm(4, 8, menu[6]);
-
 
287
    write_ascii_string_pgm(4, 9, menu[7]);
-
 
288
    write_ascii_string_pgm(4, 10, menu[8]);
-
 
289
    write_ascii_string_pgm(4, 11, menu[9]);
264
 
Line 290... Line 265...
290
        write_ascii_string_pgm(4, 12, menu[10]);
265
    // wait a bit before doing stuff so user has chance to release button
291
        write_ascii_string_pgm(4, 13, menu[11]);
266
    _delay_ms(250);
292
 
-
 
293
    config_menu_drawings(chosen);
267
 
294
 
268
    config_menu_drawings(chosen);
295
    while (inmenu) {
269
 
296
        if (s2_pressed()) {
270
    while (inmenu) {
297
            write_ascii_string(3, chosen + 2, " ");
271
        if (s2_pressed()) {
298
            chosen = (chosen + 1) % 12;
272
                        chosen = (chosen + 1) % 12;
299
            write_ascii_string(3, chosen + 2, ">");
273
                        config_menu_drawings(chosen);
300
            _delay_ms(500);
274
                        _delay_ms(500);
Line 344... Line 318...
344
                    COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT;
318
                    COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT;
345
                    config_menu_drawings(chosen);
319
                    config_menu_drawings(chosen);
346
                    break;
320
                    break;
347
                case 7: // reset uptime
321
                case 7: // reset uptime
348
                    uptime = 0;
322
                    uptime = 0;
349
                    config_menu_doclick(chosen, menu);
323
                    config_menu_doclick(chosen);
350
                    break;
324
                    break;
351
                case 8: // change mode
325
                case 8: // change mode
352
                                        #if FCONLY
326
                                        #if FCONLY
353
                                        COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(fcdisplaymodes) / sizeof(displaymode_t));
327
                                        COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(fcdisplaymodes) / sizeof(displaymode_t));
354
                                        mode = fcdisplaymodes;
328
                                        mode = fcdisplaymodes;
Line 366... Line 340...
366
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT;
340
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT;
367
                    config_menu_drawings(chosen);
341
                    config_menu_drawings(chosen);
368
                    break;
342
                    break;
369
                case 10: // save
343
                case 10: // save
370
                    save_eeprom();
344
                    save_eeprom();
371
                    config_menu_doclick(chosen, menu);
345
                    config_menu_doclick(chosen);
372
                    break;
346
                    break;
373
                case 11: // exit
347
                case 11: // exit
374
                    inmenu = 0;
348
                                        inmenu = 0;
375
                    break;
349
                    break;
376
            }
350
            }
377
            _delay_ms(250);
351
            _delay_ms(250);
378
        }
352
        }
379
    }
353
    }