Now read speed, altitude and direction changes on the GPS screen automatically with a forced minimum of 10 seconds between readings to avoid a bit of hysterisis .

Can still get full summary on long hold f1.
md1702
vk7js 2022-09-13 15:40:12 +10:00 zatwierdzone przez Silvano Seva
rodzic 3ba094f633
commit 5829df6dd3
4 zmienionych plików z 176 dodań i 87 usunięć

Wyświetl plik

@ -155,7 +155,7 @@ void vp_announceM17Info(const channel_t* channel, const vpQueueFlags_t flags);
*
*/
#ifdef GPS_PRESENT
void vp_announceGPSInfo();
void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags);
#endif
/**

Wyświetl plik

@ -242,6 +242,22 @@ typedef enum
}
vpSummaryInfoFlags_t;
typedef enum
{
vpGPSNone=0,
vpGPSIntro=0x01,
vpGPSFixQuality = 0x02,
vpGPSFixType = 0x04,
vpGPSLatitude = 0x08,
vpGPSLongitude = 0x10,
vpGPSSpeed = 0x20,
vpGPSAltitude = 0x40,
vpGPSDirection = 0x80,
vpGPSSatCount = 0x100,
vpGPSAll = 0xff,
}
vpGPSInfoFlags_t;
typedef struct
{
uint16_t freq;

Wyświetl plik

@ -527,104 +527,131 @@ void vp_announceM17Info(const channel_t* channel, const vpQueueFlags_t flags)
}
#ifdef GPS_PRESENT
void vp_announceGPSInfo()
void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags)
{
vp_flush();
vpQueueFlags_t flags = vpqIncludeDescriptions
| vpqAddSeparatingSilence;
vp_queueStringTableEntry(&currentLanguage->gps);
if (!state.settings.gps_enabled)
if (gpsInfoFlags & vpGPSIntro)
{
vp_queueStringTableEntry(&currentLanguage->off);
vp_play();
return;
}
switch (state.gps_data.fix_quality)
{
case 0:
vp_queueStringTableEntry(&currentLanguage->noFix);
vp_queueStringTableEntry(&currentLanguage->gps);
if (!state.settings.gps_enabled)
{
vp_queueStringTableEntry(&currentLanguage->off);
vp_play();
return;
case 1:
vp_queueString("SPS", vpAnnounceCommonSymbols);
break;
case 2:
vp_queueString("DGPS", vpAnnounceCommonSymbols);
break;
case 3:
vp_queueString("PPS", vpAnnounceCommonSymbols);
break;
case 6:
vp_queueStringTableEntry(&currentLanguage->fixLost);
break;
default:
vp_queueStringTableEntry(&currentLanguage->error);
vp_play();
return;
}
}
addSilenceIfNeeded(flags);
switch (state.gps_data.fix_type)
if (gpsInfoFlags & vpGPSFixQuality)
{
case 2:
vp_queueString("2D", vpAnnounceCommonSymbols);
break;
switch (state.gps_data.fix_quality)
{
case 0:
vp_queueStringTableEntry(&currentLanguage->noFix);
vp_play();
return;
case 1:
vp_queueString("SPS", vpAnnounceCommonSymbols);
break;
case 3:
vp_queueString("3D", vpAnnounceCommonSymbols);
break;
case 2:
vp_queueString("DGPS", vpAnnounceCommonSymbols);
break;
case 3:
vp_queueString("PPS", vpAnnounceCommonSymbols);
break;
case 6:
vp_queueStringTableEntry(&currentLanguage->fixLost);
break;
default:
vp_queueStringTableEntry(&currentLanguage->error);
vp_play();
return;
}
addSilenceIfNeeded(flags);
}
if (gpsInfoFlags & vpGPSFixType)
{
switch (state.gps_data.fix_type)
{
case 2:
vp_queueString("2D", vpAnnounceCommonSymbols);
break;
case 3:
vp_queueString("3D", vpAnnounceCommonSymbols);
break;
}
addSilenceIfNeeded(flags);
}
addSilenceIfNeeded(flags);
// lat/long
char buffer[16] = "\0";
snprintf(buffer, 16, "%8.6f", state.gps_data.latitude);
removeUnnecessaryZerosFromVoicePrompts(buffer);
vp_queuePrompt(PROMPT_LATITUDE);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(PROMPT_NORTH);
if (gpsInfoFlags & vpGPSLatitude)
{
// lat/long
snprintf(buffer, 16, "%8.6f", state.gps_data.latitude);
removeUnnecessaryZerosFromVoicePrompts(buffer);
vp_queuePrompt(PROMPT_LATITUDE);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(PROMPT_NORTH);
}
if (gpsInfoFlags & vpGPSLongitude)
{
float longitude = state.gps_data.longitude;
voicePrompt_t direction = (longitude < 0) ? PROMPT_WEST : PROMPT_EAST;
longitude = (longitude < 0) ? -longitude : longitude;
snprintf(buffer, 16, "%8.6f", longitude);
removeUnnecessaryZerosFromVoicePrompts(buffer);
float longitude = state.gps_data.longitude;
voicePrompt_t direction = (longitude < 0) ? PROMPT_WEST : PROMPT_EAST;
longitude = (longitude < 0) ? -longitude : longitude;
snprintf(buffer, 16, "%8.6f", longitude);
removeUnnecessaryZerosFromVoicePrompts(buffer);
vp_queuePrompt(PROMPT_LONGITUDE);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(direction);
addSilenceIfNeeded(flags);
// speed/altitude:
snprintf(buffer, 16, "%4.1fkm/h", state.gps_data.speed);
vp_queuePrompt(PROMPT_SPEED);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(PROMPT_ALTITUDE);
snprintf(buffer, 16, "%4.1fm", state.gps_data.altitude);
vp_queueString(buffer, vpAnnounceCommonSymbols);
addSilenceIfNeeded(flags);
snprintf(buffer, 16, "%3.1f", state.gps_data.tmg_true);
vp_queuePrompt(PROMPT_COMPASS);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(PROMPT_DEGREES);
addSilenceIfNeeded(flags);
vp_queuePrompt(PROMPT_SATELLITES);
vp_queueInteger(state.gps_data.satellites_in_view);
vp_queuePrompt(PROMPT_LONGITUDE);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(direction);
addSilenceIfNeeded(flags);
}
if (gpsInfoFlags & vpGPSSpeed)
{
// speed/altitude:
snprintf(buffer, 16, "%4.1fkm/h", state.gps_data.speed);
vp_queuePrompt(PROMPT_SPEED);
vp_queueString(buffer, vpAnnounceCommonSymbols);
}
if (gpsInfoFlags & vpGPSAltitude)
{
vp_queuePrompt(PROMPT_ALTITUDE);
snprintf(buffer, 16, "%4.1fm", state.gps_data.altitude);
vp_queueString(buffer, vpAnnounceCommonSymbols);
addSilenceIfNeeded(flags);
}
if (gpsInfoFlags & vpGPSDirection)
{
snprintf(buffer, 16, "%3.1f", state.gps_data.tmg_true);
vp_queuePrompt(PROMPT_COMPASS);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(PROMPT_DEGREES);
addSilenceIfNeeded(flags);
}
if (gpsInfoFlags & vpGPSSatCount)
{
vp_queuePrompt(PROMPT_SATELLITES);
vp_queueInteger(state.gps_data.satellites_in_view);
}
vp_play();
}
#endif // GPS_PRESENT
@ -769,7 +796,7 @@ void vp_announceScreen(uint8_t ui_screen)
break;
#ifdef GPS_PRESENT
case MENU_GPS:
vp_announceGPSInfo();
vp_announceGPSInfo(vpGPSAll);
break;
#endif // GPS_PRESENT
case MENU_BACKUP:

Wyświetl plik

@ -1132,6 +1132,42 @@ void ui_saveState()
last_state = state;
}
#ifdef GPS_PRESENT
static float priorGPSSpeed = 0;
static float priorGPSAltitude = 0;
static float priorGPSDirection = 0;
static uint32_t vpGPSLastUpdate = 0;
static vpGPSInfoFlags_t GetGPSDirectionOrSpeedChanged()
{
uint32_t now = getTick();
if (now - vpGPSLastUpdate < 10000)
return vpGPSNone;
vpGPSLastUpdate=now;
if (!state.settings.gps_enabled)
return vpGPSNone;
if (state.gps_data.fix_quality == 0 || state.gps_data.fix_quality >= 6)
return vpGPSNone;
vpGPSInfoFlags_t whatChanged= vpGPSNone;
if (state.gps_data.speed != priorGPSSpeed)
whatChanged |= vpGPSSpeed;
if (state.gps_data.altitude != priorGPSAltitude)
whatChanged |= vpGPSAltitude;
if (state.gps_data.tmg_true != priorGPSDirection)
whatChanged |= vpGPSDirection;
priorGPSSpeed = state.gps_data.speed;
priorGPSAltitude = state.gps_data.altitude;
priorGPSDirection = state.gps_data.tmg_true;
return whatChanged;
}
#endif // GPS_PRESENT
void ui_updateFSM(bool *sync_rtx)
{
// Check for events
@ -1591,7 +1627,7 @@ void ui_updateFSM(bool *sync_rtx)
if ((msg.keys & KEY_F1) && (state.settings.vpLevel > vpBeep))
{// quick press repeat vp, long press summary.
if (msg.long_press)
vp_announceGPSInfo();
vp_announceGPSInfo(vpGPSAll);
else
vp_replayLastPrompt();
f1Handled = true;
@ -1980,6 +2016,16 @@ void ui_updateFSM(bool *sync_rtx)
else if(event.type == EVENT_STATUS)
{
ReleaseFunctionLatchIfNeeded();
#ifdef GPS_PRESENT
if ((state.ui_screen == MENU_GPS) &&
(!txOngoing && !rtx_rxSquelchOpen()) &&
(state.settings.vpLevel > vpLow))
{// automatically read speed and direction changes only!
vpGPSInfoFlags_t whatChanged = GetGPSDirectionOrSpeedChanged();
if (whatChanged != vpGPSNone)
vp_announceGPSInfo(whatChanged);
}
#endif // GPS_PRESENT
if (txOngoing || rtx_rxSquelchOpen())
{