Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 752 → Rev 753

/C-OSD/trunk/osd_helpers.c
180,9 → 180,77
write_string_pgm_down(x, y-2, (const char *) (pgm_read_word ( &(vario_pnt[index]))), 5);
}
 
#if (NEW_ARTHORIZON == 1)
/* ##########################################################################
* artificial horizon
* NEW artificial horizon By AGRESSiVA --=-- COPTERTRONiC
* ##########################################################################*/
// draw routine
int draw_noodles(int8_t pos_x, int8_t pos_y, int8_t num, int8_t old_num) {
char noodle[5] = {0x78, 0x79, 0x7A, 0x7B, 0x7C};
int8_t line,car;
line = num / 5;
car = num - (line * 5);
if (num != old_num) {
write_char_xy(15 - pos_x , pos_y + (old_num), 0);
}
 
if (num < 0) {car = -1* car; car = 4 - car; line--; num = num - 5;}
write_char_xy(15 - pos_x , pos_y + line, noodle[car]);
 
return line;
}
 
/**
* calculate the rails of artificial horizon
* receive <nick> and <roll> values
*/
void draw_artificial_horizon(uint8_t firstline, uint8_t lastline, int16_t nick, int16_t roll) {
static int8_t old_ticy = 1,old_ticx = 0;
static int8_t old1 = 0,old2 = 0,old3 = 0,old4, old5 = 0, old6 = 0,old7 = 0,old8 = 0;
int8_t ticy = 0, ticx = 0;
uint8_t center_x = 15;
uint8_t center_y = lastline - firstline;
center_y = 7;
write_char_xy(center_x - 7 ,center_y,226);
write_char_xy(center_x + 6 ,center_y,226);
 
 
#if FCONLY
ticy = -1*(roll / 10); // rescale roll from FC debug data
ticx = -1*(nick * 10); // rescale nick from FC debug data
#else
ticy = -1*(roll / 2);
ticx = -1*(nick / 1);
#endif
 
if (ticy >= 30) ticy = 30; // limit y
if (ticx >= 30) ticx = 30; // limit x
 
//write_ndigit_number_u (0 , 5 , ticy ,3, 1);
//write_ndigit_number_u (0 , 6 , ticx ,3, 1);
 
if ((ticy != old_ticy) || (ticx != old_ticx)) {
old1 = draw_noodles( 4, 3, (ticy / 2) + 20 + ticx, old1);
old2 = draw_noodles( 3, 3, (ticy / 3) + 20 + ticx, old2);
old3 = draw_noodles( 2, 3, (ticy / 6) + 20 + ticx, old3);
old4 = draw_noodles( 1, 3, (ticy / 14) + 20 + ticx, old4);
old5 = draw_noodles( - 3, 3, -(ticy / 2) + 20 + ticx, old5);
old6 = draw_noodles( - 2, 3, -(ticy / 3) + 20 + ticx, old6);
old7 = draw_noodles( - 1, 3, -(ticy / 6) + 20 + ticx, old7);
old8 = draw_noodles( 0, 3, -(ticy / 14) + 20 + ticx, old8);
}
// update old vars
old_ticy = ticy;
old_ticx = ticx;
}
 
#else
 
/* ##########################################################################
* OLD artificial horizon
* ##########################################################################*/
 
// remember last time displayed values
int8_t old_af_x = -1, old_af_y = -1;
 
239,12 → 307,8
// update old vars
old_af_x = rollx;
old_af_y = nicky;
 
// debug numbers
//write_3digit_number_u(20,6,cpos);
//write_number_s(20,7,ypos);
//write_number_s(0,7,nick);
//write_number_s(18,11,roll);
}
 
#endif
 
#endif