From 8a0f6932b6b6e2fb919f3569324a4253f7a18b57 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Thu, 16 Feb 2023 14:36:42 +0100 Subject: [PATCH] Make PR #65 work with present version (small mods) --- data/tracker.json | 1 + src/LoRa_APRS_Tracker.cpp | 58 ++++++++++++++++++++++++++++++++++++++- src/configuration.cpp | 2 ++ src/configuration.h | 7 +++-- 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/data/tracker.json b/data/tracker.json index 174af42..06fb21c 100644 --- a/data/tracker.json +++ b/data/tracker.json @@ -8,6 +8,7 @@ "timeout": 1, "symbol": "[", "overlay": "/", + "type": "L", "smart_beacon": { "active": true, "turn_min": 25, diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 93d7a93..bcc2e27 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -244,6 +244,7 @@ void loop() { } } + String csa = ""; if (send_update && gps_loc_update) { send_update = false; @@ -327,6 +328,7 @@ void loop() { digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? LOW : HIGH); delay(Config.ptt.start_delay); } + csa = alt + "/" + course_and_speed; LoRa.beginPacket(); // Header: @@ -353,7 +355,61 @@ void loop() { if (gps_time_update) { - show_display(BeaconMan.getCurrentBeaconConfig()->callsign, createDateString(now()) + " " + createTimeString(now()), String("Sats: ") + gps.satellites.value() + " HDOP: " + gps.hdop.hdop(), String("Next Bcn: ") + (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active ? "~" : "") + createTimeString(nextBeaconTimeStamp), BatteryIsConnected ? (String("Bat: ") + batteryVoltage + "V, " + batteryChargeCurrent + "mA") : "Powered via USB", String("Smart Beacon: " + getSmartBeaconState())); + // lat/lng in Display + static String dlatlon = ""; + String C2 = ""; + + if (BeaconMan.getCurrentBeaconConfig()->type) { + C2 = BeaconMan.getCurrentBeaconConfig()->callsign + + /* " " + */ BeaconMan.getCurrentBeaconConfig()->type; + } + if (gps_loc_update) { + dlatlon = create_lat_aprs(gps.location.rawLat()) + " " + + create_long_aprs(gps.location.rawLng()); + } else { + dlatlon = BeaconMan.getCurrentBeaconConfig()->message; + } + // + if ((int)gps.hdop.hdop() > 5) { + csa = String("Sats: ") + gps.satellites.value() + + " HDOP: " + gps.hdop.hdop(); + } else { + String alt = ""; + int alt_int = max(-99999, min(999999, (int)gps.altitude.feet())); + alt_int *= 0.3048; + if (alt_int < 0) { + alt = "-" + padding(alt_int * -1, 0) + "m "; + } else { + alt = padding(alt_int, 0) + "m "; + } + String course_and_speed = ""; + int speed_int = max(0, min(999, (int)gps.speed.knots())); + String speed = padding(speed_int * 1.852, 0) + "km/h "; + int course_int = max(0, min(360, (int)gps.course.deg())); + String course = padding(course_int, 0) + "\xF7 "; + csa = speed + course + alt + gps.satellites.value() + "/" + + (int)gps.hdop.hdop(); + } + show_display(C2, createDateString(now()) + " " + createTimeString(now()), + String(csa), + String("Next Bcn: ") + + (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active + ? "~" + : "") + + createTimeString(nextBeaconTimeStamp), + BatteryIsConnected ? (String("Bat: ") + batteryVoltage + + "V, " + batteryChargeCurrent + "mA") + : "Powered via USB", + dlatlon); + // show_display(BeaconMan.getCurrentBeaconConfig()->callsign, + // createDateString(now()) + " " + createTimeString(now()), + // String("Sats: ") + gps.satellites.value() + " HDOP: " + + // gps.hdop.hdop(), String("Next Bcn: ") + + // (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active ? "~" : "") + + // createTimeString(nextBeaconTimeStamp), BatteryIsConnected ? + // (String("Bat: ") + batteryVoltage + "V, " + batteryChargeCurrent + + // "mA") : "Powered via USB", String("Smart Beacon: " + + // getSmartBeaconState())); if (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active) { // Change the Tx internal based on the current speed diff --git a/src/configuration.cpp b/src/configuration.cpp index dc9f572..4bb96b5 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -53,6 +53,8 @@ Configuration ConfigurationManagement::readConfiguration() { beacon.symbol = v["symbol"].as(); if (v.containsKey("overlay")) beacon.overlay = v["overlay"].as(); + if (v.containsKey("type")) + beacon.type = v["type"].as(); beacon.smart_beacon.active = v["smart_beacon"]["active"] | false; beacon.smart_beacon.turn_min = v["smart_beacon"]["turn_min"] | 25; diff --git a/src/configuration.h b/src/configuration.h index c7dae47..a8bac41 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -25,8 +25,10 @@ class Configuration { int min_bcn; }; - Beacon() : callsign("NOCALL-10"), path("WIDE1-1"), message("LoRa Tracker"), timeout(1), symbol("["), overlay("/"), enhance_precision(true) { - } + Beacon() + : callsign("NOCALL-10"), path("WIDE1-1"), message("LoRa Tracker"), + timeout(1), symbol("["), overlay("/"), type(""), + enhance_precision(true) {} String callsign; String path; @@ -34,6 +36,7 @@ class Configuration { int timeout; String symbol; String overlay; + String type; Smart_Beacon smart_beacon; bool enhance_precision; };