added toAprsFormat to convert decimal to DMS for lat and long

pull/93/head
alanbjohnston 5 years ago committed by GitHub
parent 1112b459a7
commit 7f4313bc0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,6 +83,7 @@ ax5043_conf_t hax5043;
ax25_conf_t hax25; ax25_conf_t hax25;
int twosToInt(int val, int len); int twosToInt(int val, int len);
float toAprsFormat(float input);
float rnd_float(double min, double max); float rnd_float(double min, double max);
void get_tlm(); void get_tlm();
void get_tlm_fox(); void get_tlm_fox();
@ -242,9 +243,15 @@ int main(int argc, char * argv[]) {
if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) {
printf("Valid latitude and longitude in config file\n"); printf("Valid latitude and longitude in config file\n");
latitude = lat_file; // convert to APRS DDMM.MM format
longitude = long_file; latitude = toAprsFormat(lat_file);
longitude = toAprsFormat(long_file);
printf("Lat/Long in APRS DDMM.MM format: %f/%f\n", latitude, longitude);
} else { // set default
latitude = toAprsFormat(latitude);
longitude = toAprsFormat(longitude);
} }
if (strcmp(sim_yes, "yes") == 0) if (strcmp(sim_yes, "yes") == 0)
sim_mode = TRUE; sim_mode = TRUE;
@ -2290,3 +2297,12 @@ int test_i2c_bus(int bus)
} }
return(output); // return bus number or -1 if there is a problem with the bus return(output); // return bus number or -1 if there is a problem with the bus
} }
float toAprsFormat(float input) {
// converts decimal coordinate (latitude or longitude) to APRS DDMM.MM format
int dd = (int) input;
int mm1 = (int)((input - dd) * 60.0);
int mm2 = (int)((input - dd - (float)mm1/60.0) * 60.0 * 60.0);
float output = dd * 100 + mm1 + (float)mm2 * 0.01;
return(output);
}

Loading…
Cancel
Save

Powered by TurnKey Linux.