Started wspr coding

This commit is contained in:
Sebastian 2018-07-13 00:47:21 +02:00
parent 2bc9b77ac4
commit 30a1e67b5a
1 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,66 @@
#include <stdio.h>
#include <ctype.h>
#include <stdint.h>
uint8_t wspr_call_char(char c) {
c = toupper(c);
if(c >= '0' && c <= '9') {
return c - '0';
}
else if(c >= 'A' && c <= 'Z') {
return 10 + (c - 'A');
}
// Turn everything else to space
else {
return 36;
}
}
uint8_t wspr_loc_char(char c) {
c = toupper(c);
if(c >= '0' && c <= '9') {
return c - '0';
}
else if(c >= 'A' && c <= 'R') {
return c - 'A';
}
// Everthing else becomes 9/I
else {
return 9;
}
}
uint8_t wspr_power(uint8_t power) {
if(power > 60) {
return 60;
}
return power;
}
uint64_t wspr_message(char *call, char* loc, uint8_t power) {
uint32_t m, n;
n = wspr_loc_char(call[0]);
n = n * 36 + wspr_loc_char(call[1]);
n = n * 10 + wspr_loc_char(call[2]);
n = n * 27 + wspr_loc_char(call[3]) - 10;
n = n * 27 + wspr_loc_char(call[4]) - 10;
n = n * 27 + wspr_loc_char(call[5]) - 10;
m = 179 - 10 * wspr_loc_char(loc[0]) - wspr_loc_char(loc[2]);
m = m * 180 + 10 * wspr_loc_char(loc[1]) + wspr_loc_char(loc[3]);
m = m * 128 + wspr_power(power) + 64;
return n << 21 | m;
}
int main(int argc, char const *argv[]) {
return 0;
}