mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2026-04-28 12:03:07 -07:00
Add GPS capability
This commit is contained in:
@@ -262,12 +262,15 @@ PROGMEM static const unsigned char menu_icons[][66] = {
|
||||
0x1F, 0xCE, 0x3D, 0xDF, 0xE4, 0x3D, 0xBF, 0xF1, 0x3E, 0x7F, 0x7F, 0x3F,
|
||||
0xFF, 0xBE, 0x3F, 0xFF, 0xC1, 0x3F, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F,
|
||||
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0x3F},
|
||||
{0x7F, 0xFE,0xFF, 0x7F, 0xFC, 0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0xF8, //LANGUAGE: 35
|
||||
{0x7F, 0xFE,0xFF, 0x7F, 0xFC, 0xFF, 0xFF, 0xF8, 0xFF, 0x00, 0x00, 0xF8, // LANGUAGE: 35
|
||||
0x00, 0x00, 0xF8, 0xCF, 0x3F, 0xFF, 0xCF, 0x3F ,0xFF, 0x9F, 0x9F, 0xFF,
|
||||
0x9F, 0x8F, 0xFF, 0x3F, 0xC7, 0xFF, 0x3F, 0xE2, 0xFF, 0xFF, 0xF0, 0xFF,
|
||||
0x7F, 0xF8, 0xFF, 0x1F, 0xF2, 0xFE, 0x87, 0x67, 0xFD, 0xE0, 0x4F, 0xFD,
|
||||
0xF9, 0xBF, 0xFB, 0xFF, 0xBF, 0xFB, 0xFF, 0x3F, 0xF8, 0xFF, 0xDF, 0xF7,
|
||||
0xFF, 0xDF, 0xF7, 0xFF, 0xDF, 0xF7}
|
||||
0xFF, 0xDF, 0xF7, 0xFF, 0xDF, 0xF7},
|
||||
{0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0xF5, 0xEF, 0xEE, 0x57, 0xF7, 0x2F, 0xFA, // GPS: 36
|
||||
0x1F, 0xFC, 0x0F, 0xDE, 0x17, 0xD5, 0xBB, 0xD6, 0xDD, 0xDB, 0xEB, 0xEC,
|
||||
0xF7, 0xF7, 0x7F, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF}
|
||||
};
|
||||
|
||||
#ifndef MARAUDER_MINI
|
||||
|
||||
108
esp32_marauder/GpsInterface.cpp
Normal file
108
esp32_marauder/GpsInterface.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
#include "GpsInterface.h"
|
||||
|
||||
char nmeaBuffer[100];
|
||||
|
||||
MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
|
||||
|
||||
HardwareSerial Serial2(2);
|
||||
|
||||
void GpsInterface::begin() {
|
||||
|
||||
Serial2.begin(9600, SERIAL_8N1, 4, 13);
|
||||
|
||||
MicroNMEA::sendSentence(Serial2, "$PSTMSETPAR,1201,0x00000042");
|
||||
MicroNMEA::sendSentence(Serial2, "$PSTMSAVEPAR");
|
||||
|
||||
MicroNMEA::sendSentence(Serial2, "$PSTMSRR");
|
||||
|
||||
delay(4000);
|
||||
|
||||
while (Serial2.available())
|
||||
Serial2.read();
|
||||
}
|
||||
|
||||
void GpsInterface::showGPSInfo() {
|
||||
Serial.print("Valid fix: ");
|
||||
Serial.println(nmea.isValid() ? "yes" : "no");
|
||||
|
||||
Serial.print("Nav. system: ");
|
||||
if (nmea.getNavSystem())
|
||||
Serial.println(nmea.getNavSystem());
|
||||
else
|
||||
Serial.println("none");
|
||||
|
||||
Serial.print("Num. satellites: ");
|
||||
Serial.println(nmea.getNumSatellites());
|
||||
|
||||
Serial.print("HDOP: ");
|
||||
Serial.println(nmea.getHDOP() / 10., 1);
|
||||
|
||||
Serial.print("Date/time: ");
|
||||
Serial.print(nmea.getYear());
|
||||
Serial.print('-');
|
||||
Serial.print(int(nmea.getMonth()));
|
||||
Serial.print('-');
|
||||
Serial.print(int(nmea.getDay()));
|
||||
Serial.print('T');
|
||||
Serial.print(int(nmea.getHour()));
|
||||
Serial.print(':');
|
||||
Serial.print(int(nmea.getMinute()));
|
||||
Serial.print(':');
|
||||
Serial.println(int(nmea.getSecond()));
|
||||
|
||||
long latitude_mdeg = nmea.getLatitude();
|
||||
long longitude_mdeg = nmea.getLongitude();
|
||||
Serial.print("Latitude (deg): ");
|
||||
Serial.println(latitude_mdeg / 1000000., 6);
|
||||
|
||||
Serial.print("Longitude (deg): ");
|
||||
Serial.println(longitude_mdeg / 1000000., 6);
|
||||
|
||||
long alt;
|
||||
Serial.print("Altitude (m): ");
|
||||
if (nmea.getAltitude(alt))
|
||||
Serial.println(alt / 1000., 3);
|
||||
else
|
||||
Serial.println("not available");
|
||||
|
||||
Serial.print("Speed: ");
|
||||
Serial.println(nmea.getSpeed() / 1000., 3);
|
||||
Serial.print("Course: ");
|
||||
Serial.println(nmea.getCourse() / 1000., 3);
|
||||
|
||||
Serial.println("-----------------------");
|
||||
nmea.clear();
|
||||
}
|
||||
|
||||
String GpsInterface::getNumSatsString() {
|
||||
return (String)num_sats;
|
||||
}
|
||||
|
||||
bool GpsInterface::getFixStatus() {
|
||||
return this->good_fix;
|
||||
}
|
||||
|
||||
void GpsInterface::main() {
|
||||
while (Serial2.available()) {
|
||||
//Fetch the character one by one
|
||||
char c = Serial2.read();
|
||||
//Serial.print(c);
|
||||
//Pass the character to the library
|
||||
nmea.process(c);
|
||||
}
|
||||
|
||||
uint8_t num_sat = nmea.getNumSatellites();
|
||||
|
||||
if ((nmea.isValid()) && (num_sat > 0)) {
|
||||
this->good_fix = true;
|
||||
this->num_sats = nmea.getNumSatellites();
|
||||
//Serial.print("Got fix: ");
|
||||
//Serial.println(num_sats);
|
||||
//this->showGPSInfo();
|
||||
}
|
||||
else if ((!nmea.isValid()) && (num_sat <= 0)) {
|
||||
this->good_fix = false;
|
||||
this->num_sats = nmea.getNumSatellites();
|
||||
//Serial.println("No fix");
|
||||
}
|
||||
}
|
||||
22
esp32_marauder/GpsInterface.h
Normal file
22
esp32_marauder/GpsInterface.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef GpsInterface_h
|
||||
#define GpsInterface_h
|
||||
|
||||
#include <MicroNMEA.h>
|
||||
|
||||
class GpsInterface {
|
||||
public:
|
||||
void begin();
|
||||
void main();
|
||||
|
||||
String getNumSatsString();
|
||||
bool getFixStatus();
|
||||
|
||||
private:
|
||||
bool good_fix = false;
|
||||
uint8_t num_sats = 0;
|
||||
//MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer));
|
||||
|
||||
void showGPSInfo();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1213,6 +1213,7 @@ void MenuFunctions::updateStatusBar()
|
||||
else
|
||||
the_color = TFT_MAROON;
|
||||
|
||||
/*
|
||||
display_obj.tft.setTextColor(the_color, STATUSBAR_COLOR);
|
||||
if (temp_obj.current_temp != temp_obj.old_temp) {
|
||||
temp_obj.old_temp = temp_obj.current_temp;
|
||||
@@ -1225,6 +1226,28 @@ void MenuFunctions::updateStatusBar()
|
||||
display_obj.tft.drawString((String)temp_obj.current_temp + " C", 0, 0, 1);
|
||||
#endif
|
||||
}
|
||||
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
||||
*/
|
||||
|
||||
// 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);
|
||||
|
||||
display_obj.tft.drawString(gps_obj.getNumSatsString(), 22, 0, 2);
|
||||
#endif
|
||||
|
||||
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
||||
|
||||
// WiFi Channel Stuff
|
||||
@@ -1257,6 +1280,8 @@ void MenuFunctions::updateStatusBar()
|
||||
// Draw battery info
|
||||
MenuFunctions::battery(false);
|
||||
|
||||
//display_obj.tft.drawString(gps_obj.getNumSatsString(), 204, 0, 2);
|
||||
|
||||
// Draw SD info
|
||||
#ifndef WRITE_PACKETS_SERIAL
|
||||
if (sd_obj.supported)
|
||||
@@ -1311,6 +1336,7 @@ void MenuFunctions::drawStatusBar()
|
||||
display_obj.tft.setTextColor(the_color, STATUSBAR_COLOR);
|
||||
temp_obj.old_temp = temp_obj.current_temp;
|
||||
display_obj.tft.fillRect(0, 0, 50, STATUS_BAR_WIDTH, STATUSBAR_COLOR);
|
||||
/*
|
||||
#ifdef HAS_ILI9341
|
||||
display_obj.tft.drawString((String)temp_obj.current_temp + " C", 4, 0, 2);
|
||||
#endif
|
||||
@@ -1319,6 +1345,28 @@ void MenuFunctions::drawStatusBar()
|
||||
display_obj.tft.drawString((String)temp_obj.current_temp + " C", 0, 0, 1);
|
||||
#endif
|
||||
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
||||
*/
|
||||
|
||||
// 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);
|
||||
|
||||
display_obj.tft.drawString(gps_obj.getNumSatsString(), 22, 0, 2);
|
||||
#endif
|
||||
|
||||
display_obj.tft.setTextColor(TFT_WHITE, STATUSBAR_COLOR);
|
||||
|
||||
|
||||
// WiFi Channel Stuff
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
//#include "a32u4_interface.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "GpsInterface.h"
|
||||
|
||||
#ifdef HAS_BUTTONS
|
||||
#include <SwitchLib.h>
|
||||
extern SwitchLib u_btn;
|
||||
@@ -34,6 +36,8 @@ extern BatteryInterface battery_obj;
|
||||
//extern A32u4Interface a32u4_obj;
|
||||
extern Settings settings_obj;
|
||||
|
||||
extern GpsInterface gps_obj;
|
||||
|
||||
#define FLASH_BUTTON 0
|
||||
|
||||
#if BATTERY_ANALOG_ON == 1
|
||||
@@ -79,6 +83,7 @@ extern Settings settings_obj;
|
||||
#define BAD_USB_ICO 33
|
||||
#define TEST_BAD_USB_ICO 34
|
||||
#define LANGUAGE 35
|
||||
#define STATUS_GPS 36
|
||||
|
||||
PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
|
||||
PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
//#define XIAO_ESP32_S3
|
||||
//// END BOARD TARGETS
|
||||
|
||||
#define MARAUDER_VERSION "v0.11.0-RC3"
|
||||
#define MARAUDER_VERSION "v0.11.0"
|
||||
|
||||
//// BOARD FEATURES
|
||||
#ifdef MARAUDER_M5STICKC
|
||||
@@ -34,6 +34,7 @@
|
||||
#define HAS_SD
|
||||
#define USE_SD
|
||||
#define HAS_TEMP_SENSOR
|
||||
//#define HAS_GPS
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_MINI
|
||||
@@ -47,6 +48,7 @@
|
||||
#define HAS_SD
|
||||
#define USE_SD
|
||||
#define HAS_TEMP_SENSOR
|
||||
//#define HAS_GPS
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_V4
|
||||
@@ -60,6 +62,7 @@
|
||||
#define HAS_SD
|
||||
#define USE_SD
|
||||
#define HAS_TEMP_SENSOR
|
||||
#define HAS_GPS
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_V6
|
||||
@@ -73,6 +76,7 @@
|
||||
#define HAS_SD
|
||||
#define USE_SD
|
||||
#define HAS_TEMP_SENSOR
|
||||
#define HAS_GPS
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_KIT
|
||||
@@ -86,6 +90,7 @@
|
||||
#define HAS_SD
|
||||
#define USE_SD
|
||||
#define HAS_TEMP_SENSOR
|
||||
#define HAS_GPS
|
||||
#endif
|
||||
|
||||
#ifdef GENERIC_ESP32
|
||||
@@ -98,6 +103,7 @@
|
||||
//#define HAS_SCREEN
|
||||
//#define HAS_SD
|
||||
//#define HAS_TEMP_SENSOR
|
||||
//#define HAS_GPS
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_FLIPPER
|
||||
@@ -108,6 +114,7 @@
|
||||
//#define HAS_NEOPIXEL_LED
|
||||
//#define HAS_PWR_MGMT
|
||||
//#define HAS_SCREEN
|
||||
//#define HAS_GPS
|
||||
#ifndef WRITE_PACKETS_SERIAL
|
||||
#define HAS_SD
|
||||
#define USE_SD
|
||||
@@ -126,6 +133,7 @@
|
||||
#define HAS_SD
|
||||
#define USE_SD
|
||||
//#define HAS_TEMP_SENSOR
|
||||
//#define HAS_GPS
|
||||
#endif
|
||||
|
||||
#ifdef MARAUDER_DEV_BOARD_PRO
|
||||
@@ -139,6 +147,7 @@
|
||||
#define HAS_SD
|
||||
#define USE_SD
|
||||
//#define HAS_TEMP_SENSOR
|
||||
//#define HAS_GPS
|
||||
#endif
|
||||
|
||||
#ifdef XIAO_ESP32_S3
|
||||
@@ -151,6 +160,7 @@
|
||||
//#define HAS_SCREEN
|
||||
//#define HAS_SD
|
||||
//#define HAS_TEMP_SENSOR
|
||||
//#define HAS_GPS
|
||||
#endif
|
||||
//// END BOARD FEATURES
|
||||
|
||||
@@ -746,4 +756,6 @@
|
||||
#endif
|
||||
//// END EVIL PORTAL STUFF
|
||||
|
||||
////
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,8 @@ https://www.online-utility.org/image/convert/to/XBM
|
||||
#include "esp_system.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "GpsInterface.h"
|
||||
|
||||
#include "Assets.h"
|
||||
#include "WiFiScan.h"
|
||||
#ifdef HAS_SD
|
||||
@@ -87,6 +89,8 @@ Buffer buffer_obj;
|
||||
Settings settings_obj;
|
||||
CommandLine cli_obj;
|
||||
|
||||
GpsInterface gps_obj;
|
||||
|
||||
#ifdef HAS_BATTERY
|
||||
BatteryInterface battery_obj;
|
||||
#endif
|
||||
@@ -197,6 +201,8 @@ void setup()
|
||||
|
||||
#endif
|
||||
|
||||
gps_obj.begin();
|
||||
|
||||
//Serial.println("\n\nHello, World!\n");
|
||||
|
||||
Serial.println("ESP-IDF version is: " + String(esp_get_idf_version()));
|
||||
@@ -375,6 +381,8 @@ void loop()
|
||||
#endif
|
||||
wifi_scan_obj.main(currentTime);
|
||||
//evil_portal_obj.main(wifi_scan_obj.currentScanMode);
|
||||
|
||||
gps_obj.main();
|
||||
|
||||
#ifdef WRITE_PACKETS_SERIAL
|
||||
buffer_obj.forceSaveSerial();
|
||||
|
||||
BIN
pictures/icons/gps_16.bmp
Normal file
BIN
pictures/icons/gps_16.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
6
pictures/xbm/gps_16.xbm
Normal file
6
pictures/xbm/gps_16.xbm
Normal file
@@ -0,0 +1,6 @@
|
||||
#define f5dc88022d18492ea6769b98921e0a5aUvT7HPFFeGcrDDT7_width 16
|
||||
#define f5dc88022d18492ea6769b98921e0a5aUvT7HPFFeGcrDDT7_height 16
|
||||
static char f5dc88022d18492ea6769b98921e0a5aUvT7HPFFeGcrDDT7_bits[] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0xF5, 0xEF, 0xEE, 0x57, 0xF7, 0x2F, 0xFA,
|
||||
0x1F, 0xFC, 0x0F, 0xDE, 0x17, 0xD5, 0xBB, 0xD6, 0xDD, 0xDB, 0xEB, 0xEC,
|
||||
0xF7, 0xF7, 0x7F, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, };
|
||||
Reference in New Issue
Block a user