Now better handle directions, and speak prior to other info as most important.

Handle 8 cardinal points north, east, south, west, north east, south east, south west and north west.
md1702
vk7js 2022-09-13 22:18:52 +10:00 zatwierdzone przez Silvano Seva
rodzic 4ba9b3ec34
commit 7cc0c6455c
1 zmienionych plików z 49 dodań i 33 usunięć

Wyświetl plik

@ -527,6 +527,23 @@ void vp_announceM17Info(const channel_t* channel, const vpQueueFlags_t flags)
}
#ifdef GPS_PRESENT
// cardinal point plus or minus this value is still considered cardinal point.
#define margin 3
static bool IsCompassCloseEnoughToCardinalPoint()
{
float tmg_true = state.gps_data.tmg_true;
return (tmg_true < (0+margin) || tmg_true > (360-margin)) || // north
(tmg_true > (90-margin) && tmg_true < (90+margin)) || // east
(tmg_true > (180-margin) && tmg_true < (180+margin)) || // south
(tmg_true > (270-margin) && tmg_true < (270+margin)) || // west
(tmg_true > (45-margin) && tmg_true < (45+margin)) || // n.w.
(tmg_true > (135-margin) && tmg_true < (135+margin)) || // s.e.
(tmg_true > (225-margin) && tmg_true < (225+margin)) || // s.w.
(tmg_true > (315-margin) && tmg_true < (315+margin)); // n.w.
}
void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags)
{
vp_flush();
@ -578,9 +595,10 @@ void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags)
}
addSilenceIfNeeded(flags);
}
if (gpsInfoFlags & vpGPSFixType)
{
}
if (gpsInfoFlags & vpGPSFixType)
{
switch (state.gps_data.fix_type)
{
case 2:
@ -596,6 +614,34 @@ void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags)
}
char buffer[17] = "\0";
if (gpsInfoFlags & vpGPSDirection)
{
vp_queuePrompt(PROMPT_COMPASS);
if (!IsCompassCloseEnoughToCardinalPoint())
{
snprintf(buffer, 16, "%3.1f", state.gps_data.tmg_true);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(PROMPT_DEGREES);
}
if (state.gps_data.tmg_true <= 45 || state.gps_data.tmg_true >= 315)
{
vp_queuePrompt(PROMPT_NORTH);
}
if (state.gps_data.tmg_true >= 45 && state.gps_data.tmg_true <= 135)
{
vp_queuePrompt(PROMPT_EAST);
}
if (state.gps_data.tmg_true >= 135 && state.gps_data.tmg_true <= 225)
{
vp_queuePrompt(PROMPT_SOUTH);
}
if (state.gps_data.tmg_true >= 225 && state.gps_data.tmg_true <= 315)
{
vp_queuePrompt(PROMPT_WEST);
}
addSilenceIfNeeded(flags);
}
if (gpsInfoFlags & vpGPSSpeed)
{
@ -614,36 +660,6 @@ void vp_announceGPSInfo(vpGPSInfoFlags_t gpsInfoFlags)
addSilenceIfNeeded(flags);
}
if (gpsInfoFlags & vpGPSDirection)
{
vp_queuePrompt(PROMPT_COMPASS);
if (state.gps_data.tmg_true < 3 || state.gps_data.tmg_true > 357)
{
vp_queuePrompt(PROMPT_NORTH);
}
else if (state.gps_data.tmg_true > 87 && state.gps_data.tmg_true < 93)
{
vp_queuePrompt(PROMPT_EAST);
}
else if (state.gps_data.tmg_true > 177 && state.gps_data.tmg_true < 183)
{
vp_queuePrompt(PROMPT_SOUTH);
}
else if (state.gps_data.tmg_true > 267 && state.gps_data.tmg_true < 273)
{
vp_queuePrompt(PROMPT_WEST);
}
else
{
snprintf(buffer, 16, "%3.1f", state.gps_data.tmg_true);
vp_queueString(buffer, vpAnnounceCommonSymbols);
vp_queuePrompt(PROMPT_DEGREES);
}
addSilenceIfNeeded(flags);
}
if (gpsInfoFlags & vpGPSLatitude)
{
// lat/long