void uartt(){
while(uart_rd[i] != '\0')
{
if(uart_rd[i] == ',')
{
t++;
aid[t]=i+1;
for (k=0;k<i-debut;k++){
//printf("maTab[%d]=%c \n",debut+k,car[debut+k]);
maTab[j]=uart_rd[debut+k];
j++;
}
debut = i+1;
}
i++;
}
aid[0]=0;
h=0;
j=1;
for (i=0;i<aid[j]-aid[j-1]-1;i++){
chaine1[i]=maTab[aid[j-1]+i-h];
}
chaine1[i]='\0';
h++;
j=2;
for (i=0;i<aid[j]-aid[j-1]-1;i++){
chaine2[i]=maTab[aid[j-1]+i-h];
}
chaine2[i+1]='\0';
h++;
j=3;
Mylat=atof(chaine2);
FloatToStr(Mylat,chaine2);
Lcd_Out(1, 1,"Longitude");
Lcd_Out(2,1 ,chaine2);
delay_ms(7000);
}
void main()
{
LATB = 0xFF;
TRISB = 0xff;
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7; // Disable comparators
TRISA = 0x00; // set direction to be output
TRISB=0;
PORTB=0;
// TRISC=0;
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Start");
UART1_Write(10);
UART1_Write(13);
//PORTC=0;
Keypad_Init(); // Initialize Keypad
Lcd_Init();
// Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
do { // Endless loop
if (UART1_Data_Ready()) {
UART1_Read_Text(uart_rd, ',',70);
Lcd_Cmd(_LCD_CLEAR);
uartt();
}
}while(1);
}