Rev 728 | Rev 758 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 728 | Rev 753 | ||
---|---|---|---|
Line 178... | Line 178... | ||
178 | else if (index < 0) index = 0; |
178 | else if (index < 0) index = 0; |
Line 179... | Line 179... | ||
179 | 179 | ||
180 | write_string_pgm_down(x, y-2, (const char *) (pgm_read_word ( &(vario_pnt[index]))), 5); |
180 | write_string_pgm_down(x, y-2, (const char *) (pgm_read_word ( &(vario_pnt[index]))), 5); |
Line -... | Line 181... | ||
- | 181 | } |
|
181 | } |
182 | |
182 | 183 | #if (NEW_ARTHORIZON == 1) |
|
183 | /* ########################################################################## |
184 | /* ########################################################################## |
- | 185 | * NEW artificial horizon By AGRESSiVA --=-- COPTERTRONiC |
|
- | 186 | * ##########################################################################*/ |
|
- | 187 | // draw routine |
|
- | 188 | int draw_noodles(int8_t pos_x, int8_t pos_y, int8_t num, int8_t old_num) { |
|
- | 189 | char noodle[5] = {0x78, 0x79, 0x7A, 0x7B, 0x7C}; |
|
- | 190 | int8_t line,car; |
|
- | 191 | ||
- | 192 | line = num / 5; |
|
- | 193 | car = num - (line * 5); |
|
- | 194 | if (num != old_num) { |
|
- | 195 | write_char_xy(15 - pos_x , pos_y + (old_num), 0); |
|
- | 196 | } |
|
- | 197 | ||
- | 198 | if (num < 0) {car = -1* car; car = 4 - car; line--; num = num - 5;} |
|
- | 199 | write_char_xy(15 - pos_x , pos_y + line, noodle[car]); |
|
- | 200 | ||
- | 201 | return line; |
|
- | 202 | } |
|
- | 203 | ||
- | 204 | /** |
|
- | 205 | * calculate the rails of artificial horizon |
|
- | 206 | * receive <nick> and <roll> values |
|
- | 207 | */ |
|
- | 208 | void draw_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) { |
|
- | 209 | static int8_t old_ticy = 1,old_ticx = 0; |
|
- | 210 | static int8_t old1 = 0,old2 = 0,old3 = 0,old4, old5 = 0, old6 = 0,old7 = 0,old8 = 0; |
|
- | 211 | int8_t ticy = 0, ticx = 0; |
|
- | 212 | uint8_t center_x = 15; |
|
- | 213 | uint8_t center_y = lastline - firstline; |
|
- | 214 | center_y = 7; |
|
- | 215 | write_char_xy(center_x - 7 ,center_y,226); |
|
- | 216 | write_char_xy(center_x + 6 ,center_y,226); |
|
- | 217 | ||
- | 218 | ||
- | 219 | #if FCONLY |
|
- | 220 | ticy = -1*(roll / 10); // rescale roll from FC debug data |
|
- | 221 | ticx = -1*(nick * 10); // rescale nick from FC debug data |
|
- | 222 | #else |
|
- | 223 | ticy = -1*(roll / 2); |
|
- | 224 | ticx = -1*(nick / 1); |
|
- | 225 | #endif |
|
- | 226 | ||
- | 227 | if (ticy >= 30) ticy = 30; // limit y |
|
- | 228 | if (ticx >= 30) ticx = 30; // limit x |
|
- | 229 | ||
- | 230 | //write_ndigit_number_u (0 , 5 , ticy ,3, 1); |
|
- | 231 | //write_ndigit_number_u (0 , 6 , ticx ,3, 1); |
|
- | 232 | ||
- | 233 | if ((ticy != old_ticy) || (ticx != old_ticx)) { |
|
- | 234 | old1 = draw_noodles( 4, 3, (ticy / 2) + 20 + ticx, old1); |
|
- | 235 | old2 = draw_noodles( 3, 3, (ticy / 3) + 20 + ticx, old2); |
|
- | 236 | old3 = draw_noodles( 2, 3, (ticy / 6) + 20 + ticx, old3); |
|
- | 237 | old4 = draw_noodles( 1, 3, (ticy / 14) + 20 + ticx, old4); |
|
- | 238 | old5 = draw_noodles( - 3, 3, -(ticy / 2) + 20 + ticx, old5); |
|
- | 239 | old6 = draw_noodles( - 2, 3, -(ticy / 3) + 20 + ticx, old6); |
|
- | 240 | old7 = draw_noodles( - 1, 3, -(ticy / 6) + 20 + ticx, old7); |
|
- | 241 | old8 = draw_noodles( 0, 3, -(ticy / 14) + 20 + ticx, old8); |
|
- | 242 | } |
|
- | 243 | // update old vars |
|
- | 244 | old_ticy = ticy; |
|
- | 245 | old_ticx = ticx; |
|
- | 246 | } |
|
- | 247 | ||
- | 248 | #else |
|
- | 249 | ||
- | 250 | /* ########################################################################## |
|
- | 251 | * OLD artificial horizon |
|
184 | * artificial horizon |
252 | * ##########################################################################*/ |
185 | * ##########################################################################*/ |
253 | |
Line 186... | Line 254... | ||
186 | // remember last time displayed values |
254 | // remember last time displayed values |
187 | int8_t old_af_x = -1, old_af_y = -1; |
255 | int8_t old_af_x = -1, old_af_y = -1; |
Line 237... | Line 305... | ||
237 | write_char_xy(rollx, lastline, 229); |
305 | write_char_xy(rollx, lastline, 229); |
Line 238... | Line 306... | ||
238 | 306 | ||
239 | // update old vars |
307 | // update old vars |
240 | old_af_x = rollx; |
308 | old_af_x = rollx; |
241 | old_af_y = nicky; |
- | |
242 | - | ||
243 | // debug numbers |
- | |
244 | //write_3digit_number_u(20,6,cpos); |
- | |
245 | //write_number_s(20,7,ypos); |
- | |
246 | //write_number_s(0,7,nick); |
- | |
247 | //write_number_s(18,11,roll); |
309 | old_af_y = nicky; |
Line 248... | Line 310... | ||
248 | } |
310 | } |
- | 311 | ||
- | 312 | #endif |