mobile station: person icon, speed in km/h

This commit is contained in:
UA1ZBE
2026-05-22 13:55:33 +03:00
parent bd65ad7438
commit 5e5b47d036

View File

@@ -43,6 +43,8 @@ struct Station {
float wxTemp; float wxTemp;
int wxHumidity; int wxHumidity;
float wxPressure; float wxPressure;
int speed;
bool isMobile;
}; };
Station stations[MAX_STATIONS]; Station stations[MAX_STATIONS];
@@ -130,6 +132,21 @@ bool parseWxData(const String& body, float& tempC, int& humidity, float& pressur
return found; return found;
} }
int parseSpeed(const String& body) {
int len = body.length();
if (len > 80) len = 80;
for (int i = 0; i < len - 7; i++) {
if (isDigit(body[i]) && isDigit(body[i + 1]) && isDigit(body[i + 2]) &&
body[i + 3] == '/' &&
isDigit(body[i + 4]) && isDigit(body[i + 5]) && isDigit(body[i + 6])) {
int c = body.substring(i, i + 3).toInt();
int s = body.substring(i + 4, i + 7).toInt();
if (c >= 0 && c <= 360 && s >= 0 && s <= 999) return s;
}
}
return -1;
}
// ============== APRS PARSER ============== // ============== APRS PARSER ==============
bool parsePosition(const String& data, float& lat, float& lon) { bool parsePosition(const String& data, float& lat, float& lon) {
int nsIdx = -1; int nsIdx = -1;
@@ -230,6 +247,8 @@ void handleMessage(std::shared_ptr<APRSMessage> msg) {
s.hasPos = parsePosition(body, s.lat, s.lon); s.hasPos = parsePosition(body, s.lat, s.lon);
s.comment = stripPosition(body); s.comment = stripPosition(body);
s.isWx = parseWxData(body, s.wxTemp, s.wxHumidity, s.wxPressure); s.isWx = parseWxData(body, s.wxTemp, s.wxHumidity, s.wxPressure);
s.speed = parseSpeed(body);
s.isMobile = s.speed > 0;
if (s.hasPos) { if (s.hasPos) {
s.distance = haversine(HOME_LAT, HOME_LON, s.lat, s.lon); s.distance = haversine(HOME_LAT, HOME_LON, s.lat, s.lon);
@@ -345,6 +364,21 @@ void drawWxStation(int idx) {
u8g2.drawUTF8(wx, y, wl.c_str()); u8g2.drawUTF8(wx, y, wl.c_str());
} }
const unsigned char person_bits[] = {
0x0C, 0x00,
0x0C, 0x00,
0x1E, 0x00,
0x0C, 0x00,
0x1E, 0x00,
0x33, 0x00,
0x21, 0x00,
0x40, 0x80,
0x40, 0x80,
0x01, 0x40,
0x00, 0x80,
0x00, 0x00,
};
void drawStationScreen(int idx) { void drawStationScreen(int idx) {
Station& s = stations[idx]; Station& s = stations[idx];
if (s.isWx) { if (s.isWx) {
@@ -361,8 +395,14 @@ void drawStationScreen(int idx) {
return; return;
} }
int cx = 2;
if (s.isMobile) {
u8g2.drawXBM(cx, 16, 12, 12, person_bits);
cx = 18;
}
u8g2.setFont(u8g2_font_10x20_t_cyrillic); u8g2.setFont(u8g2_font_10x20_t_cyrillic);
u8g2.drawUTF8(2, 34, s.callsign.c_str()); u8g2.drawUTF8(cx, 34, s.callsign.c_str());
u8g2.setFont(u8g2_font_6x12_t_cyrillic); u8g2.setFont(u8g2_font_6x12_t_cyrillic);
int y = 50; int y = 50;
@@ -383,7 +423,12 @@ void drawStationScreen(int idx) {
y += 14; y += 14;
} }
if (s.comment.length() > 0) { if (s.isMobile) {
char sp[24];
float kmh = s.speed * 1.852;
snprintf(sp, sizeof(sp), "Speed: %.0f km/h", kmh);
u8g2.drawUTF8(2, y, sp);
} else if (s.comment.length() > 0) {
String c = s.comment; String c = s.comment;
if (u8g2.getUTF8Width(c.c_str()) > 124) { if (u8g2.getUTF8Width(c.c_str()) > 124) {
while (u8g2.getUTF8Width(c.c_str()) > 120 && c.length() > 0) while (u8g2.getUTF8Width(c.c_str()) > 120 && c.length() > 0)