From 7386e12fb8d24f7f3854de066bb091c16c5be24c Mon Sep 17 00:00:00 2001 From: jake Date: Tue, 1 Oct 2024 19:15:35 -0700 Subject: [PATCH] Added helper functions for the display + init func. + update distance. + update direction. + update battery state. + reset func. --- src/multi-tracker.cpp | 50 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/src/multi-tracker.cpp b/src/multi-tracker.cpp index e019636..7d0935c 100644 --- a/src/multi-tracker.cpp +++ b/src/multi-tracker.cpp @@ -28,6 +28,10 @@ static int prevHeading = -1; // Store previous heading to avoid frequent unsigned long lastUpdate = 0; // Time tracking for updates const int updateInterval = 500; // Update interval in milliseconds (500ms = 0.5s) +const uint8_t MAX_BATT_PERCENTAGE = 100; +const uint8_t MIN_BATT_PERCENTAGE = 0; + + typedef struct MSG{ uint8_t id; double latitude; @@ -168,9 +172,7 @@ void setup(void) { // Initialize Serial Communication for debugging Serial.begin(SERIAL_BUADRATE); - // Display Setup - 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_Init(); // Magnetometer Setup if (!lis2mdl.begin()) { // Initialize the magnetometer @@ -262,6 +264,48 @@ void updateLEDs(int heading) { } } +// Updates the distance part of the display +void TFT_UpdateDistance(uint16_t meters) { + +} + +// Updates the direction part of the display +void TFT_UpdateDirection() { + +} + +// Updates the batter/voltage state. +uint8_t TFT_UpdateBatteryState(uint8_t percentage) { + if(percentage > MAX_BATT_PERCENTAGE || percentage < MIN_BATT_PERCENTAGE){ + return Err; + } + + return Ok; +} + +// Displays the specifications of the node. +void TFT_DisplaySpecs(void) { + +} + + +// Resets the the display +uint8_t TFT_Reset() { + +} + +// Initalizes the Screen with default startup screen. +uint8_t TFT_Init(void) { + // Display Setup + 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_UpdateDistance(0); + TFT_UpdateDirection(0); + TFT_UpdateBatteryState(100); +} + + // Placeholder for updating the TFT display with GPS data void updateDisplay() { // Disable interrupts while using the dispaly.