generated from TDD-Templates/cmake_cpputest_template
Removed includes and serial debugging statments.
- Commented out all the Serial print statments. - Commented out all headers not needed for MVP(minimum viable product)
This commit is contained in:
parent
9f8982f60c
commit
508522a2b7
|
@ -1,11 +1,11 @@
|
||||||
#include <Adafruit_LIS2MDL.h> // Magnetometer (Compass) library
|
//#include <Adafruit_LIS2MDL.h> // Magnetometer (Compass) library
|
||||||
#include <Adafruit_Sensor.h> // Unified sensor library
|
//#include <Adafruit_Sensor.h> // Unified sensor library
|
||||||
#include <Wire.h> // I2C communication
|
//#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 <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)
|
||||||
|
@ -15,9 +15,9 @@
|
||||||
//GLOBAL VARS/OBJS
|
//GLOBAL VARS/OBJS
|
||||||
|
|
||||||
// MAGNETOMETER (LIS2MDL) CONFIGURATION
|
// MAGNETOMETER (LIS2MDL) CONFIGURATION
|
||||||
Adafruit_LIS2MDL lis2mdl = Adafruit_LIS2MDL(12345); // Create magnetometer object
|
//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
|
//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.
|
||||||
|
@ -55,14 +55,14 @@ MSG msg_in;
|
||||||
|
|
||||||
|
|
||||||
void MSG_Print(MSG *msg) {
|
void MSG_Print(MSG *msg) {
|
||||||
Serial.print("ID: ");
|
//Serial.print("ID: ");
|
||||||
Serial.println(msg->id);
|
//Serial.println(msg->id);
|
||||||
|
|
||||||
Serial.print("Latitude: ");
|
//Serial.print("Latitude: ");
|
||||||
Serial.println(msg->latitude);
|
//Serial.println(msg->latitude);
|
||||||
|
|
||||||
Serial.print("Longitude: ");
|
//Serial.print("Longitude: ");
|
||||||
Serial.println(msg->longitude);
|
//Serial.println(msg->longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Radio_Reset(void) {
|
void Radio_Reset(void) {
|
||||||
|
@ -73,7 +73,7 @@ void Radio_Reset(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Radio_Setup(void) {
|
uint8_t Radio_Setup(void) {
|
||||||
Serial.println("Radio_Setup()");
|
//Serial.println("Radio_Setup()");
|
||||||
|
|
||||||
pinMode(RFM9X_RST, OUTPUT);
|
pinMode(RFM9X_RST, OUTPUT);
|
||||||
digitalWrite(RFM9X_RST, HIGH);
|
digitalWrite(RFM9X_RST, HIGH);
|
||||||
|
@ -81,21 +81,21 @@ uint8_t Radio_Setup(void) {
|
||||||
Radio_Reset();
|
Radio_Reset();
|
||||||
|
|
||||||
while (!rf95.init()) {
|
while (!rf95.init()) {
|
||||||
Serial.println("Radio_Setup(): Failed to initialize");
|
//Serial.println("Radio_Setup(): Failed to initialize");
|
||||||
Serial.println("Check SPI connections!");
|
//Serial.println("Check SPI connections!");
|
||||||
return Err;
|
return Err;
|
||||||
}
|
}
|
||||||
Serial.println("LoRa radio init OK!");
|
//Serial.println("LoRa radio init OK!");
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Radio_Configure(void) {
|
uint8_t Radio_Configure(void) {
|
||||||
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
|
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
|
||||||
if(!rf95.setFrequency(RF95_FREQ)) {
|
if(!rf95.setFrequency(RF95_FREQ)) {
|
||||||
Serial.println("Radio_Configure(): failed to set frequency");
|
//Serial.println("Radio_Configure(): failed to set frequency");
|
||||||
return Err;
|
return Err;
|
||||||
}
|
}
|
||||||
Serial.print("Set Freq to: "); Serial.println(RF9X_FREQ);
|
//Serial.println(RF9X_FREQ);
|
||||||
|
|
||||||
rf95.setTxPower(RF9X_MIN_DB, false);
|
rf95.setTxPower(RF9X_MIN_DB, false);
|
||||||
|
|
||||||
|
@ -103,17 +103,17 @@ uint8_t Radio_Configure(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Radio_SendMsg(MSG *msg) {
|
uint8_t Radio_SendMsg(MSG *msg) {
|
||||||
Serial.println("Radio_SendMsg()");
|
//Serial.println("Radio_SendMsg()");
|
||||||
|
|
||||||
Serial.println("Sending Message: ");
|
//Serial.println("Sending Message: ");
|
||||||
Serial.print("Message size: ");
|
//Serial.print("Message size: ");
|
||||||
Serial.println(sizeof(MSG));
|
//Serial.println(sizeof(MSG));
|
||||||
|
|
||||||
MSG_Print(msg);
|
MSG_Print(msg);
|
||||||
|
|
||||||
rf95.send((uint8_t *)msg, sizeof(MSG));
|
rf95.send((uint8_t *)msg, sizeof(MSG));
|
||||||
|
|
||||||
Serial.println("waiting for packet sent...");
|
//Serial.println("waiting for packet sent...");
|
||||||
delay(10);
|
delay(10);
|
||||||
rf95.waitPacketSent();
|
rf95.waitPacketSent();
|
||||||
|
|
||||||
|
@ -121,13 +121,13 @@ uint8_t Radio_SendMsg(MSG *msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Radio_CheckForMsg(MSG *msg) {
|
uint8_t Radio_CheckForMsg(MSG *msg) {
|
||||||
Serial.println("Radio_CheckForMsg()");
|
//Serial.println("Radio_CheckForMsg()");
|
||||||
|
|
||||||
//Now we wait for an packet.
|
//Now we wait for an packet.
|
||||||
if (rf95.waitAvailableTimeout(1000)) {
|
if (rf95.waitAvailableTimeout(1000)) {
|
||||||
// Should be a reply message for us now
|
// Should be a reply message for us now
|
||||||
if (rf95.recv(buffer, sizeof(MSG))) {
|
if (rf95.recv(buffer, sizeof(MSG))) {
|
||||||
Serial.print("Received reply: ");
|
//Serial.print("Received reply: ");
|
||||||
|
|
||||||
msg->id = (uint8_t) buffer[0];
|
msg->id = (uint8_t) buffer[0];
|
||||||
msg->latitude = *(double *) &buffer[1];
|
msg->latitude = *(double *) &buffer[1];
|
||||||
|
@ -135,14 +135,14 @@ uint8_t Radio_CheckForMsg(MSG *msg) {
|
||||||
|
|
||||||
MSG_Print(msg);
|
MSG_Print(msg);
|
||||||
|
|
||||||
Serial.print("RSSI: ");
|
//Serial.print("RSSI: ");
|
||||||
Serial.println(rf95.lastRssi(), DEC);
|
//Serial.println(rf95.lastRssi(), DEC);
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Receive failed");
|
//Serial.println("Receive failed");
|
||||||
return ReceiveFailed;
|
return ReceiveFailed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Serial.println("No reply");
|
//Serial.println("No reply");
|
||||||
return NoReply;
|
return NoReply;
|
||||||
}
|
}
|
||||||
return Ok;
|
return Ok;
|
||||||
|
@ -156,8 +156,8 @@ void Radio_Main(MSG *msg_out, MSG *msg_in) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Serial.print("TX Power set to:");
|
//Serial.print("TX Power set to:");
|
||||||
Serial.println(db);
|
//Serial.println(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,9 +170,9 @@ void Radio_Main(MSG *msg_out, MSG *msg_in) {
|
||||||
|
|
||||||
//Returns the result type and updates the global values(coordinates).
|
//Returns the result type and updates the global values(coordinates).
|
||||||
uint8_t GPS_GetCoordinates() {
|
uint8_t GPS_GetCoordinates() {
|
||||||
Serial.println("GPS_GetCoordinates()");
|
//Serial.println("GPS_GetCoordinates()");
|
||||||
if (!gpsSerial.available()) {
|
if (!gpsSerial.available()) {
|
||||||
Serial.println("INFO: GPS not availble.");
|
//Serial.println("INFO: GPS not availble.");
|
||||||
return NoReply;
|
return NoReply;
|
||||||
}
|
}
|
||||||
gps.encode(gpsSerial.read()); // Decode the GPS data
|
gps.encode(gpsSerial.read()); // Decode the GPS data
|
||||||
|
@ -192,7 +192,7 @@ void setup(void) {
|
||||||
|
|
||||||
// Magnetometer Setup
|
// Magnetometer Setup
|
||||||
if (!lis2mdl.begin()) { // Initialize the magnetometer
|
if (!lis2mdl.begin()) { // Initialize the magnetometer
|
||||||
Serial.println("Error: LIS2MDL not detected. Check your wiring!");
|
//Serial.println("Error: LIS2MDL not detected. Check your wiring!");
|
||||||
while (1) delay(10); // Stop the program if the sensor isn't detected
|
while (1) delay(10); // Stop the program if the sensor isn't detected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ void updateLEDs(int heading) {
|
||||||
|
|
||||||
// Updates the distance part of the display
|
// Updates the distance part of the display
|
||||||
void TFT_UpdateDistance(uint16_t meters) {
|
void TFT_UpdateDistance(uint16_t meters) {
|
||||||
Serial.println("TFT_UpdateDistance()");
|
//Serial.println("TFT_UpdateDistance()");
|
||||||
tft.setTextSize(4);
|
tft.setTextSize(4);
|
||||||
tft.setCursor(0, 20);
|
tft.setCursor(0, 20);
|
||||||
tft.setTextColor(ST77XX_WHITE);
|
tft.setTextColor(ST77XX_WHITE);
|
||||||
|
@ -317,20 +317,20 @@ uint8_t TFT_UpdateBatteryState(uint8_t percentage) {
|
||||||
|
|
||||||
// Displays the specifications of the node.
|
// Displays the specifications of the node.
|
||||||
void TFT_DisplaySpecs(void) {
|
void TFT_DisplaySpecs(void) {
|
||||||
Serial.println("TFT_DisplaySpecs(): No data");
|
//Serial.println("TFT_DisplaySpecs(): No data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Resets the the display
|
// Resets the the display
|
||||||
uint8_t TFT_Reset() {
|
uint8_t TFT_Reset() {
|
||||||
Serial.println("TFT_Reset()");
|
//Serial.println("TFT_Reset()");
|
||||||
tft.fillScreen(ST77XX_BLACK); // Set the screen background to black
|
tft.fillScreen(ST77XX_BLACK); // Set the screen background to black
|
||||||
//Can add default startup logo/screen here for later.
|
//Can add default startup logo/screen here for later.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initalizes the Screen with default startup screen.
|
// Initalizes the Screen with default startup screen.
|
||||||
uint8_t TFT_Init(void) {
|
uint8_t TFT_Init(void) {
|
||||||
Serial.println("TFT_Init()");
|
//Serial.println("TFT_Init()");
|
||||||
// Display Setup
|
// Display Setup
|
||||||
tft.init(TFT_X, TFT_Y); // Initialize the display with a resolution of 240x280 pixels
|
tft.init(TFT_X, TFT_Y); // Initialize the display with a resolution of 240x280 pixels
|
||||||
tft.fillScreen(ST77XX_BLACK); // Set the screen background to black
|
tft.fillScreen(ST77XX_BLACK); // Set the screen background to black
|
||||||
|
@ -345,7 +345,7 @@ uint8_t TFT_Init(void) {
|
||||||
// Placeholder for updating the TFT display with GPS data
|
// Placeholder for updating the TFT display with GPS data
|
||||||
void updateDisplay() {
|
void updateDisplay() {
|
||||||
//Print out our debugging statment.
|
//Print out our debugging statment.
|
||||||
Serial.println("updateDisplay()");
|
//Serial.println("updateDisplay()");
|
||||||
|
|
||||||
// Disable interrupts while using the dispaly.
|
// Disable interrupts while using the dispaly.
|
||||||
cli();
|
cli();
|
||||||
|
@ -372,7 +372,7 @@ void updateDisplay() {
|
||||||
|
|
||||||
// Future function to handle LoRa transmission of GPS data - See adafruit LORA code examples
|
// Future function to handle LoRa transmission of GPS data - See adafruit LORA code examples
|
||||||
void sendGPSData() {
|
void sendGPSData() {
|
||||||
Serial.println("sendGPSData()");
|
//Serial.println("sendGPSData()");
|
||||||
// Add logic here to transmit the device's GPS coordinates using LoRa
|
// Add logic here to transmit the device's GPS coordinates using LoRa
|
||||||
// You will need to:
|
// You will need to:
|
||||||
// - Get the current GPS coordinates
|
// - Get the current GPS coordinates
|
||||||
|
@ -391,15 +391,15 @@ void sendGPSData() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Serial.print("TX Power set to:");
|
//Serial.print("TX Power set to:");
|
||||||
Serial.println(db);
|
//Serial.println(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future function to receive GPS data from the other device via LoRa - See adafruit LORA code examples
|
// Future function to receive GPS data from the other device via LoRa - See adafruit LORA code examples
|
||||||
void receiveGPSData() {
|
void receiveGPSData() {
|
||||||
Serial.println("receiveGPSData()");
|
//Serial.println("receiveGPSData()");
|
||||||
// Add logic here to receive the paired device's GPS coordinates using LoRa
|
// Add logic here to receive the paired device's GPS coordinates using LoRa
|
||||||
// You will need to:
|
// You will need to:
|
||||||
// - Listen for incoming LoRa packets
|
// - Listen for incoming LoRa packets
|
||||||
|
@ -410,7 +410,7 @@ void receiveGPSData() {
|
||||||
|
|
||||||
// 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() {
|
||||||
Serial.println("handleEdgeCases()");
|
//Serial.println("handleEdgeCases()");
|
||||||
// Add logic here to handle cases where:
|
// Add logic here to handle cases where:
|
||||||
// - GPS signal is lost: Display a message on the screen or flash the LED ring
|
// - GPS signal is lost: Display a message on the screen or flash the LED ring
|
||||||
// - Devices are too close: Display a warning if the GPS data is unreliable due to proximity
|
// - Devices are too close: Display a warning if the GPS data is unreliable due to proximity
|
||||||
|
|
Loading…
Reference in New Issue