diff --git a/firmware/application/protocols/encoders.hpp b/firmware/application/protocols/encoders.hpp index d23b38f491..bd61caf87a 100644 --- a/firmware/application/protocols/encoders.hpp +++ b/firmware/application/protocols/encoders.hpp @@ -28,27 +28,27 @@ #define __ENCODERS_H__ namespace encoders { - - #define ENC_TYPES_COUNT 14 + + #define ENC_TYPES_COUNT 13 #define OOK_SAMPLERATE 2280000U - + #define ENCODER_UM3750 8 - + size_t make_bitstream(std::string& fragments); void bitstream_append(size_t& bitstream_length, uint32_t bit_count, uint32_t bits); struct encoder_def_t { - char name[16]; // Encoder chip ref/name + char name[16]; // Encoder chip ref/name char address_symbols[8]; // List of possible symbols like "01", "01F"... - char data_symbols[8]; // Same + char data_symbols[8]; // Same uint16_t clk_per_symbol; // Oscillator periods per symbol - uint16_t clk_per_fragment; // Oscillator periods per symbol fragment (state) + uint16_t clk_per_fragment; // Oscillator periods per symbol fragment (state) char bit_format[4][20]; // List of fragments for each symbol in previous *_symbols list order - uint8_t word_length; // Total # of symbols (not counting sync) - char word_format[32]; // A for Address, D for Data, S for sync - char sync[64]; // Like bit_format + uint8_t word_length; // Total # of symbols (not counting sync) + char word_format[32]; // A for Address, D for Data, S for sync + char sync[64]; // Like bit_format uint32_t default_speed; // Default encoder clk frequency (often set by shitty resistor) - uint8_t repeat_min; // Minimum repeat count + uint8_t repeat_min; // Minimum repeat count uint16_t pause_symbols; // Length of pause between repeats in symbols }; @@ -65,7 +65,7 @@ namespace encoders { 150000, 2, 0 }, - + // PT2260-R4 { "2260-R4", @@ -77,7 +77,7 @@ namespace encoders { 150000, 2, 0 }, - + // PT2262 { "2262 ", @@ -89,7 +89,7 @@ namespace encoders { 20000, 4, 0 }, - + // 16-bit ? { "16-bit ", @@ -101,7 +101,7 @@ namespace encoders { 25000, 50, 0 // ? }, - + // RT1527 { "1527 ", @@ -113,7 +113,7 @@ namespace encoders { 100000, 4, 10 // ? }, - + // HK526E { "526E ", @@ -125,7 +125,7 @@ namespace encoders { 20000, 4, 10 // ? }, - + // HT12E { "12E ", @@ -137,19 +137,8 @@ namespace encoders { 3000, 4, 10 // ? }, - - // VD5026 13 bits ? - { - "5026 ", - "0123", "0123", - 128, 8, - { "1000000010000000", "1111111011111110", "1111111010000000", "1000000011111110" }, - 12, "SAAAAAAAAAAAA", - "000000000000000000000000000000000000000000000001", // ? - 100000, 4, - 10 // ? - }, - + + // UM3750 { "UM3750 ", @@ -161,7 +150,7 @@ namespace encoders { 100000, 4, (3 * 12) - 6 // Compensates for pause delay bug in proc_ook }, - + // UM3758 { "UM3758 ", @@ -173,7 +162,7 @@ namespace encoders { 160000, 4, 10 // ? }, - + // BA5104 { "BA5104 ", @@ -185,7 +174,7 @@ namespace encoders { 455000, 4, 10 // ? }, - + // MC145026 { "145026 ", @@ -197,7 +186,7 @@ namespace encoders { 455000, 2, 2 }, - + // HT6*** TODO: Add individual variations { "HT6*** ", @@ -209,7 +198,7 @@ namespace encoders { 80000, 3, 10 // ? }, - + // TC9148 { "TC9148 ", diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 4c574c6301..4c3ac774d9 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -97,7 +97,7 @@ SystemStatusView::SystemStatusView( .background = Color::dark_grey(), .foreground = Color::white(), }; - + add_children({ &backdrop, &button_back, @@ -110,33 +110,33 @@ SystemStatusView::SystemStatusView( &image_clock_status, &sd_card_status_view, }); - + button_back.id = -1; // Special ID used by FocusManager title.set_style(&style_systemstatus); - + if (portapack::persistent_memory::stealth_mode()) button_stealth.set_foreground(ui::Color::green()); - + /*if (!portapack::persistent_memory::ui_config_textentry()) button_textentry.set_bitmap(&bitmap_icon_keyboard); else button_textentry.set_bitmap(&bitmap_icon_unistroke);*/ refresh(); - + button_back.on_select = [this](ImageButton&){ if (this->on_back) this->on_back(); }; - + button_stealth.on_select = [this](ImageButton&) { this->on_stealth(); }; - + button_bias_tee.on_select = [this](ImageButton&) { this->on_bias_tee(); }; - + /*button_textentry.on_select = [this](ImageButton&) { this->on_textentry(); };*/ @@ -159,7 +159,7 @@ void SystemStatusView::refresh() { button_bias_tee.set_bitmap(&bitmap_icon_biast_off); button_bias_tee.set_foreground(ui::Color::light_grey()); } - + if (portapack::clock_manager.get_reference().source == ClockManager::ReferenceSource::External) { image_clock_status.set_bitmap(&bitmap_icon_clk_ext); button_bias_tee.set_foreground(ui::Color::green()); @@ -167,7 +167,7 @@ void SystemStatusView::refresh() { image_clock_status.set_bitmap(&bitmap_icon_clk_int); button_bias_tee.set_foreground(ui::Color::light_grey()); } - + set_dirty(); } @@ -186,7 +186,7 @@ void SystemStatusView::set_title(const std::string new_value) { void SystemStatusView::on_stealth() { bool mode = not portapack::persistent_memory::stealth_mode(); - + portapack::persistent_memory::set_stealth_mode(mode); button_stealth.set_foreground(mode ? Color::green() : Color::light_grey()); @@ -214,10 +214,10 @@ void SystemStatusView::on_bias_tee() { /*void SystemStatusView::on_textentry() { uint8_t cfg; - + cfg = portapack::persistent_memory::ui_config_textentry(); portapack::persistent_memory::set_config_textentry(cfg ^ 1); - + if (!cfg) button_textentry.set_bitmap(&bitmap_icon_unistroke); else @@ -316,10 +316,10 @@ void NavigationView::free_view() { void NavigationView::update_view() { const auto new_view = view_stack.back().get(); - + add_child(new_view); new_view->set_parent_rect({ {0, 0}, size() }); - + focus(); set_dirty(); @@ -359,7 +359,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) { { "SSTV", ui::Color::dark_grey(), &bitmap_icon_sstv, [&nav](){ nav.push(); } }, { "TETRA", ui::Color::dark_grey(), &bitmap_icon_tetra, [&nav](){ nav.push(); } }, }); - + set_highlighted(4); // Default selection is "Audio" } @@ -421,20 +421,20 @@ void SystemMenuView::hackrf_mode(NavigationView& nav) { SystemMenuView::SystemMenuView(NavigationView& nav) { add_items({ - { "Play dead", ui::Color::red(), &bitmap_icon_playdead, [&nav](){ nav.push(); } }, - { "Receivers", ui::Color::dark_cyan(), &bitmap_icon_receivers, [&nav](){ nav.push(); } }, - { "Transmit", ui::Color::green(), &bitmap_icon_transmit, [&nav](){ nav.push(); } }, - { "Capture", ui::Color::blue(), &bitmap_icon_capture, [&nav](){ nav.push(); } }, - { "Replay", ui::Color::purple(), &bitmap_icon_replay, [&nav](){ nav.push(); } }, - { "Calls", ui::Color::yellow(), &bitmap_icon_closecall, [&nav](){ nav.push(); } }, - { "Scanner", ui::Color::orange(), &bitmap_icon_scanner, [&nav](){ nav.push(); } }, - { "Utilities", ui::Color::light_grey(), &bitmap_icon_utilities, [&nav](){ nav.push(); } }, - { "Settings", ui::Color::cyan(), &bitmap_icon_setup, [&nav](){ nav.push(); } }, - //{ "Debug", ui::Color::cyan(), nullptr, [&nav](){ nav.push(); } }, - { "HackRF", ui::Color::cyan(), &bitmap_icon_hackrf, [this, &nav](){ hackrf_mode(nav); } }, - { "About", ui::Color::cyan(), nullptr, [&nav](){ nav.push(); } } + { "Play dead", ui::Color::cyan(), &bitmap_icon_playdead, [&nav](){ nav.push(); } }, + { "Receivers", ui::Color::cyan(), &bitmap_icon_receivers, [&nav](){ nav.push(); } }, + { "Transmit", ui::Color::cyan(), &bitmap_icon_transmit, [&nav](){ nav.push(); } }, + { "Capture", ui::Color::cyan(), &bitmap_icon_capture, [&nav](){ nav.push(); } }, + { "Replay", ui::Color::cyan(), &bitmap_icon_replay, [&nav](){ nav.push(); } }, + { "Calls", ui::Color::cyan(), &bitmap_icon_closecall, [&nav](){ nav.push(); } }, + { "Scanner", ui::Color::cyan(), &bitmap_icon_scanner, [&nav](){ nav.push(); } }, + { "Utilities", ui::Color::cyan(), &bitmap_icon_utilities, [&nav](){ nav.push(); } }, + { "Settings", ui::Color::cyan(), &bitmap_icon_setup, [&nav](){ nav.push(); } }, + //{ "Debug", ui::Color::cyan(), nullptr, [&nav](){ nav.push(); } }, + { "HackRF", ui::Color::cyan(), &bitmap_icon_hackrf, [this, &nav](){ hackrf_mode(nav); } }, + { "About", ui::Color::cyan(), nullptr, [&nav](){ nav.push(); } } }); - + set_highlighted(1); // Startup selection is "Receivers" } @@ -455,7 +455,7 @@ SystemView::SystemView( set_style(&style_default); constexpr ui::Dim status_view_height = 16; - + add_child(&status_view); status_view.set_parent_rect({ { 0, 0 }, @@ -475,22 +475,21 @@ SystemView::SystemView( this->status_view.set_title(new_view.title()); }; - // portapack::persistent_memory::set_playdead_sequence(0x8D1); - + // Initial view - /*if ((portapack::persistent_memory::playing_dead() == 0x5920C1DF) || // Enable code - (portapack::persistent_memory::ui_config() & 16)) { // Login option + if ((portapack::persistent_memory::playing_dead() == 0x5920C1DF) || // Enable code + (portapack::persistent_memory::config_login())) { // Login option + navigation_view.push(); navigation_view.push(); - } else {*/ - + } else { navigation_view.push(); - + if (portapack::persistent_memory::config_splash()) navigation_view.push(); //else // navigation_view.push(); - - //} + + } } Context& SystemView::context() const { @@ -508,7 +507,7 @@ BMPView::BMPView(NavigationView& nav) { &text_info, &button_done }); - + button_done.on_select = [this, &nav](Button&){ nav.pop(); }; @@ -550,7 +549,7 @@ ModalMessageView::ModalMessageView( { if (type == INFO) { add_child(&button_ok); - + button_ok.on_select = [&nav](Button&){ nav.pop(); }; @@ -559,7 +558,7 @@ ModalMessageView::ModalMessageView( &button_yes, &button_no }); - + button_yes.on_select = [this, &nav](Button&){ if (on_choice_) on_choice_(true); nav.pop(); @@ -573,7 +572,7 @@ ModalMessageView::ModalMessageView( &button_yes, &button_no }); - + button_yes.on_select = [this, &nav](Button&){ if (on_choice_) on_choice_(true); nav.pop(); @@ -584,7 +583,7 @@ ModalMessageView::ModalMessageView( }; } else { // ABORT add_child(&button_ok); - + button_ok.on_select = [this, &nav](Button&){ if (on_choice_) on_choice_(true); nav.pop_modal(); @@ -594,9 +593,9 @@ ModalMessageView::ModalMessageView( void ModalMessageView::paint(Painter& painter) { size_t pos, i = 0, start = 0; - + portapack::display.drawBMP({ 100, 48 }, modal_warning_bmp, false); - + // Terrible... while ((pos = message_.find("\n", start)) != std::string::npos) { painter.draw_string( diff --git a/firmware/application/ui_playdead.cpp b/firmware/application/ui_playdead.cpp index 83537c9dec..728875c702 100644 --- a/firmware/application/ui_playdead.cpp +++ b/firmware/application/ui_playdead.cpp @@ -35,45 +35,41 @@ void PlayDeadView::focus() { void PlayDeadView::paint(Painter& painter) { if (persistent_memory::config_login()) { // Blank the whole display - painter.fill_rectangle( - display.screen_rect(), - style().background - ); + //painter.fill_rectangle( + // display.screen_rect(), + // style().background + //); } } PlayDeadView::PlayDeadView(NavigationView& nav) { rtc::RTC datetime; - + persistent_memory::set_playing_dead(0x5920C1DF); // Enable - + add_children({ &text_playdead1, &text_playdead2, &text_playdead3, &button_seq_entry, }); - + // Seed from RTC rtcGetTime(&RTCD1, &datetime); text_playdead2.set("0x" + to_string_hex(lfsr_iterate(datetime.second()), 6) + "00"); - + text_playdead3.hidden(true); - + button_seq_entry.on_dir = [this](Button&, KeyEvent key){ sequence = (sequence << 3) | (static_cast::type>(key) + 1); return true; }; - + button_seq_entry.on_select = [this, &nav](Button&){ if (sequence == persistent_memory::playdead_sequence()) { persistent_memory::set_playing_dead(0x82175E23); // Disable - if (persistent_memory::config_login()) { - text_playdead3.hidden(false); - } else { nav.pop(); nav.push(); - } } else { sequence = 0; }