Subversion Repositories Projects

Rev

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

Rev 523 Rev 728
Line 1... Line 1...
1
/****************************************************************************
1
/****************************************************************************
2
 *   Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje                    *
2
 *   Copyright (C) 2009-2010 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   *
Line 35... Line 35...
35
                    write_char_xy(27, top_line, 0xCC); // small meters m height
35
                    write_char_xy(27, top_line, 0xCC); // small meters m height
36
                    write_char_xy(20, top_line + 1, 0xB0); // left circle
36
                    write_char_xy(20, top_line + 1, 0xB0); // left circle
37
                    write_char_xy(22, top_line + 1, 0xB2); // right circle
37
                    write_char_xy(22, top_line + 1, 0xB2); // right circle
38
                    write_char_xy(27, top_line + 1, 0xCC); // small meters m home
38
                    write_char_xy(27, top_line + 1, 0xCC); // small meters m home
39
                    write_char_xy(7, bottom_line, 0x9E); // small V
39
                    write_char_xy(7, bottom_line, 0x9E); // small V
40
                        if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) {
40
                        if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) || (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) {
41
                                write_char_xy(7, bottom_line - 1, 0x9F); // small A
41
                                write_char_xy(7, bottom_line - 1, 0x9F); // small A
42
                                write_char_xy(14, bottom_line - 1, 0xB5); // mah
42
                                write_char_xy(14, bottom_line - 1, 0xB5); // mah
43
                                if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) {
43
                                if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) {
44
                                        write_char_xy(21, bottom_line - 1, 0x9E); // small V
44
                                        write_char_xy(21, bottom_line - 1, 0x9E); // small V
45
                                }
45
                                }
Line 105... Line 105...
105
                // finer resolution, 0xa0 is first character and we add the index 0 <= index < 16
105
                // finer resolution, 0xa0 is first character and we add the index 0 <= index < 16
Line 106... Line 106...
106
                write_char_xy(21, top_line + 1, 0xa0 + heading_fine_conv(heading_home));
106
                write_char_xy(21, top_line + 1, 0xa0 + heading_fine_conv(heading_home));
Line 107... Line 107...
107
 
107
 
108
                write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 10, 3, 0);
108
                write_ndigit_number_u(24, top_line + 1, naviData.HomePositionDeviation.Distance / 10, 3, 0);
109
 
109
 
110
                // center
110
                // center
111
                if (naviData.MKFlags & FLAG_MOTOR_RUN) { // should be engines running
111
                if (naviData.FCFlags & FLAG_MOTOR_RUN) { // should be engines running
112
                    if (!(old_MKFlags & FLAG_MOTOR_RUN)) { // motors just started, clear middle
112
                    if (!(old_MKFlags & FLAG_MOTOR_RUN)) { // motors just started, clear middle
113
                        clear();
113
                        clear();
Line 138... Line 138...
138
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[2])))); // max Distance
138
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[2])))); // max Distance
139
                        write_ndigit_number_u(19, line, max_Distance / 10, 3, 0);
139
                        write_ndigit_number_u(19, line, max_Distance / 10, 3, 0);
140
                        write_char_xy(22, line, 204); // small meters m
140
                        write_char_xy(22, line, 204); // small meters m
141
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[3])))); // min voltage
141
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[3])))); // min voltage
142
                        write_ndigit_number_u_10th(18, line, min_UBat, 3, 0);
142
                        write_ndigit_number_u_10th(18, line, min_UBat, 3, 0);
143
                        write_char_xy(22, line, 0x9E); // small V
143
                        write_char_xy(22, line, 0x9E); // small V
144
                                if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) {
144
                                if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) || (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) {
145
                                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[7])))); // ampere
145
                                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[7])))); // ampere
146
                                        write_ndigit_number_u_10th(18, line, max_ampere / 10, 3, 0);
146
                                        write_ndigit_number_u_10th(18, line, max_ampere / 10, 3, 0);
147
                                        write_char_xy(22, line, 0x9F); // small A
147
                                        write_char_xy(22, line, 0x9F); // small A
148
                                }
148
                                }                              
149
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[4])))); // max time
149
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[4])))); // max time
150
                        write_time(16, line, max_FlyingTime);
150
                        write_time(16, line, max_FlyingTime);
151
                        write_char_xy(22, line, 210); // fly clock
151
                        write_char_xy(22, line, 210); // fly clock
152
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[5])))); // longitude
152
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[5])))); // longitude
153
                        write_gps_pos(15, line, naviData.CurrentPosition.Longitude);
153
                        write_gps_pos(15, line, naviData.CurrentPosition.Longitude);
154
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[6])))); // latitude
154
                        write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[6])))); // latitude
155
                        write_gps_pos(15, line, naviData.CurrentPosition.Latitude);
155
                        write_gps_pos(15, line, naviData.CurrentPosition.Latitude);
156
                    } else if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { // if no stats there is space horizon
156
                    } else if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { // if no stats there is space horizon
157
                                if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) {
157
                                if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) || (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) {
158
                                draw_artificial_horizon(top_line + 2, bottom_line - 2, naviData.AngleNick, naviData.AngleRoll);
158
                                draw_artificial_horizon(top_line + 2, bottom_line - 2, naviData.AngleNick, naviData.AngleRoll);
159
                                } else {
159
                                } else {
160
                                draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll);
160
                                draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll);
161
                                }
161
                                }
Line 163... Line 163...
163
                }
163
                }
164
                if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) {
164
                if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) {
165
                    draw_big_variometer(27, 8, naviData.Variometer);
165
                    draw_big_variometer(27, 8, naviData.Variometer);
Line 166... Line 166...
166
                }
166
                }
167
 
167
 
168
                // pre-bottom line
168
                // pre-bottom line
169
                if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) {
169
                if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) && !(COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) {
170
                        //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0);
170
                        //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0);
171
                        write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0);
171
                        write_ndigit_number_u_10th(3, bottom_line - 1, ampere / 10, 3, 0);
172
                        write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0);
172
                        write_ndigit_number_s(10, bottom_line - 1, ampere_wasted / 10, 4, 0);
173
                        if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) {
173
                        if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) {
-
 
174
                                write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0);
-
 
175
                        }      
-
 
176
                } else if (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT) {
174
                                write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0);
177
                        write_ndigit_number_u_10th(3, bottom_line - 1, naviData.Current, 3, 0);
Line -... Line 178...
-
 
178
                        write_ndigit_number_u(10, bottom_line - 1, naviData.UsedCapacity, 4, 0);
-
 
179
                }
175
                        }
180
 
176
                }
181
                //DEBUGwrite_ndigit_number_u(1, 5, COSD_FLAGS_MODES, 3, 0);
177
 
182
 
178
                // bottom line
183
                // bottom line
179
                draw_battery(2, bottom_line, min_voltage, naviData.UBat, max_voltage);
184
                draw_battery(2, bottom_line, min_voltage, naviData.UBat, max_voltage);
Line 207... Line 212...
207
        }
212
        }
208
 
213
 
Line 209... Line 214...
209
        //write_number_s(8, 5, RxDataLen);
214
        //write_number_s(8, 5, RxDataLen);
210
        //write_number_s(16, 5, setsReceived++);
215
        //write_number_s(16, 5, setsReceived++);
211
 
216
 
212
        // remember statistics (only when engines running)
217
        // remember statistics (only when engines running)
213
        if (naviData.MKFlags & FLAG_MOTOR_RUN) {
218
        if (naviData.FCFlags & FLAG_MOTOR_RUN) {
214
                if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) {
219
                if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) {
215
                        if (naviData.CurrentPosition.Altitude / 1000 - altimeter_offset > max_Altimeter) max_Altimeter = naviData.CurrentPosition.Altitude / 1000;
220
                        if (naviData.CurrentPosition.Altitude / 1000 - altimeter_offset > max_Altimeter) max_Altimeter = naviData.CurrentPosition.Altitude / 1000;
Line 219... Line 224...
219
            if (naviData.GroundSpeed > max_GroundSpeed) max_GroundSpeed = naviData.GroundSpeed;
224
            if (naviData.GroundSpeed > max_GroundSpeed) max_GroundSpeed = naviData.GroundSpeed;
220
            if (naviData.HomePositionDeviation.Distance > max_Distance) {
225
            if (naviData.HomePositionDeviation.Distance > max_Distance) {
221
                max_Distance = naviData.HomePositionDeviation.Distance;
226
                max_Distance = naviData.HomePositionDeviation.Distance;
222
            }
227
            }
223
            if (naviData.UBat < min_UBat) min_UBat = naviData.UBat;
228
            if (naviData.UBat < min_UBat) min_UBat = naviData.UBat;
-
 
229
            if (naviData.FlyingTime > max_FlyingTime) max_FlyingTime = naviData.FlyingTime;
224
            if (naviData.FlyingTime > max_FlyingTime) max_FlyingTime = naviData.FlyingTime;
230
                if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) && !(COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) {
-
 
231
                        if (ampere > max_ampere) max_ampere = ampere;
-
 
232
                } else if (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT) {
-
 
233
                        if (naviData.Current * 10 > max_ampere) max_ampere = naviData.Current * 10;
225
                if (ampere > max_ampere) max_ampere = ampere;
234
                }
Line 226... Line 235...
226
        }
235
        }
227
 
236
 
228
        // remember last values
237
        // remember last values
229
        last_RC_Quality = naviData.RC_Quality;
238
        last_RC_Quality = naviData.RC_Quality;
230
        last_UBat = naviData.UBat;
239
        last_UBat = naviData.UBat;
Line 231... Line 240...
231
        old_MKFlags = naviData.MKFlags;
240
        old_MKFlags = naviData.FCFlags;
232
        seconds_since_last_data = 0;
241
        seconds_since_last_data = 0;