From 4d5b968cdbc8ff9f345d41029742ec3c1e1986bd Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 6 Oct 2024 12:54:38 -0700 Subject: [PATCH] Removed unused and commented out code. I removed the two functions for the sending and receiving gps data into a single 'Radio_Main()' function. Helps to reduce the program size a bit. --- src/multi-tracker.cpp | 56 ++++--------------------------------------- 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/src/multi-tracker.cpp b/src/multi-tracker.cpp index a986929..81ec63a 100644 --- a/src/multi-tracker.cpp +++ b/src/multi-tracker.cpp @@ -1,11 +1,7 @@ -//#include // Magnetometer (Compass) library -//#include // Unified sensor library -//#include // I2C communication #include // Core graphics library for the display #include // Specific library for the ST7735 display #include // Specific library for the ST7789 display #include // SPI communication for the display -//#include // Library to control the LED ring (WS2812) #include // Library to handle GPS data #include // Software serial for GPS communication #include // RadioHead Library(LoRa) @@ -14,10 +10,7 @@ //GLOBAL VARS/OBJS -// MAGNETOMETER (LIS2MDL) CONFIGURATION -//Adafruit_LIS2MDL lis2mdl = Adafruit_LIS2MDL(12345); // Create magnetometer object Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); // Initialize display -//CRGB leds[NUM_LEDS]; // Array to hold LED colors SoftwareSerial gpsSerial(GPS_RX_PIN, GPS_TX_PIN); // Software serial for GPS TinyGPSPlus gps; // TinyGPS++ object to process GPS data RH_RF95 rf95(RFM9X_CS, RFM9X_INT); // Radio instance. @@ -215,9 +208,11 @@ void setup(void) { void loop() { //unsigned long currentTime = millis(); // Get the current time + //Update GPS + GPS_GetCoordinates(); + //Handle the Radio data. - sendGPSData(); - receiveGPSData(); + Radio_Main(&msg_out, &msg_in); //Preform display update. updateDisplay(); @@ -314,12 +309,6 @@ void updateDisplay() { // You can add code here to: // - Display the current distance between devices using the GPS data // - Display any other relevant information, such as GPS coordinates or signal strength - // Example: - // tft.setCursor(10, 50); // Set cursor position - // tft.setTextColor(ST77XX_WHITE); // Set text color - // tft.setTextSize(2); // Set text size - // tft.print("Distance: "); - // tft.print(calculatedDistance); tft.fillScreen(ST77XX_BLACK); // Set the screen background to black TFT_UpdateDistance(0); @@ -330,43 +319,6 @@ void updateDisplay() { sei(); } -// Future function to handle LoRa transmission of GPS data - See adafruit LORA code examples -void sendGPSData() { -//Serial.println("sendGPSData()"); - // Add logic here to transmit the device's GPS coordinates using LoRa - // You will need to: - // - Get the current GPS coordinates - // - Format the data for transmission - // - Use the LoRa library to send the data to the paired device - // Example: LoRa.beginPacket(); LoRa.print(latitude); LoRa.print(longitude); LoRa.endPacket(); - - //Don't waste cpu cycles if no new gps data. - if(GPS_GetCoordinates() == NoReply){ - return; - } - - for(db = RF9X_MIN_DB; db <= RF9X_MAX_DB; db++) { - Radio_SendMsg(&msg_out); - if(Radio_CheckForMsg(&msg_in) == Ok) { - break; - } - else{ -//Serial.print("TX Power set to:"); -//Serial.println(db); - } - } -} - -// Future function to receive GPS data from the other device via LoRa - See adafruit LORA code examples -void receiveGPSData() { -//Serial.println("receiveGPSData()"); - // Add logic here to receive the paired device's GPS coordinates using LoRa - // You will need to: - // - Listen for incoming LoRa packets - // - Parse the received data - // - Update the display and LED ring based on the other device's location - // Example: if (LoRa.parsePacket()) { double otherLat = LoRa.read(); double otherLon = LoRa.read(); } -} // Future function to handle edge cases (e.g., GPS signal loss, close proximity) void handleEdgeCases() {