Subversion Repositories Projects

Rev

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

Rev 495 Rev 497
Line 35... Line 35...
35
#include "osd_helpers.h"
35
#include "osd_helpers.h"
36
#include "config.h"
36
#include "config.h"
37
#include "spi.h"
37
#include "spi.h"
38
#include "buttons.h"
38
#include "buttons.h"
39
#include "ppm.h"
39
#include "ppm.h"
-
 
40
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
-
 
41
#include "osd_ncmode_default.h"
-
 
42
#include "osd_ncmode_minimal.h"
-
 
43
#include "osd_fcmode_default.h"
-
 
44
#endif
Line 40... Line 45...
40
 
45
 
41
/* TODO:
46
/* TODO:
42
 * - verifiy correctness of values
47
 * - verifiy correctness of values
43
 * - clean up code :)
48
 * - clean up code :)
Line 44... Line -...
44
 */
-
 
45
 
-
 
46
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
-
 
Line 47... Line 49...
47
// data structs not needed for character flashing
49
 */
48
#include "mk-data-structs.h"
50
 
49
 
51
 
Line 66... Line 68...
66
volatile uint16_t timer = 0;
68
volatile uint16_t timer = 0;
Line 67... Line 69...
67
 
69
 
68
// remember last time data was received
70
// remember last time data was received
Line -... Line 71...
-
 
71
volatile uint8_t seconds_since_last_data = 0;
-
 
72
 
-
 
73
// general PAL|NTSC distingiusch stuff
-
 
74
uint8_t top_line = 1;
-
 
75
uint8_t bottom_line = 14;
-
 
76
 
-
 
77
// battery voltages
-
 
78
uint8_t min_voltage = 0;
-
 
79
uint8_t max_voltage = 0;
-
 
80
 
-
 
81
// Flags
-
 
82
uint8_t COSD_FLAGS = 0, COSD_FLAGS2 = 0;
-
 
83
 
-
 
84
// stats for after flight
-
 
85
int16_t max_Altimeter = 0;
-
 
86
uint8_t min_UBat = 255;
-
 
87
uint16_t max_GroundSpeed = 0;
-
 
88
int16_t max_Distance = 0;
-
 
89
uint16_t max_FlyingTime = 0;
-
 
90
 
-
 
91
// flags from last round to check for changes
69
volatile uint8_t seconds_since_last_data = 0;
92
uint8_t old_MKFlags = 0;
70
 
93
 
71
// store stats description in progmem to save space
94
// store stats description in progmem to save space
72
const char stats_item_0[] PROGMEM = "max Altitude:";
95
const char stats_item_0[] PROGMEM = "max Altitude:";
73
const char stats_item_1[] PROGMEM = "max Speed   :";
96
const char stats_item_1[] PROGMEM = "max Speed   :";
74
const char stats_item_2[] PROGMEM = "max Distance:";
97
const char stats_item_2[] PROGMEM = "max Distance:";
75
const char stats_item_3[] PROGMEM = "min Voltage :";
98
const char stats_item_3[] PROGMEM = "min Voltage :";
76
const char stats_item_4[] PROGMEM = "max Time    :";
99
const char stats_item_4[] PROGMEM = "max Time    :";
77
const char stats_item_5[] PROGMEM = "longitude   :";
100
const char stats_item_5[] PROGMEM = "longitude   :";
78
const char stats_item_6[] PROGMEM = "latitude    :";
101
const char stats_item_6[] PROGMEM = "latitude    :";
79
const char stats_item_7[] PROGMEM = "max current :";
102
const char stats_item_7[] PROGMEM = "max current :";
Line 80... Line -...
80
const char* stats_item_pointers[] PROGMEM = {stats_item_0, stats_item_1, stats_item_2,
-
 
81
    stats_item_3, stats_item_4, stats_item_5, stats_item_6, stats_item_7};
103
const char* stats_item_pointers[8] PROGMEM = {stats_item_0, stats_item_1, stats_item_2,
82
 
104
    stats_item_3, stats_item_4, stats_item_5, stats_item_6, stats_item_7};
83
#if !(FCONLY)
105
 
84
//char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "};
106
//char* directions[8] = {"NE", "E ", "SE", "S ", "SW", "W ", "NW", "N "};
85
    //char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219};
107
    //char arrowdir[8] = {218, 217, 224, 223, 222, 221, 220, 219};
Line 98... Line 120...
98
        str_S,
120
        str_S,
99
        str_SW,
121
        str_SW,
100
        str_W,
122
        str_W,
101
        str_NW,
123
        str_NW,
102
        str_N};
124
        str_N};
103
#endif
-
 
Line -... Line 125...
-
 
125
 
-
 
126
/* ##########################################################################
-
 
127
 * Different display mode function pointers
104
 
128
 * ##########################################################################*/
-
 
129
#if !(ALLCHARSDEBUG|(WRITECHARS != -1))
-
 
130
const char str_1[] PROGMEM  = "default";
Line -... Line 131...
-
 
131
const char str_2[] PROGMEM  = "minimal";
105
#endif // ends !(ALLCHARSDEBUG|(WRITECHARS != -1))
132
 
106
 
133
const displaymode_t ncdisplaymodes[] PROGMEM = {
-
 
134
   { osd_ncmode_default, (char *)str_1 },
-
 
135
   { osd_ncmode_minimal, (char *)str_2 }
-
 
136
};
107
// general PAL|NTSC distingiusch stuff
137
 
-
 
138
const displaymode_t fcdisplaymodes[] PROGMEM = {
Line 108... Line -...
108
uint8_t top_line = 1;
-
 
109
uint8_t bottom_line = 14;
139
   { osd_fcmode_default, (char *)str_1 },
110
 
140
};
111
// battery voltages
-
 
112
uint8_t min_voltage = 0;
141
 
113
uint8_t max_voltage = 0;
-
 
Line 114... Line 142...
114
 
142
int (*osd_ncmode)(void) = (int(*)(void)) &osd_ncmode_default;
115
// Flags
143
int (*osd_fcmode)(void) = (int(*)(void)) &osd_ncmode_default;
116
uint8_t COSD_FLAGS = 0, COSD_FLAGS2 = 0;
144
#endif
Line 281... Line 309...
281
 
309
 
282
    // and disable debug...
310
    // and disable debug...
283
    usart1_request_mk_data(0, 'd', 0);
311
    usart1_request_mk_data(0, 'd', 0);
Line 284... Line -...
284
#endif
-
 
285
 
-
 
286
    // stats for after flight
-
 
287
    int16_t max_Altimeter = 0;
-
 
288
    uint8_t min_UBat = 255;
-
 
289
#if !(FCONLY)
-
 
290
    uint16_t max_GroundSpeed = 0;
-
 
291
    int16_t max_Distance = 0;
-
 
292
    uint16_t max_FlyingTime = 0;
-
 
293
 
-
 
294
    // flags from last round to check for changes
-
 
295
    uint8_t old_MKFlags = 0;
-
 
296
#endif
312
#endif
297
 
313
 
298
    while (1) {
314
    while (1) {
299
        // in case SPI is ready and there is nothing to send right now
315
        // in case SPI is ready and there is nothing to send right now
300
        if (!icnt && spi_ready) {
316
        if (!icnt && spi_ready) {
Line 342... Line 358...
342
                // init on first data retrival, distinguished by last battery :)
358
                // init on first data retrival, distinguished by last battery :)
343
                if (last_UBat == 255) {
359
                if (last_UBat == 255) {
344
                    // fix for min_UBat
360
                    // fix for min_UBat
345
                    min_UBat = debugData.Analog[9];
361
                    min_UBat = debugData.Analog[9];
346
                    init_cosd(debugData.Analog[9]);
362
                    init_cosd(debugData.Analog[9]);
347
                }
363
                }
348
                #include OSD_FCMODE
364
                                osd_fcmode();
349
            }
365
            }
350
#else
366
#else
351
            if (rxd_buffer[2] == 'O') { // NC OSD Data
367
            if (rxd_buffer[2] == 'O') { // NC OSD Data
352
                Decode64();
368
                Decode64();
353
                naviData = *((NaviData_t*) pRxData);
369
                naviData = *((NaviData_t*) pRxData);
Line 356... Line 372...
356
                if (last_UBat == 255) {
372
                if (last_UBat == 255) {
357
                    // fix for min_UBat
373
                    // fix for min_UBat
358
                    min_UBat = naviData.UBat;
374
                    min_UBat = naviData.UBat;
359
                    init_cosd(naviData.UBat);
375
                    init_cosd(naviData.UBat);
360
                }
376
                }
361
                #include OSD_NCMODE
377
                                osd_ncmode();
362
            }
378
            }
363
#endif
379
#endif
364
            rxd_buffer_locked = 0;
380
            rxd_buffer_locked = 0;
365
        }
381
        }
366
        // handle keypress
382
        // handle keypress