Add latlon_to_grid function

pull/26/head
Jason Milldrum 2021-07-12 13:55:23 -07:00
rodzic a787ff00f3
commit 431cbafd3f
4 zmienionych plików z 62 dodań i 1 usunięć

Wyświetl plik

@ -261,6 +261,22 @@ Public Methods
*/
```
### latlon_to_grid()
```
/*
* latlon_to_grid(float lat, float lon, char* ret_grid)
*
* Takes a station latitude and longitude provided in decimal degrees format and
* returns a string with the 6-digit Maidenhead grid designator.
*
* lat - Latitude in decimal degrees format.
* lon - Longitude in decimal degrees format.
* ret_grid - Derived Maidenhead grid square. A pointer to a character array of
* at least 7 bytes must be provided here for the function return value.
*
*/
```
Tokens
------
Here are the defines, structs, and enumerations you will find handy to use with the library.
@ -277,6 +293,10 @@ Also, a big thank you to Murray Greenman, ZL1BPU for working allowing me to pick
Changelog
---------
* v1.3.1
* Added latitude/longitude to Maidenhead grid convenience function
* v1.3.0
* WSPR Type 2 and Type 3 message capability added

Wyświetl plik

@ -1,5 +1,5 @@
name=Etherkit JTEncode
version=1.3.0
version=1.3.1
author=Jason Milldrum <milldrum@gmail.com>
maintainer=Jason Milldrum <milldrum@gmail.com>
sentence=Generate JT65, JT9, JT4, FT8, WSPR, and FSQ symbols on your Arduino.

Wyświetl plik

@ -445,6 +445,46 @@ void JTEncode::ft8_encode(const char * msg, uint8_t * symbols)
ft8_merge_sync_vector(s, symbols);
}
/*
* latlon_to_grid(float lat, float lon, char* ret_grid)
*
* Takes a station latitude and longitude provided in decimal degrees format and
* returns a string with the 6-digit Maidenhead grid designator.
*
* lat - Latitude in decimal degrees format.
* lon - Longitude in decimal degrees format.
* ret_grid - Derived Maidenhead grid square. A pointer to a character array of
* at least 7 bytes must be provided here for the function return value.
*
*/
void JTEncode::latlon_to_grid(float lat, float lon, char* ret_grid)
{
char grid[7];
memset(grid, 0, 7);
// Normalize lat and lon
lon += 180.0;
lat += 90.0;
// Derive first coordinate pair
grid[0] = (char)((uint8_t)(lon / 20) + 'A');
grid[1] = (char)((uint8_t)(lat / 10) + 'A');
// Derive second coordinate pair
lon = lon - ((uint8_t)(lon / 20) * 20);
lat = lat - ((uint8_t)(lat / 10) * 10);
grid[2] = (char)((uint8_t)(lon / 2) + '0');
grid[3] = (char)((uint8_t)(lat) + '0');
// Derive third coordinate pair
lon = lon - ((uint8_t)(lon / 2) * 2);
lat = lat - ((uint8_t)(lat));
grid[4] = (char)((uint8_t)(lon * 12) + 'a');
grid[5] = (char)((uint8_t)(lat * 24) + 'a');
strncpy(ret_grid, grid, 6);
}
/* Private Class Members */
uint8_t JTEncode::jt_code(char c)

Wyświetl plik

@ -225,6 +225,7 @@ public:
void fsq_encode(const char *, const char *, uint8_t *);
void fsq_dir_encode(const char *, const char *, const char, const char *, uint8_t *);
void ft8_encode(const char *, uint8_t *);
void latlon_to_grid(float, float, char*);
private:
uint8_t jt_code(char);
uint8_t ft_code(char);