Subversion Repositories Projects

Rev

Rev 474 | Rev 497 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 474 Rev 489
1
/****************************************************************************
1
/****************************************************************************
2
 *   Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje                    *
2
 *   Copyright (C) 2009 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   *
8
 *   the Free Software Foundation; either version 2 of the License.         *
8
 *   the Free Software Foundation; either version 2 of the License.         *
9
 *                                                                          *
9
 *                                                                          *
10
 *   This program is distributed in the hope that it will be useful,        *
10
 *   This program is distributed in the hope that it will be useful,        *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13
 *   GNU General Public License for more details.                           *
13
 *   GNU General Public License for more details.                           *
14
 *                                                                          *
14
 *                                                                          *
15
 *   You should have received a copy of the GNU General Public License      *
15
 *   You should have received a copy of the GNU General Public License      *
16
 *   along with this program; if not, write to the                          *
16
 *   along with this program; if not, write to the                          *
17
 *   Free Software Foundation, Inc.,                                        *
17
 *   Free Software Foundation, Inc.,                                        *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
19
 ****************************************************************************/
19
 ****************************************************************************/
20
 
20
 
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 "max7456_software_spi.h"
26
#include "max7456_software_spi.h"
27
#include "config.h"
27
#include "config.h"
28
#include "main.h"
28
#include "main.h"
29
#include "buttons.h"
29
#include "buttons.h"
30
#include "usart1.h"
30
#include "usart1.h"
31
 
31
 
32
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
32
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
33
 
33
 
34
// store more fixed strings in progmen
34
// store more fixed strings in progmen
35
char ON[] PROGMEM = "ON ";
35
char ON[] PROGMEM = "ON ";
36
char OFF[] PROGMEM = "OFF";
36
char OFF[] PROGMEM = "OFF";
37
 
37
 
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
 
43
 
44
// store init strings in progmem
44
// store init strings in progmem
45
char init_0[] PROGMEM = "C-OSD Initialisation";
45
const char init_0[] PROGMEM = "C-OSD Initialisation";
46
char init_1[] PROGMEM = "FC only Mode";
46
const char init_1[] PROGMEM = "FC only Mode";
47
char init_2[] PROGMEM = "NaviCtrl Mode";
47
const char init_2[] PROGMEM = "NaviCtrl Mode";
48
char init_3[] PROGMEM = "Guessing Number of Cells";
48
const char init_3[] PROGMEM = "Guessing Number of Cells";
49
char init_4[] PROGMEM = "Number of Cells:";
49
const char init_4[] PROGMEM = "Number of Cells:";
50
char init_5[] PROGMEM = "Warn Voltage   :";
50
const char init_5[] PROGMEM = "Warn Voltage   :";
51
char init_6[] PROGMEM = "Max Voltage    :";
51
const char init_6[] PROGMEM = "Max Voltage    :";
52
char* init_point[] PROGMEM = {init_0, init_1, init_2, init_3, init_4, init_5, init_6};
52
const char* init_point[] PROGMEM = {init_0, init_1, init_2, init_3, init_4, init_5, init_6};
53
 
53
 
54
char ee_message0[] PROGMEM = "Loading Data from EEPROM";
54
const char ee_message0[] PROGMEM = "Loading Data from EEPROM";
55
char ee_message1[] PROGMEM = "No saved Data in EEPROM";
55
const char ee_message1[] PROGMEM = "No saved Data in EEPROM";
56
char* ee_msg[] PROGMEM = {ee_message0, ee_message1};
56
const char* ee_msg[] PROGMEM = {ee_message0, ee_message1};
57
 
57
 
58
// video modes
58
// video modes
59
char VM_PAL[] PROGMEM = "PAL ";
59
const char VM_PAL[] PROGMEM = "PAL ";
60
char VM_NTSC[] PROGMEM = "NTSC";
60
const char VM_NTSC[] PROGMEM = "NTSC";
61
 
61
 
62
// menu strings to progmem
62
// menu strings to progmem
63
char menu_item0[] PROGMEM = "Video Mode";
63
const char menu_item0[] PROGMEM = "Video Mode";
64
char menu_item1[] PROGMEM = "Full HUD";
64
const char menu_item1[] PROGMEM = "Full HUD";
65
char menu_item2[] PROGMEM = "Art.Horizon in HUD";
65
const char menu_item2[] PROGMEM = "Art.Horizon in HUD";
66
char menu_item3[] PROGMEM = "Big Vario bar";
66
const char menu_item3[] PROGMEM = "Big Vario bar";
67
char menu_item4[] PROGMEM = "Statistics";
67
const char menu_item4[] PROGMEM = "Statistics";
68
char menu_item5[] PROGMEM = "Warnings"; // TODO: do it!
68
const char menu_item5[] PROGMEM = "Warnings"; // TODO: do it!
69
char menu_item6[] PROGMEM = "Reset uptime";
69
const char menu_item6[] PROGMEM = "Reset uptime";
70
char menu_item7[] PROGMEM = "Request OSD-data";
70
const char menu_item7[] PROGMEM = "Request OSD-data";
71
char menu_item8[] PROGMEM = "Disable Debug-data";
71
const char menu_item8[] PROGMEM = "Disable Debug-data";
72
char menu_item9[] PROGMEM = "Save config";
72
const char menu_item9[] PROGMEM = "Save config";
73
char menu_item10[] PROGMEM = "EXIT";
73
const char menu_item10[] PROGMEM = "EXIT";
74
char* menu[] = {menu_item0, menu_item1, menu_item2, menu_item3, menu_item4,
74
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};
75
        menu_item5, menu_item6, menu_item7, menu_item8, menu_item9, menu_item10};
76
 
76
 
77
/**
77
/**
78
 * read data saved in eeprom, print out message if <verbose> is set
78
 * read data saved in eeprom, print out message if <verbose> is set
79
 */
79
 */
80
void get_eeprom(uint8_t verbose) {
80
void get_eeprom(uint8_t verbose) {
81
        if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
81
        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
82
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[0]); // Loading data
83
                COSD_FLAGS = eeprom_read_byte(&ee_COSD_FLAGS);
83
                COSD_FLAGS = eeprom_read_byte(&ee_COSD_FLAGS);
84
        } else {
84
        } else {
85
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // No data found
85
                if (verbose) write_ascii_string_pgm(2, 9, ee_msg[1]); // No data found
86
        }
86
        }
87
}
87
}
88
 
88
 
89
/**
89
/**
90
 * save data to eeprom
90
 * save data to eeprom
91
 */
91
 */
92
void save_eeprom() {
92
void save_eeprom() {
93
        eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
93
        eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
94
        eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
94
        eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
95
        eeprom_write_byte(&ee_COSD_FLAGS, COSD_FLAGS);
95
        eeprom_write_byte(&ee_COSD_FLAGS, COSD_FLAGS);
96
}
96
}
97
 
97
 
98
/**
98
/**
99
 * auto config some stuff on startup, currently only battery cells
99
 * auto config some stuff on startup, currently only battery cells
100
 * TODO: this is testing stuff, strings should go progmem and so on...
100
 * TODO: this is testing stuff, strings should go progmem and so on...
101
 */
101
 */
102
void init_cosd(uint8_t UBat) {
102
void init_cosd(uint8_t UBat) {
103
    clear();
103
    clear();
104
        write_ascii_string_pgm(2, 1, init_point[0]); // C-OSD Initialisation
104
        write_ascii_string_pgm(2, 1, init_point[0]); // C-OSD Initialisation
105
    //write_ascii_string(2, 1, "C-OSD Initialisation");
105
    //write_ascii_string(2, 1, "C-OSD Initialisation");
106
#if FCONLY
106
#if FCONLY
107
        write_ascii_string_pgm(2, 2, init_point[1]); // FC only mode
107
        write_ascii_string_pgm(2, 2, init_point[1]); // FC only mode
108
    //write_ascii_string(2, 2, "FC only Mode");
108
    //write_ascii_string(2, 2, "FC only Mode");
109
#else
109
#else
110
        write_ascii_string_pgm(2, 2, init_point[2]); // NaviCtrl Mode
110
        write_ascii_string_pgm(2, 2, init_point[2]); // NaviCtrl Mode
111
    //write_ascii_string(2, 2, "NaviCtrl Mode");
111
    //write_ascii_string(2, 2, "NaviCtrl Mode");
112
#endif
112
#endif
113
    write_ascii_string(2, 3, BUILDDATE);
113
    write_ascii_string(2, 3, BUILDDATE);
114
    uint8_t cellnum = 0;
114
    uint8_t cellnum = 0;
115
    if (CELL_NUM == -1) {
115
    if (CELL_NUM == -1) {
116
                write_ascii_string_pgm(2, 4, init_point[3]); // Guessing Number of Cells
116
                write_ascii_string_pgm(2, 4, init_point[3]); // Guessing Number of Cells
117
        //write_ascii_string(2, 6, "Guessing Number of Cells");
117
        //write_ascii_string(2, 6, "Guessing Number of Cells");
118
        do {
118
        do {
119
            cellnum++;
119
            cellnum++;
120
        } while (UBat > ((cellnum * CELL_VOLT_MAX) + 23));
120
        } while (UBat > ((cellnum * CELL_VOLT_MAX) + 23));
121
    } else {
121
    } else {
122
        cellnum = CELL_NUM;
122
        cellnum = CELL_NUM;
123
    }
123
    }
124
    min_voltage = cellnum * CELL_VOLT_MIN;
124
    min_voltage = cellnum * CELL_VOLT_MIN;
125
    max_voltage = cellnum * CELL_VOLT_MAX;
125
    max_voltage = cellnum * CELL_VOLT_MAX;
126
        write_ascii_string_pgm(2, 5, init_point[4]); // Number of Cells
126
        write_ascii_string_pgm(2, 5, init_point[4]); // Number of Cells
127
    //write_ascii_string(2, 5, "Number of Cells:");
127
    //write_ascii_string(2, 5, "Number of Cells:");
128
    write_ndigit_number_u(21, 5, cellnum, 1, 0);
128
    write_ndigit_number_u(21, 5, cellnum, 1, 0);
129
        write_ascii_string_pgm(2, 6, init_point[5]); // Warn Voltage
129
        write_ascii_string_pgm(2, 6, init_point[5]); // Warn Voltage
130
    //write_ascii_string(2, 6, "Warn Voltage   :");
130
    //write_ascii_string(2, 6, "Warn Voltage   :");
131
    write_ndigit_number_s_10th(20, 6, min_voltage, 100, 0);
131
    write_ndigit_number_s_10th(20, 6, min_voltage, 100, 0);
132
        write_ascii_string_pgm(2, 7, init_point[6]); // Max Voltage
132
        write_ascii_string_pgm(2, 7, init_point[6]); // Max Voltage
133
    //write_ascii_string(2, 7, "Max Voltage    :");
133
    //write_ascii_string(2, 7, "Max Voltage    :");
134
    write_ndigit_number_s_10th(20, 7, max_voltage, 100, 0);
134
    write_ndigit_number_s_10th(20, 7, max_voltage, 100, 0);
135
 
135
 
136
        get_eeprom(1);
136
        get_eeprom(1);
137
 
137
 
138
    //write_ascii_string_pgm(23, 2, vm[COSD_FLAGS & COSD_FLAG_NTSC]);
138
    //write_ascii_string_pgm(23, 2, vm[COSD_FLAGS & COSD_FLAG_NTSC]);
139
        if (COSD_FLAGS & COSD_FLAG_NTSC) {
139
        if (COSD_FLAGS & COSD_FLAG_NTSC) {
140
                write_ascii_string_pgm(23, 2, VM_NTSC);
140
                write_ascii_string_pgm(23, 2, VM_NTSC);
141
        } else {
141
        } else {
142
                write_ascii_string_pgm(23, 2, VM_PAL);
142
                write_ascii_string_pgm(23, 2, VM_PAL);
143
        }
143
        }
144
 
144
 
145
    _delay_ms(200);
145
    _delay_ms(200);
146
    clear();
146
    clear();
147
    // update flags to paint display again because of clear
147
    // update flags to paint display again because of clear
148
    COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN;
148
    COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN;
149
}
149
}
150
 
150
 
151
/* ##########################################################################
151
/* ##########################################################################
152
 * A simple config menu for the flags
152
 * A simple config menu for the flags
153
 * ##########################################################################*/
153
 * ##########################################################################*/
154
 
154
 
155
/**
155
/**
156
 * helper function for menu updating
156
 * helper function for menu updating
157
 */
157
 */
158
void config_menu_drawings(uint8_t chosen) {
158
void config_menu_drawings(uint8_t chosen) {
159
    // clear prevoius _cursor_
159
    // clear prevoius _cursor_
160
    write_ascii_string(3, (chosen + 2) % 10, " ");
160
    write_ascii_string(3, (chosen + 2) % 10, " ");
161
    // draw current _cursor_
161
    // draw current _cursor_
162
    write_ascii_string(3, chosen + 2, ">");
162
    write_ascii_string(3, chosen + 2, ">");
163
 
163
 
164
        if (COSD_FLAGS & COSD_FLAG_NTSC) {
164
        if (COSD_FLAGS & COSD_FLAG_NTSC) {
165
                write_ascii_string_pgm(23, 2, VM_NTSC);
165
                write_ascii_string_pgm(23, 2, VM_NTSC);
166
        } else {
166
        } else {
167
                write_ascii_string_pgm(23, 2, VM_PAL);
167
                write_ascii_string_pgm(23, 2, VM_PAL);
168
        }
168
        }
169
         
169
         
170
    if (COSD_FLAGS & COSD_FLAG_HUD) {
170
    if (COSD_FLAGS & COSD_FLAG_HUD) {
171
        write_ascii_string_pgm(23, 3, ON);
171
        write_ascii_string_pgm(23, 3, ON);
172
    } else {
172
    } else {
173
        write_ascii_string_pgm(23, 3, OFF);
173
        write_ascii_string_pgm(23, 3, OFF);
174
    }
174
    }
175
    if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) {
175
    if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) {
176
        write_ascii_string_pgm(23, 4, ON);
176
        write_ascii_string_pgm(23, 4, ON);
177
    } else {
177
    } else {
178
        write_ascii_string_pgm(23, 4, OFF);
178
        write_ascii_string_pgm(23, 4, OFF);
179
    }
179
    }
180
    if (COSD_FLAGS & COSD_FLAG_BIGVARIO) {
180
    if (COSD_FLAGS & COSD_FLAG_BIGVARIO) {
181
        write_ascii_string_pgm(23, 5, ON);
181
        write_ascii_string_pgm(23, 5, ON);
182
    } else {
182
    } else {
183
        write_ascii_string_pgm(23, 5, OFF);
183
        write_ascii_string_pgm(23, 5, OFF);
184
    }
184
    }
185
    if (COSD_FLAGS & COSD_FLAG_STATS) {
185
    if (COSD_FLAGS & COSD_FLAG_STATS) {
186
        write_ascii_string_pgm(23, 6, ON);
186
        write_ascii_string_pgm(23, 6, ON);
187
    } else {
187
    } else {
188
        write_ascii_string_pgm(23, 6, OFF);
188
        write_ascii_string_pgm(23, 6, OFF);
189
    }
189
    }
190
    if (COSD_FLAGS & COSD_FLAG_WARNINGS) {
190
    if (COSD_FLAGS & COSD_FLAG_WARNINGS) {
191
        write_ascii_string_pgm(23, 7, ON);
191
        write_ascii_string_pgm(23, 7, ON);
192
    } else {
192
    } else {
193
        write_ascii_string_pgm(23, 7, OFF);
193
        write_ascii_string_pgm(23, 7, OFF);
194
    }
194
    }
195
}
195
}
196
 
196
 
197
/**
197
/**
198
 * some sort of clicking response in the menu
198
 * some sort of clicking response in the menu
199
 */
199
 */
200
void config_menu_doclick(uint8_t chosen, char** menu) {
200
void config_menu_doclick(uint8_t chosen, const char* menu[]) {
201
    write_ascii_string(4, chosen + 2, "DONE              ");
201
    write_ascii_string(4, chosen + 2, "DONE              ");
202
    _delay_ms(500);
202
    _delay_ms(500);
203
    write_ascii_string_pgm(4, chosen + 2, menu[chosen]);
203
    write_ascii_string_pgm(4, chosen + 2, menu[chosen]);
204
}
204
}
205
 
205
 
206
/**
206
/**
207
 * a simple config menu tryout
207
 * a simple config menu tryout
208
 */
208
 */
209
void config_menu(void) {
209
void config_menu(void) {
210
    // disable interrupts (makes the menu more smoothely)
210
    // disable interrupts (makes the menu more smoothely)
211
    cli();
211
    cli();
212
 
212
 
213
    // clear screen
213
    // clear screen
214
    clear();
214
    clear();
215
 
215
 
216
    uint8_t inmenu = 1;
216
    uint8_t inmenu = 1;
217
    uint8_t chosen = 0;
217
    uint8_t chosen = 0;
218
    write_ascii_string(6, 1, "C-OSD Config Menu");
218
    write_ascii_string(6, 1, "C-OSD Config Menu");
219
 
219
 
220
    // wait a bit before doing stuff so user has chance to release button
220
    // wait a bit before doing stuff so user has chance to release button
221
    _delay_ms(250);
221
    _delay_ms(250);
222
 
222
 
223
        write_ascii_string_pgm(4, 2, menu[0]);
223
        write_ascii_string_pgm(4, 2, menu[0]);
224
    write_ascii_string_pgm(4, 3, menu[1]);
224
    write_ascii_string_pgm(4, 3, menu[1]);
225
    write_ascii_string_pgm(4, 4, menu[2]);
225
    write_ascii_string_pgm(4, 4, menu[2]);
226
    write_ascii_string_pgm(4, 5, menu[3]);
226
    write_ascii_string_pgm(4, 5, menu[3]);
227
    write_ascii_string_pgm(4, 6, menu[4]);
227
    write_ascii_string_pgm(4, 6, menu[4]);
228
    write_ascii_string_pgm(4, 7, menu[5]);
228
    write_ascii_string_pgm(4, 7, menu[5]);
229
    write_ascii_string_pgm(4, 8, menu[6]);
229
    write_ascii_string_pgm(4, 8, menu[6]);
230
    write_ascii_string_pgm(4, 9, menu[7]);
230
    write_ascii_string_pgm(4, 9, menu[7]);
231
    write_ascii_string_pgm(4, 10, menu[8]);
231
    write_ascii_string_pgm(4, 10, menu[8]);
232
    write_ascii_string_pgm(4, 11, menu[9]);
232
    write_ascii_string_pgm(4, 11, menu[9]);
233
        write_ascii_string_pgm(4, 12, menu[10]);
233
        write_ascii_string_pgm(4, 12, menu[10]);
234
 
234
 
235
    config_menu_drawings(chosen);
235
    config_menu_drawings(chosen);
236
 
236
 
237
    while (inmenu) {
237
    while (inmenu) {
238
        if (s2_pressed()) {
238
        if (s2_pressed()) {
239
            write_ascii_string(3, chosen + 2, " ");
239
            write_ascii_string(3, chosen + 2, " ");
240
            chosen = (chosen + 1) % 11;
240
            chosen = (chosen + 1) % 11;
241
            write_ascii_string(3, chosen + 2, ">");
241
            write_ascii_string(3, chosen + 2, ">");
242
            _delay_ms(500);
242
            _delay_ms(500);
243
        } else if (s1_pressed()) {
243
        } else if (s1_pressed()) {
244
            switch (chosen) {
244
            switch (chosen) {
245
                case 0: // full HUD
245
                case 0: // full HUD
246
                    COSD_FLAGS ^= COSD_FLAG_NTSC;
246
                    COSD_FLAGS ^= COSD_FLAG_NTSC;
247
                                        // Setup Video Mode
247
                                        // Setup Video Mode
248
                                        if (COSD_FLAGS & COSD_FLAG_NTSC) {
248
                                        if (COSD_FLAGS & COSD_FLAG_NTSC) {
249
                                            // NTSC + enable display immediately (VM0)
249
                                            // NTSC + enable display immediately (VM0)
250
                                            spi_send_byte(0x00, 0b00001000);
250
                                            spi_send_byte(0x00, 0b00001000);
251
 
251
 
252
                                                bottom_line = 12;
252
                                                bottom_line = 12;
253
                                        } else {
253
                                        } else {
254
                                            // PAL + enable display immediately (VM0)
254
                                            // PAL + enable display immediately (VM0)
255
                                            spi_send_byte(0x00, 0b01001000);
255
                                            spi_send_byte(0x00, 0b01001000);
256
 
256
 
257
                                                bottom_line = 14;
257
                                                bottom_line = 14;
258
                                        }
258
                                        }
259
                    config_menu_drawings(chosen);
259
                    config_menu_drawings(chosen);
260
                    break;
260
                    break;
261
                case 1: // full HUD
261
                case 1: // full HUD
262
                    COSD_FLAGS ^= COSD_FLAG_HUD;
262
                    COSD_FLAGS ^= COSD_FLAG_HUD;
263
                    config_menu_drawings(chosen);
263
                    config_menu_drawings(chosen);
264
                    break;
264
                    break;
265
                case 2: // art horizon
265
                case 2: // art horizon
266
                    COSD_FLAGS ^= COSD_FLAG_ARTHORIZON;
266
                    COSD_FLAGS ^= COSD_FLAG_ARTHORIZON;
267
                    config_menu_drawings(chosen);
267
                    config_menu_drawings(chosen);
268
                    break;
268
                    break;
269
                case 3: // big vario
269
                case 3: // big vario
270
                    COSD_FLAGS ^= COSD_FLAG_BIGVARIO;
270
                    COSD_FLAGS ^= COSD_FLAG_BIGVARIO;
271
                    config_menu_drawings(chosen);
271
                    config_menu_drawings(chosen);
272
                    break;
272
                    break;
273
                case 4: // statistics
273
                case 4: // statistics
274
                    COSD_FLAGS ^= COSD_FLAG_STATS;
274
                    COSD_FLAGS ^= COSD_FLAG_STATS;
275
                    config_menu_drawings(chosen);
275
                    config_menu_drawings(chosen);
276
                    break;
276
                    break;
277
                case 5: // warnings
277
                case 5: // warnings
278
                    COSD_FLAGS ^= COSD_FLAG_WARNINGS;
278
                    COSD_FLAGS ^= COSD_FLAG_WARNINGS;
279
                    config_menu_drawings(chosen);
279
                    config_menu_drawings(chosen);
280
                    break;
280
                    break;
281
                case 6: // reset uptime
281
                case 6: // reset uptime
282
                    uptime = 0;
282
                    uptime = 0;
283
                    config_menu_doclick(chosen, menu);
283
                    config_menu_doclick(chosen, menu);
284
                    break;
284
                    break;
285
                case 7: // re-request OSD data
285
                case 7: // re-request OSD data
286
#if FCONLY
286
#if FCONLY
287
                    // request data ever 100ms from FC;
287
                    // request data ever 100ms from FC;
288
                    usart1_request_mk_data(0, 'd', 100);
288
                    usart1_request_mk_data(0, 'd', 100);
289
#else
289
#else
290
                    // request OSD Data from NC every 100ms
290
                    // request OSD Data from NC every 100ms
291
                    usart1_request_mk_data(1, 'o', 100);
291
                    usart1_request_mk_data(1, 'o', 100);
292
 
292
 
293
                    // and disable debug...
293
                    // and disable debug...
294
                    usart1_request_mk_data(0, 'd', 0);
294
                    usart1_request_mk_data(0, 'd', 0);
295
#endif
295
#endif
296
                    config_menu_doclick(chosen, menu);
296
                    config_menu_doclick(chosen, menu);
297
                    break;
297
                    break;
298
                case 8: // disable debug data
298
                case 8: // disable debug data
299
                    // disable sending of debug data
299
                    // disable sending of debug data
300
                    // may result in smoother ddata display
300
                    // may result in smoother ddata display
301
                    usart1_request_mk_data(0, 'd', 0);
301
                    usart1_request_mk_data(0, 'd', 0);
302
                    config_menu_doclick(chosen, menu);
302
                    config_menu_doclick(chosen, menu);
303
                    break;
303
                    break;
304
                case 9: // save
304
                case 9: // save
305
                    save_eeprom();
305
                    save_eeprom();
306
                    config_menu_doclick(chosen, menu);
306
                    config_menu_doclick(chosen, menu);
307
                    break;
307
                    break;
308
                case 10: // exit
308
                case 10: // exit
309
                    inmenu = 0;
309
                    inmenu = 0;
310
                    break;
310
                    break;
311
            }
311
            }
312
            _delay_ms(250);
312
            _delay_ms(250);
313
        }
313
        }
314
    }
314
    }
315
 
315
 
316
    // clear screen up again
316
    // clear screen up again
317
    clear();
317
    clear();
318
 
318
 
319
    // update flags to paint display again if needed
319
    // update flags to paint display again if needed
320
    COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN;
320
    COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN;
321
 
321
 
322
    // enable interrupts again
322
    // enable interrupts again
323
    sei();
323
    sei();
324
}
324
}
325
 
325
 
326
#endif
326
#endif
327
 
327