kopia lustrzana https://github.com/OpenRTX/OpenRTX
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
rodzic
3ba094f633
commit
5829df6dd3
|
@ -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
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(¤tLanguage->gps);
|
||||
if (!state.settings.gps_enabled)
|
||||
|
||||
if (gpsInfoFlags & vpGPSIntro)
|
||||
{
|
||||
vp_queueStringTableEntry(¤tLanguage->off);
|
||||
vp_play();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state.gps_data.fix_quality)
|
||||
{
|
||||
case 0:
|
||||
vp_queueStringTableEntry(¤tLanguage->noFix);
|
||||
vp_queueStringTableEntry(¤tLanguage->gps);
|
||||
if (!state.settings.gps_enabled)
|
||||
{
|
||||
vp_queueStringTableEntry(¤tLanguage->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(¤tLanguage->fixLost);
|
||||
break;
|
||||
|
||||
default:
|
||||
vp_queueStringTableEntry(¤tLanguage->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(¤tLanguage->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(¤tLanguage->fixLost);
|
||||
break;
|
||||
|
||||
default:
|
||||
vp_queueStringTableEntry(¤tLanguage->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:
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue