Added debugging statements and put the new functions into the loop

This commit is contained in:
jakeg00dwin 2024-10-04 02:51:44 -07:00
parent 5ecbbceeb9
commit 14f6f68eaa
1 changed files with 26 additions and 6 deletions

View File

@ -247,7 +247,11 @@ void loop() {
} }
//Handle the Radio data. //Handle the Radio data.
sendGPSData();
receiveGPSData();
//Preform display update.
updateDisplay();
} }
// Function to update the LED ring based on heading direction // Function to update the LED ring based on heading direction
@ -266,6 +270,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()");
tft.setTextWrap(false); tft.setTextWrap(false);
tft.setCursor(0, 0); tft.setCursor(0, 0);
tft.setTextColor(ST77XX_WHITE); tft.setTextColor(ST77XX_WHITE);
@ -276,6 +281,8 @@ void TFT_UpdateDistance(uint16_t meters) {
} }
// Updates the direction part of the display // Updates the direction part of the display
// Mostly optional if you want to add degrees for navigation in addtion to
// the led ring.
void TFT_UpdateDirection(uint16_t degrees) { void TFT_UpdateDirection(uint16_t degrees) {
tft.setTextWrap(false); tft.setTextWrap(false);
tft.setCursor(0, 40); tft.setCursor(0, 40);
@ -303,6 +310,13 @@ 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");
}
// Resets the the display
uint8_t 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
TFT_UpdateDistance(0); TFT_UpdateDistance(0);
@ -310,14 +324,9 @@ void TFT_DisplaySpecs(void) {
TFT_UpdateBatteryState(100); TFT_UpdateBatteryState(100);
} }
// Resets the the display
uint8_t TFT_Reset() {
}
// 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()");
// 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
@ -331,6 +340,9 @@ 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.
Serial.println("updateDisplay()");
// Disable interrupts while using the dispaly. // Disable interrupts while using the dispaly.
cli(); cli();
@ -345,12 +357,17 @@ void updateDisplay() {
// tft.print("Distance: "); // tft.print("Distance: ");
// tft.print(calculatedDistance); // tft.print(calculatedDistance);
TFT_UpdateDistance(0);
TFT_UpdateDirection(0);
TFT_UpdateBatteryState(100);
//Re-Enable interrupts globally. //Re-Enable interrupts globally.
sei(); sei();
} }
// 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()");
// 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
@ -362,6 +379,7 @@ void sendGPSData() {
// 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()");
// 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
@ -372,8 +390,10 @@ 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()");
// 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
// - LoRa communication is lost: Display a notification or error on the screen // - LoRa communication is lost: Display a notification or error on the screen
} }