mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-08 04:28:47 +00:00
Compare commits
1 Commits
8cd2a2ae27
...
b9dd902ee2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b9dd902ee2 |
@ -1,14 +1,7 @@
|
|||||||
#include "DisplayFormatters.h"
|
#include "DisplayFormatters.h"
|
||||||
|
|
||||||
const char *DisplayFormatters::getModemPresetDisplayName(meshtastic_Config_LoRaConfig_ModemPreset preset, bool useShortName,
|
const char *DisplayFormatters::getModemPresetDisplayName(meshtastic_Config_LoRaConfig_ModemPreset preset, bool useShortName)
|
||||||
bool usePreset)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// If use_preset is false, always return "Custom"
|
|
||||||
if (!usePreset) {
|
|
||||||
return "Custom";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case meshtastic_Config_LoRaConfig_ModemPreset_SHORT_TURBO:
|
case meshtastic_Config_LoRaConfig_ModemPreset_SHORT_TURBO:
|
||||||
return useShortName ? "ShortT" : "ShortTurbo";
|
return useShortName ? "ShortT" : "ShortTurbo";
|
||||||
|
@ -4,6 +4,5 @@
|
|||||||
class DisplayFormatters
|
class DisplayFormatters
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const char *getModemPresetDisplayName(meshtastic_Config_LoRaConfig_ModemPreset preset, bool useShortName,
|
static const char *getModemPresetDisplayName(meshtastic_Config_LoRaConfig_ModemPreset preset, bool useShortName);
|
||||||
bool usePreset);
|
|
||||||
};
|
};
|
||||||
|
@ -843,6 +843,9 @@ void GPS::setPowerState(GPSPowerState newState, uint32_t sleepTime)
|
|||||||
setPowerPMU(true); // Power (PMU): on
|
setPowerPMU(true); // Power (PMU): on
|
||||||
writePinStandby(false); // Standby (pin): awake (not standby)
|
writePinStandby(false); // Standby (pin): awake (not standby)
|
||||||
setPowerUBLOX(true); // Standby (UBLOX): awake
|
setPowerUBLOX(true); // Standby (UBLOX): awake
|
||||||
|
#ifdef GNSS_AIROHA
|
||||||
|
lastFixStartMsec = 0;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GPS_SOFTSLEEP:
|
case GPS_SOFTSLEEP:
|
||||||
@ -860,7 +863,9 @@ void GPS::setPowerState(GPSPowerState newState, uint32_t sleepTime)
|
|||||||
writePinStandby(true); // Standby (pin): asleep (not awake)
|
writePinStandby(true); // Standby (pin): asleep (not awake)
|
||||||
setPowerUBLOX(false, sleepTime); // Standby (UBLOX): asleep, timed
|
setPowerUBLOX(false, sleepTime); // Standby (UBLOX): asleep, timed
|
||||||
#ifdef GNSS_AIROHA
|
#ifdef GNSS_AIROHA
|
||||||
|
if (config.position.gps_update_interval * 1000 >= GPS_FIX_HOLD_TIME * 2) {
|
||||||
digitalWrite(PIN_GPS_EN, LOW);
|
digitalWrite(PIN_GPS_EN, LOW);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -872,7 +877,9 @@ void GPS::setPowerState(GPSPowerState newState, uint32_t sleepTime)
|
|||||||
writePinStandby(true); // Standby (pin): asleep
|
writePinStandby(true); // Standby (pin): asleep
|
||||||
setPowerUBLOX(false, 0); // Standby (UBLOX): asleep, indefinitely
|
setPowerUBLOX(false, 0); // Standby (UBLOX): asleep, indefinitely
|
||||||
#ifdef GNSS_AIROHA
|
#ifdef GNSS_AIROHA
|
||||||
|
if (config.position.gps_update_interval * 1000 >= GPS_FIX_HOLD_TIME * 2) {
|
||||||
digitalWrite(PIN_GPS_EN, LOW);
|
digitalWrite(PIN_GPS_EN, LOW);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1055,8 +1062,6 @@ void GPS::down()
|
|||||||
}
|
}
|
||||||
// If update interval long enough (or softsleep unsupported): hardsleep instead
|
// If update interval long enough (or softsleep unsupported): hardsleep instead
|
||||||
setPowerState(GPS_HARDSLEEP, sleepTime);
|
setPowerState(GPS_HARDSLEEP, sleepTime);
|
||||||
// Reset the fix quality to 0, since we're off.
|
|
||||||
fixQual = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1116,19 +1121,11 @@ int32_t GPS::runOnce()
|
|||||||
shouldPublish = true;
|
shouldPublish = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t prev_fixQual = fixQual;
|
|
||||||
bool gotLoc = lookForLocation();
|
bool gotLoc = lookForLocation();
|
||||||
if (gotLoc && !hasValidLocation) { // declare that we have location ASAP
|
if (gotLoc && !hasValidLocation) { // declare that we have location ASAP
|
||||||
LOG_DEBUG("hasValidLocation RISING EDGE");
|
LOG_DEBUG("hasValidLocation RISING EDGE");
|
||||||
hasValidLocation = true;
|
hasValidLocation = true;
|
||||||
shouldPublish = true;
|
shouldPublish = true;
|
||||||
// Hold for 20secs after getting a lock to download ephemeris etc
|
|
||||||
fixHoldEnds = millis() + 20000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gotLoc && prev_fixQual == 0) { // just got a lock after turning back on.
|
|
||||||
fixHoldEnds = millis() + 20000;
|
|
||||||
shouldPublish = true; // Publish immediately, since next publish is at end of hold
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tooLong = scheduling.searchedTooLong();
|
bool tooLong = scheduling.searchedTooLong();
|
||||||
@ -1137,7 +1134,8 @@ int32_t GPS::runOnce()
|
|||||||
|
|
||||||
// Once we get a location we no longer desperately want an update
|
// Once we get a location we no longer desperately want an update
|
||||||
if ((gotLoc && gotTime) || tooLong) {
|
if ((gotLoc && gotTime) || tooLong) {
|
||||||
if (tooLong && !gotLoc) {
|
|
||||||
|
if (tooLong) {
|
||||||
// we didn't get a location during this ack window, therefore declare loss of lock
|
// we didn't get a location during this ack window, therefore declare loss of lock
|
||||||
if (hasValidLocation) {
|
if (hasValidLocation) {
|
||||||
LOG_DEBUG("hasValidLocation FALLING EDGE");
|
LOG_DEBUG("hasValidLocation FALLING EDGE");
|
||||||
@ -1145,15 +1143,9 @@ int32_t GPS::runOnce()
|
|||||||
p = meshtastic_Position_init_default;
|
p = meshtastic_Position_init_default;
|
||||||
hasValidLocation = false;
|
hasValidLocation = false;
|
||||||
}
|
}
|
||||||
if (millis() > fixHoldEnds) {
|
|
||||||
shouldPublish = true; // publish our update at the end of the lock hold
|
|
||||||
publishUpdate();
|
|
||||||
down();
|
down();
|
||||||
#ifdef GPS_DEBUG
|
shouldPublish = true; // publish our update for this just finished acquisition window
|
||||||
} else {
|
|
||||||
LOG_DEBUG("Holding for GPS data download: %d ms (numSats=%d)", fixHoldEnds - millis(), p.sats_in_view);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If state has changed do a publish
|
// If state has changed do a publish
|
||||||
@ -1516,6 +1508,24 @@ static int32_t toDegInt(RawDegrees d)
|
|||||||
*/
|
*/
|
||||||
bool GPS::lookForTime()
|
bool GPS::lookForTime()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef GNSS_AIROHA
|
||||||
|
uint8_t fix = reader.fixQuality();
|
||||||
|
if (fix >= 1 && fix <= 5) {
|
||||||
|
if (lastFixStartMsec > 0) {
|
||||||
|
if (Throttle::isWithinTimespanMs(lastFixStartMsec, GPS_FIX_HOLD_TIME)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
clearBuffer();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lastFixStartMsec = millis();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
auto ti = reader.time;
|
auto ti = reader.time;
|
||||||
auto d = reader.date;
|
auto d = reader.date;
|
||||||
if (ti.isValid() && d.isValid()) { // Note: we don't check for updated, because we'll only be called if needed
|
if (ti.isValid() && d.isValid()) { // Note: we don't check for updated, because we'll only be called if needed
|
||||||
@ -1554,6 +1564,25 @@ The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of s
|
|||||||
*/
|
*/
|
||||||
bool GPS::lookForLocation()
|
bool GPS::lookForLocation()
|
||||||
{
|
{
|
||||||
|
#ifdef GNSS_AIROHA
|
||||||
|
if ((config.position.gps_update_interval * 1000) >= (GPS_FIX_HOLD_TIME * 2)) {
|
||||||
|
uint8_t fix = reader.fixQuality();
|
||||||
|
if (fix >= 1 && fix <= 5) {
|
||||||
|
if (lastFixStartMsec > 0) {
|
||||||
|
if (Throttle::isWithinTimespanMs(lastFixStartMsec, GPS_FIX_HOLD_TIME)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
clearBuffer();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lastFixStartMsec = millis();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// By default, TinyGPS++ does not parse GPGSA lines, which give us
|
// By default, TinyGPS++ does not parse GPGSA lines, which give us
|
||||||
// the 2D/3D fixType (see NMEAGPS.h)
|
// the 2D/3D fixType (see NMEAGPS.h)
|
||||||
// At a minimum, use the fixQuality indicator in GPGGA (FIXME?)
|
// At a minimum, use the fixQuality indicator in GPGGA (FIXME?)
|
||||||
|
@ -159,7 +159,7 @@ class GPS : private concurrency::OSThread
|
|||||||
uint8_t fixType = 0; // fix type from GPGSA
|
uint8_t fixType = 0; // fix type from GPGSA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t fixHoldEnds = 0;
|
uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
|
||||||
uint32_t rx_gpio = 0;
|
uint32_t rx_gpio = 0;
|
||||||
uint32_t tx_gpio = 0;
|
uint32_t tx_gpio = 0;
|
||||||
|
|
||||||
|
@ -263,6 +263,12 @@ void drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
display->drawString(x + 1, y, "USB");
|
display->drawString(x + 1, y, "USB");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// auto mode = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, true);
|
||||||
|
|
||||||
|
// display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode), y, mode);
|
||||||
|
// if (config.display.heading_bold)
|
||||||
|
// display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode) - 1, y, mode);
|
||||||
|
|
||||||
uint32_t currentMillis = millis();
|
uint32_t currentMillis = millis();
|
||||||
uint32_t seconds = currentMillis / 1000;
|
uint32_t seconds = currentMillis / 1000;
|
||||||
uint32_t minutes = seconds / 60;
|
uint32_t minutes = seconds / 60;
|
||||||
@ -392,7 +398,7 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
display->drawString(nameX, getTextPositions(display)[line++], shortnameble);
|
display->drawString(nameX, getTextPositions(display)[line++], shortnameble);
|
||||||
|
|
||||||
// === Second Row: Radio Preset ===
|
// === Second Row: Radio Preset ===
|
||||||
auto mode = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false, config.lora.use_preset);
|
auto mode = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
|
||||||
char regionradiopreset[25];
|
char regionradiopreset[25];
|
||||||
const char *region = myRegion ? myRegion->name : NULL;
|
const char *region = myRegion ? myRegion->name : NULL;
|
||||||
if (region != nullptr) {
|
if (region != nullptr) {
|
||||||
|
@ -368,7 +368,7 @@ const char *Channels::getName(size_t chIndex)
|
|||||||
// Per mesh.proto spec, if bandwidth is specified we must ignore modemPreset enum, we assume that in that case
|
// Per mesh.proto spec, if bandwidth is specified we must ignore modemPreset enum, we assume that in that case
|
||||||
// the app effed up and forgot to set channelSettings.name
|
// the app effed up and forgot to set channelSettings.name
|
||||||
if (config.lora.use_preset) {
|
if (config.lora.use_preset) {
|
||||||
channelName = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false, config.lora.use_preset);
|
channelName = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
|
||||||
} else {
|
} else {
|
||||||
channelName = "Custom";
|
channelName = "Custom";
|
||||||
}
|
}
|
||||||
@ -382,8 +382,7 @@ bool Channels::isDefaultChannel(ChannelIndex chIndex)
|
|||||||
const auto &ch = getByIndex(chIndex);
|
const auto &ch = getByIndex(chIndex);
|
||||||
if (ch.settings.psk.size == 1 && ch.settings.psk.bytes[0] == 1) {
|
if (ch.settings.psk.size == 1 && ch.settings.psk.bytes[0] == 1) {
|
||||||
const char *name = getName(chIndex);
|
const char *name = getName(chIndex);
|
||||||
const char *presetName =
|
const char *presetName = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
|
||||||
DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false, config.lora.use_preset);
|
|
||||||
// Check if the name is the default derived from the modem preset
|
// Check if the name is the default derived from the modem preset
|
||||||
if (strcmp(name, presetName) == 0)
|
if (strcmp(name, presetName) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
@ -589,8 +589,7 @@ void RadioInterface::applyModemConfig()
|
|||||||
|
|
||||||
// Check if we use the default frequency slot
|
// Check if we use the default frequency slot
|
||||||
RadioInterface::uses_default_frequency_slot =
|
RadioInterface::uses_default_frequency_slot =
|
||||||
channel_num ==
|
channel_num == hash(DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false)) % numChannels;
|
||||||
hash(DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false, config.lora.use_preset)) % numChannels;
|
|
||||||
|
|
||||||
// Old frequency selection formula
|
// Old frequency selection formula
|
||||||
// float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);
|
// float freq = myRegion->freqStart + ((((myRegion->freqEnd - myRegion->freqStart) / numChannels) / 2) * channel_num);
|
||||||
|
@ -124,6 +124,7 @@ extern "C" {
|
|||||||
#define GPS_RTC_INT (0 + 15) // P0.15, normal is LOW, wake by HIGH
|
#define GPS_RTC_INT (0 + 15) // P0.15, normal is LOW, wake by HIGH
|
||||||
#define GPS_RESETB_OUT (32 + 14) // P1.14, always input pull_up
|
#define GPS_RESETB_OUT (32 + 14) // P1.14, always input pull_up
|
||||||
|
|
||||||
|
#define GPS_FIX_HOLD_TIME 15000 // ms
|
||||||
#define BATTERY_PIN 2 // P0.02/AIN0, BAT_ADC
|
#define BATTERY_PIN 2 // P0.02/AIN0, BAT_ADC
|
||||||
#define BATTERY_IMMUTABLE
|
#define BATTERY_IMMUTABLE
|
||||||
#define ADC_MULTIPLIER (2.0F)
|
#define ADC_MULTIPLIER (2.0F)
|
||||||
|
@ -123,6 +123,7 @@ extern "C" {
|
|||||||
#define GPS_RESETB_OUT (32 + 14) // P1.14, awlays input pull_up
|
#define GPS_RESETB_OUT (32 + 14) // P1.14, awlays input pull_up
|
||||||
|
|
||||||
// #define GPS_THREAD_INTERVAL 50
|
// #define GPS_THREAD_INTERVAL 50
|
||||||
|
#define GPS_FIX_HOLD_TIME 15000 // ms
|
||||||
|
|
||||||
#define BATTERY_PIN 2
|
#define BATTERY_PIN 2
|
||||||
// #define ADC_CHANNEL ADC1_GPIO2_CHANNEL
|
// #define ADC_CHANNEL ADC1_GPIO2_CHANNEL
|
||||||
|
Loading…
Reference in New Issue
Block a user