Rev 1593 | Rev 1866 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1593 | Rev 1773 | ||
---|---|---|---|
1 | /**************************************************************************** |
1 | /**************************************************************************** |
2 | * Copyright (C) 2009-2012 by Claas Anders "CaScAdE" Rathje * |
2 | * Copyright (C) 2009-2012 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 * |
8 | * the Free Software Foundation; either version 2 of the License. * |
8 | * the Free Software Foundation; either version 2 of the License. * |
9 | * * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
13 | * GNU General Public License for more details. * |
14 | * * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ****************************************************************************/ |
19 | ****************************************************************************/ |
20 | 20 | ||
21 | #include "main.h" |
21 | #include "main.h" |
22 | #include <avr/pgmspace.h> |
22 | #include <avr/pgmspace.h> |
23 | #include "osd_helpers.h" |
23 | #include "osd_helpers.h" |
24 | #include "max7456_software_spi.h" |
24 | #include "max7456_software_spi.h" |
25 | 25 | ||
26 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
26 | #if !(ALLCHARSDEBUG|(WRITECHARS != -1)) |
27 | 27 | ||
28 | /* ########################################################################## |
28 | /* ########################################################################## |
29 | * compass stuff |
29 | * compass stuff |
30 | * ##########################################################################*/ |
30 | * ##########################################################################*/ |
31 | 31 | ||
32 | /** |
32 | /** |
33 | * convert the <heading> gotton from NC into an index |
33 | * convert the <heading> gotton from NC into an index |
34 | */ |
34 | */ |
35 | uint8_t heading_conv(uint16_t heading) { |
35 | uint8_t heading_conv(uint16_t heading) { |
36 | if (heading > 23 && heading < 68) { |
36 | if (heading > 23 && heading < 68) { |
37 | //direction = "NE"; |
37 | //direction = "NE"; |
38 | return 0; |
38 | return 0; |
39 | } else if (heading > 67 && heading < 113) { |
39 | } else if (heading > 67 && heading < 113) { |
40 | //direction = "E "; |
40 | //direction = "E "; |
41 | return 1; |
41 | return 1; |
42 | } else if (heading > 112 && heading < 158) { |
42 | } else if (heading > 112 && heading < 158) { |
43 | //direction = "SE"; |
43 | //direction = "SE"; |
44 | return 2; |
44 | return 2; |
45 | } else if (heading > 157 && heading < 203) { |
45 | } else if (heading > 157 && heading < 203) { |
46 | //direction = "S "; |
46 | //direction = "S "; |
47 | return 3; |
47 | return 3; |
48 | } else if (heading > 202 && heading < 248) { |
48 | } else if (heading > 202 && heading < 248) { |
49 | //direction = "SW"; |
49 | //direction = "SW"; |
50 | return 4; |
50 | return 4; |
51 | } else if (heading > 247 && heading < 293) { |
51 | } else if (heading > 247 && heading < 293) { |
52 | //direction = "W "; |
52 | //direction = "W "; |
53 | return 5; |
53 | return 5; |
54 | } else if (heading > 292 && heading < 338) { |
54 | } else if (heading > 292 && heading < 338) { |
55 | //direction = "NW"; |
55 | //direction = "NW"; |
56 | return 6; |
56 | return 6; |
57 | } |
57 | } |
58 | //direction = "N "; |
58 | //direction = "N "; |
59 | return 7; |
59 | return 7; |
60 | } |
60 | } |
61 | 61 | ||
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 | } |
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[] PROGMEM = {216, 215, 216, 211, 216, 215, 216, 213, 216, 215, 216, 212, |
76 | static const char rose[] 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 % 360) / 22); |
83 | uint8_t front = 19 + ((heading % 360) / 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 | } |
87 | } |
87 | } |
88 | 88 | ||
89 | /* ########################################################################## |
89 | /* ########################################################################## |
90 | * battery index |
90 | * battery index |
91 | * ##########################################################################*/ |
91 | * ##########################################################################*/ |
92 | 92 | ||
93 | /** |
93 | /** |
94 | * draw a battery symbol at <x>/<y> according to <voltage> |
94 | * draw a battery symbol at <x>/<y> according to <voltage> |
95 | */ |
95 | */ |
96 | 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) { |
97 | uint8_t percent = (100 * (voltage - min_voltage) / (max_voltage - min_voltage)); |
97 | uint8_t percent = (100 * (voltage - min_voltage) / (max_voltage - min_voltage)); |
98 | if (percent > 100) percent = 100; |
98 | if (percent > 100) percent = 100; |
99 | if (voltage < min_voltage) percent = 0; |
99 | if (voltage < min_voltage) percent = 0; |
100 | write_char_xy(x, y, 0x9d - (percent * 13 / 100)); |
100 | write_char_xy(x, y, 0x9d - (percent * 13 / 100)); |
101 | //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); |
102 | } |
102 | } |
103 | 103 | ||
104 | 104 | ||
105 | 105 | ||
106 | /* ########################################################################## |
106 | /* ########################################################################## |
107 | * draw logo |
107 | * draw logo |
108 | * ##########################################################################*/ |
108 | * ##########################################################################*/ |
109 | 109 | ||
110 | /** |
110 | /** |
111 | * draw the logo at <x>/<y> |
111 | * draw the logo at <x>/<y> |
112 | */ |
112 | */ |
113 | void draw_logo(uint8_t x, uint8_t y) { |
113 | void draw_logo(uint8_t x, uint8_t y) { |
114 | uint8_t chr = 0x50; |
114 | uint8_t chr = 0x50; |
115 | 115 | ||
116 | for (uint8_t yy = y; yy < y + 2; yy++) { |
116 | for (uint8_t yy = y; yy < y + 2; yy++) { |
117 | for (uint8_t xx = x; xx < x + 8; xx++) { |
117 | for (uint8_t xx = x; xx < x + 8; xx++) { |
118 | write_char_xy(xx, yy, chr++); |
118 | write_char_xy(xx, yy, chr++); |
119 | } |
119 | } |
120 | } |
120 | } |
121 | } |
121 | } |
122 | 122 | ||
123 | /* ########################################################################## |
123 | /* ########################################################################## |
124 | * variometer |
124 | * variometer |
125 | * ##########################################################################*/ |
125 | * ##########################################################################*/ |
126 | 126 | ||
127 | /** |
127 | /** |
128 | * draw variometer arrows at <x>/<y> according to <variometer> |
128 | * draw variometer arrows at <x>/<y> according to <variometer> |
129 | */ |
129 | */ |
130 | void draw_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
130 | void draw_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
131 | uint8_t chr = 0xbb; |
131 | uint8_t chr = 0xbb; |
132 | if (variometer > 0) { // gain height |
132 | if (variometer > 0) { // gain height |
133 | chr = 0x70 + (variometer / 5); |
133 | chr = 0x70 + (variometer / 5); |
134 | if (chr > 0x73) chr = 0x73; |
134 | if (chr > 0x73) chr = 0x73; |
135 | } else { // sink |
135 | } else { // sink |
136 | chr = 0x77 - (variometer / -5); |
136 | chr = 0x77 - (variometer / -5); |
137 | if (chr < 0x74) chr = 0x74; |
137 | if (chr < 0x74) chr = 0x74; |
138 | } |
138 | } |
139 | write_char_xy(x, y, chr); |
139 | write_char_xy(x, y, chr); |
140 | } |
140 | } |
- | 141 | ||
141 | 142 | ||
142 | // big vario arrays |
143 | // big vario array |
143 | const char vario_00[5] PROGMEM = {0x00, 0x00, 0xc2, 0xff, 0xff}; |
144 | const char vario_pnt[15][5] PROGMEM = { |
144 | const char vario_01[5] PROGMEM = {0x00, 0x00, 0xc2, 0xff, 0xc0}; |
145 | {0x00, 0x00, 0xc2, 0xff, 0xff}, |
145 | const char vario_02[5] PROGMEM = {0x00, 0x00, 0xc2, 0xff, 0xc1}; |
146 | {0x00, 0x00, 0xc2, 0xff, 0xc0}, |
146 | const char vario_03[5] PROGMEM = {0x00, 0x00, 0xc2, 0xff, 0x00}; |
147 | {0x00, 0x00, 0xc2, 0xff, 0xc1}, |
147 | const char vario_04[5] PROGMEM = {0x00, 0x00, 0xc2, 0xc0, 0x00}; |
148 | {0x00, 0x00, 0xc2, 0xff, 0x00}, |
148 | const char vario_05[5] PROGMEM = {0x00, 0x00, 0xc2, 0xc1, 0x00}; |
149 | {0x00, 0x00, 0xc2, 0xc0, 0x00}, |
149 | const char vario_06[5] PROGMEM = {0x00, 0x00, 0xc2, 0x00, 0x00}; |
150 | {0x00, 0x00, 0xc2, 0xc1, 0x00}, |
150 | const char vario_07[5] PROGMEM = {0x00, 0x00, 0xbb, 0x00, 0x00}; |
151 | {0x00, 0x00, 0xc2, 0x00, 0x00}, |
151 | const char vario_08[5] PROGMEM = {0x00, 0x00, 0xc3, 0x00, 0x00}; |
152 | {0x00, 0x00, 0xbb, 0x00, 0x00}, |
152 | const char vario_09[5] PROGMEM = {0x00, 0xc4, 0xc3, 0x00, 0x00}; |
153 | {0x00, 0x00, 0xc3, 0x00, 0x00}, |
153 | const char vario_10[5] PROGMEM = {0x00, 0xc5, 0xc3, 0x00, 0x00}; |
154 | {0x00, 0xc4, 0xc3, 0x00, 0x00}, |
154 | const char vario_11[5] PROGMEM = {0x00, 0xff, 0xc3, 0x00, 0x00}; |
155 | {0x00, 0xc5, 0xc3, 0x00, 0x00}, |
155 | const char vario_12[5] PROGMEM = {0xc4, 0xff, 0xc3, 0x00, 0x00}; |
156 | {0x00, 0xff, 0xc3, 0x00, 0x00}, |
156 | const char vario_13[5] PROGMEM = {0xc5, 0xff, 0xc3, 0x00, 0x00}; |
157 | {0xc4, 0xff, 0xc3, 0x00, 0x00}, |
157 | const char vario_14[5] PROGMEM = {0xff, 0xff, 0xc3, 0x00, 0x00}; |
- | |
158 | const char* vario_pnt[15] PROGMEM = {vario_00, vario_01, vario_02, vario_03, vario_04, |
158 | {0xc5, 0xff, 0xc3, 0x00, 0x00}, |
159 | vario_05, vario_06, vario_07, vario_08, |
- | |
160 | vario_09, vario_10, vario_11, vario_12, |
159 | {0xff, 0xff, 0xc3, 0x00, 0x00} |
161 | vario_13, vario_14}; |
160 | }; |
162 | 161 | ||
163 | /** |
162 | /** |
164 | * draw a bigger vario with middle at <x>/<y> acording to <variometer> |
163 | * draw a bigger vario with middle at <x>/<y> acording to <variometer> |
165 | */ |
164 | */ |
166 | void draw_big_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
165 | void draw_big_variometer(uint8_t x, uint8_t y, int16_t variometer) { |
167 | int16_t index = 7 + variometer; |
166 | int16_t index = 7 + variometer; |
168 | if (index > 14) index = 14; |
167 | if (index > 14) index = 14; |
169 | else if (index < 0) index = 0; |
168 | else if (index < 0) index = 0; |
170 | 169 | ||
171 | write_string_pgm_down(x, y - 2, (const char *)(pgm_read_word(&(vario_pnt[index]))), 5); |
170 | write_string_pgm_down(x, y - 2, vario_pnt[index], 5); |
172 | } |
171 | } |
173 | 172 | ||
174 | 173 | ||
175 | /* ########################################################################## |
174 | /* ########################################################################## |
176 | * NEW artificial horizon By AGRESSiVA --=-- COPTERTRONiC |
175 | * NEW artificial horizon By AGRESSiVA --=-- COPTERTRONiC |
177 | * ##########################################################################*/ |
176 | * ##########################################################################*/ |
178 | // draw routine |
177 | // draw routine |
179 | 178 | ||
180 | int draw_noodles(int8_t pos_x, int8_t pos_y, int8_t num, int8_t old_num) { |
179 | int draw_noodles(int8_t pos_x, int8_t pos_y, int8_t num, int8_t old_num) { |
181 | const char noodle[5] = {0x78, 0x79, 0x7A, 0x7B, 0x7C}; |
180 | const char noodle[5] = {0x78, 0x79, 0x7A, 0x7B, 0x7C}; |
182 | int8_t line, car; |
181 | int8_t line, car; |
183 | 182 | ||
184 | line = num / 5; |
183 | line = num / 5; |
185 | car = num - (line * 5); |
184 | car = num - (line * 5); |
186 | if (num != old_num) { |
185 | if (num != old_num) { |
187 | write_char_xy(15 - pos_x, pos_y + (old_num), 0); |
186 | write_char_xy(15 - pos_x, pos_y + (old_num), 0); |
188 | } |
187 | } |
189 | 188 | ||
190 | if (num < 0) { |
189 | if (num < 0) { |
191 | car = -1 * car; |
190 | car = -1 * car; |
192 | car = 4 - car; |
191 | car = 4 - car; |
193 | line--; |
192 | line--; |
194 | num = num - 5; |
193 | num = num - 5; |
195 | } |
194 | } |
196 | write_char_xy(15 - pos_x, pos_y + line, noodle[car]); |
195 | write_char_xy(15 - pos_x, pos_y + line, noodle[car]); |
197 | 196 | ||
198 | return line; |
197 | return line; |
199 | } |
198 | } |
200 | 199 | ||
201 | /** |
200 | /** |
202 | * calculate the rails of artificial horizon |
201 | * calculate the rails of artificial horizon |
203 | * receive <nick> and <roll> values |
202 | * receive <nick> and <roll> values |
204 | */ |
203 | */ |
205 | void draw_agressiva_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
204 | void draw_agressiva_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
206 | static int8_t old_ticy = 1, old_ticx = 0; |
205 | static int8_t old_ticy = 1, old_ticx = 0; |
207 | static int8_t old1 = 0, old2 = 0, old3 = 0, old4, old5 = 0, old6 = 0, old7 = 0, old8 = 0; |
206 | static int8_t old1 = 0, old2 = 0, old3 = 0, old4, old5 = 0, old6 = 0, old7 = 0, old8 = 0; |
208 | int8_t ticy = 0, ticx = 0; |
207 | int8_t ticy = 0, ticx = 0; |
209 | uint8_t center_x = 15; |
208 | uint8_t center_x = 15; |
210 | uint8_t center_y = lastline - firstline; |
209 | uint8_t center_y = lastline - firstline; |
211 | center_y = 7; |
210 | center_y = 7; |
212 | write_char_xy(center_x - 7, center_y, 226); // left bar |
211 | write_char_xy(center_x - 7, center_y, 226); // left bar |
213 | write_char_xy(center_x + 6, center_y, 226); // right bar |
212 | write_char_xy(center_x + 6, center_y, 226); // right bar |
214 | 213 | ||
215 | 214 | ||
216 | #if FCONLY |
215 | #if FCONLY |
217 | ticy = -1 * (roll / 10); // rescale roll from FC debug data |
216 | ticy = -1 * (roll / 10); // rescale roll from FC debug data |
218 | ticx = -1 * (nick * 10); // rescale nick from FC debug data |
217 | ticx = -1 * (nick * 10); // rescale nick from FC debug data |
219 | #else |
218 | #else |
220 | ticy = -1 * (roll / 2); |
219 | ticy = -1 * (roll / 2); |
221 | ticx = -1 * (nick / 1); |
220 | ticx = -1 * (nick / 1); |
222 | #endif |
221 | #endif |
223 | 222 | ||
224 | if (ticy >= 30) ticy = 30; // limit y |
223 | if (ticy >= 30) ticy = 30; // limit y |
225 | if (ticx >= 30) ticx = 30; // limit x |
224 | if (ticx >= 30) ticx = 30; // limit x |
226 | 225 | ||
227 | //write_ndigit_number_u (0 , 5 , ticy ,3, 1); |
226 | //write_ndigit_number_u (0 , 5 , ticy ,3, 1); |
228 | //write_ndigit_number_u (0 , 6 , ticx ,3, 1); |
227 | //write_ndigit_number_u (0 , 6 , ticx ,3, 1); |
229 | 228 | ||
230 | //if ((ticy != old_ticy) || (ticx != old_ticx)) { |
229 | //if ((ticy != old_ticy) || (ticx != old_ticx)) { |
231 | old1 = draw_noodles(4, 3, (ticy / 2) + 20 + ticx, old1); |
230 | old1 = draw_noodles(4, 3, (ticy / 2) + 20 + ticx, old1); |
232 | old2 = draw_noodles(3, 3, (ticy / 3) + 20 + ticx, old2); |
231 | old2 = draw_noodles(3, 3, (ticy / 3) + 20 + ticx, old2); |
233 | old3 = draw_noodles(2, 3, (ticy / 6) + 20 + ticx, old3); |
232 | old3 = draw_noodles(2, 3, (ticy / 6) + 20 + ticx, old3); |
234 | old4 = draw_noodles(1, 3, (ticy / 14) + 20 + ticx, old4); |
233 | old4 = draw_noodles(1, 3, (ticy / 14) + 20 + ticx, old4); |
235 | old5 = draw_noodles(-3, 3, -(ticy / 2) + 20 + ticx, old5); |
234 | old5 = draw_noodles(-3, 3, -(ticy / 2) + 20 + ticx, old5); |
236 | old6 = draw_noodles(-2, 3, -(ticy / 3) + 20 + ticx, old6); |
235 | old6 = draw_noodles(-2, 3, -(ticy / 3) + 20 + ticx, old6); |
237 | old7 = draw_noodles(-1, 3, -(ticy / 6) + 20 + ticx, old7); |
236 | old7 = draw_noodles(-1, 3, -(ticy / 6) + 20 + ticx, old7); |
238 | old8 = draw_noodles(0, 3, -(ticy / 14) + 20 + ticx, old8); |
237 | old8 = draw_noodles(0, 3, -(ticy / 14) + 20 + ticx, old8); |
239 | //} |
238 | //} |
240 | // update old vars |
239 | // update old vars |
241 | old_ticy = ticy; |
240 | old_ticy = ticy; |
242 | old_ticx = ticx; |
241 | old_ticx = ticx; |
243 | } |
242 | } |
244 | 243 | ||
245 | 244 | ||
246 | /* ########################################################################## |
245 | /* ########################################################################## |
247 | * OLD artificial horizon |
246 | * OLD artificial horizon |
248 | * ##########################################################################*/ |
247 | * ##########################################################################*/ |
249 | 248 | ||
250 | // remember last time displayed values |
249 | // remember last time displayed values |
251 | int8_t old_af_x = -1, old_af_y = -1; |
250 | int8_t old_af_x = -1, old_af_y = -1; |
252 | 251 | ||
253 | /** |
252 | /** |
254 | * draw roll und nick indicators (could be enhanced to full artificial horizon) |
253 | * draw roll und nick indicators (could be enhanced to full artificial horizon) |
255 | * from line <firstline> to <listlines> for given <nick> and <roll> values |
254 | * from line <firstline> to <listlines> for given <nick> and <roll> values |
256 | */ |
255 | */ |
257 | void draw_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
256 | void draw_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
258 | const char noodle[5] = {225, 225, 226, 227, 227}; |
257 | const char noodle[5] = {225, 225, 226, 227, 227}; |
259 | uint8_t center_x = 15; |
258 | uint8_t center_x = 15; |
260 | uint8_t center_y = lastline - firstline; |
259 | uint8_t center_y = lastline - firstline; |
261 | center_y = 7; |
260 | center_y = 7; |
262 | write_char_xy(center_x, center_y, 228); |
261 | write_char_xy(center_x, center_y, 228); |
263 | uint8_t cpos, nicky, rollx; |
262 | uint8_t cpos, nicky, rollx; |
264 | 263 | ||
265 | // which line |
264 | // which line |
266 | int8_t ypos = nick / 20; |
265 | int8_t ypos = nick / 20; |
267 | // which character from the array? |
266 | // which character from the array? |
268 | if (nick < 0) { |
267 | if (nick < 0) { |
269 | cpos = -1 * ((nick - (ypos * 20)) / 4); |
268 | cpos = -1 * ((nick - (ypos * 20)) / 4); |
270 | ypos--; |
269 | ypos--; |
271 | } else cpos = 4 - ((nick - (ypos * 20)) / 4); |
270 | } else cpos = 4 - ((nick - (ypos * 20)) / 4); |
272 | if (cpos > 4) cpos = 4; |
271 | if (cpos > 4) cpos = 4; |
273 | 272 | ||
274 | nicky = center_y - ypos; |
273 | nicky = center_y - ypos; |
275 | if (nicky > lastline) nicky = lastline; |
274 | if (nicky > lastline) nicky = lastline; |
276 | else if (nicky < firstline) nicky = firstline; |
275 | else if (nicky < firstline) nicky = firstline; |
277 | 276 | ||
278 | // ensure roll-borders |
277 | // ensure roll-borders |
279 | rollx = (roll / 8) + 15; |
278 | rollx = (roll / 8) + 15; |
280 | if (rollx < 2) rollx = 2; |
279 | if (rollx < 2) rollx = 2; |
281 | else if (rollx > 28) rollx = 28; |
280 | else if (rollx > 28) rollx = 28; |
282 | 281 | ||
283 | 282 | ||
284 | // clear roll |
283 | // clear roll |
285 | if (old_af_x != rollx && old_af_x >= 0) { |
284 | if (old_af_x != rollx && old_af_x >= 0) { |
286 | write_char_xy(old_af_x, lastline, 0); |
285 | write_char_xy(old_af_x, lastline, 0); |
287 | } |
286 | } |
288 | 287 | ||
289 | // clear nick |
288 | // clear nick |
290 | if (old_af_y != nicky && old_af_y >= 0) { |
289 | if (old_af_y != nicky && old_af_y >= 0) { |
291 | write_char_xy(center_x - 1, old_af_y, 0); |
290 | write_char_xy(center_x - 1, old_af_y, 0); |
292 | write_char_xy(center_x + 1, old_af_y, 0); |
291 | write_char_xy(center_x + 1, old_af_y, 0); |
293 | } |
292 | } |
294 | 293 | ||
295 | 294 | ||
296 | // draw nick |
295 | // draw nick |
297 | write_char_xy(center_x - 1, nicky, noodle[cpos]); |
296 | write_char_xy(center_x - 1, nicky, noodle[cpos]); |
298 | write_char_xy(center_x + 1, nicky, noodle[cpos]); |
297 | write_char_xy(center_x + 1, nicky, noodle[cpos]); |
299 | 298 | ||
300 | // draw roll |
299 | // draw roll |
301 | write_char_xy(rollx, lastline, 229); |
300 | write_char_xy(rollx, lastline, 229); |
302 | 301 | ||
303 | // update old vars |
302 | // update old vars |
304 | old_af_x = rollx; |
303 | old_af_x = rollx; |
305 | old_af_y = nicky; |
304 | old_af_y = nicky; |
306 | } |
305 | } |
307 | 306 | ||
308 | /** |
307 | /** |
309 | * draw scope of a second camera |
308 | * draw scope of a second camera |
310 | */ |
309 | */ |
311 | void draw_scope() { |
310 | void draw_scope() { |
312 | /* |
311 | /* |
313 | write_char_xy(scope[0], scope[1], 0xEC); |
312 | write_char_xy(scope[0], scope[1], 0xEC); |
314 | write_char_xy(scope[2], scope[3], 0xED); |
313 | write_char_xy(scope[2], scope[3], 0xED); |
315 | write_char_xy(scope[4], scope[5], 0xEE); |
314 | write_char_xy(scope[4], scope[5], 0xEE); |
316 | write_char_xy(scope[6], scope[7], 0xEF); |
315 | write_char_xy(scope[6], scope[7], 0xEF); |
317 | */ |
316 | */ |
318 | // save 20 byte :) |
317 | // save 20 byte :) |
319 | for (int i = 0; i < 4; i++) { |
318 | for (int i = 0; i < 4; i++) { |
320 | write_char_xy( |
319 | write_char_xy( |
321 | scope[i * 3], |
320 | scope[i * 3], |
322 | scope[(i * 3) + 1], |
321 | scope[(i * 3) + 1], |
323 | 0xEC + i + (scope[(i * 3) + 2] * 4)); |
322 | 0xEC + i + (scope[(i * 3) + 2] * 4)); |
324 | } |
323 | } |
325 | } |
324 | } |
326 | 325 | ||
327 | /** |
326 | /** |
328 | * draw stats |
327 | * draw stats |
329 | */ |
328 | */ |
330 | void draw_stats() { |
329 | void draw_stats() { |
331 | #if FCONLY |
330 | #if FCONLY |
332 | #else |
331 | #else |
333 | uint8_t line = 3; |
332 | uint8_t line = 3; |
334 | write_ascii_string_pgm(1, line, PSTR("max Alt :")); // max Altitude |
333 | write_ascii_string_pgm(1, line, PSTR("max Alt :")); // max Altitude |
335 | write_ascii_string_pgm(1, ++line, PSTR("max Spd :")); // max Speed |
334 | write_ascii_string_pgm(1, ++line, PSTR("max Spd :")); // max Speed |
336 | write_ascii_string_pgm(1, ++line, PSTR("max Dist:")); // max Distance |
335 | write_ascii_string_pgm(1, ++line, PSTR("max Dist:")); // max Distance |
337 | 336 | ||
338 | draw_logo(19, 4); |
337 | draw_logo(19, 4); |
339 | 338 | ||
340 | if (COSD_FLAGS_CONFIG & COSD_FLAG_FEET) { |
339 | if (COSD_FLAGS_CONFIG & COSD_FLAG_FEET) { |
341 | write_ndigit_number_s(13, line - 2, max_Altimeter * 32 / 10, 4, 0); |
340 | write_ndigit_number_s(13, line - 2, max_Altimeter * 32 / 10, 4, 0); |
342 | write_char_xy(17, line - 2, 0x7E); // small feet ft |
341 | write_char_xy(17, line - 2, 0x7E); // small feet ft |
343 | write_ndigit_number_u(14, line - 1, (uint16_t)(((uint32_t)max_GroundSpeed * (uint32_t)279) / (uint32_t)12500), 3, 0); |
342 | write_ndigit_number_u(14, line - 1, (uint16_t)(((uint32_t)max_GroundSpeed * (uint32_t)279) / (uint32_t)12500), 3, 0); |
344 | write_char_xy(17, line - 1, 0x7D); // mp/h |
343 | write_char_xy(17, line - 1, 0x7D); // mp/h |
345 | write_ndigit_number_u(13, line - 0, max_Distance / 10 * 32 / 10, 4, 0); |
344 | write_ndigit_number_u(13, line - 0, max_Distance / 10 * 32 / 10, 4, 0); |
346 | write_char_xy(17, line - 0, 0x7E); // small feet ft |
345 | write_char_xy(17, line - 0, 0x7E); // small feet ft |
347 | } else { |
346 | } else { |
348 | write_ndigit_number_s(13, line - 2, max_Altimeter, 4, 0); |
347 | write_ndigit_number_s(13, line - 2, max_Altimeter, 4, 0); |
349 | write_char_xy(17, line - 2, 204); // small meters m |
348 | write_char_xy(17, line - 2, 204); // small meters m |
350 | write_ndigit_number_u(14, line - 1, (uint16_t)(((uint32_t)max_GroundSpeed * (uint32_t)9) / (uint32_t)250), 3, 0); |
349 | write_ndigit_number_u(14, line - 1, (uint16_t)(((uint32_t)max_GroundSpeed * (uint32_t)9) / (uint32_t)250), 3, 0); |
351 | write_char_xy(17, line - 1, 203); // km/h |
350 | write_char_xy(17, line - 1, 203); // km/h |
352 | write_ndigit_number_u(13, line - 0, max_Distance / 10, 4, 0); |
351 | write_ndigit_number_u(13, line - 0, max_Distance / 10, 4, 0); |
353 | write_char_xy(17, line - 0, 204); // small meters m |
352 | write_char_xy(17, line - 0, 204); // small meters m |
354 | } |
353 | } |
355 | 354 | ||
356 | write_ascii_string_pgm(1, ++line, PSTR("min Volt:")); // min voltage |
355 | write_ascii_string_pgm(1, ++line, PSTR("min Volt:")); // min voltage |
357 | write_ndigit_number_u_10th(13, line, min_UBat, 3, 0); |
356 | write_ndigit_number_u_10th(13, line, min_UBat, 3, 0); |
358 | write_char_xy(17, line, 0x9E); // small V |
357 | write_char_xy(17, line, 0x9E); // small V |
359 | if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) || (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) { |
358 | if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) || (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) { |
360 | write_ascii_string_pgm(1, ++line, PSTR("max curr:")); // ampere |
359 | write_ascii_string_pgm(1, ++line, PSTR("max curr:")); // ampere |
361 | write_ndigit_number_u_10th(13, line, max_ampere / 10, 3, 0); |
360 | write_ndigit_number_u_10th(13, line, max_ampere / 10, 3, 0); |
362 | write_char_xy(17, line, 0x9F); // small A |
361 | write_char_xy(17, line, 0x9F); // small A |
363 | 362 | ||
364 | // wasted mampere in this flight (will count up after landing) |
363 | // wasted mampere in this flight (will count up after landing) |
365 | if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) && !(COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) { |
364 | if ((COSD_FLAGS_RUNTIME & COSD_FLAG_STROMREC) && !(COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT)) { |
366 | write_ndigit_number_u(18, line, (ampere_wasted / 10) - wasted_ampere_offset, 5, 0); |
365 | write_ndigit_number_u(18, line, (ampere_wasted / 10) - wasted_ampere_offset, 5, 0); |
367 | } else if (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT) { |
366 | } else if (COSD_FLAGS_MODES & COSD_FLAG_FCCURRENT) { |
368 | 367 | ||
369 | write_ndigit_number_u(18, line, naviData.UsedCapacity - wasted_ampere_offset, 5, 0); |
368 | write_ndigit_number_u(18, line, naviData.UsedCapacity - wasted_ampere_offset, 5, 0); |
370 | } |
369 | } |
371 | 370 | ||
372 | write_char_xy(23, line, 0xB5); // mah |
371 | write_char_xy(23, line, 0xB5); // mah |
373 | } |
372 | } |
374 | write_ascii_string_pgm(1, ++line, PSTR("max Time:")); // max time |
373 | write_ascii_string_pgm(1, ++line, PSTR("max Time:")); // max time |
375 | write_time(11, line, max_FlyingTime); |
374 | write_time(11, line, max_FlyingTime); |
376 | write_char_xy(17, line, 210); // fly clock |
375 | write_char_xy(17, line, 210); // fly clock |
377 | write_ascii_string_pgm(1, ++line, PSTR("long :")); // longitude |
376 | write_ascii_string_pgm(1, ++line, PSTR("long :")); // longitude |
378 | write_gps_pos(11, line, naviData.CurrentPosition.Longitude); |
377 | write_gps_pos(11, line, naviData.CurrentPosition.Longitude); |
379 | write_ascii_string_pgm(1, ++line, PSTR("lat :")); // latitude |
378 | write_ascii_string_pgm(1, ++line, PSTR("lat :")); // latitude |
380 | write_gps_pos(11, line, naviData.CurrentPosition.Latitude); |
379 | write_gps_pos(11, line, naviData.CurrentPosition.Latitude); |
381 | #endif |
380 | #endif |
382 | } |
381 | } |
383 | 382 | ||
384 | #endif |
383 | #endif |
385 | 384 |