From 285ef0bb93dde3879b928a2f64d9377369e53884 Mon Sep 17 00:00:00 2001 From: Stefan Brand Date: Sun, 20 Jun 2021 18:35:13 +0200 Subject: [PATCH] Fix SatsInView --- lib/gps/gps.cpp | 12 ++++-------- lib/gps/gps.h | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/gps/gps.cpp b/lib/gps/gps.cpp index 54eb7dc..d7323ce 100644 --- a/lib/gps/gps.cpp +++ b/lib/gps/gps.cpp @@ -2,11 +2,10 @@ byte CFG_RST[12] = {0xb5, 0x62, 0x06, 0x04, 0x04, 0x00, 0x00, 0x00, 0x01,0x00, 0x0F, 0x66}; -void Gps::init() -{ +Gps::Gps() { Serial.begin(9600); Serial.setTimeout(2); - Serial.write(CFG_RST, sizeof(CFG_RST)); // Soft Reset GPS on Start + // Serial.write(CFG_RST, sizeof(CFG_RST)); // Soft Reset GPS on Start satsInView.begin(tGps, "GPGSV", 3); // NMEA Sentence GPGSV, Element 3 (Sat in View) } @@ -18,10 +17,7 @@ void Gps::encode() while((previousMillis + 100) > millis()) { while (Serial.available() ) - { - char data = Serial.read(); - tGps.encode(data); - } + tGps.encode((char)Serial.read()); } //Serial.println(""); } @@ -52,7 +48,7 @@ bool Gps::buildPacket(uint8_t txBuffer[9]) void Gps::gdisplay(uint16_t dispBuffer[]) { dispBuffer[0] = tGps.hdop.value()/10; - dispBuffer[1] = TinyGPSPlus::parseDecimal(satsInView.value()); + dispBuffer[1] = atoi(satsInView.value()); dispBuffer[2] = tGps.satellites.value(); dispBuffer[3] = tGps.altitude.meters(); dispBuffer[4] = tGps.speed.kmph(); diff --git a/lib/gps/gps.h b/lib/gps/gps.h index 0df3eb9..7730e61 100644 --- a/lib/gps/gps.h +++ b/lib/gps/gps.h @@ -6,7 +6,7 @@ class Gps { public: - void init(); + Gps(); bool checkGpsFix(); bool buildPacket(uint8_t txBuffer[]); void gdisplay(uint16_t dispBuffer[]); @@ -17,7 +17,7 @@ class Gps uint16_t altitudeGps; uint8_t hdopGps; TinyGPSPlus tGps; - TinyGPSCustom satsInView; + TinyGPSCustom satsInView; }; #endif \ No newline at end of file