generated from TDD-Templates/cmake_cpputest_template
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.
This commit is contained in:
parent
6374bbf01f
commit
4d5b968cdb
|
@ -1,11 +1,7 @@
|
||||||
//#include <Adafruit_LIS2MDL.h> // Magnetometer (Compass) library
|
|
||||||
//#include <Adafruit_Sensor.h> // Unified sensor library
|
|
||||||
//#include <Wire.h> // I2C communication
|
|
||||||
#include <Adafruit_GFX.h> // Core graphics library for the display
|
#include <Adafruit_GFX.h> // Core graphics library for the display
|
||||||
#include <Adafruit_ST7735.h> // Specific library for the ST7735 display
|
#include <Adafruit_ST7735.h> // Specific library for the ST7735 display
|
||||||
#include <Adafruit_ST7789.h> // Specific library for the ST7789 display
|
#include <Adafruit_ST7789.h> // Specific library for the ST7789 display
|
||||||
#include <SPI.h> // SPI communication for the display
|
#include <SPI.h> // SPI communication for the display
|
||||||
//#include <FastLED.h> // Library to control the LED ring (WS2812)
|
|
||||||
#include <TinyGPS++.h> // Library to handle GPS data
|
#include <TinyGPS++.h> // Library to handle GPS data
|
||||||
#include <SoftwareSerial.h> // Software serial for GPS communication
|
#include <SoftwareSerial.h> // Software serial for GPS communication
|
||||||
#include <RH_RF95.h> // RadioHead Library(LoRa)
|
#include <RH_RF95.h> // RadioHead Library(LoRa)
|
||||||
|
@ -14,10 +10,7 @@
|
||||||
|
|
||||||
//GLOBAL VARS/OBJS
|
//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
|
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
|
SoftwareSerial gpsSerial(GPS_RX_PIN, GPS_TX_PIN); // Software serial for GPS
|
||||||
TinyGPSPlus gps; // TinyGPS++ object to process GPS data
|
TinyGPSPlus gps; // TinyGPS++ object to process GPS data
|
||||||
RH_RF95 rf95(RFM9X_CS, RFM9X_INT); // Radio instance.
|
RH_RF95 rf95(RFM9X_CS, RFM9X_INT); // Radio instance.
|
||||||
|
@ -215,9 +208,11 @@ void setup(void) {
|
||||||
void loop() {
|
void loop() {
|
||||||
//unsigned long currentTime = millis(); // Get the current time
|
//unsigned long currentTime = millis(); // Get the current time
|
||||||
|
|
||||||
|
//Update GPS
|
||||||
|
GPS_GetCoordinates();
|
||||||
|
|
||||||
//Handle the Radio data.
|
//Handle the Radio data.
|
||||||
sendGPSData();
|
Radio_Main(&msg_out, &msg_in);
|
||||||
receiveGPSData();
|
|
||||||
|
|
||||||
//Preform display update.
|
//Preform display update.
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
|
@ -314,12 +309,6 @@ void updateDisplay() {
|
||||||
// You can add code here to:
|
// You can add code here to:
|
||||||
// - Display the current distance between devices using the GPS data
|
// - Display the current distance between devices using the GPS data
|
||||||
// - Display any other relevant information, such as GPS coordinates or signal strength
|
// - 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.fillScreen(ST77XX_BLACK); // Set the screen background to black
|
||||||
TFT_UpdateDistance(0);
|
TFT_UpdateDistance(0);
|
||||||
|
@ -330,43 +319,6 @@ void updateDisplay() {
|
||||||
sei();
|
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)
|
// Future function to handle edge cases (e.g., GPS signal loss, close proximity)
|
||||||
void handleEdgeCases() {
|
void handleEdgeCases() {
|
||||||
|
|
Loading…
Reference in New Issue