Subversion Repositories Projects

Rev

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

Rev 835 Rev 837
Line 26... Line 26...
26
#include <util/delay.h>
26
#include <util/delay.h>
27
#include "max7456_software_spi.h"
27
#include "max7456_software_spi.h"
28
#include "config.h"
28
#include "config.h"
29
#include "buttons.h"
29
#include "buttons.h"
30
#include "usart1.h"
30
#include "usart1.h"
-
 
31
#include "osd_helpers.h"
Line 31... Line 32...
31
 
32
 
Line 32... Line 33...
32
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
33
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
33
 
34
 
34
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
35
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
35
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
36
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
36
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;
-
 
39
uint8_t EEMEM ee_COSD_DISPLAYMODE = 0;
-
 
40
uint8_t EEMEM ee_COSD_SCOPE [8] = {
-
 
41
    5, 5,
-
 
42
    25, 5,
-
 
43
    5, 10,
Line 37... Line 44...
37
uint8_t EEMEM ee_COSD_FLAGS_CONFIG = 0;
44
    25, 10
38
uint8_t EEMEM ee_COSD_DISPLAYMODE = 0;
45
};
39
 
46
 
Line 55... Line 62...
55
        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
56
        COSD_FLAGS_MODES = eeprom_read_byte(&ee_COSD_FLAGS_MODES);
63
        COSD_FLAGS_MODES = eeprom_read_byte(&ee_COSD_FLAGS_MODES);
57
        COSD_FLAGS_CONFIG = eeprom_read_byte(&ee_COSD_FLAGS_CONFIG);
64
        COSD_FLAGS_CONFIG = eeprom_read_byte(&ee_COSD_FLAGS_CONFIG);
58
        COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE);
65
        COSD_DISPLAYMODE = eeprom_read_byte(&ee_COSD_DISPLAYMODE);
59
        //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++) {
-
 
68
            scope[i] = eeprom_read_byte(&ee_COSD_SCOPE[i]);
-
 
69
        }
60
    } else {
70
    } else {
61
        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
62
    }
72
    }
63
}
73
}
Line 69... Line 79...
69
    eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
79
    eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
70
    eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
80
    eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
71
    eeprom_write_byte(&ee_COSD_FLAGS_MODES, COSD_FLAGS_MODES);
81
    eeprom_write_byte(&ee_COSD_FLAGS_MODES, COSD_FLAGS_MODES);
72
    eeprom_write_byte(&ee_COSD_FLAGS_CONFIG, COSD_FLAGS_CONFIG);
82
    eeprom_write_byte(&ee_COSD_FLAGS_CONFIG, COSD_FLAGS_CONFIG);
73
    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++) {
-
 
85
        eeprom_write_byte(&ee_COSD_SCOPE[i], scope[i]);
-
 
86
    }
74
}
87
}
Line 75... Line 88...
75
 
88
 
76
/**
89
/**
77
 * auto config some stuff on startup, currently only battery cells
90
 * auto config some stuff on startup, currently only battery cells
Line 150... Line 163...
150
    usart1_request_blocking('V', PSTR(REQUEST_FC_VERSION));
163
    usart1_request_blocking('V', PSTR(REQUEST_FC_VERSION));
151
#else
164
#else
152
    usart1_request_nc_uart();
165
    usart1_request_nc_uart();
153
    _delay_ms(200);
166
    _delay_ms(200);
154
    usart1_request_nc_uart();
167
    usart1_request_nc_uart();
155
   
168
 
156
    //usart1_request_mk_data(1, 'v', 0);
169
    //usart1_request_mk_data(1, 'v', 0);
157
    write_ascii_string_pgm(2, 11, PSTR("NC VERSION: ........"));
170
    write_ascii_string_pgm(2, 11, PSTR("NC VERSION: ........"));
158
    usart1_request_blocking('V', PSTR(REQUEST_NC_VERSION));
171
    usart1_request_blocking('V', PSTR(REQUEST_NC_VERSION));
159
#endif
172
#endif
160
    str_VersionInfo VersionInfo;
173
    str_VersionInfo VersionInfo;
Line 213... Line 226...
213
 */
226
 */
214
void config_menu_drawings(uint8_t chosen) {
227
void config_menu_drawings(uint8_t chosen) {
215
    static uint8_t old_y = 0;
228
    static uint8_t old_y = 0;
216
    uint8_t x = MENU_LEFT, y = MENU_TOP, line = MENU_TOP;
229
    uint8_t x = MENU_LEFT, y = MENU_TOP, line = MENU_TOP;
Line 217... Line 230...
217
 
230
 
218
    if (chosen > 5 && chosen < 12) { // right
231
    if (chosen > 5 && chosen < 13) { // right
219
        x = MENU_MIDDLE;
232
        x = MENU_MIDDLE;
220
        y = chosen - 6 + MENU_TOP;
233
        y = chosen - 6 + MENU_TOP;
221
    } else if (chosen < 7) {
234
    } else if (chosen < 7) {
222
        y = chosen + MENU_TOP;
235
        y = chosen + MENU_TOP;
Line 274... Line 287...
274
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO);
287
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO);
Line 275... Line 288...
275
 
288
 
276
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Passive"));
289
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Passive"));
Line 277... Line 290...
277
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_PASSIVE);
290
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_PASSIVE);
278
 
291
 
-
 
292
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Cam Scope"));
-
 
293
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_SHOW_SCOPE);
-
 
294
 
Line 279... Line 295...
279
    /*write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("?????"));
295
    write_ascii_string_pgm(MENU_MIDDLE, ++line, PSTR("Move Scope"));
280
    onoff(MENU_MIDDLE + 10, line, COSD_FLAGS_CONFIG & COSD_FLAG_PASSIVE);*/
296
 
Line 281... Line 297...
281
 
297
 
Line 299... Line 315...
299
    _delay_ms(500);
315
    _delay_ms(500);
300
    config_menu_drawings(chosen);
316
    config_menu_drawings(chosen);
301
}
317
}
Line 302... Line 318...
302
 
318
 
-
 
319
/**
-
 
320
 * move around the four scope edges
-
 
321
 */
-
 
322
void move_scope() {
-
 
323
    uint8_t mode = 0;
-
 
324
    clear();
-
 
325
    draw_scope();
-
 
326
    _delay_ms(500);
-
 
327
    while (mode < 8) {
-
 
328
        if (s2_pressed()) { // next
-
 
329
            mode++;
-
 
330
            _delay_ms(500);
-
 
331
        } else if (s1_pressed()) {
-
 
332
            scope[mode] = (scope[mode] + 1) % (mode % 2 == 0 ? 30 : bottom_line);
-
 
333
            clear();
-
 
334
            draw_scope();
-
 
335
            _delay_ms(100);
-
 
336
        }
-
 
337
    }
-
 
338
    clear();
-
 
339
}
-
 
340
 
303
/**
341
/**
304
 * a simple config menu tryout
342
 * a simple config menu tryout
305
 */
343
 */
306
void config_menu(void) {
344
void config_menu(void) {
307
    // disable interrupts (makes the menu more smoothely)
345
    // disable interrupts (makes the menu more smoothely)
Line 320... Line 358...
320
    config_menu_drawings(chosen);
358
    config_menu_drawings(chosen);
Line 321... Line 359...
321
 
359
 
322
    while (inmenu) {
360
    while (inmenu) {
323
        if (s2_pressed()) {
361
        if (s2_pressed()) {
324
            chosen = (chosen + 1) % 17;
362
            chosen = (chosen + 1) % 17;
325
            if (chosen == 11) chosen = 13; // SKIP unused menu space for now
363
            //if (chosen == 12) chosen = 13; // SKIP unused menu space for now
326
            config_menu_drawings(chosen);
364
            config_menu_drawings(chosen);
327
            _delay_ms(500);
365
            _delay_ms(500);
328
        } else if (s1_pressed()) {
366
        } else if (s1_pressed()) {
329
            switch (chosen) {
367
            switch (chosen) {
Line 370... Line 408...
370
                    COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO;
408
                    COSD_FLAGS_MODES ^= COSD_FLAG_BIGVARIO;
371
                    break;
409
                    break;
372
                case 10: // passive
410
                case 10: // passive
373
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_PASSIVE;
411
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_PASSIVE;
374
                    break;
412
                    break;
-
 
413
                case 11: // scope
-
 
414
                    COSD_FLAGS_CONFIG ^= COSD_FLAG_SHOW_SCOPE;
-
 
415
                    break;
-
 
416
                case 12: // move scope
-
 
417
                    move_scope();
-
 
418
                    break;
375
                case 13: // reset uptime
419
                case 13: // reset uptime
376
                    uptime = 0;
420
                    uptime = 0;
377
                    config_menu_doclick(chosen);
421
                    config_menu_doclick(chosen);
378
                    break;
422
                    break;
379
                case 14: // change mode
423
                case 14: // change mode