Rev 758 | Rev 800 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 758 | Rev 761 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | /** |
62 | /** |
63 | * convert the <heading> gotton from NC into a more |
63 | * convert the <heading> gotton from NC into a more |
64 | * precise index |
64 | * precise index |
65 | */ |
65 | */ |
66 | uint8_t heading_fine_conv(uint16_t heading) { |
66 | uint8_t heading_fine_conv(uint16_t heading) { |
67 | heading = ((heading * 10) + 113) % 3600; |
67 | heading = ((heading * 10) + 113) % 3600; |
68 | return (heading / 225); |
68 | return (heading / 225); |
69 | } |
69 | } |
Line 70... | Line 70... | ||
70 | 70 | ||
71 | /** |
71 | /** |
72 | * draw a compass rose at <x>/<y> for <heading> |
72 | * draw a compass rose at <x>/<y> for <heading> |
73 | */ |
73 | */ |
74 | void draw_compass(uint8_t x, uint8_t y, uint16_t heading) { |
74 | void draw_compass(uint8_t x, uint8_t y, uint16_t heading) { |
75 | //char* rose = "---N---O---S---W---N---O---S---W---N---O---S---W"; |
75 | //char* rose = "---N---O---S---W---N---O---S---W---N---O---S---W"; |
76 | static char rose[48] PROGMEM = {216, 215, 216, 211, 216, 215, 216, 213, 216, 215, 216, 212, |
76 | static char rose[48] PROGMEM = {216, 215, 216, 211, 216, 215, 216, 213, 216, 215, 216, 212, |
77 | 216, 215, 216, 214, 216, 215, 216, 211, 216, 215, 216, 213, |
77 | 216, 215, 216, 214, 216, 215, 216, 211, 216, 215, 216, 213, |
78 | 216, 215, 216, 212, 216, 215, 216, 214, 216, 215, 216, 211, |
78 | 216, 215, 216, 212, 216, 215, 216, 214, 216, 215, 216, 211, |
79 | 216, 215, 216, 213, 216, 215, 216, 212, 216, 215, 216, 214}; |
79 | 216, 215, 216, 213, 216, 215, 216, 212, 216, 215, 216, 214}; |
80 | // the center is char 19 (north), we add the current heading in 8th |
80 | // the center is char 19 (north), we add the current heading in 8th |
81 | // which would be 22.5 degrees, but float would bloat up the code |
81 | // which would be 22.5 degrees, but float would bloat up the code |
82 | // and *10 / 225 would take ages... so we take the uncorrect way |
82 | // and *10 / 225 would take ages... so we take the uncorrect way |
83 | uint8_t front = 19 + (heading / 22); |
83 | uint8_t front = 19 + (heading / 22); |
84 | for (uint8_t i = 0; i < 9; i++) { |
84 | for (uint8_t i = 0; i < 9; i++) { |
85 | write_char_xy(x++, y, pgm_read_byte(&rose[front - 4 + i])); |
85 | write_char_xy(x++, y, pgm_read_byte(&rose[front - 4 + i])); |
86 | } |
86 | } |
Line 87... | Line 87... | ||
87 | } |
87 | } |
88 | 88 | ||
89 | /* ########################################################################## |
89 | /* ########################################################################## |
- | 90 | * battery index |
|
90 | * battery index |
91 | * ##########################################################################*/ |
91 | * ##########################################################################*/ |
92 | |
92 | /** |
93 | /** |
93 | * draw a battery symbol at <x>/<y> according to <voltage> |
94 | * draw a battery symbol at <x>/<y> according to <voltage> |
94 | */ |
95 | */ |
95 | void draw_battery(uint8_t x, uint8_t y, uint8_t min_voltage, uint8_t voltage, uint8_t max_voltage) { |
96 | void draw_battery(uint8_t x, uint8_t y, uint8_t min_voltage, uint8_t voltage, uint8_t max_voltage) { |
96 | uint8_t percent = (100* (voltage - min_voltage) / (max_voltage - min_voltage)); |
97 | uint8_t percent = (100 * (voltage - min_voltage) / (max_voltage - min_voltage)); |
97 | if (percent > 100) percent = 100; |
98 | if (percent > 100) percent = 100; |
98 | if (voltage < min_voltage) percent = 0; |
99 | if (voltage < min_voltage) percent = 0; |
99 | write_char_xy(x, y, 0x9d - (percent * 13 / 100)); |
100 | write_char_xy(x, y, 0x9d - (percent * 13 / 100)); |
Line 100... | Line 101... | ||
100 | //write_ndigit_number_u(x, y-1, percent * 13 / 100, 100, 0); |
101 | //write_ndigit_number_u(x, y-1, percent * 13 / 100, 100, 0); |
101 | } |
102 | } |
102 | 103 | ||
- | 104 | /* ########################################################################## |
|
103 | /* ########################################################################## |
105 | * variometer |
104 | * variometer |
106 | * ##########################################################################*/ |
105 | * ##########################################################################*/ |
107 | |
106 | /** |
108 | /** |
107 | * draw variometer arrows at <x>/<y> according to <variometer> |
109 | * draw variometer arrows at <x>/<y> according to <variometer> |
108 | */ |
110 | */ |
109 | void draw_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
111 | void draw_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
110 | if (variometer == 0) { |
112 | if (variometer == 0) { |
111 | write_char_xy(x, y, 0xbb); // plain line |
113 | write_char_xy(x, y, 0xbb); // plain line |
112 | } else if (variometer > 0) { // gain height |
114 | } else if (variometer > 0) { // gain height |
113 | switch (variometer / 5){ |
115 | switch (variometer / 5) { |
114 | case 0: |
116 | case 0: |
115 | //write_char_xy(x, y, 0xba); // smallest arrow up |
117 | //write_char_xy(x, y, 0xba); // smallest arrow up |
116 | write_char_xy(x, y, 0x70); // one arrow up |
118 | write_char_xy(x, y, 0x70); // one arrow up |
117 | break; |
119 | break; |
118 | case 1: |
120 | case 1: |
119 | //write_char_xy(x, y, 0xb9); // small arrow up |
121 | //write_char_xy(x, y, 0xb9); // small arrow up |
120 | write_char_xy(x, y, 0x71); // two arrows up |
122 | write_char_xy(x, y, 0x71); // two arrows up |
121 | break; |
123 | break; |
122 | case 2: |
124 | case 2: |
123 | //write_char_xy(x, y, 0xb8); // large arrow up |
125 | //write_char_xy(x, y, 0xb8); // large arrow up |
124 | write_char_xy(x, y, 0x72); // three arrows up |
126 | write_char_xy(x, y, 0x72); // three arrows up |
125 | break; |
127 | break; |
126 | default: |
128 | default: |
127 | //write_char_xy(x, y, 0xb7); // largest arrow up |
129 | //write_char_xy(x, y, 0xb7); // largest arrow up |
128 | write_char_xy(x, y, 0x73); // three black arrows up |
130 | write_char_xy(x, y, 0x73); // three black arrows up |
129 | } |
131 | } |
130 | } else { // sink |
132 | } else { // sink |
131 | switch (variometer / -5){ |
133 | switch (variometer / -5) { |
132 | case 0: |
134 | case 0: |
133 | //write_char_xy(x, y, 0xbc); // smallest arrow down |
135 | //write_char_xy(x, y, 0xbc); // smallest arrow down |
134 | write_char_xy(x, y, 0x77); // one arrow down |
136 | write_char_xy(x, y, 0x77); // one arrow down |
135 | break; |
137 | break; |
136 | case 1: |
138 | case 1: |
137 | //write_char_xy(x, y, 0xbd); // small arrow down |
139 | //write_char_xy(x, y, 0xbd); // small arrow down |
138 | write_char_xy(x, y, 0x76); // two arrows down |
140 | write_char_xy(x, y, 0x76); // two arrows down |
139 | break; |
141 | break; |
140 | case 2: |
142 | case 2: |
141 | //write_char_xy(x, y, 0xbe); // large arrow down |
143 | //write_char_xy(x, y, 0xbe); // large arrow down |
142 | write_char_xy(x, y, 0x75); // three arrows down |
144 | write_char_xy(x, y, 0x75); // three arrows down |
143 | break; |
145 | break; |
144 | default: |
146 | default: |
145 | //write_char_xy(x, y, 0xbf); // largest arrow down |
147 | //write_char_xy(x, y, 0xbf); // largest arrow down |
146 | write_char_xy(x, y, 0x74); // three black arrows down |
148 | write_char_xy(x, y, 0x74); // three black arrows down |
Line 147... | Line 149... | ||
147 | } |
149 | } |
148 | } |
150 | } |
149 | } |
151 | } |
Line 162... | Line 164... | ||
162 | const char vario_10[5] PROGMEM = {0x00, 0xc5, 0xc3, 0x00, 0x00}; |
164 | const char vario_10[5] PROGMEM = {0x00, 0xc5, 0xc3, 0x00, 0x00}; |
163 | const char vario_11[5] PROGMEM = {0x00, 0xff, 0xc3, 0x00, 0x00}; |
165 | const char vario_11[5] PROGMEM = {0x00, 0xff, 0xc3, 0x00, 0x00}; |
164 | const char vario_12[5] PROGMEM = {0xc4, 0xff, 0xc3, 0x00, 0x00}; |
166 | const char vario_12[5] PROGMEM = {0xc4, 0xff, 0xc3, 0x00, 0x00}; |
165 | const char vario_13[5] PROGMEM = {0xc5, 0xff, 0xc3, 0x00, 0x00}; |
167 | const char vario_13[5] PROGMEM = {0xc5, 0xff, 0xc3, 0x00, 0x00}; |
166 | const char vario_14[5] PROGMEM = {0xff, 0xff, 0xc3, 0x00, 0x00}; |
168 | const char vario_14[5] PROGMEM = {0xff, 0xff, 0xc3, 0x00, 0x00}; |
167 | const char* vario_pnt[15] PROGMEM = {vario_00, vario_01, vario_02, vario_03, vario_04, |
169 | const char* vario_pnt[15] PROGMEM = {vario_00, vario_01, vario_02, vario_03, vario_04, |
168 | vario_05, vario_06, vario_07, vario_08, |
170 | vario_05, vario_06, vario_07, vario_08, |
169 | vario_09, vario_10, vario_11, vario_12, |
171 | vario_09, vario_10, vario_11, vario_12, |
170 | vario_13, vario_14}; |
172 | vario_13, vario_14}; |
Line 171... | Line 173... | ||
171 | 173 | ||
172 | /** |
174 | /** |
173 | * draw a bigger vario with middle at <x>/<y> acording to <variometer> |
175 | * draw a bigger vario with middle at <x>/<y> acording to <variometer> |
174 | */ |
176 | */ |
175 | void draw_big_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
177 | void draw_big_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
176 | int16_t index = 7 + variometer; |
178 | int16_t index = 7 + variometer; |
177 | if (index > 14) index = 14; |
179 | if (index > 14) index = 14; |
178 | else if (index < 0) index = 0; |
180 | else if (index < 0) index = 0; |
179 | 181 | ||
180 | write_string_pgm_down(x, y-2, (const char *) (pgm_read_word ( &(vario_pnt[index]))), 5); |
182 | write_string_pgm_down(x, y - 2, (const char *)(pgm_read_word(&(vario_pnt[index]))), 5); |
Line 181... | Line 183... | ||
181 | } |
183 | } |
182 | 184 | ||
183 | /* ########################################################################## |
185 | /* ########################################################################## |
184 | * NEW artificial horizon By AGRESSiVA --=-- COPTERTRONiC |
186 | * NEW artificial horizon By AGRESSiVA --=-- COPTERTRONiC |
- | 187 | * ##########################################################################*/ |
|
185 | * ##########################################################################*/ |
188 | // draw routine |
186 | // draw routine |
189 | |
187 | int draw_noodles(int8_t pos_x, int8_t pos_y, int8_t num, int8_t old_num) { |
190 | int draw_noodles(int8_t pos_x, int8_t pos_y, int8_t num, int8_t old_num) { |
188 | const char noodle[5] = {0x78, 0x79, 0x7A, 0x7B, 0x7C}; |
191 | const char noodle[5] = {0x78, 0x79, 0x7A, 0x7B, 0x7C}; |
189 | int8_t line, car; |
192 | int8_t line, car; |
190 | 193 | ||
191 | line = num / 5; |
194 | line = num / 5; |
192 | car = num - (line * 5); |
195 | car = num - (line * 5); |
193 | if (num != old_num) { |
196 | if (num != old_num) { |
Line -... | Line 197... | ||
- | 197 | write_char_xy(15 - pos_x, pos_y + (old_num), 0); |
|
- | 198 | } |
|
- | 199 | ||
- | 200 | if (num < 0) { |
|
194 | write_char_xy(15 - pos_x , pos_y + (old_num), 0); |
201 | car = -1 * car; |
- | 202 | car = 4 - car; |
|
195 | } |
203 | line--; |
Line 196... | Line 204... | ||
196 | 204 | num = num - 5; |
|
197 | if (num < 0) {car = -1* car; car = 4 - car; line--; num = num - 5;} |
205 | } |
Line 198... | Line 206... | ||
198 | write_char_xy(15 - pos_x , pos_y + line, noodle[car]); |
206 | write_char_xy(15 - pos_x, pos_y + line, noodle[car]); |
199 | 207 | ||
200 | return line; |
208 | return line; |
201 | } |
209 | } |
202 | 210 | ||
203 | /** |
211 | /** |
204 | * calculate the rails of artificial horizon |
212 | * calculate the rails of artificial horizon |
205 | * receive <nick> and <roll> values |
213 | * receive <nick> and <roll> values |
206 | */ |
214 | */ |
207 | void draw_agressiva_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
215 | void draw_agressiva_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
208 | static int8_t old_ticy = 1,old_ticx = 0; |
216 | static int8_t old_ticy = 1, old_ticx = 0; |
209 | static int8_t old1 = 0,old2 = 0,old3 = 0,old4, old5 = 0, old6 = 0,old7 = 0,old8 = 0; |
217 | static int8_t old1 = 0, old2 = 0, old3 = 0, old4, old5 = 0, old6 = 0, old7 = 0, old8 = 0; |
210 | int8_t ticy = 0, ticx = 0; |
218 | int8_t ticy = 0, ticx = 0; |
Line 211... | Line 219... | ||
211 | uint8_t center_x = 15; |
219 | uint8_t center_x = 15; |
212 | uint8_t center_y = lastline - firstline; |
220 | uint8_t center_y = lastline - firstline; |
213 | center_y = 7; |
221 | center_y = 7; |
214 | write_char_xy(center_x - 7 ,center_y,226); // left bar |
222 | write_char_xy(center_x - 7, center_y, 226); // left bar |
215 | write_char_xy(center_x + 6 ,center_y,226); // right bar |
223 | write_char_xy(center_x + 6, center_y, 226); // right bar |
216 | 224 | ||
217 | 225 | ||
Line 218... | Line 226... | ||
218 | #if FCONLY |
226 | #if FCONLY |
219 | ticy = -1*(roll / 10); // rescale roll from FC debug data |
227 | ticy = -1 * (roll / 10); // rescale roll from FC debug data |
Line 220... | Line 228... | ||
220 | ticx = -1*(nick * 10); // rescale nick from FC debug data |
228 | ticx = -1 * (nick * 10); // rescale nick from FC debug data |
221 | #else |
229 | #else |
Line 222... | Line 230... | ||
222 | ticy = -1*(roll / 2); |
230 | ticy = -1 * (roll / 2); |
223 | ticx = -1*(nick / 1); |
231 | ticx = -1 * (nick / 1); |
224 | #endif |
232 | #endif |
225 | 233 | ||
226 | if (ticy >= 30) ticy = 30; // limit y |
234 | if (ticy >= 30) ticy = 30; // limit y |
227 | if (ticx >= 30) ticx = 30; // limit x |
235 | if (ticx >= 30) ticx = 30; // limit x |
228 | 236 | ||
229 | //write_ndigit_number_u (0 , 5 , ticy ,3, 1); |
237 | //write_ndigit_number_u (0 , 5 , ticy ,3, 1); |
230 | //write_ndigit_number_u (0 , 6 , ticx ,3, 1); |
238 | //write_ndigit_number_u (0 , 6 , ticx ,3, 1); |
231 | 239 | ||
232 | //if ((ticy != old_ticy) || (ticx != old_ticx)) { |
240 | //if ((ticy != old_ticy) || (ticx != old_ticx)) { |
233 | old1 = draw_noodles( 4, 3, (ticy / 2) + 20 + ticx, old1); |
241 | old1 = draw_noodles(4, 3, (ticy / 2) + 20 + ticx, old1); |
234 | old2 = draw_noodles( 3, 3, (ticy / 3) + 20 + ticx, old2); |
242 | old2 = draw_noodles(3, 3, (ticy / 3) + 20 + ticx, old2); |
235 | old3 = draw_noodles( 2, 3, (ticy / 6) + 20 + ticx, old3); |
243 | old3 = draw_noodles(2, 3, (ticy / 6) + 20 + ticx, old3); |
Line 236... | Line 244... | ||
236 | old4 = draw_noodles( 1, 3, (ticy / 14) + 20 + ticx, old4); |
244 | old4 = draw_noodles(1, 3, (ticy / 14) + 20 + ticx, old4); |
237 | old5 = draw_noodles( - 3, 3, -(ticy / 2) + 20 + ticx, old5); |
245 | old5 = draw_noodles(-3, 3, -(ticy / 2) + 20 + ticx, old5); |
Line 255... | Line 263... | ||
255 | /** |
263 | /** |
256 | * draw roll und nick indicators (could be enhanced to full artificial horizon) |
264 | * draw roll und nick indicators (could be enhanced to full artificial horizon) |
257 | * from line <firstline> to <listlines> for given <nick> and <roll> values |
265 | * from line <firstline> to <listlines> for given <nick> and <roll> values |
258 | */ |
266 | */ |
259 | void draw_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
267 | void draw_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
260 | const char noodle[5] = {225, 225, 226, 227, 227}; |
268 | const char noodle[5] = {225, 225, 226, 227, 227}; |
261 | uint8_t center_x = 15; |
269 | uint8_t center_x = 15; |
262 | uint8_t center_y = lastline - firstline; |
270 | uint8_t center_y = lastline - firstline; |
263 | center_y = 7; |
271 | center_y = 7; |
264 | write_char_xy(center_x,center_y,228); |
272 | write_char_xy(center_x, center_y, 228); |
265 | uint8_t cpos, nicky, rollx; |
273 | uint8_t cpos, nicky, rollx; |
266 | 274 | ||
267 | // which line |
275 | // which line |
268 | int8_t ypos = nick / 20; |
276 | int8_t ypos = nick / 20; |
269 | // which character from the array? |
277 | // which character from the array? |
270 | if (nick < 0) { |
278 | if (nick < 0) { |
271 | cpos = -1*((nick - (ypos * 20))/4); |
279 | cpos = -1 * ((nick - (ypos * 20)) / 4); |
272 | ypos--; |
280 | ypos--; |
273 | } else cpos = 4-((nick - (ypos * 20))/4); |
281 | } else cpos = 4 - ((nick - (ypos * 20)) / 4); |
274 | if (cpos > 4) cpos = 4; |
282 | if (cpos > 4) cpos = 4; |
275 | 283 | ||
276 | nicky = center_y - ypos; |
284 | nicky = center_y - ypos; |
277 | if (nicky > lastline) nicky = lastline; |
285 | if (nicky > lastline) nicky = lastline; |
278 | else if (nicky < firstline) nicky = firstline; |
286 | else if (nicky < firstline) nicky = firstline; |
279 | 287 | ||
280 | // ensure roll-borders |
288 | // ensure roll-borders |
281 | rollx = (roll / 8)+15; |
289 | rollx = (roll / 8) + 15; |
282 | if (rollx < 2) rollx = 2; |
290 | if (rollx < 2) rollx = 2; |
283 | else if (rollx > 28) rollx = 28; |
291 | else if (rollx > 28) rollx = 28; |
284 | 292 | ||
285 | 293 | ||
286 | // clear roll |
294 | // clear roll |
287 | if (old_af_x != rollx && old_af_x >= 0) { |
295 | if (old_af_x != rollx && old_af_x >= 0) { |
288 | write_char_xy(old_af_x, lastline, 0); |
296 | write_char_xy(old_af_x, lastline, 0); |
289 | } |
297 | } |
290 | 298 | ||
291 | // clear nick |
299 | // clear nick |
292 | if (old_af_y != nicky && old_af_y >= 0) { |
300 | if (old_af_y != nicky && old_af_y >= 0) { |
293 | write_char_xy(center_x-1, old_af_y, 0); |
301 | write_char_xy(center_x - 1, old_af_y, 0); |
294 | write_char_xy(center_x+1, old_af_y, 0); |
302 | write_char_xy(center_x + 1, old_af_y, 0); |
295 | } |
303 | } |
296 | 304 | ||
297 | 305 | ||
298 | // draw nick |
306 | // draw nick |
299 | write_char_xy(center_x-1, nicky, noodle[cpos]); |
307 | write_char_xy(center_x - 1, nicky, noodle[cpos]); |
300 | write_char_xy(center_x+1, nicky, noodle[cpos]); |
308 | write_char_xy(center_x + 1, nicky, noodle[cpos]); |
301 | 309 | ||
302 | // draw roll |
310 | // draw roll |
303 | write_char_xy(rollx, lastline, 229); |
311 | write_char_xy(rollx, lastline, 229); |
304 | 312 | ||
305 | // update old vars |
313 | // update old vars |
306 | old_af_x = rollx; |
314 | old_af_x = rollx; |
307 | old_af_y = nicky; |
315 | old_af_y = nicky; |
308 | } |
316 | } |
Line 309... | Line 317... | ||
309 | 317 |