POCSAG Processor Rewrite (#1437)

* WIP Refactoring
* WordExtractor building
* Fix buffer sizes and squelch execute
* Move impls to cpp file
* Baud indicator
* WIP new bit extractor
* New approach for bit extraction.
* Code fit and finish
* Fix case on button
* Cleanup
* Adjust rate miss threshold
* Fix count bits error calculation.
This commit is contained in:
Kyle Reed
2023-09-08 10:41:09 -07:00
committed by GitHub
parent 9525738118
commit 31e8019642
13 changed files with 648 additions and 534 deletions

View File

@@ -105,6 +105,7 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav)
&field_volume,
&image_status,
&text_packet_count,
&widget_baud,
&widget_bits,
&widget_frames,
&button_ignore_last,
@@ -274,11 +275,27 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage* message) {
}
void POCSAGAppView::on_stats(const POCSAGStatsMessage* stats) {
widget_baud.set_rate(stats->baud_rate);
widget_bits.set_bits(stats->current_bits);
widget_frames.set_frames(stats->current_frames);
widget_frames.set_sync(stats->has_sync);
}
void BaudIndicator::paint(Painter& painter) {
auto p = screen_pos();
char top = '-';
char bot = '-';
if (rate_ > 0) {
auto r = rate_ / 100;
top = (r / 10) + '0';
bot = (r % 10) + '0';
}
painter.draw_char(p, Styles::white_small, top);
painter.draw_char({p.x(), p.y() + 8}, Styles::white_small, bot);
}
void BitsIndicator::paint(Painter&) {
auto p = screen_pos();
for (size_t i = 0; i < sizeof(bits_) * 8; ++i) {
@@ -295,7 +312,7 @@ void FrameIndicator::paint(Painter& painter) {
painter.draw_rectangle({p, {2, height}}, has_sync_ ? Color::green() : Color::grey());
for (size_t i = 0; i < height; ++i) {
auto p2 = p + Point{2, 16 - (int)i};
auto p2 = p + Point{2, 15 - (int)i};
painter.draw_hline(p2, 2, i < frame_count_ ? Color::white() : Color::black());
}
}

View File

@@ -52,6 +52,24 @@ class POCSAGLogger {
namespace ui {
class BaudIndicator : public Widget {
public:
BaudIndicator(Point position)
: Widget{{position, {5, height}}} {}
void paint(Painter& painter) override;
void set_rate(uint16_t rate) {
if (rate != rate_) {
rate_ = rate;
set_dirty();
}
}
private:
static constexpr uint8_t height = 16;
uint16_t rate_ = 0;
};
class BitsIndicator : public Widget {
public:
BitsIndicator(Point position)
@@ -247,10 +265,13 @@ class POCSAGAppView : public View {
"0"};
BitsIndicator widget_bits{
{9 * 7 + 6, 1 * 16 + 2}};
{8 * 8 + 1, 1 * 16 + 2}};
FrameIndicator widget_frames{
{9 * 8, 1 * 16 + 2}};
{8 * 8 + 4, 1 * 16 + 2}};
BaudIndicator widget_baud{
{8 * 9 + 1, 1 * 16 + 2}};
Button button_ignore_last{
{10 * 8, 1 * 16, 12 * 8, 20},

View File

@@ -370,7 +370,7 @@ class SetConverterSettingsView : public View {
Button button_return{
{16 * 8, 16 * 16, 12 * 8, 32},
"return",
"Return",
};
};