Detect GPS module

This commit is contained in:
Just Call Me Koko
2023-08-30 15:57:44 -04:00
parent 3c9458e0f5
commit 0106081308
6 changed files with 78 additions and 41 deletions

View File

@@ -17,8 +17,12 @@ void GpsInterface::begin() {
delay(4000);
while (Serial2.available())
Serial2.read();
if (Serial2.available()) {
Serial.println("GPS Attached Successfully");
this->gps_enabled = true;
while (Serial2.available())
Serial2.read();
}
}
void GpsInterface::showGPSInfo() {
@@ -82,6 +86,10 @@ bool GpsInterface::getFixStatus() {
return this->good_fix;
}
bool GpsInterface::getGpsModuleStatus() {
return this->gps_enabled;
}
void GpsInterface::main() {
while (Serial2.available()) {
//Fetch the character one by one

View File

@@ -10,8 +10,10 @@ class GpsInterface {
String getNumSatsString();
bool getFixStatus();
bool getGpsModuleStatus();
private:
bool gps_enabled = false;
bool good_fix = false;
uint8_t num_sats = 0;
//MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));

View File

@@ -1230,22 +1230,26 @@ void MenuFunctions::updateStatusBar()
*/
// GPS Stuff
if (gps_obj.getFixStatus())
the_color = TFT_GREEN;
else
the_color = TFT_RED;
#ifdef HAS_ILI9341
display_obj.tft.drawXBitmap(4,
0,
menu_icons[STATUS_GPS],
16,
16,
STATUSBAR_COLOR,
the_color);
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
#ifdef HAS_GPS
if (gps_obj.getGpsModuleStatus()) {
if (gps_obj.getFixStatus())
the_color = TFT_GREEN;
else
the_color = TFT_RED;
#ifdef HAS_ILI9341
display_obj.tft.drawXBitmap(4,
0,
menu_icons[STATUS_GPS],
16,
16,
STATUSBAR_COLOR,
the_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
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
@@ -1348,22 +1352,26 @@ void MenuFunctions::drawStatusBar()
*/
// GPS Stuff
if (gps_obj.getFixStatus())
the_color = TFT_GREEN;
else
the_color = TFT_RED;
#ifdef HAS_ILI9341
display_obj.tft.drawXBitmap(4,
0,
menu_icons[STATUS_GPS],
16,
16,
STATUSBAR_COLOR,
the_color);
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
#ifdef HAS_GPS
if (gps_obj.getGpsModuleStatus()) {
if (gps_obj.getFixStatus())
the_color = TFT_GREEN;
else
the_color = TFT_RED;
#ifdef HAS_ILI9341
display_obj.tft.drawXBitmap(4,
0,
menu_icons[STATUS_GPS],
16,
16,
STATUSBAR_COLOR,
the_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
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);

View File

@@ -16,7 +16,9 @@
//#include "a32u4_interface.h"
#include "settings.h"
#include "GpsInterface.h"
#ifdef HAS_GPS
#include "GpsInterface.h"
#endif
#ifdef HAS_BUTTONS
#include <SwitchLib.h>
@@ -36,7 +38,10 @@ extern BatteryInterface battery_obj;
//extern A32u4Interface a32u4_obj;
extern Settings settings_obj;
extern GpsInterface gps_obj;
#ifdef HAS_GPS
extern GpsInterface gps_obj;
#endif
#define FLASH_BUTTON 0

View File

@@ -11,11 +11,11 @@
//// BOARD TARGETS
//#define MARAUDER_M5STICKC
//#define MARAUDER_MINI
//#define MARAUDER_V4
#define MARAUDER_V4
//#define MARAUDER_V6
//#define MARAUDER_KIT
//#define GENERIC_ESP32
#define MARAUDER_FLIPPER
//#define MARAUDER_FLIPPER
//#define ESP32_LDDB
//#define MARAUDER_DEV_BOARD_PRO
//#define XIAO_ESP32_S3

View File

@@ -24,7 +24,9 @@ https://www.online-utility.org/image/convert/to/XBM
#include "esp_system.h"
#include <Arduino.h>
#include "GpsInterface.h"
#ifdef HAS_GPS
#include "GpsInterface.h"
#endif
#include "Assets.h"
#include "WiFiScan.h"
@@ -89,7 +91,9 @@ Buffer buffer_obj;
Settings settings_obj;
CommandLine cli_obj;
GpsInterface gps_obj;
#ifdef HAS_GPS
GpsInterface gps_obj;
#endif
#ifdef HAS_BATTERY
BatteryInterface battery_obj;
@@ -201,8 +205,6 @@ void setup()
#endif
gps_obj.begin();
//Serial.println("\n\nHello, World!\n");
Serial.println("ESP-IDF version is: " + String(esp_get_idf_version()));
@@ -334,6 +336,16 @@ void setup()
delay(500);
#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
display_obj.tft.println(F(text_table0[8]));
@@ -382,7 +394,9 @@ void loop()
wifi_scan_obj.main(currentTime);
//evil_portal_obj.main(wifi_scan_obj.currentScanMode);
gps_obj.main();
#ifdef HAS_GPS
gps_obj.main();
#endif
#ifdef WRITE_PACKETS_SERIAL
buffer_obj.forceSaveSerial();