Rev 520 | Rev 728 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 520 | Rev 523 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | #include "osd_ncmode_default.h" |
24 | #include "osd_ncmode_default.h" |
Line 25... | Line 25... | ||
25 | 25 | ||
Line 26... | Line 26... | ||
26 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
26 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
27 | 27 | ||
28 | int osd_ncmode_default() { |
28 | int osd_ncmode_default() { |
29 | if (COSD_FLAGS & COSD_FLAG_HUD) { |
29 | if (COSD_FLAGS_MODES & COSD_FLAG_HUD) { |
30 | // write icons at init or after menu/mode-switch |
30 | // write icons at init or after menu/mode-switch |
31 | if (!(COSD_FLAGS2 & COSD_ICONS_WRITTEN)) { |
31 | if (!(COSD_FLAGS_RUNTIME & COSD_ICONS_WRITTEN)) { |
32 | write_char_xy(5, top_line, 0xCB); // km/h |
32 | write_char_xy(5, top_line, 0xCB); // km/h |
33 | write_char_xy(10, top_line, 0xCA); // RC-transmitter |
33 | write_char_xy(10, top_line, 0xCA); // RC-transmitter |
34 | write_char_xy(16, top_line, 0xD0); // degree symbol |
34 | write_char_xy(16, top_line, 0xD0); // degree symbol |
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_FLAGS2 & COSD_FLAG_STROMREC) { |
40 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
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 & 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 | } |
46 | } |
46 | } |
47 | write_char_xy(14, bottom_line, 0xD1); // on clock |
47 | write_char_xy(14, bottom_line, 0xD1); // on clock |
48 | write_char_xy(21, bottom_line, 0xD2); // fly clock |
48 | write_char_xy(21, bottom_line, 0xD2); // fly clock |
49 | write_char_xy(26, bottom_line, 0xC8); // sat1 |
49 | write_char_xy(26, bottom_line, 0xC8); // sat1 |
50 | write_char_xy(27, bottom_line, 0xC9); // sat2 |
50 | write_char_xy(27, bottom_line, 0xC9); // sat2 |
Line 51... | Line 51... | ||
51 | COSD_FLAGS2 |= COSD_ICONS_WRITTEN; |
51 | COSD_FLAGS_RUNTIME |= COSD_ICONS_WRITTEN; |
52 | } |
52 | } |
Line 74... | Line 74... | ||
74 | 74 | ||
Line 75... | Line 75... | ||
75 | write_ascii_string_pgm(17, top_line, (const char *) (pgm_read_word ( &(directions[heading_conv(naviData.CompassHeading)])))); |
75 | write_ascii_string_pgm(17, top_line, (const char *) (pgm_read_word ( &(directions[heading_conv(naviData.CompassHeading)])))); |
Line 76... | Line 76... | ||
76 | 76 | ||
77 | draw_variometer(21, top_line, naviData.Variometer); |
77 | draw_variometer(21, top_line, naviData.Variometer); |
78 | 78 | ||
79 | //note:lephisto:according to several sources it's /30 |
79 | if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) { |
- | 80 | if (naviData.CurrentPosition.Altitude / 1000 - altimeter_offset > 10 || naviData.CurrentPosition.Altitude / 1000 - altimeter_offset < -10) { |
|
- | 81 | // above 10m only write full meters |
|
80 | if (naviData.Altimeter > 300 || naviData.Altimeter < -300) { |
82 | write_ndigit_number_s(23, top_line, (int16_t) (naviData.CurrentPosition.Altitude / 1000 - altimeter_offset), 4, 0); // GPS |
- | 83 | } else { |
|
81 | // above 10m only write full meters |
84 | // up to 10m write meters.dm |
- | 85 | write_ndigit_number_s_10th(23, top_line, (int16_t) (naviData.CurrentPosition.Altitude / 100 - altimeter_offset * 10), 3, 0); // GPS |
|
- | 86 | } |
|
82 | write_ndigit_number_s(23, top_line, naviData.Altimeter / 30, 4, 0); // BARO |
87 | } else { |
83 | //write_ndigit_number_s(23, top_line, (int16_t) (naviData.CurrentPosition.Altitude / 1000), 4, 0); // GPS |
88 | //note:lephisto:according to several sources it's /30 |
- | 89 | if (naviData.Altimeter > 300 || naviData.Altimeter < -300) { |
|
- | 90 | // above 10m only write full meters |
|
84 | } else { |
91 | write_ndigit_number_s(23, top_line, naviData.Altimeter / 30, 4, 0); // BARO |
- | 92 | } else { |
|
85 | // up to 10m write meters.dm |
93 | // up to 10m write meters.dm |
- | 94 | write_ndigit_number_s_10th(23, top_line, naviData.Altimeter / 3, 3, 0); // BARO |
|
86 | write_ndigit_number_s_10th(23, top_line, naviData.Altimeter / 3, 3, 0); // BARO |
95 | } |
87 | //write_ndigit_number_s_10th(23, top_line, (int16_t) (naviData.CurrentPosition.Altitude / 1000), 3, 0); // GPS |
96 | } |
Line 88... | Line 97... | ||
88 | } |
97 | |
89 | 98 | ||
Line 99... | Line 108... | ||
99 | 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); |
100 | 109 | ||
101 | // center |
110 | // center |
102 | if (naviData.MKFlags & FLAG_MOTOR_RUN) { // should be engines running |
111 | if (naviData.MKFlags & FLAG_MOTOR_RUN) { // should be engines running |
- | 112 | if (!(old_MKFlags & FLAG_MOTOR_RUN)) { // motors just started, clear middle |
|
- | 113 | clear(); |
|
103 | if (!(old_MKFlags & FLAG_MOTOR_RUN)) { // motors just started, clear middle |
114 | // remember current heigth for gps offset |
104 | clear(); |
115 | altimeter_offset = naviData.CurrentPosition.Altitude / 1000; |
105 | // update flags to paint display again if needed |
116 | // update flags to paint display again if needed |
106 | COSD_FLAGS2 &= ~COSD_ICONS_WRITTEN; |
117 | COSD_FLAGS_RUNTIME &= ~COSD_ICONS_WRITTEN; |
107 | } |
118 | } |
108 | if (COSD_FLAGS & COSD_FLAG_ARTHORIZON) { |
119 | if (COSD_FLAGS_MODES & COSD_FLAG_ARTHORIZON) { |
109 | if (COSD_FLAGS2 & COSD_FLAG_STROMREC) { |
120 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
110 | draw_artificial_horizon(top_line + 2, bottom_line - 2, naviData.AngleNick, naviData.AngleRoll); |
121 | draw_artificial_horizon(top_line + 2, bottom_line - 2, naviData.AngleNick, naviData.AngleRoll); |
111 | } else { |
122 | } else { |
112 | draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
123 | draw_artificial_horizon(top_line + 2, bottom_line - 1, naviData.AngleNick, naviData.AngleRoll); |
113 | } |
124 | } |
114 | } |
125 | } |
115 | // motors are on, assume we were/are flying |
126 | // motors are on, assume we were/are flying |
116 | COSD_FLAGS2 |= COSD_WASFLYING; |
127 | COSD_FLAGS_RUNTIME |= COSD_WASFLYING; |
117 | } else { |
128 | } else { |
118 | // stats |
129 | // stats |
119 | if ((COSD_FLAGS2 & COSD_WASFLYING) && (COSD_FLAGS & COSD_FLAG_STATS)) { |
130 | if ((COSD_FLAGS_RUNTIME & COSD_WASFLYING) && (COSD_FLAGS_MODES & COSD_FLAG_STATS)) { |
120 | uint8_t line = 3; |
131 | uint8_t line = 3; |
121 | write_ascii_string_pgm(2, line, (const char *) (pgm_read_word(&(stats_item_pointers[0])))); // max Altitude |
132 | write_ascii_string_pgm(2, line, (const char *) (pgm_read_word(&(stats_item_pointers[0])))); // max Altitude |
122 | write_ndigit_number_s(18, line, max_Altimeter / 30, 4, 0); |
133 | write_ndigit_number_s(18, line, max_Altimeter, 4, 0); |
123 | write_char_xy(22, line, 204); // small meters m |
134 | write_char_xy(22, line, 204); // small meters m |
124 | write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[1])))); // max Speed |
135 | write_ascii_string_pgm(2, ++line, (const char *) (pgm_read_word(&(stats_item_pointers[1])))); // max Speed |
125 | write_ndigit_number_u(19, line, (uint16_t) (((uint32_t) max_GroundSpeed * (uint32_t) 9) / (uint32_t) 250), 3, 0); |
136 | write_ndigit_number_u(19, line, (uint16_t) (((uint32_t) max_GroundSpeed * (uint32_t) 9) / (uint32_t) 250), 3, 0); |
126 | write_char_xy(22, line, 203); // km/h |
137 | write_char_xy(22, line, 203); // km/h |
127 | 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 |
128 | write_ndigit_number_u(19, line, max_Distance / 10, 3, 0); |
139 | write_ndigit_number_u(19, line, max_Distance / 10, 3, 0); |
129 | write_char_xy(22, line, 204); // small meters m |
140 | write_char_xy(22, line, 204); // small meters m |
130 | 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 |
131 | write_ndigit_number_u_10th(18, line, min_UBat, 3, 0); |
142 | write_ndigit_number_u_10th(18, line, min_UBat, 3, 0); |
132 | write_char_xy(22, line, 0x9E); // small V |
143 | write_char_xy(22, line, 0x9E); // small V |
133 | if (COSD_FLAGS2 & COSD_FLAG_STROMREC) { |
144 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
134 | 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 |
135 | 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); |
136 | write_char_xy(22, line, 0x9F); // small A |
147 | write_char_xy(22, line, 0x9F); // small A |
Line 139... | Line 150... | ||
139 | write_time(16, line, max_FlyingTime); |
150 | write_time(16, line, max_FlyingTime); |
140 | write_char_xy(22, line, 210); // fly clock |
151 | write_char_xy(22, line, 210); // fly clock |
141 | 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 |
142 | write_gps_pos(15, line, naviData.CurrentPosition.Longitude); |
153 | write_gps_pos(15, line, naviData.CurrentPosition.Longitude); |
143 | 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 |
144 | write_gps_pos(15, line, naviData.CurrentPosition.Latitude); |
155 | write_gps_pos(15, line, naviData.CurrentPosition.Latitude); |
145 | } else if (COSD_FLAGS & 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 |
146 | if (COSD_FLAGS2 & COSD_FLAG_STROMREC) { |
157 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
147 | 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); |
148 | } else { |
159 | } else { |
149 | 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); |
150 | } |
161 | } |
151 | } |
162 | } |
152 | } |
163 | } |
153 | if (COSD_FLAGS & COSD_FLAG_BIGVARIO) { |
164 | if (COSD_FLAGS_MODES & COSD_FLAG_BIGVARIO) { |
154 | draw_big_variometer(27, 8, naviData.Variometer); |
165 | draw_big_variometer(27, 8, naviData.Variometer); |
Line 155... | Line 166... | ||
155 | } |
166 | } |
156 | 167 | ||
157 | // pre-bottom line |
168 | // pre-bottom line |
158 | if (COSD_FLAGS2 & COSD_FLAG_STROMREC) { |
169 | if (COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) { |
159 | //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0); |
170 | //write_ndigit_number_s(3, bottom_line - 1, ampere, 4, 0); |
160 | 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); |
161 | 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); |
162 | if (COSD_FLAGS & COSD_FLAG_STROMVOLT) { |
173 | if (COSD_FLAGS_MODES & COSD_FLAG_STROMVOLT) { |
163 | write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0); |
174 | write_ndigit_number_u_10th(17, bottom_line - 1, s_volt, 3, 0); |
Line 164... | Line 175... | ||
164 | } |
175 | } |
Line 197... | Line 208... | ||
197 | 208 | ||
198 | //write_number_s(8, 5, RxDataLen); |
209 | //write_number_s(8, 5, RxDataLen); |
Line 199... | Line 210... | ||
199 | //write_number_s(16, 5, setsReceived++); |
210 | //write_number_s(16, 5, setsReceived++); |
200 | 211 | ||
- | 212 | // remember statistics (only when engines running) |
|
- | 213 | if (naviData.MKFlags & FLAG_MOTOR_RUN) { |
|
- | 214 | if (COSD_FLAGS_CONFIG & COSD_FLAG_GPSHEIGHT) { |
|
201 | // remember statistics (only when engines running) |
215 | if (naviData.CurrentPosition.Altitude / 1000 - altimeter_offset > max_Altimeter) max_Altimeter = naviData.CurrentPosition.Altitude / 1000; |
- | 216 | } else { |
|
202 | if (naviData.MKFlags & FLAG_MOTOR_RUN) { |
217 | if (naviData.Altimeter / 30 > max_Altimeter) max_Altimeter = naviData.Altimeter / 30; |
203 | if (naviData.Altimeter > max_Altimeter) max_Altimeter = naviData.Altimeter; |
218 | } |
204 | if (naviData.GroundSpeed > max_GroundSpeed) max_GroundSpeed = naviData.GroundSpeed; |
219 | if (naviData.GroundSpeed > max_GroundSpeed) max_GroundSpeed = naviData.GroundSpeed; |
205 | if (naviData.HomePositionDeviation.Distance > max_Distance) { |
220 | if (naviData.HomePositionDeviation.Distance > max_Distance) { |
206 | max_Distance = naviData.HomePositionDeviation.Distance; |
221 | max_Distance = naviData.HomePositionDeviation.Distance; |