feat: add option to configure position ambiguity for privacy reasons
This commit is contained in:
parent
486715dd5f
commit
67e974c4e4
1 changed files with 86 additions and 32 deletions
58
src/main.cpp
58
src/main.cpp
|
@ -14,7 +14,10 @@
|
||||||
#include "afsk_sinus.hpp"
|
#include "afsk_sinus.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SEND_INVALID
|
||||||
#define SEND_INVALID 0
|
#define SEND_INVALID 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DESTINATION "WIDE1 \x01"
|
#define DESTINATION "WIDE1 \x01"
|
||||||
#define TXDELAY 32
|
#define TXDELAY 32
|
||||||
#define FRAME_REPEAT 3
|
#define FRAME_REPEAT 3
|
||||||
|
@ -198,6 +201,7 @@ struct __attribute__((packed)) EepromConfig {
|
||||||
uint16_t interval;
|
uint16_t interval;
|
||||||
uint8_t commentLen;
|
uint8_t commentLen;
|
||||||
uint8_t comment[32];
|
uint8_t comment[32];
|
||||||
|
uint8_t positionAmbiguity;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EepromConfig config;
|
struct EepromConfig config;
|
||||||
|
@ -227,6 +231,7 @@ uint32_t lastPressed = 0;
|
||||||
bool off = true;
|
bool off = true;
|
||||||
bool editingConfig = false;
|
bool editingConfig = false;
|
||||||
bool editingComment = false;
|
bool editingComment = false;
|
||||||
|
bool editingAmbiguity = false;
|
||||||
uint8_t configEditState = 0;
|
uint8_t configEditState = 0;
|
||||||
uint8_t commentEditState = 0;
|
uint8_t commentEditState = 0;
|
||||||
|
|
||||||
|
@ -254,13 +259,14 @@ uint8_t mirrorByte(uint8_t byt) {
|
||||||
|
|
||||||
|
|
||||||
void createDefaultConfig() {
|
void createDefaultConfig() {
|
||||||
config.flag = 1;
|
config.flag = 2;
|
||||||
memset(&config.srcCallsign, ' ', 6);
|
memset(&config.srcCallsign, ' ', 6);
|
||||||
config.srcSsid = 0;
|
config.srcSsid = 0;
|
||||||
config.marker = 'b';
|
config.marker = 'b';
|
||||||
config.interval = 300;
|
config.interval = 300;
|
||||||
config.commentLen = 0;
|
config.commentLen = 0;
|
||||||
memset(&config.comment, ' ', 32);
|
memset(&config.comment, ' ', 32);
|
||||||
|
config.positionAmbiguity = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeEepromConfig() {
|
void writeEepromConfig() {
|
||||||
|
@ -507,6 +513,29 @@ void editComment() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void editAmbiguity() {
|
||||||
|
if (abcPressed) {
|
||||||
|
abcPressed = false;
|
||||||
|
config.positionAmbiguity = (config.positionAmbiguity + 1) % 5;
|
||||||
|
}
|
||||||
|
if (setPressed) {
|
||||||
|
setPressed = false;
|
||||||
|
writeEepromConfig();
|
||||||
|
editingAmbiguity = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd.print("Pos. Ambiguity");
|
||||||
|
lcd.setCursor(0, 1);
|
||||||
|
lcd.print(" 47\xdf ");
|
||||||
|
lcd.print(config.positionAmbiguity > 0 ? '1' : '_');
|
||||||
|
lcd.print(config.positionAmbiguity > 1 ? '2' : '_');
|
||||||
|
lcd.print('.');
|
||||||
|
lcd.print(config.positionAmbiguity > 2 ? '3' : '_');
|
||||||
|
lcd.print(config.positionAmbiguity > 3 ? '4' : '_');
|
||||||
|
lcd.print('\'');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
uint8_t nmeaState = 0;
|
uint8_t nmeaState = 0;
|
||||||
char nmeaStr[256]; // NMEA-0183 messages should only be 82 characters, but the NEO-6M sends much longer messages
|
char nmeaStr[256]; // NMEA-0183 messages should only be 82 characters, but the NEO-6M sends much longer messages
|
||||||
|
@ -624,10 +653,24 @@ void readNmeaRmc() {
|
||||||
rmc.lonDeg, rmc.lonMin, rmc.lonDir,
|
rmc.lonDeg, rmc.lonMin, rmc.lonDir,
|
||||||
config.marker, rmc.course, rmc.speed);
|
config.marker, rmc.course, rmc.speed);
|
||||||
} else {
|
} else {
|
||||||
snprintf(aprs, 256, "/012058z4700.00N/00700.00Eb000/000");
|
snprintf(aprs, 256, "/012058z4712.34N/00712.34Eb000/000");
|
||||||
|
}
|
||||||
|
// Insert position ambiguity
|
||||||
|
if (config.positionAmbiguity < 1) {
|
||||||
|
aprs[10] = aprs[20] = ' ';
|
||||||
|
}
|
||||||
|
if (config.positionAmbiguity < 2) {
|
||||||
|
aprs[11] = aprs[21] = ' ';
|
||||||
|
}
|
||||||
|
if (config.positionAmbiguity < 3) {
|
||||||
|
aprs[13] = aprs[23] = ' ';
|
||||||
|
}
|
||||||
|
if (config.positionAmbiguity < 4) {
|
||||||
|
aprs[14] = aprs[24] = ' ';
|
||||||
}
|
}
|
||||||
memcpy(aprs+34, config.comment, config.commentLen);
|
memcpy(aprs+34, config.comment, config.commentLen);
|
||||||
aprs[34+config.commentLen] = 0;
|
aprs[34+config.commentLen] = 0;
|
||||||
|
Serial.println(aprs);
|
||||||
// AX.25 3.8 - FCS is sent MSB first
|
// AX.25 3.8 - FCS is sent MSB first
|
||||||
uint16_t fcs = 0xffff;
|
uint16_t fcs = 0xffff;
|
||||||
for (size_t i = 0; i < sizeof(frame); ++i) {
|
for (size_t i = 0; i < sizeof(frame); ++i) {
|
||||||
|
@ -710,6 +753,10 @@ void loop() {
|
||||||
editComment();
|
editComment();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (editingAmbiguity) {
|
||||||
|
editAmbiguity();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (abcPressed) {
|
if (abcPressed) {
|
||||||
abcPressed = false;
|
abcPressed = false;
|
||||||
page = (page + 1) % 4;
|
page = (page + 1) % 4;
|
||||||
|
@ -728,10 +775,17 @@ void loop() {
|
||||||
setPressed = false;
|
setPressed = false;
|
||||||
editingComment = true;
|
editingComment = true;
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
|
printComment();
|
||||||
lcd.blink();
|
lcd.blink();
|
||||||
}
|
}
|
||||||
} else if (page == 2) {
|
} else if (page == 2) {
|
||||||
printLocation();
|
printLocation();
|
||||||
|
if (setPressed) {
|
||||||
|
setPressed = false;
|
||||||
|
editingAmbiguity = true;
|
||||||
|
lcd.clear();
|
||||||
|
editAmbiguity();
|
||||||
|
}
|
||||||
} else if (page == 3) {
|
} else if (page == 3) {
|
||||||
printDateTime();
|
printDateTime();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue