mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-12 08:30:27 -04:00
ADSB RX text color bugfix
ADSB RX entries now "age" after 10 and 20 seconds
This commit is contained in:
parent
a08ee18e3b
commit
3aae333974
7 changed files with 85 additions and 26 deletions
|
@ -144,7 +144,7 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
|
||||||
std::string alphanum_text = "";
|
std::string alphanum_text = "";
|
||||||
|
|
||||||
if (message->packet.flag() != NORMAL)
|
if (message->packet.flag() != NORMAL)
|
||||||
console.writeln("\n\x1B\x01RX ERROR: " + pocsag::flag_str(message->packet.flag()));
|
console.writeln("\n\x1B\x0CRX ERROR: " + pocsag::flag_str(message->packet.flag()));
|
||||||
else {
|
else {
|
||||||
pocsag_decode_batch(message->packet, &pocsag_state);
|
pocsag_decode_batch(message->packet, &pocsag_state);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "ui_alphanum.hpp"
|
#include "ui_alphanum.hpp"
|
||||||
#include "ui_geomap.hpp"
|
#include "ui_geomap.hpp"
|
||||||
|
|
||||||
|
#include "rtc_time.hpp"
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
#include "baseband_api.hpp"
|
#include "baseband_api.hpp"
|
||||||
|
@ -43,18 +44,35 @@ void RecentEntriesTable<AircraftRecentEntries>::draw(
|
||||||
Painter& painter,
|
Painter& painter,
|
||||||
const Style& style
|
const Style& style
|
||||||
) {
|
) {
|
||||||
|
char aged_color;
|
||||||
|
Color target_color;
|
||||||
|
|
||||||
|
if (entry.age < 10) {
|
||||||
|
aged_color = 0x10;
|
||||||
|
target_color = Color::green();
|
||||||
|
} else if ((entry.age >= 10) && (entry.age < 30)) {
|
||||||
|
aged_color = 0x07;
|
||||||
|
target_color = Color::light_grey();
|
||||||
|
} else {
|
||||||
|
aged_color = 0x08;
|
||||||
|
target_color = Color::dark_grey();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string string = "\x1B";
|
||||||
|
string += aged_color;
|
||||||
|
string += to_string_hex(entry.ICAO_address, 6) + " " +
|
||||||
|
entry.callsign + " " +
|
||||||
|
(entry.hits <= 999 ? to_string_dec_uint(entry.hits, 4) : "999+") + " " +
|
||||||
|
entry.time_string;
|
||||||
|
|
||||||
painter.draw_string(
|
painter.draw_string(
|
||||||
target_rect.location(),
|
target_rect.location(),
|
||||||
style,
|
style,
|
||||||
to_string_hex(entry.ICAO_address, 6) +
|
string
|
||||||
(entry.pos.valid ? " \x1B\x02" : " ") +
|
|
||||||
entry.callsign + " \x1B\x00" +
|
|
||||||
(entry.hits <= 999 ? to_string_dec_uint(entry.hits, 4) : "999+") + " " +
|
|
||||||
entry.time_string
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (entry.pos.valid)
|
if (entry.pos.valid)
|
||||||
painter.draw_bitmap(target_rect.location() + Point(15 * 8, 0), bitmap_target, style.foreground, style.background);
|
painter.draw_bitmap(target_rect.location() + Point(15 * 8, 0), bitmap_target, target_color, style.background);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ADSBRxView::focus() {
|
void ADSBRxView::focus() {
|
||||||
|
@ -62,6 +80,7 @@ void ADSBRxView::focus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ADSBRxView::~ADSBRxView() {
|
ADSBRxView::~ADSBRxView() {
|
||||||
|
rtc_time::signal_tick_second -= signal_token_tick_second;
|
||||||
receiver_model.disable();
|
receiver_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
|
@ -70,18 +89,17 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) {
|
||||||
rtc::RTC datetime;
|
rtc::RTC datetime;
|
||||||
std::string str_timestamp;
|
std::string str_timestamp;
|
||||||
std::string callsign;
|
std::string callsign;
|
||||||
|
std::string str_info;
|
||||||
|
|
||||||
auto frame = message->frame;
|
auto frame = message->frame;
|
||||||
|
|
||||||
uint32_t ICAO_address = frame.get_ICAO_address();
|
uint32_t ICAO_address = frame.get_ICAO_address();
|
||||||
|
|
||||||
|
|
||||||
if (frame.check_CRC() && frame.get_ICAO_address()) {
|
if (frame.check_CRC() && frame.get_ICAO_address()) {
|
||||||
frame.set_rx_timestamp(datetime.minute() * 60 + datetime.second());
|
rtcGetTime(&RTCD1, &datetime);
|
||||||
|
|
||||||
auto& entry = ::on_packet(recent, ICAO_address);
|
auto& entry = ::on_packet(recent, ICAO_address);
|
||||||
|
|
||||||
rtcGetTime(&RTCD1, &datetime);
|
frame.set_rx_timestamp(datetime.minute() * 60 + datetime.second());
|
||||||
|
entry.reset_age();
|
||||||
str_timestamp = to_string_datetime(datetime, HMS);
|
str_timestamp = to_string_datetime(datetime, HMS);
|
||||||
entry.set_time_string(str_timestamp);
|
entry.set_time_string(str_timestamp);
|
||||||
|
|
||||||
|
@ -98,13 +116,13 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) {
|
||||||
entry.set_frame_pos(frame, raw_data[6] & 4);
|
entry.set_frame_pos(frame, raw_data[6] & 4);
|
||||||
|
|
||||||
if (entry.pos.valid) {
|
if (entry.pos.valid) {
|
||||||
callsign = "Alt:" + to_string_dec_uint(entry.pos.altitude) +
|
str_info = "Alt:" + to_string_dec_uint(entry.pos.altitude) +
|
||||||
" Lat" + to_string_dec_int(entry.pos.latitude) +
|
" Lat" + to_string_dec_int(entry.pos.latitude) +
|
||||||
"." + to_string_dec_int((int)(entry.pos.latitude * 1000) % 100) +
|
"." + to_string_dec_int((int)(entry.pos.latitude * 1000) % 100) +
|
||||||
" Lon" + to_string_dec_int(entry.pos.longitude) +
|
" Lon" + to_string_dec_int(entry.pos.longitude) +
|
||||||
"." + to_string_dec_int((int)(entry.pos.longitude * 1000) % 100);
|
"." + to_string_dec_int((int)(entry.pos.longitude * 1000) % 100);
|
||||||
|
|
||||||
entry.set_pos_string(callsign);
|
entry.set_info_string(str_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +131,14 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ADSBRxView::on_tick_second() {
|
||||||
|
for (auto& entry : recent) {
|
||||||
|
entry.inc_age();
|
||||||
|
if ((entry.age == 10) || (entry.age == 30))
|
||||||
|
recent_entries_view.set_dirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ADSBRxView::ADSBRxView(NavigationView&) {
|
ADSBRxView::ADSBRxView(NavigationView&) {
|
||||||
baseband::run_image(portapack::spi_flash::image_tag_adsb_rx);
|
baseband::run_image(portapack::spi_flash::image_tag_adsb_rx);
|
||||||
|
|
||||||
|
@ -129,11 +155,15 @@ ADSBRxView::ADSBRxView(NavigationView&) {
|
||||||
|
|
||||||
recent_entries_view.set_parent_rect({ 0, 64, 240, 224 });
|
recent_entries_view.set_parent_rect({ 0, 64, 240, 224 });
|
||||||
recent_entries_view.on_select = [this](const AircraftRecentEntry& entry) {
|
recent_entries_view.on_select = [this](const AircraftRecentEntry& entry) {
|
||||||
text_debug_a.set(entry.pos_string);
|
text_debug_a.set(entry.info_string);
|
||||||
text_debug_b.set(to_string_hex_array(entry.frame_pos_even.get_raw_data(), 14));
|
text_debug_b.set(to_string_hex_array(entry.frame_pos_even.get_raw_data(), 14));
|
||||||
text_debug_c.set(to_string_hex_array(entry.frame_pos_odd.get_raw_data(), 14));
|
text_debug_c.set(to_string_hex_array(entry.frame_pos_odd.get_raw_data(), 14));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
|
||||||
|
on_tick_second();
|
||||||
|
};
|
||||||
|
|
||||||
baseband::set_adsb();
|
baseband::set_adsb();
|
||||||
|
|
||||||
receiver_model.set_tuning_frequency(1090000000);
|
receiver_model.set_tuning_frequency(1090000000);
|
||||||
|
|
|
@ -40,6 +40,7 @@ struct AircraftRecentEntry {
|
||||||
|
|
||||||
uint32_t ICAO_address { };
|
uint32_t ICAO_address { };
|
||||||
uint16_t hits { 0 };
|
uint16_t hits { 0 };
|
||||||
|
uint32_t age { 0 };
|
||||||
adsb_pos pos { false, 0, 0, 0 };
|
adsb_pos pos { false, 0, 0, 0 };
|
||||||
|
|
||||||
ADSBFrame frame_pos_even { };
|
ADSBFrame frame_pos_even { };
|
||||||
|
@ -47,7 +48,7 @@ struct AircraftRecentEntry {
|
||||||
|
|
||||||
std::string callsign { " " };
|
std::string callsign { " " };
|
||||||
std::string time_string { "" };
|
std::string time_string { "" };
|
||||||
std::string pos_string { "" };
|
std::string info_string { "" };
|
||||||
|
|
||||||
AircraftRecentEntry(
|
AircraftRecentEntry(
|
||||||
const uint32_t ICAO_address
|
const uint32_t ICAO_address
|
||||||
|
@ -79,13 +80,21 @@ struct AircraftRecentEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_pos_string(std::string& new_pos_string) {
|
void set_info_string(std::string& new_info_string) {
|
||||||
pos_string = new_pos_string;
|
info_string = new_info_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_time_string(std::string& new_time_string) {
|
void set_time_string(std::string& new_time_string) {
|
||||||
time_string = new_time_string;
|
time_string = new_time_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reset_age() {
|
||||||
|
age = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void inc_age() {
|
||||||
|
age++;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using AircraftRecentEntries = RecentEntries<AircraftRecentEntry>;
|
using AircraftRecentEntries = RecentEntries<AircraftRecentEntry>;
|
||||||
|
@ -101,6 +110,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void on_frame(const ADSBFrameMessage * message);
|
void on_frame(const ADSBFrameMessage * message);
|
||||||
|
void on_tick_second();
|
||||||
|
|
||||||
const RecentEntriesColumns columns { {
|
const RecentEntriesColumns columns { {
|
||||||
{ "ICAO", 6 },
|
{ "ICAO", 6 },
|
||||||
|
@ -111,6 +121,8 @@ private:
|
||||||
AircraftRecentEntries recent { };
|
AircraftRecentEntries recent { };
|
||||||
RecentEntriesView<RecentEntries<AircraftRecentEntry>> recent_entries_view { columns, recent };
|
RecentEntriesView<RecentEntries<AircraftRecentEntry>> recent_entries_view { columns, recent };
|
||||||
|
|
||||||
|
SignalToken signal_token_tick_second { };
|
||||||
|
|
||||||
RSSI rssi {
|
RSSI rssi {
|
||||||
{ 19 * 8, 4, 10 * 8, 8 },
|
{ 19 * 8, 4, 10 * 8, 8 },
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,14 +26,23 @@
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
Color term_colors[8] = {
|
// CGA palette
|
||||||
|
Color term_colors[16] = {
|
||||||
Color::black(),
|
Color::black(),
|
||||||
Color::red(),
|
Color::dark_blue(),
|
||||||
Color::green(),
|
Color::dark_green(),
|
||||||
Color::yellow(),
|
Color::dark_cyan(),
|
||||||
|
Color::dark_red(),
|
||||||
|
Color::dark_magenta(),
|
||||||
|
Color::dark_yellow(),
|
||||||
|
Color::light_grey(),
|
||||||
|
Color::dark_grey(),
|
||||||
Color::blue(),
|
Color::blue(),
|
||||||
Color::magenta(),
|
Color::green(),
|
||||||
Color::cyan(),
|
Color::cyan(),
|
||||||
|
Color::red(),
|
||||||
|
Color::magenta(),
|
||||||
|
Color::yellow(),
|
||||||
Color::white()
|
Color::white()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -104,10 +104,16 @@ struct Color {
|
||||||
static constexpr Color cyan() {
|
static constexpr Color cyan() {
|
||||||
return { 0, 255, 255 };
|
return { 0, 255, 255 };
|
||||||
}
|
}
|
||||||
|
static constexpr Color dark_cyan() {
|
||||||
|
return { 0, 127, 127 };
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr Color magenta() {
|
static constexpr Color magenta() {
|
||||||
return { 255, 0, 255 };
|
return { 255, 0, 255 };
|
||||||
}
|
}
|
||||||
|
static constexpr Color dark_magenta() {
|
||||||
|
return { 127, 0, 127 };
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr Color white() {
|
static constexpr Color white() {
|
||||||
return { 255, 255, 255 };
|
return { 255, 255, 255 };
|
||||||
|
@ -128,7 +134,7 @@ struct Color {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Color term_colors[8];
|
extern Color term_colors[16];
|
||||||
|
|
||||||
struct ColorRGB888 {
|
struct ColorRGB888 {
|
||||||
uint8_t r;
|
uint8_t r;
|
||||||
|
|
|
@ -51,8 +51,10 @@ int Painter::draw_string(Point p, const Font& font, const Color foreground,
|
||||||
|
|
||||||
for(const auto c : text) {
|
for(const auto c : text) {
|
||||||
if (escape) {
|
if (escape) {
|
||||||
pen = term_colors[c & 7];
|
if (c <= 15)
|
||||||
if (!c) pen = foreground;
|
pen = term_colors[c & 15];
|
||||||
|
else
|
||||||
|
pen = foreground;
|
||||||
escape = false;
|
escape = false;
|
||||||
} else {
|
} else {
|
||||||
if (c == '\x1B') {
|
if (c == '\x1B') {
|
||||||
|
|
BIN
firmware/graphics/target.png
Normal file
BIN
firmware/graphics/target.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 132 B |
Loading…
Add table
Add a link
Reference in a new issue