Untitled
c_cpp
a month ago
1.9 kB
2
Indexable
Never
#include <Arduino.h> #include "../lib/MVC/DataView.h" #include "../lib/MVC/DataController.h" #include "../lib/MVC/MVCSettings.h" #include <cstdlib> #include <TinyGPS++.h> // Include TinyGPS++ for GPS data TinyGPSPlus gps; // Initialize TinyGPS++ object for GPS data DataView dataView = DataView(); DataController dataController = DataController(&dataView); char names[6][8] = {"Bjarke", "Benny", "Birger", "Bjarne", "Bent", "Birk"}; void setup() { Serial.begin(9600); delay(2000); dataView.initialiseView(); dataView.showStartScreen(); //to initialize the start screen for(int i = 0; i < 6; i++){ srand(i); dataController.addGroupMember(Member(names[i], NavigationData())); } } char input = ' '; void loop() { if (gps.location.isValid() && gps.date.isValid() && gps.time.isValid()) { // Clear the screen before updating dataView.clearScreen(); // Display latitude and longitude char latLonStr[50]; sprintf(latLonStr, "Lat: %.6f", gps.location.lat()); dataView.drawTextAt(0, 0, latLonStr, strlen(latLonStr), false); sprintf(latLonStr, "Long: %.6f", gps.location.lng()); dataView.drawTextAt(0, 16, latLonStr, strlen(latLonStr), false); // Display GPS signal strength char signalStr[20]; sprintf(signalStr, "Signal: %d", gps.satellites.value()); dataView.drawTextAt(0, 32, signalStr, strlen(signalStr), false); // Display time of day char timeStr[20]; sprintf(timeStr, "Time: %02d:%02d:%02d", gps.time.hour(), gps.time.minute(), gps.time.second()); dataView.drawTextAt(0, 48, timeStr, strlen(timeStr), false); // Update the display to show the changes dataView.updateNavOverview(false); } }