Change format for latitude and longitude

This commit is contained in:
norbert-walter 2022-03-09 09:44:27 +01:00
parent 0513974219
commit 1becfcd07d
2 changed files with 10 additions and 22 deletions

View File

@ -107,18 +107,8 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
} }
course = course * 57.2958; // Unit conversion form rad to deg course = course * 57.2958; // Unit conversion form rad to deg
// Format 3 numbers with prefix zero
snprintf(buffer,bsize,"%03.0f",course); snprintf(buffer,bsize,"%03.0f",course);
/*
if(course < 10){
snprintf(buffer,bsize,"%2.1f",course);
}
if(course >= 10 && course < 100){
snprintf(buffer,bsize,"%2.1f",course);
}
if(course >= 100){
snprintf(buffer,bsize,"%3.0f",course);
}
*/
result.unit = "Deg"; result.unit = "Deg";
} }
//######################################################## //########################################################
@ -249,21 +239,20 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
double lat = value->value; double lat = value->value;
String latitude = ""; String latitude = "";
String latdir = ""; String latdir = "";
float degree = int(lat); float degree = abs(int(lat));
float minute = (lat - degree) * 60; float minute = abs((lat - int(lat)) * 60);
float secound = (minute - int(minute)) * 60;
if(lat > 0){ if(lat > 0){
latdir = "N"; latdir = "N";
} }
else{ else{
latdir = "S"; latdir = "S";
} }
latitude = String(degree,0) + "\" " + String(minute,0) + "' " + String(secound, 4) + " " + latdir; latitude = String(degree,0) + "\" " + String(minute,4) + "' " + latdir;
result.unit = ""; result.unit = "";
strcpy(buffer, latitude.c_str()); strcpy(buffer, latitude.c_str());
} }
else{ else{
snprintf(buffer,bsize," 51\" 35' %2.4f", 2.0 + float(random(0, 1000)) / 1000.0); snprintf(buffer,bsize," 51\" %2.4f' N", 35.0 + float(random(0, 10)) / 10000.0);
} }
} }
//######################################################## //########################################################
@ -272,21 +261,20 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
double lon = value->value; double lon = value->value;
String longitude = ""; String longitude = "";
String londir = ""; String londir = "";
float degree = int(lon); float degree = abs(int(lon));
float minute = (lon - degree) * 60; float minute = abs((lon - int(lon)) * 60);
float secound = (minute - int(minute)) * 60;
if(lon > 0){ if(lon > 0){
londir = "E"; londir = "E";
} }
else{ else{
londir = "W"; londir = "W";
} }
longitude = String(degree,0) + "\" " + String(minute,0) + "' " + String(secound, 4) + " " + londir; longitude = String(degree,0) + "\" " + String(minute,4) + "' " + londir;
result.unit = ""; result.unit = "";
strcpy(buffer, longitude.c_str()); strcpy(buffer, longitude.c_str());
} }
else{ else{
snprintf(buffer,bsize," 15\" 06' %2.4f", 9.0 + float(random(0, 1000)) / 1000.0); snprintf(buffer,bsize," 15\" %2.4f'", 6.0 + float(random(0, 10)) / 100000.0);
} }
} }
//######################################################## //########################################################

View File

@ -105,7 +105,7 @@ class PageDST810 : public Page
bgcolor = GxEPD_BLACK; bgcolor = GxEPD_BLACK;
} }
// Clear display by call in obp60task.cpp in main loop // Clear display by call in obp60task.cpp in main loop
// ############### Value 1 ################ // ############### Value 1 ################
// Show name // Show name