README.md: even nicer example
This commit is contained in:
parent
f9f9bed148
commit
f872935244
15
README.md
15
README.md
@ -54,20 +54,19 @@ The library doesn't perform this conversion automatically for the following reas
|
||||
```c
|
||||
char line[MINMEA_MAX_LENGTH];
|
||||
while (fgets(line, sizeof(line), stdin) != NULL) {
|
||||
printf("%s", line);
|
||||
switch (minmea_sentence_id(line)) {
|
||||
case MINMEA_SENTENCE_RMC: {
|
||||
struct minmea_sentence_rmc frame;
|
||||
if (minmea_parse_rmc(&frame, line)) {
|
||||
printf("$xxRMC: raw coordinates and speed: (%d/%d,%d/%d) %d/%d\n",
|
||||
printf("$RMC: raw coordinates and speed: (%d/%d,%d/%d) %d/%d\n",
|
||||
frame.latitude.value, frame.latitude.scale,
|
||||
frame.longitude.value, frame.longitude.scale,
|
||||
frame.speed.value, frame.speed.scale);
|
||||
printf("$xxRMC fixed-point coordinates and speed scaled to three decimal places: (%d,%d) %d\n",
|
||||
printf("$RMC fixed-point coordinates and speed scaled to three decimal places: (%d,%d) %d\n",
|
||||
minmea_rescale(&frame.latitude, 1000),
|
||||
minmea_rescale(&frame.longitude, 1000),
|
||||
minmea_rescale(&frame.speed, 1000));
|
||||
printf("$xxRMC floating point degree coordinates and speed: (%f,%f) %f\n",
|
||||
printf("$RMC floating point degree coordinates and speed: (%f,%f) %f\n",
|
||||
minmea_tocoord(&frame.latitude),
|
||||
minmea_tocoord(&frame.longitude),
|
||||
minmea_tofloat(&frame.speed));
|
||||
@ -77,17 +76,17 @@ while (fgets(line, sizeof(line), stdin) != NULL) {
|
||||
case MINMEA_SENTENCE_GGA: {
|
||||
struct minmea_sentence_gga frame;
|
||||
if (minmea_parse_gga(&frame, line)) {
|
||||
printf("$xxGGA: fix quality: %d\n", frame.fix_quality);
|
||||
printf("$GGA: fix quality: %d\n", frame.fix_quality);
|
||||
}
|
||||
} break;
|
||||
|
||||
case MINMEA_SENTENCE_GSV: {
|
||||
struct minmea_sentence_gsv frame;
|
||||
if (minmea_parse_gsv(&frame, line)) {
|
||||
printf("$xxGSV: message %d of %d\n", frame.msg_nr, frame.total_msgs);
|
||||
printf("$xxGSV: sattelites in view: %d\n", frame.total_sats);
|
||||
printf("$GSV: message %d of %d\n", frame.msg_nr, frame.total_msgs);
|
||||
printf("$GSV: sattelites in view: %d\n", frame.total_sats);
|
||||
for (int i = 0; i < 4; i++)
|
||||
printf("$xxGSV: sat nr %d, elevation: %d, azimuth: %d, snr: %d dbm\n",
|
||||
printf("$GSV: sat nr %d, elevation: %d, azimuth: %d, snr: %d dbm\n",
|
||||
frame.sats[i].nr,
|
||||
frame.sats[i].elevation,
|
||||
frame.sats[i].azimuth,
|
||||
|
Loading…
Reference in New Issue
Block a user