mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-12 15:50:36 -08:00
Detect GPS module
This commit is contained in:
@@ -17,8 +17,12 @@ void GpsInterface::begin() {
|
|||||||
|
|
||||||
delay(4000);
|
delay(4000);
|
||||||
|
|
||||||
while (Serial2.available())
|
if (Serial2.available()) {
|
||||||
Serial2.read();
|
Serial.println("GPS Attached Successfully");
|
||||||
|
this->gps_enabled = true;
|
||||||
|
while (Serial2.available())
|
||||||
|
Serial2.read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpsInterface::showGPSInfo() {
|
void GpsInterface::showGPSInfo() {
|
||||||
@@ -82,6 +86,10 @@ bool GpsInterface::getFixStatus() {
|
|||||||
return this->good_fix;
|
return this->good_fix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GpsInterface::getGpsModuleStatus() {
|
||||||
|
return this->gps_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void GpsInterface::main() {
|
void GpsInterface::main() {
|
||||||
while (Serial2.available()) {
|
while (Serial2.available()) {
|
||||||
//Fetch the character one by one
|
//Fetch the character one by one
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ class GpsInterface {
|
|||||||
|
|
||||||
String getNumSatsString();
|
String getNumSatsString();
|
||||||
bool getFixStatus();
|
bool getFixStatus();
|
||||||
|
bool getGpsModuleStatus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool gps_enabled = false;
|
||||||
bool good_fix = false;
|
bool good_fix = false;
|
||||||
uint8_t num_sats = 0;
|
uint8_t num_sats = 0;
|
||||||
//MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
|
//MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
|
||||||
|
|||||||
@@ -1230,22 +1230,26 @@ void MenuFunctions::updateStatusBar()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// GPS Stuff
|
// GPS Stuff
|
||||||
if (gps_obj.getFixStatus())
|
#ifdef HAS_GPS
|
||||||
the_color = TFT_GREEN;
|
if (gps_obj.getGpsModuleStatus()) {
|
||||||
else
|
if (gps_obj.getFixStatus())
|
||||||
the_color = TFT_RED;
|
the_color = TFT_GREEN;
|
||||||
|
else
|
||||||
|
the_color = TFT_RED;
|
||||||
|
|
||||||
#ifdef HAS_ILI9341
|
#ifdef HAS_ILI9341
|
||||||
display_obj.tft.drawXBitmap(4,
|
display_obj.tft.drawXBitmap(4,
|
||||||
0,
|
0,
|
||||||
menu_icons[STATUS_GPS],
|
menu_icons[STATUS_GPS],
|
||||||
16,
|
16,
|
||||||
16,
|
16,
|
||||||
STATUSBAR_COLOR,
|
STATUSBAR_COLOR,
|
||||||
the_color);
|
the_color);
|
||||||
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
||||||
|
|
||||||
display_obj.tft.drawString(gps_obj.getNumSatsString(), 22, 0, 2);
|
display_obj.tft.drawString(gps_obj.getNumSatsString(), 22, 0, 2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
||||||
@@ -1348,22 +1352,26 @@ void MenuFunctions::drawStatusBar()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// GPS Stuff
|
// GPS Stuff
|
||||||
if (gps_obj.getFixStatus())
|
#ifdef HAS_GPS
|
||||||
the_color = TFT_GREEN;
|
if (gps_obj.getGpsModuleStatus()) {
|
||||||
else
|
if (gps_obj.getFixStatus())
|
||||||
the_color = TFT_RED;
|
the_color = TFT_GREEN;
|
||||||
|
else
|
||||||
|
the_color = TFT_RED;
|
||||||
|
|
||||||
#ifdef HAS_ILI9341
|
#ifdef HAS_ILI9341
|
||||||
display_obj.tft.drawXBitmap(4,
|
display_obj.tft.drawXBitmap(4,
|
||||||
0,
|
0,
|
||||||
menu_icons[STATUS_GPS],
|
menu_icons[STATUS_GPS],
|
||||||
16,
|
16,
|
||||||
16,
|
16,
|
||||||
STATUSBAR_COLOR,
|
STATUSBAR_COLOR,
|
||||||
the_color);
|
the_color);
|
||||||
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
||||||
|
|
||||||
display_obj.tft.drawString(gps_obj.getNumSatsString(), 22, 0, 2);
|
display_obj.tft.drawString(gps_obj.getNumSatsString(), 22, 0, 2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
//#include "a32u4_interface.h"
|
//#include "a32u4_interface.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include "GpsInterface.h"
|
#ifdef HAS_GPS
|
||||||
|
#include "GpsInterface.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_BUTTONS
|
#ifdef HAS_BUTTONS
|
||||||
#include <SwitchLib.h>
|
#include <SwitchLib.h>
|
||||||
@@ -36,7 +38,10 @@ extern BatteryInterface battery_obj;
|
|||||||
//extern A32u4Interface a32u4_obj;
|
//extern A32u4Interface a32u4_obj;
|
||||||
extern Settings settings_obj;
|
extern Settings settings_obj;
|
||||||
|
|
||||||
extern GpsInterface gps_obj;
|
|
||||||
|
#ifdef HAS_GPS
|
||||||
|
extern GpsInterface gps_obj;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FLASH_BUTTON 0
|
#define FLASH_BUTTON 0
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
//// BOARD TARGETS
|
//// BOARD TARGETS
|
||||||
//#define MARAUDER_M5STICKC
|
//#define MARAUDER_M5STICKC
|
||||||
//#define MARAUDER_MINI
|
//#define MARAUDER_MINI
|
||||||
//#define MARAUDER_V4
|
#define MARAUDER_V4
|
||||||
//#define MARAUDER_V6
|
//#define MARAUDER_V6
|
||||||
//#define MARAUDER_KIT
|
//#define MARAUDER_KIT
|
||||||
//#define GENERIC_ESP32
|
//#define GENERIC_ESP32
|
||||||
#define MARAUDER_FLIPPER
|
//#define MARAUDER_FLIPPER
|
||||||
//#define ESP32_LDDB
|
//#define ESP32_LDDB
|
||||||
//#define MARAUDER_DEV_BOARD_PRO
|
//#define MARAUDER_DEV_BOARD_PRO
|
||||||
//#define XIAO_ESP32_S3
|
//#define XIAO_ESP32_S3
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ https://www.online-utility.org/image/convert/to/XBM
|
|||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "GpsInterface.h"
|
#ifdef HAS_GPS
|
||||||
|
#include "GpsInterface.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Assets.h"
|
#include "Assets.h"
|
||||||
#include "WiFiScan.h"
|
#include "WiFiScan.h"
|
||||||
@@ -89,7 +91,9 @@ Buffer buffer_obj;
|
|||||||
Settings settings_obj;
|
Settings settings_obj;
|
||||||
CommandLine cli_obj;
|
CommandLine cli_obj;
|
||||||
|
|
||||||
GpsInterface gps_obj;
|
#ifdef HAS_GPS
|
||||||
|
GpsInterface gps_obj;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_BATTERY
|
#ifdef HAS_BATTERY
|
||||||
BatteryInterface battery_obj;
|
BatteryInterface battery_obj;
|
||||||
@@ -201,8 +205,6 @@ void setup()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gps_obj.begin();
|
|
||||||
|
|
||||||
//Serial.println("\n\nHello, World!\n");
|
//Serial.println("\n\nHello, World!\n");
|
||||||
|
|
||||||
Serial.println("ESP-IDF version is: " + String(esp_get_idf_version()));
|
Serial.println("ESP-IDF version is: " + String(esp_get_idf_version()));
|
||||||
@@ -334,6 +336,16 @@ void setup()
|
|||||||
delay(500);
|
delay(500);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_GPS
|
||||||
|
gps_obj.begin();
|
||||||
|
#ifdef HAS_SCREEN
|
||||||
|
if (gps_obj.getGpsModuleStatus())
|
||||||
|
display_obj.tft.println("GPS Module connected");
|
||||||
|
else
|
||||||
|
display_obj.tft.println("GPS Module NOT connected");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_SCREEN
|
#ifdef HAS_SCREEN
|
||||||
display_obj.tft.println(F(text_table0[8]));
|
display_obj.tft.println(F(text_table0[8]));
|
||||||
|
|
||||||
@@ -382,7 +394,9 @@ void loop()
|
|||||||
wifi_scan_obj.main(currentTime);
|
wifi_scan_obj.main(currentTime);
|
||||||
//evil_portal_obj.main(wifi_scan_obj.currentScanMode);
|
//evil_portal_obj.main(wifi_scan_obj.currentScanMode);
|
||||||
|
|
||||||
gps_obj.main();
|
#ifdef HAS_GPS
|
||||||
|
gps_obj.main();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WRITE_PACKETS_SERIAL
|
#ifdef WRITE_PACKETS_SERIAL
|
||||||
buffer_obj.forceSaveSerial();
|
buffer_obj.forceSaveSerial();
|
||||||
|
|||||||
Reference in New Issue
Block a user