#include "obj.h" objectstruct objlist[ MAXOBJLIST + 1]; void clearObjList( void ) { unsigned int ct; ct = 0; while( ct < MAXOBJLIST ) { sprintf( objlist[ct].name , " %03u \0", ct ); sprintf( objlist[ct].ra , "+000:00:00\0"); sprintf( objlist[ct].dec , "+000:00:00\0"); ct++; } } // this is called by config // it avoids a complete download of // a complete new objectlist. void serialObjListDownload( void ) { char tmp[20]; clearObjList(); lcd_clear(); sprintf(tmp, "READY TO RECEIVE" ); lcd_puts(1,0,tmp); //starting interrupt, and other stuff //waiting till first stuff is received //then lcd_clear(); sprintf(tmp, "DOWNLOAD RUNNING" ); lcd_puts(1,0,tmp); //storing //at least lcd_clear(); sprintf(tmp, "DOWNLOAD READY" ); lcd_puts(1,0,tmp); wait_10ms(100); wait_10ms(100); } //subroutine for getObj //for choosing an object to get //prints only names of object int chooseListObject( void ) { unsigned char KEY; int y,_y,upd; KEY = 0; y = 0; _y = 0; upd = 1; while( KEY != KEY_EXIT ) { if( upd ) { lcd_clear(); lcd_puts(0,0,objlist[ y + 0 ].name); lcd_puts(1,0,objlist[ y + 1 ].name); lcd_puts(2,0,objlist[ y + 2 ].name); lcd_puts(3,0,objlist[ y + 3 ].name); upd = 0; } lcd_setcursor(_y,0); lcd_putchar( 'X' ); KEY = 0; while( KEY == 0 ){ KEY = readkey(); } if(KEY == KEY_DOWN ){ lcd_setcursor(_y,0); lcd_putchar(' '); _y++; if(_y > 3 ){ if( y < ( MAXOBJLIST - 4 ) ) { y++; upd = 1; } _y = 3; } continue; } if(KEY == KEY_UP ){ lcd_setcursor(_y,0); lcd_putchar(' '); if(_y > 0 ){ _y--; } else { if( y > 0 ){ y--; upd = 1; } _y = 0; } continue; } if( KEY == KEY_GUIDE ) { y = y + _y; return(y); } } return(-1); } void setObjListDegrees( int azalt, char * ho, char *ve) { char tmp1[20]; char tmp2[20]; long l1,l2,l3,l4,l5,l6; strcpy(tmp1,ho); strcpy(tmp2,ve); tmp1[4] = 0; tmp1[7] = 0; tmp2[4] = 0; tmp2[7] = 0; l1 = atol(&tmp1[1]); l2 = atol(&tmp1[5]); l3 = atol(&tmp1[8]); l4 = atol(&tmp2[1]); l5 = atol(&tmp2[5]); l6 = atol(&tmp2[8]); l1 = l1 * 3600; if(! azalt){ l1 = l1 * 15; } l2 = l2 * 60; l1 = l1 + l2 + l3; l1 = l1 * 10; if(tmp1[0] == '-'){ l1 = l1 * -1; } l4 = l4 * 3600; l5 = l5 * 60; l4 = l4 + l5 + l6; l4 = l4 * 10; if(tmp2[0] == '-'){ l4 = l4 * -1; } OBJ_ARC10_HO = l1; OBJ_ARC10_VE = l4; if(azalt){ OBJ_DEG_AZ = lArc10dDegrees( l1 ); OBJ_DEG_ALT = lArc10dDegrees( l4 ); } else { OBJ_DEG_RA = lArc10dHours( l1 ); OBJ_DEG_DEC = lArc10dDegrees( l4 ); } } unsigned char alphconvert( unsigned char KEY, unsigned char mode ) { unsigned char k; k = KEY; switch( mode ) { case 0: break; case 1: switch( KEY ) { case KEY_1: k = 'A'; break; case KEY_2: k = 'B'; break; case KEY_3: k = 'C'; break; case KEY_4: k = 'D'; break; case KEY_5: k = 'E'; break; case KEY_6: k = 'F'; break; case KEY_7: k = 'G'; break; case KEY_8: k = 'H'; break; case KEY_9: k = 'I'; break; case KEY_0: k = 'J'; break; } break; case 2: switch( KEY ) { case KEY_1: k = 'K'; break; case KEY_2: k = 'L'; break; case KEY_3: k = 'M'; break; case KEY_4: k = 'N'; break; case KEY_5: k = 'O'; break; case KEY_6: k = 'P'; break; case KEY_7: k = 'Q'; break; case KEY_8: k = 'R'; break; case KEY_9: k = 'S'; break; case KEY_0: k = 'T'; break; } break; case 3: switch( KEY ) { case KEY_1: k = 'U'; break; case KEY_2: k = 'V'; break; case KEY_3: k = 'W'; break; case KEY_4: k = 'X'; break; case KEY_5: k = 'Y'; break; case KEY_6: k = 'Z'; break; case KEY_7: k = '-'; break; case KEY_8: k = '+'; break; case KEY_9: k = '.'; break; case KEY_0: k = ' '; break; } break; } return( k ); } void editListObj( char *name, char *ra, char *dec ) { char tmp1[20]; char tmp2[20]; char tmp3[20]; unsigned char KEY,x,y,txt; strcpy( tmp1, name); strcpy( tmp2, ra); strcpy( tmp3, dec); lcd_on(2); lcd_clear(); KEY = 0; x = 1; y = 0; txt = 0; while(KEY != KEY_E ){ KEY = 0; lcd_puts(0,0,tmp1); lcd_puts(1,0,tmp2); lcd_puts(2,0,tmp3); lcd_setcursor(y,x); KEY = 0; while(! KEY ) { KEY = readkey(); } if( ( y == 0 ) && ( KEY == KEY_C ) ){ txt++; if(txt > 3 ){ txt = 0; } continue; } if(KEY == KEY_UP ){ if( y > 0 ){ y--; } x = 1; continue; } if(KEY == KEY_DOWN ){ if(y < 2 ){ y++; } x = 1; continue; } if(KEY == KEY_LEFT){ if(x > 0 ){ x--; } if( y > 0 ){ if(x == 4 ){ x--; } if(x == 7){ x--; } } else { if( x < 1){ x = 1; } } continue; } if( ( y > 0 ) && ( x == 0 )){ if( ( KEY >= KEY_0 ) || ( KEY <= KEY_9 ) ){ if( y == 1 ) { if(tmp2[x] == '+'){ tmp2[x] = '-'; } else { tmp2[x] = '+'; } } else { if(tmp3[x] == '+'){ tmp3[x] = '-'; } else { tmp3[x] = '+'; } } KEY = KEY_RIGHT; } } else { if( ( KEY >= KEY_0 ) && ( KEY <= KEY_9) ){ if( y == 0 ){ if( x > 0 ){ KEY = alphconvert( KEY, txt ); tmp1[x] = ( unsigned char )KEY; } else { x = 1; } } else { if( y == 1 ) { tmp2[x] = ( unsigned char )KEY; } if( y == 2 ) { tmp3[x] = ( unsigned char )KEY; } } KEY = KEY_RIGHT; } } if(KEY == KEY_RIGHT);{ x++; if( y > 0 ){ if(x == 4 ){ x++; } if(x == 7){ x++; } if(x > 9){ x--; } } else { if( x > 15){ x--; } } continue; } } strcpy( name, tmp1); strcpy( ra, tmp2); strcpy( dec, tmp3); } // this is called by scope // usr can choose an object from // objectlist void getListObj( void ) { int res; res = chooseListObject(); if( res < 0 ){ return; } setObjListDegrees( 0 , (char *)&objlist[res].ra[0] , (char *)&objlist[res].dec[0]); } // this is called by config // usr can choose an object from // objjectlist, and editing it. void setListObj( void ) { int res; res = chooseListObject(); if( res < 0 ){ return; } editListObj( (char *)&objlist[res].name[0], (char *)&objlist[res].ra[0], (char *)&objlist[res].dec[0] ); }