Better rendering when no fix is present

This commit is contained in:
Niccolò Izzo 2021-02-13 11:23:40 +01:00
parent 586b524625
commit a0814fd5d1
1 changed files with 61 additions and 51 deletions

View File

@ -240,60 +240,70 @@ void _ui_drawMenuGPS(ui_state_t* ui_state)
// Print "GPS" on top bar // Print "GPS" on top bar
gfx_print(layout.top_pos, "GPS", layout.top_font, gfx_print(layout.top_pos, "GPS", layout.top_font,
TEXT_ALIGN_CENTER, color_white); TEXT_ALIGN_CENTER, color_white);
// Print GPS status // Print GPS status, if no fix, hide details
switch(last_state.gps_data.fix_quality) if (last_state.gps_data.fix_quality == 0)
{ {
case 0: point_t fix_pos = {layout.line2_pos.x, SCREEN_HEIGHT * 2 / 5};
fix_buf = "No fix"; gfx_print(fix_pos, "No Fix", layout.line3_font, TEXT_ALIGN_CENTER,
break; color_white);
case 1: } else if (last_state.gps_data.fix_quality == 6)
fix_buf = "SPS"; {
break; point_t fix_pos = {layout.line2_pos.x, SCREEN_HEIGHT * 2 / 5};
case 2: gfx_print(fix_pos, "Fix Lost", layout.line3_font, TEXT_ALIGN_CENTER,
fix_buf = "DGPS"; color_white);
break; } else
case 3: {
fix_buf = "PPS"; switch(last_state.gps_data.fix_quality)
break; {
default: case 1:
fix_buf = "ERROR"; fix_buf = "SPS";
break; break;
} case 2:
fix_buf = "DGPS";
break;
case 3:
fix_buf = "PPS";
break;
default:
fix_buf = "ERROR";
break;
}
switch(last_state.gps_data.fix_type) switch(last_state.gps_data.fix_type)
{ {
case 1: case 1:
type_buf = ""; type_buf = "";
break; break;
case 2: case 2:
type_buf = "2D"; type_buf = "2D";
break; break;
case 3: case 3:
type_buf = "3D"; type_buf = "3D";
break; break;
default: default:
type_buf = "ERROR"; type_buf = "ERROR";
break; break;
}
gfx_print(layout.line1_pos, fix_buf, layout.top_font, TEXT_ALIGN_LEFT,
color_white);
gfx_print(layout.line1_pos, "N ", layout.top_font, TEXT_ALIGN_CENTER,
color_white);
snprintf(lat_buf, 12, "%8.6f", last_state.gps_data.latitude);
gfx_print(layout.line1_pos, lat_buf, layout.top_font, TEXT_ALIGN_RIGHT,
color_white);
gfx_print(layout.line2_pos, type_buf, layout.top_font, TEXT_ALIGN_LEFT,
color_white);
gfx_print(layout.line2_pos, "E ", layout.top_font, TEXT_ALIGN_CENTER,
color_white);
snprintf(lon_buf, 12, "%8.6f", last_state.gps_data.longitude);
gfx_print(layout.line2_pos, lon_buf, layout.top_font, TEXT_ALIGN_RIGHT,
color_white);
snprintf(data_buf, 25, "S %5.2fkm/h A %5.2fm",
last_state.gps_data.speed,
last_state.gps_data.altitude);
gfx_print(layout.bottom_pos, data_buf, layout.bottom_font, TEXT_ALIGN_CENTER,
color_white);
} }
gfx_print(layout.line1_pos, fix_buf, layout.top_font, TEXT_ALIGN_LEFT,
color_white);
gfx_print(layout.line1_pos, "N ", layout.top_font, TEXT_ALIGN_CENTER,
color_white);
snprintf(lat_buf, 12, "%8.6f", last_state.gps_data.latitude);
gfx_print(layout.line1_pos, lat_buf, layout.top_font, TEXT_ALIGN_RIGHT,
color_white);
gfx_print(layout.line2_pos, type_buf, layout.top_font, TEXT_ALIGN_LEFT,
color_white);
gfx_print(layout.line2_pos, "E ", layout.top_font, TEXT_ALIGN_CENTER,
color_white);
snprintf(lon_buf, 12, "%8.6f", last_state.gps_data.longitude);
gfx_print(layout.line2_pos, lon_buf, layout.top_font, TEXT_ALIGN_RIGHT,
color_white);
snprintf(data_buf, 25, "S %5.2fkm/h A %5.2fm",
last_state.gps_data.speed,
last_state.gps_data.altitude);
gfx_print(layout.bottom_pos, data_buf, layout.bottom_font, TEXT_ALIGN_CENTER,
color_white);
// Draw compass // Draw compass
point_t compass_pos = {layout.horizontal_pad * 2, SCREEN_HEIGHT / 2}; point_t compass_pos = {layout.horizontal_pad * 2, SCREEN_HEIGHT / 2};
gfx_drawGPScompass(compass_pos, SCREEN_WIDTH / 9, last_state.gps_data.satellites); gfx_drawGPScompass(compass_pos, SCREEN_WIDTH / 9, last_state.gps_data.satellites);