fixing display of numbers
This commit is contained in:
parent
5f9ae91a4c
commit
7ee9042e34
1 changed files with 50 additions and 27 deletions
|
@ -44,6 +44,15 @@ void setup()
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String toDoubleInt(int number)
|
||||||
|
{
|
||||||
|
if(number < 10)
|
||||||
|
{
|
||||||
|
return "0" + String(number);
|
||||||
|
}
|
||||||
|
return String(number);
|
||||||
|
}
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
@ -54,42 +63,56 @@ void loop()
|
||||||
gps.encode(c);
|
gps.encode(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned long next_update = -1;
|
||||||
|
static bool send_update = true;
|
||||||
|
|
||||||
|
bool gps_time_update = false;
|
||||||
if(gps.time.isUpdated())
|
if(gps.time.isUpdated())
|
||||||
{
|
{
|
||||||
static int update_min = -1;
|
gps_time_update = true;
|
||||||
if(gps.time.isValid()
|
}
|
||||||
&& (gps.time.minute() == update_min || update_min == -1)
|
|
||||||
&& gps.location.isValid()
|
if(gps.time.isValid() && (next_update <= gps.time.minute() || next_update == -1))
|
||||||
&& gps.location.isUpdated())
|
{
|
||||||
{
|
send_update = true;
|
||||||
APRSMessage msg;
|
}
|
||||||
msg.setSource(CALL);
|
|
||||||
msg.setDestination("APLT0");
|
if(send_update && gps.location.isValid() && gps.location.isUpdated())
|
||||||
char body_char[50];
|
{
|
||||||
sprintf(body_char, "=%s/%s>%s", create_lat_aprs(gps.location.rawLat()).c_str(), create_long_aprs(gps.location.rawLng()).c_str(), BEACON_MESSAGE);
|
next_update = (gps.time.minute() + BEACON_TIMEOUT) % 60;
|
||||||
msg.getAPRSBody()->setData(String(body_char));
|
send_update = false;
|
||||||
String data = msg.encode();
|
|
||||||
Serial.println(data);
|
APRSMessage msg;
|
||||||
show_display("<< TX >>", data);
|
msg.setSource(CALL);
|
||||||
LoRa.beginPacket();
|
msg.setDestination("APLT0");
|
||||||
// Header:
|
String lat = create_lat_aprs(gps.location.rawLat());
|
||||||
LoRa.write('<');
|
String lng = create_long_aprs(gps.location.rawLng());
|
||||||
LoRa.write(0xFF);
|
msg.getAPRSBody()->setData(String("=") + lat + "/" + lng + ">" + BEACON_MESSAGE);
|
||||||
LoRa.write(0x01);
|
String data = msg.encode();
|
||||||
// APRS Data:
|
Serial.println(data);
|
||||||
LoRa.write((const uint8_t *)data.c_str(), data.length());
|
show_display("<< TX >>", data);
|
||||||
LoRa.endPacket();
|
LoRa.beginPacket();
|
||||||
update_min = (gps.time.minute() + BEACON_TIMEOUT) % 60;
|
// Header:
|
||||||
}
|
LoRa.write('<');
|
||||||
|
LoRa.write(0xFF);
|
||||||
|
LoRa.write(0x01);
|
||||||
|
// APRS Data:
|
||||||
|
LoRa.write((const uint8_t *)data.c_str(), data.length());
|
||||||
|
LoRa.endPacket();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gps_time_update)
|
||||||
|
{
|
||||||
show_display(CALL,
|
show_display(CALL,
|
||||||
String("Time: ") + gps.time.hour() + String(":") + gps.time.minute() + String(":") + gps.time.second(),
|
String("Time: ") + toDoubleInt(gps.time.hour()) + String(":") + toDoubleInt(gps.time.minute()) + String(":") + toDoubleInt(gps.time.second()),
|
||||||
String("Date: ") + gps.date.day() + String(".") + gps.date.month() + String(".") + gps.date.year(),
|
String("Date: ") + toDoubleInt(gps.date.day()) + String(".") + toDoubleInt(gps.date.month()) + String(".") + gps.date.year(),
|
||||||
String("Sat's: ") + gps.satellites.value() + String(" HDOP: ") + gps.hdop.hdop(),
|
String("Sat's: ") + gps.satellites.value() + String(" HDOP: ") + gps.hdop.hdop(),
|
||||||
String("Lat: ") + gps.location.lat() + String(" Lng: ") + gps.location.lng(),
|
String("Lat: ") + gps.location.lat() + String(" Lng: ") + gps.location.lng(),
|
||||||
String("") + create_lat_aprs(gps.location.rawLat()) + String(" ") + create_long_aprs(gps.location.rawLng())
|
String("") + create_lat_aprs(gps.location.rawLat()) + String(" ") + create_long_aprs(gps.location.rawLng())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(millis() > 5000 && gps.charsProcessed() < 10)
|
if(millis() > 5000 && gps.charsProcessed() < 10)
|
||||||
{
|
{
|
||||||
Serial.println("No GPS detected!");
|
Serial.println("No GPS detected!");
|
||||||
|
|
Loading…
Reference in a new issue