add routine to output waypoint data

pull/1806/head
Thomas Göttgens 2022-10-16 12:28:49 +02:00
rodzic 7fde56b8ac
commit 27bcf67c0c
2 zmienionych plików z 32 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,26 @@
#include "NMEAWPL.h"
/* -------------------------------------------
* 1 2 3 4 5 6
* | | | | | |
* $--WPL,llll.ll,a,yyyyy.yy,a,c--c*hh<CR><LF>
*
* Field Number:
* 1 Latitude
* 2 N or S (North or South)
* 3 Longitude
* 4 E or W (East or West)
* 5 Waypoint name
* 6 Checksum
*/
uint printWPL(char *buf, Position &pos, const char *name)
{
uint len = sprintf(buf, "$GNWPL,%07.2f,%c,%08.2f,%c,%s", pos.latitude_i * 1e-5, pos.latitude_i < 0 ? 'S' : 'N', pos.longitude_i * 1e-5, pos.longitude_i < 0 ? 'W' : 'E', name);
uint chk = 0;
for (uint i = 1; i < len; i++) {
chk ^= buf[i];
}
len += sprintf(buf + len, "*%02X\r\n", chk);
return len;
}

Wyświetl plik

@ -0,0 +1,6 @@
#pragma once
#include <Arduino.h>
#include "main.h"
uint printWPL(char *buf, Position &pos, const char *name);