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
118
src/main.cpp
118
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() {
|
||||||
|
@ -503,10 +509,33 @@ void editComment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lcd.print((char) config.comment[commentEditState]);
|
lcd.print((char) config.comment[commentEditState]);
|
||||||
lcd.setCursor(commentEditState%16, commentEditState/16);
|
lcd.setCursor(commentEditState%16, commentEditState/16);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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) {
|
||||||
|
@ -702,39 +745,50 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
readNmeaRmc();
|
readNmeaRmc();
|
||||||
if (editingConfig) {
|
if (editingConfig) {
|
||||||
editConfig();
|
editConfig();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (editingComment) {
|
||||||
|
editComment();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (editingAmbiguity) {
|
||||||
|
editAmbiguity();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (abcPressed) {
|
||||||
|
abcPressed = false;
|
||||||
|
page = (page + 1) % 4;
|
||||||
|
lcd.clear();
|
||||||
|
}
|
||||||
|
if (page == 0) {
|
||||||
|
printConfig();
|
||||||
|
if (setPressed) {
|
||||||
|
setPressed = false;
|
||||||
|
editingConfig = true;
|
||||||
|
lcd.blink();
|
||||||
}
|
}
|
||||||
if (editingComment) {
|
} else if (page == 1) {
|
||||||
editComment();
|
printComment();
|
||||||
return;
|
if (setPressed) {
|
||||||
}
|
setPressed = false;
|
||||||
if (abcPressed) {
|
editingComment = true;
|
||||||
abcPressed = false;
|
|
||||||
page = (page + 1) % 4;
|
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
}
|
|
||||||
if (page == 0) {
|
|
||||||
printConfig();
|
|
||||||
if (setPressed) {
|
|
||||||
setPressed = false;
|
|
||||||
editingConfig = true;
|
|
||||||
lcd.blink();
|
|
||||||
}
|
|
||||||
} else if (page == 1) {
|
|
||||||
printComment();
|
printComment();
|
||||||
if (setPressed) {
|
lcd.blink();
|
||||||
setPressed = false;
|
|
||||||
editingComment = true;
|
|
||||||
lcd.clear();
|
|
||||||
lcd.blink();
|
|
||||||
}
|
|
||||||
} else if (page == 2) {
|
|
||||||
printLocation();
|
|
||||||
} else if (page == 3) {
|
|
||||||
printDateTime();
|
|
||||||
}
|
}
|
||||||
|
} else if (page == 2) {
|
||||||
|
printLocation();
|
||||||
|
if (setPressed) {
|
||||||
|
setPressed = false;
|
||||||
|
editingAmbiguity = true;
|
||||||
|
lcd.clear();
|
||||||
|
editAmbiguity();
|
||||||
|
}
|
||||||
|
} else if (page == 3) {
|
||||||
|
printDateTime();
|
||||||
|
}
|
||||||
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
|
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
|
||||||
if (!abcPressed && !setPressed) {
|
if (!abcPressed && !setPressed) {
|
||||||
off = true;
|
off = true;
|
||||||
|
|
Loading…
Reference in a new issue