Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1st landing #574

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
.vscode/c_cpp_properties.json
.vscode/settings.json
esp32_marauder/.vscode/settings.json
.DS_Store
.gitignore
.gitignore
56 changes: 56 additions & 0 deletions esp32_marauder/calebGPSInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "calebGPSInterface.h"

// Constructor
CalebGPSInterface::CalebGPSInterface() : Serial2(1) { // Use Serial2 as default
}

// Initialize the GPS module
void CalebGPSInterface::begin() {
Serial2.begin(9600, SERIAL_8N1, GPS_TX, GPS_RX); // Start communication with GPS module
Serial.println("GPS Module Initialized");
}

// Update GPS data by reading from the serial buffer
void CalebGPSInterface::updateGPS() {
while (Serial2.available()) {
char c = Serial2.read();
gps.encode(c); // Process GPS data with TinyGPS++
}
}

// Get Latitude as a string
String CalebGPSInterface::getLatitude() {
if (gps.location.isValid()) {
return String(gps.location.lat(), 6); // Return latitude
} else {
return "Invalid";
}
}

// Get Longitude as a string
String CalebGPSInterface::getLongitude() {
if (gps.location.isValid()) {
return String(gps.location.lng(), 6); // Return longitude
} else {
return "Invalid";
}
}

// Get Altitude in meters
float CalebGPSInterface::getAltitude() {
if (gps.altitude.isValid()) {
return gps.altitude.meters(); // Return altitude in meters
} else {
return 0.0;
}
}

// Check if GPS fix is valid
bool CalebGPSInterface::isGPSFixValid() {
return gps.location.isValid(); // Return true if GPS fix is valid
}

// Get the number of satellites
int CalebGPSInterface::getNumSatellites() {
return gps.satellites.value(); // Return the number of satellites
}
25 changes: 25 additions & 0 deletions esp32_marauder/calebGPSInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#ifndef CalebGPSInterface_h
#define CalebGPSInterface_h

#include <TinyGPS++.h>
#include <HardwareSerial.h>

class CalebGPSInterface {
public:
CalebGPSInterface(); // Constructor
void begin(); // Initialize GPS
void updateGPS(); // Read GPS data
String getLatitude(); // Get Latitude as String
String getLongitude();// Get Longitude as String
float getAltitude(); // Get Altitude in meters
bool isGPSFixValid(); // Check if GPS fix is valid
int getNumSatellites();// Get number of satellites

private:
TinyGPSPlus gps; // TinyGPS++ object
HardwareSerial Serial2; // HardwareSerial for GPS communication
};

#endif
10 changes: 10 additions & 0 deletions esp32_marauder/esp32_marauder.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ https://www.online-utility.org/image/convert/to/XBM
#include "freertos/task.h"
#include "esp_system.h"
#include <Arduino.h>
#include "calebGPSInterface.h"

#ifdef HAS_GPS
#include "GpsInterface.h"
#include "calebGPSInterface.h"
#endif

#include "Assets.h"
Expand Down Expand Up @@ -83,6 +85,7 @@ EvilPortal evil_portal_obj;
Buffer buffer_obj;
Settings settings_obj;
CommandLine cli_obj;
CalebGPSInterface gpsInterface;

#ifdef HAS_GPS
GpsInterface gps_obj;
Expand Down Expand Up @@ -183,6 +186,7 @@ void setup()
Serial.begin(115200);

Serial.println("ESP-IDF version is: " + String(esp_get_idf_version()));
gpsInterface.begin();

#ifdef HAS_SCREEN
display_obj.RunSetup();
Expand Down Expand Up @@ -327,6 +331,12 @@ void setup()

void loop()
{
gpsInterface.updateGPS();
Serial.print("Latitude: ");
Serial.println(gpsInterface.getLatitude());
Serial.print("Longitude: ");
Serial.println(gpsInterface.getLongitude());

currentTime = millis();
bool mini = false;

Expand Down
39 changes: 39 additions & 0 deletions esp32_marauder/gps_module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <TinyGPS++.h>
#include <HardwareSerial.h>
#include "gps_module.h"

// Initialize TinyGPS++ library and HardwareSerial
TinyGPSPlus gps;
HardwareSerial gpsSerial(1); // UART1 for GPS (change pins if necessary)

//Initialize GPS

/*#ifdef MARAUDER_MINI
pinMode(26, OUTPUT);

delay(1);

analogWrite(26, 243);
delay(1);

Serial.println("Activated GPS");
delay(100);
#endif*/

void setupGPS () {
gpsSerial.begin(9600, SERIAL_8N1, 16, 17); // Adjust pins if needed
Serial.println("GPS Module initialized");
}

// Function to read GPS data
void readGPS() {
while (gpsSerial.available() > 0) {
gps.encode(gpsSerial.read());
if (gps.location.isUpdated()) {
Serial.print("Latitude: ");
Serial.println(gps.location.lat(), 6);
Serial.print("Longitude: ");
Serial.println(gps.location.lng(), 6);
}
}
}
Loading