mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-10-18 09:11:47 +00:00
POCSAG bitrate selection and logging toggle
Small checkboxes
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
// Color bitmaps generated with:
|
||||
// Gimp image > indexed colors (16), then "xxd -i *.bmp"
|
||||
|
||||
//BUG: Bad console scroll init
|
||||
|
||||
//TEST: Imperial in whipcalc
|
||||
//TEST: Numbers
|
||||
//TEST: Jammer
|
||||
|
@@ -51,6 +51,7 @@ static std::string bitrate_str(BitRate bitrate) {
|
||||
static std::string flag_str(PacketFlag packetflag) {
|
||||
switch (packetflag) {
|
||||
case PacketFlag::NORMAL: return "OK";
|
||||
case PacketFlag::IDLE: return "IDLE";
|
||||
case PacketFlag::TIMED_OUT: return "TIMED OUT";
|
||||
case PacketFlag::TOO_LONG: return "TOO LONG";
|
||||
default: return "";
|
||||
@@ -108,10 +109,12 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
|
||||
&rssi,
|
||||
&channel,
|
||||
&options_freq,
|
||||
&button_setfreq,
|
||||
&field_rf_amp,
|
||||
&field_lna,
|
||||
&field_vga,
|
||||
&button_setfreq,
|
||||
&options_bitrate,
|
||||
&check_log,
|
||||
&console
|
||||
});
|
||||
|
||||
@@ -124,6 +127,16 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) {
|
||||
static_cast<int8_t>(receiver_model.lna()),
|
||||
static_cast<int8_t>(receiver_model.vga())
|
||||
});
|
||||
|
||||
check_log.set_value(logging);
|
||||
check_log.on_select = [this](Checkbox&) {
|
||||
logging = check_log.value();
|
||||
};
|
||||
|
||||
options_bitrate.set_selected_index(1); // 1200bps
|
||||
options_bitrate.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
this->on_bitrate_changed(v);
|
||||
};
|
||||
|
||||
options_freq.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
this->on_band_changed(v);
|
||||
@@ -170,7 +183,7 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
|
||||
ascii_data |= ((codeword >> 11) & 0xFFFFF);
|
||||
ascii_idx += 20;
|
||||
|
||||
// Packet 20 bits to 7 bit reversed ASCII
|
||||
// Raw 20 bits to 7 bit reversed ASCII
|
||||
while (ascii_idx >= 7) {
|
||||
ascii_idx -= 7;
|
||||
ascii_char = (ascii_data >> ascii_idx) & 0x7F;
|
||||
@@ -202,7 +215,7 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
|
||||
}
|
||||
}
|
||||
|
||||
if (logger) logger->on_packet(message->packet, target_frequency());
|
||||
if (logger && logging) logger->on_packet(message->packet, target_frequency());
|
||||
|
||||
if (eom) {
|
||||
std::string console_info;
|
||||
@@ -221,7 +234,8 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
|
||||
if (logger) logger->on_decoded(message->packet, console_info, output_text);
|
||||
|
||||
} else {
|
||||
console_info += pocsag::format::bitrate_str(message->packet.bitrate()) + " Tone only";
|
||||
console_info += pocsag::format::bitrate_str(message->packet.bitrate()) + " ";
|
||||
console_info += pocsag::format::flag_str(message->packet.flag());
|
||||
|
||||
console.writeln(console_info);
|
||||
}
|
||||
@@ -237,6 +251,16 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
|
||||
}
|
||||
}
|
||||
|
||||
void POCSAGAppView::on_bitrate_changed(const uint32_t new_bitrate) {
|
||||
const pocsag::BitRate bitrates[3] = {
|
||||
pocsag::BitRate::FSK512,
|
||||
pocsag::BitRate::FSK1200,
|
||||
pocsag::BitRate::FSK2400
|
||||
};
|
||||
|
||||
baseband::set_pocsag(bitrates[new_bitrate]);
|
||||
}
|
||||
|
||||
void POCSAGAppView::on_band_changed(const uint32_t new_band_frequency) {
|
||||
if (new_band_frequency) set_target_frequency(new_band_frequency);
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
void on_decoded(const pocsag::POCSAGPacket& packet, const std::string info, const std::string text);
|
||||
|
||||
private:
|
||||
LogFile log_file;
|
||||
LogFile log_file { };
|
||||
};
|
||||
|
||||
namespace ui {
|
||||
@@ -68,9 +68,12 @@ private:
|
||||
static constexpr uint32_t sampling_rate = 1536000;
|
||||
static constexpr uint32_t baseband_bandwidth = 1750000;
|
||||
|
||||
bool logging { true };
|
||||
uint32_t batch_cnt = 0;
|
||||
uint32_t address, function;
|
||||
uint32_t ascii_data, ascii_idx;
|
||||
uint32_t address { 0 };
|
||||
uint32_t function { 0 };
|
||||
uint32_t ascii_data { 0 };
|
||||
uint32_t ascii_idx { 0 };
|
||||
std::string output_text = "";
|
||||
|
||||
MessageHandlerRegistration message_handler_packet {
|
||||
@@ -93,7 +96,7 @@ private:
|
||||
|
||||
OptionsField options_freq {
|
||||
{ 0 * 8, 0 * 16 },
|
||||
8,
|
||||
7,
|
||||
{
|
||||
{ "Entered", 0 },
|
||||
{ "FR .025", 466025000 },
|
||||
@@ -104,10 +107,26 @@ private:
|
||||
{ "FR .231", 466231250 }
|
||||
}
|
||||
};
|
||||
|
||||
Button button_setfreq {
|
||||
{ 0, 20, 12 * 8, 20 },
|
||||
"----.----"
|
||||
};
|
||||
OptionsField options_bitrate {
|
||||
{ 13 * 8, 22 },
|
||||
8,
|
||||
{
|
||||
{ "512 bps ", 0 },
|
||||
{ "1200 bps", 1 },
|
||||
{ "2400 bps", 2 }
|
||||
}
|
||||
};
|
||||
Checkbox check_log {
|
||||
{ 22 * 8, 22 },
|
||||
3,
|
||||
"LOG",
|
||||
true
|
||||
};
|
||||
|
||||
Console console {
|
||||
{ 0, 48, 240, 256 }
|
||||
@@ -125,7 +144,7 @@ private:
|
||||
{ 18 * 8, 0 * 16 }
|
||||
};
|
||||
|
||||
std::unique_ptr<POCSAGLogger> logger;
|
||||
std::unique_ptr<POCSAGLogger> logger { };
|
||||
|
||||
uint32_t target_frequency_ = initial_target_frequency;
|
||||
|
||||
@@ -135,6 +154,7 @@ private:
|
||||
void on_show_list();
|
||||
|
||||
void on_band_changed(const uint32_t new_band_frequency);
|
||||
void on_bitrate_changed(const uint32_t new_bitrate);
|
||||
|
||||
uint32_t target_frequency() const;
|
||||
void set_target_frequency(const uint32_t new_value);
|
||||
|
@@ -111,6 +111,11 @@ void set_direction(const rf::Direction new_direction) {
|
||||
rf_path.set_direction(direction);
|
||||
|
||||
baseband_codec.set_mode((direction == rf::Direction::Transmit) ? max5864::Mode::Transmit : max5864::Mode::Receive);
|
||||
|
||||
if (direction == rf::Direction::Receive)
|
||||
led_rx.on();
|
||||
else
|
||||
led_tx.on();
|
||||
}
|
||||
|
||||
bool set_tuning_frequency(const rf::Frequency frequency) {
|
||||
@@ -169,6 +174,9 @@ void disable() {
|
||||
second_if.set_mode(max2837::Mode::Standby);
|
||||
first_if.disable();
|
||||
set_rf_amp(false);
|
||||
|
||||
led_rx.off();
|
||||
led_tx.off();
|
||||
}
|
||||
|
||||
void enable(Configuration configuration) {
|
||||
|
@@ -282,7 +282,7 @@ ReceiverMenuView::ReceiverMenuView(NavigationView& nav) {
|
||||
{ "Audio", ui::Color::green(), nullptr, [&nav](){ nav.push<AnalogAudioView>(); } },
|
||||
{ "CCIR", ui::Color::grey(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "Nordic/BTLE", ui::Color::grey(), &bitmap_icon_nordic, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
{ "POCSAG 1200", ui::Color::cyan(), nullptr, [&nav](){ nav.push<POCSAGAppView>(); } },
|
||||
{ "POCSAG", ui::Color::cyan(), nullptr, [&nav](){ nav.push<POCSAGAppView>(); } },
|
||||
{ "SIGFOX", ui::Color::grey(), &bitmap_icon_foxhunt, [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView
|
||||
{ "Transponders", ui::Color::green(), nullptr, [&nav](){ nav.push<TranspondersMenuView>(); } },
|
||||
} });
|
||||
|
Reference in New Issue
Block a user