Added GPS Reset menu item

pull/8/head
Max-Plastix 2022-02-07 23:27:02 -08:00
rodzic 549a51951a
commit 4d64271b07
3 zmienionych plików z 42 dodań i 21 usunięć

Wyświetl plik

@ -2,12 +2,13 @@
#include "gps.h"
#include <Arduino.h>
#include "SparkFun_Ublox_Arduino_Library_Series_6_7.h"
#include <HardwareSerial.h>
#include <TinyGPS++.h>
#include "SparkFun_Ublox_Arduino_Library_Series_6_7.h"
#include "configuration.h"
HardwareSerial gpsSerial(GPS_SERIAL_NUM);
SFE_UBLOX_GPS myGNSS;
@ -34,9 +35,6 @@ void gps_setup(void) {
// Drain any waiting garbage
while (gpsSerial.read() != -1)
;
// Flush out line noise from our side
//char zeros[] = {0, 0, 0, 0, 0, 0};
//gpsSerial.write(zeros, sizeof(zeros));
if (0)
myGNSS.enableDebugging();
@ -91,9 +89,6 @@ void gps_setup(void) {
myGNSS.setUART1Output(COM_TYPE_NMEA); // We do want NMEA
if (0)
myGNSS.factoryReset();
myGNSS.setNavigationFrequency(2); // Produce X solutions per second
#if 0
@ -102,7 +97,6 @@ void gps_setup(void) {
myGNSS.disableNMEAMessage(UBX_NMEA_GAQ, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GBQ, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GBS, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GLL, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GLQ, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GNQ, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GNS, COM_PORT_UART1);
@ -110,13 +104,14 @@ void gps_setup(void) {
myGNSS.disableNMEAMessage(UBX_NMEA_GRS, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GST, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_TXT, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_VLW, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_VTG, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_ZDA, COM_PORT_UART1);
#endif
myGNSS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GLL, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_VTG, COM_PORT_UART1);
myGNSS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1); // Don't need SV list (on by default)
myGNSS.enableNMEAMessage(UBX_NMEA_RMC, COM_PORT_UART1); // For Speed
myGNSS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_UART1); // For Time & Location & SV count
@ -125,6 +120,20 @@ void gps_setup(void) {
myGNSS.saveConfiguration(); // Save the current settings to flash and BBR
}
void gps_full_reset(void) {
Serial.println("Resetting GPS...");
myGNSS.factoryReset();
delay(5000);
Serial.println("Reconfiguring GPS...");
gps_setup();
delay(1000);
// Drain any waiting garbage
while (gpsSerial.read() != -1)
;
// gps_passthrough();
// ESP.restart();
}
void gps_passthrough(void) {
Serial.println("GPS Passthrough forever...");
while (1) {

Wyświetl plik

@ -11,3 +11,4 @@ void gps_setup(void);
void gps_time(char *buffer, uint8_t size);
void gps_passthrough(void);
void gps_end(void);
void gps_full_reset(void);

Wyświetl plik

@ -78,7 +78,14 @@ unsigned int rest_tx_interval_s; // prefs REST_TX_INTERVAL
unsigned int tx_interval_s; // Currently-active time interval
enum activity_state { ACTIVITY_MOVING, ACTIVITY_REST, ACTIVITY_SLEEP, ACTIVITY_GPS_LOST, ACTIVITY_WOKE, ACTIVITY_INVALID };
enum activity_state {
ACTIVITY_MOVING,
ACTIVITY_REST,
ACTIVITY_SLEEP,
ACTIVITY_GPS_LOST,
ACTIVITY_WOKE,
ACTIVITY_INVALID
};
enum activity_state active_state = ACTIVITY_INVALID;
boolean never_rest = NEVER_REST;
@ -101,7 +108,7 @@ bool pmu_irq = false; // true when PMU IRQ pending
bool oled_found = false;
bool axp192_found = false;
uint8_t oled_addr = 0; // i2c address of OLED controller
uint8_t oled_addr = 0; // i2c address of OLED controller
bool packetQueued;
bool isJoined = false;
@ -220,7 +227,7 @@ bool gpslost_uplink(void) {
if (!SEND_GPSLOST_UPLINKS)
return false;
minutes_lost = (last_fix_time - millis()) / 1000 / 60;
pack_lat_lon(last_send_lat, last_send_lon);
txBuffer[6] = battery_byte();
@ -777,7 +784,7 @@ void low_power_sleep(uint32_t seconds) {
Serial.printf("Sleep %d..\n", seconds);
Serial.flush();
screen_off();
digitalWrite(RED_LED, HIGH); // LED Off
@ -806,7 +813,7 @@ void low_power_sleep(uint32_t seconds) {
if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_GPIO) {
// Try not to puke, but we pretend we moved if they hit a key, to exit SLEEP and restart timers
last_moved_ms = screen_last_active_ms = millis();
was_screen_on = true; // Lies
was_screen_on = true; // Lies
Serial.println("(GPIO)");
}
Serial.println("..woke");
@ -983,7 +990,7 @@ const char *find_irq_name(void) {
else if (axp.isVbusPlugInIRQ())
irq_name = "USB Connected"; // "VbusPlugIn";
else if (axp.isVbusRemoveIRQ())
irq_name = "USB Removed"; // "VbusRemove";
irq_name = "USB Removed"; // "VbusRemove";
else if (axp.isVbusLowVHOLDIRQ())
irq_name = "VbusLowVHOLD";
else if (axp.isBattPlugInIRQ())
@ -1144,6 +1151,10 @@ void menu_stay_on(void) {
screen_stay_on = !screen_stay_on;
}
void menu_gps_reset(void) {
gps_full_reset();
}
dr_t sf_list[] = {DR_SF7, DR_SF8, DR_SF9, DR_SF10};
#define SF_ENTRIES (sizeof(sf_list) / sizeof(sf_list[0]))
uint8_t sf_index = 0;
@ -1162,9 +1173,9 @@ void menu_change_sf(void) {
struct menu_entry menu[] = {
{"Send Now", menu_send_now}, {"Power Off", menu_power_off}, {"Distance +", menu_distance_plus},
{"Distance -", menu_distance_minus}, {"Time +", menu_time_plus}, {"Time -", menu_time_minus},
{"Change SF", menu_change_sf}, {"Full Reset", menu_flush_prefs}, {"USB GPS", menu_gps_passthrough},
{"Change SF", menu_change_sf}, {"Helium ReJoin", menu_flush_prefs}, {"USB GPS", menu_gps_passthrough},
{"Deadzone Here", menu_deadzone_here}, {"No Deadzone", menu_no_deadzone}, {"Stay On", menu_stay_on},
{"Experiment", menu_experiment}};
{"GPS Reset", menu_gps_reset}, {"Experiment", menu_experiment}};
#define MENU_ENTRIES (sizeof(menu) / sizeof(menu[0]))
const char *menu_prev;
@ -1204,10 +1215,10 @@ void loop() {
uint32_t now = millis();
gps_loop(0 /* active_state == ACTIVITY_WOKE */); // Update GPS
now_fix_count = tGPS.sentencesWithFix(); // Did we get a new fix?
now_fix_count = tGPS.sentencesWithFix(); // Did we get a new fix?
if (now_fix_count != last_fix_count) {
last_fix_count = now_fix_count;
last_fix_time = now; // Note the time of most recent fix
last_fix_time = now; // Note the time of most recent fix
}
ttn_loop();