Subversion Repositories Projects

Rev

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

Rev 758 Rev 761
Line 21... Line 21...
21
#include <avr/io.h>
21
#include <avr/io.h>
22
#include <avr/eeprom.h>
22
#include <avr/eeprom.h>
23
#include <avr/pgmspace.h>
23
#include <avr/pgmspace.h>
24
#include <avr/interrupt.h>
24
#include <avr/interrupt.h>
25
#include <util/delay.h>
25
#include <util/delay.h>
26
//#include <avr/delay.h>
-
 
27
#include "max7456_software_spi.h"
26
#include "max7456_software_spi.h"
28
#include "config.h"
27
#include "config.h"
29
#include "main.h"
28
#include "main.h"
30
#include "buttons.h"
29
#include "buttons.h"
31
#include "usart1.h"
30
#include "usart1.h"
Line 53... Line 52...
53
 
52
 
54
/**
53
/**
55
 * read data saved in eeprom, print out message if <verbose> is set
54
 * read data saved in eeprom, print out message if <verbose> is set
56
 */
55
 */
57
void get_eeprom(uint8_t verbose) {
56
void get_eeprom(uint8_t verbose) {
58
        if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
57
    if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
59
                #if !(ALLCHARSDEBUG|(WRITECHARS != -1))
58
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
60
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data
59
        if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data
61
                #endif
60
#endif
62
                COSD_FLAGS_MODES = eeprom_read_byte(&ee_COSD_FLAGS_MODES);
61
        COSD_FLAGS_MODES = eeprom_read_byte(&ee_COSD_FLAGS_MODES);
63
                COSD_FLAGS_CONFIG = eeprom_read_byte(&ee_COSD_FLAGS_CONFIG);
62
        COSD_FLAGS_CONFIG = eeprom_read_byte(&ee_COSD_FLAGS_CONFIG);
64
                COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE);
63
        COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE);
65
                //if (verbose) write_ndigit_number_u(23, 11, COSD_DISPLAYMODE, 2, 0);
64
        //if (verbose) write_ndigit_number_u(23, 11, COSD_DISPLAYMODE, 2, 0);
66
        } else {
65
    } else {
67
                #if !(ALLCHARSDEBUG|(WRITECHARS != -1))
66
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
68
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // Loading data
67
        if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // Loading data
69
                #endif
68
#endif
70
        }
69
    }
Line 71... Line 70...
71
}
70
}
Line 72... Line 71...
72
 
71
 
73
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
72
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
74
 
73
 
75
/**
74
/**
76
 * save data to eeprom
75
 * save data to eeprom
77
 */
76
 */
78
void save_eeprom() {
77
void save_eeprom() {
79
        eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
78
    eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
80
        eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
79
    eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
81
        eeprom_write_byte(&ee_COSD_FLAGS_MODES, COSD_FLAGS_MODES);
80
    eeprom_write_byte(&ee_COSD_FLAGS_MODES, COSD_FLAGS_MODES);
Line 82... Line -...
82
        eeprom_write_byte(&ee_COSD_FLAGS_CONFIG, COSD_FLAGS_CONFIG);
-
 
83
        eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE);
81
    eeprom_write_byte(&ee_COSD_FLAGS_CONFIG, COSD_FLAGS_CONFIG);
84
}
82
    eeprom_write_byte(&ee_COSD_DISPLAYMODE, COSD_DISPLAYMODE);
85
 
83
}
86
 
84
 
87
/**
85
/**
88
 * auto config some stuff on startup, currently only battery cells
86
 * auto config some stuff on startup, currently only battery cells
89
 */
87
 */
90
void init_cosd(uint8_t UBat) {
88
void init_cosd(uint8_t UBat) {
91
    clear();
89
    clear();
92
        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
93
#if FCONLY
91
#if FCONLY
94
        write_ascii_string_pgm(2, 2, PSTR("FC only Mode")); // FC only mode
92
    write_ascii_string_pgm(2, 2, PSTR("FC only Mode")); // FC only mode
95
#else
93
#else
96
        write_ascii_string_pgm(2, 2, PSTR("NaviCtrl Mode")); // NaviCtrl Mode
94
    write_ascii_string_pgm(2, 2, PSTR("NaviCtrl Mode")); // NaviCtrl Mode
97
#endif
95
#endif
98
    write_ascii_string_pgm(2, 3, PSTR(BUILDDATE));
96
    write_ascii_string_pgm(2, 3, PSTR(BUILDDATE));
99
    uint8_t cellnum = 0;
97
    uint8_t cellnum = 0;
100
    if (CELL_NUM == -1) {
98
    if (CELL_NUM == -1) {
101
                write_ascii_string_pgm(2, 4, PSTR("Guessing Number of Cells")); // Guessing Number of Cells
99
        write_ascii_string_pgm(2, 4, PSTR("Guessing Number of Cells")); // Guessing Number of Cells
102
        do {
100
        do {
103
            cellnum++;
101
            cellnum++;
104
        } while (UBat > ((cellnum * CELL_VOLT_MAX) + 23));
102
        } while (UBat > ((cellnum * CELL_VOLT_MAX) + 23));
105
    } else {
103
    } else {
106
        cellnum = CELL_NUM;
104
        cellnum = CELL_NUM;
107
    }
105
    }
108
    min_voltage = cellnum * CELL_VOLT_MIN;
106
    min_voltage = cellnum * CELL_VOLT_MIN;
109
    max_voltage = cellnum * CELL_VOLT_MAX;
107
    max_voltage = cellnum * CELL_VOLT_MAX;
110
        write_ascii_string_pgm(2, 5, PSTR("Number of Cells:")); // Number of Cells
108
    write_ascii_string_pgm(2, 5, PSTR("Number of Cells:")); // Number of Cells
111
    write_ndigit_number_u(21, 5, cellnum, 1, 0);
109
    write_ndigit_number_u(21, 5, cellnum, 1, 0);
Line 112... Line 110...
112
        write_ascii_string_pgm(2, 6, PSTR("Warn Voltage   :")); // Warn Voltage
110
    write_ascii_string_pgm(2, 6, PSTR("Warn Voltage   :")); // Warn Voltage
Line 113... Line 111...
113
    write_ndigit_number_s_10th(20, 6, min_voltage, 3, 0);
111
    write_ndigit_number_s_10th(20, 6, min_voltage, 3, 0);
114
        write_ascii_string_pgm(2, 7, PSTR("Max Voltage    :")); // Max Voltage
112
    write_ascii_string_pgm(2, 7, PSTR("Max Voltage    :")); // Max Voltage
115
    write_ndigit_number_s_10th(20, 7, max_voltage, 3, 0);
113
    write_ndigit_number_s_10th(20, 7, max_voltage, 3, 0);
116
 
114
 
117
        get_eeprom(1);
115
    get_eeprom(1);
118
 
116
 
119
    //write_ascii_string_pgm(23, 2, vm[COSD_FLAGS & COSD_FLAG_NTSC]);
117
    //write_ascii_string_pgm(23, 2, vm[COSD_FLAGS & COSD_FLAG_NTSC]);
120
        if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) {
118
    if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) {
121
                write_ascii_string_pgm(23, 2, VM_NTSC);
119
        write_ascii_string_pgm(23, 2, VM_NTSC);
122
        } else {
120
    } else {
123
                write_ascii_string_pgm(23, 2, VM_PAL);
121
        write_ascii_string_pgm(23, 2, VM_PAL);
124
        }
122
    }
125
 
123
 
126
        // request version from board
124
    // request version from board
127
        rxd_buffer_locked = 0;
125
    rxd_buffer_locked = 0;
128
        usart1_EnableTXD();
126
    usart1_EnableTXD();
129
        #if FCONLY
127
#if FCONLY
130
                //usart1_request_mk_data(0, 'v', 0);
128
    //usart1_request_mk_data(0, 'v', 0);
131
                write_ascii_string_pgm(2, 11, PSTR("FC VERSION: ........"));
129
    write_ascii_string_pgm(2, 11, PSTR("FC VERSION: ........"));
132
                usart1_puts_pgm(PSTR(REQUEST_FC_VERSION));
130
    usart1_puts_pgm(PSTR(REQUEST_FC_VERSION));
133
        #else
131
#else
134
                //usart1_request_mk_data(1, 'v', 0);    
132
    //usart1_request_mk_data(1, 'v', 0);
135
                usart1_puts_pgm(PSTR(REQUEST_NC_VERSION));
133
    usart1_puts_pgm(PSTR(REQUEST_NC_VERSION));
136
                write_ascii_string_pgm(2, 11, PSTR("NC VERSION: ........"));
134
    write_ascii_string_pgm(2, 11, PSTR("NC VERSION: ........"));
137
        #endif
135
#endif
138
        usart1_DisableTXD();
136
    usart1_DisableTXD();
139
        // wait for response
137
    // wait for response
140
        while (rxd_buffer_locked == 0) {
138
    while (rxd_buffer_locked == 0) {
141
                asm("nop");
139
        asm("nop");
142
        }
140
    }
143
        Decode64();
141
    Decode64();
144
        str_VersionInfo VersionInfo;
142
    str_VersionInfo VersionInfo;
145
        VersionInfo = *((str_VersionInfo*) pRxData);
-
 
146
       
-
 
147
        write_ndigit_number_u(14, 11, VersionInfo.SWMajor, 3, 1);
-
 
148
        write_ndigit_number_u(18, 11, VersionInfo.SWMinor, 3, 1);
-
 
149
        write_ascii_char(22 + 11*30, 'a' + VersionInfo.SWPatch);
-
 
150
        // end version request
-
 
151
 
-
 
152
 
-
 
153
        #if FCONLY
-
 
154
        COSD_DISPLAYMODE %= (sizeof(fcdisplaymodes) / sizeof(displaymode_t));
-
 
155
        mode = fcdisplaymodes;
-
 
156
        mode += COSD_DISPLAYMODE;
-
 
157
        osd_fcmode = (int(*)(void)) pgm_read_word(&mode->dfun);
-
 
158
        // re-request data ever 100ms from FC;
-
 
159
        //usart1_request_mk_data(0, 'd', 100);
-
 
160
        #else
-
 
161
        COSD_DISPLAYMODE %= (sizeof(ncdisplaymodes) / sizeof(displaymode_t));
-
 
Line -... Line 143...
-
 
143
    VersionInfo = *((str_VersionInfo*)pRxData);
-
 
144
 
-
 
145
    write_ndigit_number_u(14, 11, VersionInfo.SWMajor, 3, 1);
-
 
146
    write_ndigit_number_u(18, 11, VersionInfo.SWMinor, 3, 1);
-
 
147
    write_ascii_char(22 + 11 * 30, 'a' + VersionInfo.SWPatch);
-
 
148
    // end version request
-
 
149
 
-
 
150
 
-
 
151
#if FCONLY
-
 
152
    COSD_DISPLAYMODE %= (sizeof (fcdisplaymodes) / sizeof (displaymode_t));
-
 
153
    mode = fcdisplaymodes;
-
 
154
    mode += COSD_DISPLAYMODE;
-
 
155
    osd_fcmode = (int(*)(void)) pgm_read_word(&mode->dfun);
-
 
156
    // re-request data ever 100ms from FC;
-
 
157
    //usart1_request_mk_data(0, 'd', 100);
-
 
158
#else
-
 
159
    COSD_DISPLAYMODE %= (sizeof (ncdisplaymodes) / sizeof (displaymode_t));
162
        mode = ncdisplaymodes;
160
    mode = ncdisplaymodes;
163
        mode += COSD_DISPLAYMODE;
161
    mode += COSD_DISPLAYMODE;
164
        osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun);
162
    osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun);
165
        // re-request OSD Data from NC every 100ms
163
    // re-request OSD Data from NC every 100ms
166
        //usart1_request_mk_data(1, 'o', 100);
164
    //usart1_request_mk_data(1, 'o', 100);
Line 177... Line 175...
177
 * ##########################################################################*/
175
 * ##########################################################################*/
Line 178... Line 176...
178
 
176
 
179
/**
177
/**
180
 * helper function for flag display
178
 * helper function for flag display
181
 */
179
 */
182
void onoff(uint8_t col, uint8_t line, uint8_t onoff) { 
180
void onoff(uint8_t col, uint8_t line, uint8_t onoff) {
183
        if (onoff) {             
181
    if (onoff) {
184
                write_ascii_string_pgm(col, line, PSTR("ON "));
182
        write_ascii_string_pgm(col, line, PSTR("ON "));
185
        } else {
183
    } else {
186
                write_ascii_string_pgm(col, line, PSTR("OFF"));
184
        write_ascii_string_pgm(col, line, PSTR("OFF"));
187
        }
185
    }
Line 188... Line -...
188
}
-
 
189
 
186
}
190
 
187
 
191
/**
188
/**
192
 * helper function for menu updating
189
 * helper function for menu updating
193
 */
190
 */
194
void config_menu_drawings(uint8_t chosen) {
191
void config_menu_drawings(uint8_t chosen) {
Line 195... Line 192...
195
        static uint8_t old_y = 0;
192
    static uint8_t old_y = 0;
196
        uint8_t x = MENU_LEFT, y = MENU_TOP, line = MENU_TOP;
193
    uint8_t x = MENU_LEFT, y = MENU_TOP, line = MENU_TOP;
197
 
194
 
198
        if (chosen > 5 && chosen < 12) {        // right
195
    if (chosen > 5 && chosen < 12) { // right
199
                x = MENU_MIDDLE;
196
        x = MENU_MIDDLE;
200
                y = chosen - 6 + MENU_TOP;
197
        y = chosen - 6 + MENU_TOP;
201
        } else if (chosen < 7) {
198
    } else if (chosen < 7) {
202
                y = chosen + MENU_TOP;
199
        y = chosen + MENU_TOP;
Line 203... Line 200...
203
        } else {
200
    } else {
204
                y = chosen - 6 + MENU_TOP;
201
        y = chosen - 6 + MENU_TOP;
205
        }
202
    }
206
 
203
 
207
    // clear prevoius _cursor_ and draw current
204
    // clear prevoius _cursor_ and draw current
208
        for (uint8_t myx = MENU_LEFT; myx < 29; myx++) {
205
    for (uint8_t myx = MENU_LEFT; myx < 29; myx++) {
209
                write_char_att_xy(myx, old_y, 0);
206
        write_char_att_xy(myx, old_y, 0);
210
                if (myx > x - 1 && myx < x + 14) {
207
        if (myx > x - 1 && myx < x + 14) {
211
                        write_char_att_xy(myx, y, BLACKBG | INVERT);
208
            write_char_att_xy(myx, y, BLACKBG | INVERT);
212
                }
209
        }
213
        };
210
    };
214
 
211
 
215
        write_ascii_string_pgm(MENU_LEFT, line, PSTR("Video"));
212
    write_ascii_string_pgm(MENU_LEFT, line, PSTR("Video"));
216
        if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) {
213
    if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) {
217
                write_ascii_string_pgm(MENU_LEFT + 10, line, VM_NTSC);
214
        write_ascii_string_pgm(MENU_LEFT + 10, line, VM_NTSC);
218
        } else {
215
    } else {
219
                write_ascii_string_pgm(MENU_LEFT + 10, line, VM_PAL);
216
        write_ascii_string_pgm(MENU_LEFT + 10, line, VM_PAL);
220
        }
217
    }
221
       
218
 
222
        write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Full HUD"));
219
    write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Full HUD"));
223
        onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_HUD);
220
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_HUD);
224
   
221
 
225
        write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Horizon"));
222
    write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Horizon"));
226
        onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON);
223
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON);
227
 
224
 
228
        write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Aggr.Hor."));
225
    write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Aggr.Hor."));
Line 229... Line 226...
229
        onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_AGGRHORIZON);
226
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_AGGRHORIZON);
230
   
227
 
-
 
228
    write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Stats"));
-
 
229
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STATS);
-
 
230
 
Line 231... Line 231...
231
        write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("Stats"));
231
    write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("A by FC"));
232
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STATS);
232
    onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT);
Line 233... Line -...
233
 
-
 
234
        write_ascii_string_pgm(MENU_LEFT, ++line, PSTR("A by FC"));
-
 
235
        onoff(MENU_LEFT + 10, line, COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT);
-
 
236
 
233
 
237
        // 2nd col
234
    // 2nd col
238
        line = 2;
235
    line = 2;
239
 
236
 
240
        write_ascii_string_pgm(MENU_MIDDLE, line, PSTR("V C-Strom"));
237
    write_ascii_string_pgm(MENU_MIDDLE, line, PSTR("V C-Strom"));
241
        onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT);
238
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT);
242
   
239
 
243
        write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Height by"));
240
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Height by"));
244
        if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) {
241
    if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) {
245
                write_ascii_string_pgm(MENU_MIDDLE + 10, line, PSTR(" GPS"));
242
        write_ascii_string_pgm(MENU_MIDDLE + 10, line, PSTR(" GPS"));
246
        } else {
243
    } else {
247
                write_ascii_string_pgm(MENU_MIDDLE + 10, line, PSTR("BARO"));
244
        write_ascii_string_pgm(MENU_MIDDLE + 10, line, PSTR("BARO"));
248
        }
245
    }
249
 
246
 
250
        write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Feet/mph"));
247
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Feet/mph"));
251
        onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_FEET);
248
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_FEET);
252
 
-
 
253
        write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Big Vario"));
-
 
254
        onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO);
-
 
255
 
-
 
256
 
-
 
257
        // bottom
-
 
Line -... Line 249...
-
 
249
 
-
 
250
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Big Vario"));
-
 
251
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO);
-
 
252
 
-
 
253
 
-
 
254
    // bottom
258
        write_ascii_string_pgm(MENU_LEFT, 9, PSTR("Reset uptime"));
255
    write_ascii_string_pgm(MENU_LEFT, 9, PSTR("Reset uptime"));
259
 
256
 
Line 260... Line 257...
260
        write_ascii_string_pgm(MENU_LEFT, 10, PSTR("Display Mode"));    
257
    write_ascii_string_pgm(MENU_LEFT, 10, PSTR("Display Mode"));
261
        write_ascii_string_pgm(18, 10, (const char *) (pgm_read_word(&(mode->desc))));
258
    write_ascii_string_pgm(18, 10, (const char *)(pgm_read_word(&(mode->desc))));
262
       
259
 
Line 284... Line 281...
284
 
281
 
285
    // clear screen
282
    // clear screen
Line 286... Line 283...
286
    clear();
283
    clear();
287
 
284
 
288
    uint8_t chosen = 0;
285
    uint8_t chosen = 0;
Line 289... Line 286...
289
        uint8_t inmenu = 1;
286
    uint8_t inmenu = 1;
290
    write_ascii_string_pgm(6, 1, PSTR("C-OSD Config Menu"));
287
    write_ascii_string_pgm(6, 1, PSTR("C-OSD Config Menu"));
Line 291... Line 288...
291
 
288
 
Line 292... Line 289...
292
    // wait a bit before doing stuff so user has chance to release button
289
    // wait a bit before doing stuff so user has chance to release button
293
    _delay_ms(250);
290
    _delay_ms(250);
294
 
291
 
295
    config_menu_drawings(chosen);
292
    config_menu_drawings(chosen);
296
 
293
 
297
    while (inmenu) {
294
    while (inmenu) {
298
        if (s2_pressed()) {
295
        if (s2_pressed()) {
299
                        chosen = (chosen + 1) % 17;
296
            chosen = (chosen + 1) % 17;
300
                        if (chosen == 10) chosen = 13; // SKIP unused menu space for now
297
            if (chosen == 10) chosen = 13; // SKIP unused menu space for now
301
                        config_menu_drawings(chosen);
298
            config_menu_drawings(chosen);
302
                        _delay_ms(500);
299
            _delay_ms(500);
303
        } else if (s1_pressed()) {
300
        } else if (s1_pressed()) {
304
            switch (chosen) {
301
            switch (chosen) {
305
                case 0: // NTSC or PAL
302
                case 0: // NTSC or PAL
306
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_NTSC;
303
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_NTSC;
307
                                        // Setup Video Mode
304
                    // Setup Video Mode
308
                                        if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) {
305
                    if (COSD_FLAGS_CONFIG & COSD_FLAG_NTSC) {
309
                                            // NTSC + enable display immediately (VM0)
306
                        // NTSC + enable display immediately (VM0)
310
                                            spi_send_byte(0x00, 0b00001000);
307
                        spi_send_byte(0x00, 0b00001000);
Line 311... Line 308...
311
 
308
 
312
                                                bottom_line = 12;
309
                        bottom_line = 12;
313
                                        } else {
310
                    } else {
314
                                            // PAL + enable display immediately (VM0)
311
                        // PAL + enable display immediately (VM0)
315
                                            spi_send_byte(0x00, 0b01001000);
312
                        spi_send_byte(0x00, 0b01001000);
316
 
313
 
317
                                                bottom_line = 14;
314
                        bottom_line = 14;
Line 330... Line 327...
330
                    COSD_FLAGS_MODES ^= COSD_FLAG_STATS;
327
                    COSD_FLAGS_MODES ^= COSD_FLAG_STATS;
331
                    break;
328
                    break;
332
                case 5: // current by fc
329
                case 5: // current by fc
333
                    COSD_FLAGS_MODES ^= COSD_FLAG_FCCURRENT;
330
                    COSD_FLAGS_MODES ^= COSD_FLAG_FCCURRENT;
334
                    break;
331
                    break;
335
                                case 6: // 2nd voltage by c-strom
332
                case 6: // 2nd voltage by c-strom
336
                    COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT;
333
                    COSD_FLAGS_MODES ^= COSD_FLAG_STROMVOLT;
337
                    break;
334
                    break;
338
                case 7: // GPS or BARO height
335
                case 7: // GPS or BARO height
339
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT;
336
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_GPSHEIGHT;
340
                    break;
337
                    break;
341
                case 8: // Feet and mph?
338
                case 8: // Feet and mph?
342
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_FEET;
339
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_FEET;
343
                    break;
340
                    break;
344
                                case 9: // big vario
341
                case 9: // big vario
345
                    COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO;
342
                    COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO;
346
                    break;
343
                    break;
347
                case 13: // reset uptime
344
                case 13: // reset uptime
348
                    uptime = 0;
345
                    uptime = 0;
349
                                        config_menu_doclick(chosen);
346
                    config_menu_doclick(chosen);
350
                    break;
347
                    break;
351
                case 14: // change mode
348
                case 14: // change mode
352
                                        #if FCONLY
349
#if FCONLY
353
                                        COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(fcdisplaymodes) / sizeof(displaymode_t));
350
                    COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof (fcdisplaymodes) / sizeof (displaymode_t));
354
                                        mode = fcdisplaymodes;
351
                    mode = fcdisplaymodes;
355
                                        mode += COSD_DISPLAYMODE;
352
                    mode += COSD_DISPLAYMODE;
356
                                        osd_fcmode = (int(*)(void)) pgm_read_word(&mode->dfun);
353
                    osd_fcmode = (int(*)(void)) pgm_read_word(&mode->dfun);
357
                                        #else
354
#else
358
                                        COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof(ncdisplaymodes) / sizeof(displaymode_t));
355
                    COSD_DISPLAYMODE = (COSD_DISPLAYMODE + 1) % (sizeof (ncdisplaymodes) / sizeof (displaymode_t));
359
                                        mode = ncdisplaymodes;
356
                    mode = ncdisplaymodes;
360
                                        mode += COSD_DISPLAYMODE;
357
                    mode += COSD_DISPLAYMODE;
361
                                        osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun);
358
                    osd_ncmode = (int(*)(void)) pgm_read_word(&mode->dfun);
362
                                        #endif
359
#endif
363
                    break;
360
                    break;
364
                case 15: // save
361
                case 15: // save
365
                    save_eeprom();
362
                    save_eeprom();
366
                                        config_menu_doclick(chosen);
363
                    config_menu_doclick(chosen);
367
                    break;
364
                    break;
368
                case 16: // exit
365
                case 16: // exit
369
                                        inmenu = 0;
366
                    inmenu = 0;
370
                                        config_menu_doclick(chosen);
367
                    config_menu_doclick(chosen);
371
                    break;
368
                    break;
372
            }
369
            }
373
                        config_menu_drawings(chosen);
370
            config_menu_drawings(chosen);
374
            _delay_ms(250);
371
            _delay_ms(250);
375
        }
372
        }
376
    }
373
    }
Line 377... Line 374...
377
 
374