Hi all
I need to edit the hole part and the decimal part of a value stored as an int32_t ( GPS coordinates actually)
In my sketch I display the values with (Using Mega 2560)
String Create_Int32_t_String(int32_t Num) {
char buffer[32];
sprintf(buffer, "%s%ld.%04ld", Num < 0 ? "-" : "", abs(Num) / 10000, abs(Num) % 10000);
return String(buffer);
}
Which works really good
However I need the user to be able to change the GPS coordinates
So I have a function that includes
case 1:
int32_t Top_Part = abs(GPS_Display_Data.User_latitude) / 10000;
int32_t Lower_Part = abs(GPS_Display_Data.User_latitude) % 10000;
if (LCD_Cursor_Postion == 5) { // changing the hole number part
if (Increase == true) {
Top_Part++; // increase the upper part
if (Top_Part > 90) { Top_Part = 90; }
} else {
Top_Part--; // decrease the upper part
if (Top_Part < -90) { Top_Part = -90; }
}
} else { // changing the decimal number part
if (Increase == true) {
Lower_Part++; // increase the upper part
} else {
Lower_Part--; // decrease the lower part
}
}
GPS_Display_Data.User_latitude = Top_Part + Lower_Part;
Clear_LCD_Line(1);
LCD_4_Line.print("Lat : ");
LCD_4_Line.print(Create_Int32_t_String(GPS_Display_Data.User_latitude)); // display the GPS latitude after converting the new user latitude value to a string
break;
The problem I'm having is I do not seem to be able to work out how I do this correctly so I get a proper Latitude by adding the Top_Part to the Lower_Part-
ie - GPS_Display_Data.User_latitude = Top_Part + Lower_Part;
I know the problem is my lack of knowledge but if someone could point me in the right direction, but perhaps Ive got the hole function wrong
I would be very appreciative for any help given
Kind Regards Grant Brown