diff --git a/firmware/application/baseband_api.cpp b/firmware/application/baseband_api.cpp index bf91a5fe..fae60570 100644 --- a/firmware/application/baseband_api.cpp +++ b/firmware/application/baseband_api.cpp @@ -166,7 +166,7 @@ void set_adsb() { send_message(&message); } -void set_jammer(const bool run, const uint32_t type, const uint32_t speed) { +void set_jammer(const bool run, const jammer::JammerType type, const uint32_t speed) { const JammerConfigureMessage message { run, type, diff --git a/firmware/application/baseband_api.hpp b/firmware/application/baseband_api.hpp index 695d7913..c0548d0c 100644 --- a/firmware/application/baseband_api.hpp +++ b/firmware/application/baseband_api.hpp @@ -25,6 +25,7 @@ #include "message.hpp" #include "pocsag_packet.hpp" +#include "jammer.hpp" #include "dsp_fir_taps.hpp" @@ -67,7 +68,7 @@ void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint32_t progress_notice); void set_pocsag(const pocsag::BitRate bitrate); void set_adsb(); -void set_jammer(const bool run, const uint32_t type, const uint32_t speed); +void set_jammer(const bool run, const jammer::JammerType type, const uint32_t speed); void set_rds_data(const uint16_t message_length); void set_spectrum(const size_t sampling_rate, const size_t trigger); diff --git a/firmware/application/bht.cpp b/firmware/application/bht.cpp index 5014903a..e6beefc4 100644 --- a/firmware/application/bht.cpp +++ b/firmware/application/bht.cpp @@ -36,6 +36,8 @@ std::string gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t re char ook_bitstream[256]; char ep_message[13] = { 0 }; + (void)relay_state_B; + // EP frame // Repeated 2x 26 times // Whole frame + space = 128ms, data only = 64ms diff --git a/firmware/application/ui_adsbtx.cpp b/firmware/application/ui_adsbtx.cpp index 59f8404a..b4381d2c 100644 --- a/firmware/application/ui_adsbtx.cpp +++ b/firmware/application/ui_adsbtx.cpp @@ -112,24 +112,18 @@ ADSBTxView::ADSBTxView(NavigationView& nav) { baseband::run_image(portapack::spi_flash::image_tag_adsb_tx); add_children({ - &text_format, + &labels, &options_format, - &text_icaolabel, &sym_icao, - &text_callsign, &button_callsign, - &text_altitude, &field_altitude, - &text_latitude, &field_lat_degrees, &field_lat_minutes, &field_lat_seconds, - &text_longitude, &field_lon_degrees, &field_lon_minutes, &field_lon_seconds, &check_emergency, - &text_squawk, &field_squawk, &text_frame_a, &text_frame_b, diff --git a/firmware/application/ui_adsbtx.hpp b/firmware/application/ui_adsbtx.hpp index 3f64bf2a..b93ef847 100644 --- a/firmware/application/ui_adsbtx.hpp +++ b/firmware/application/ui_adsbtx.hpp @@ -74,10 +74,16 @@ private: .foreground = Color::red(), }; - Text text_format { - { 2 * 8, 1 * 16, 7 * 8, 16 }, - "Format:" + Labels labels { + { { 2 * 8, 2 * 8 }, "Format:", Color::light_grey() }, + { { 2 * 8, 4 * 8 }, "ICAO24:", Color::light_grey() }, + { { 2 * 8, 7 * 8 }, "ID:", Color::light_grey() }, + { { 2 * 8, 10 * 8 }, "Altitude: feet", Color::light_grey() }, + { { 2 * 8, 12 * 8 }, "Latitude: * ' \"", Color::light_grey() }, // No ° symbol in 8x16 font + { { 2 * 8, 14 * 8 }, "Longitude: * ' \"", Color::light_grey() }, // No ° symbol in 8x16 font + { { 15 * 8, 18 * 8 }, "Squawk", Color::light_grey() } }; + OptionsField options_format { { 10 * 8, 1 * 16 }, 9, @@ -88,29 +94,17 @@ private: } }; - Text text_icaolabel { - { 2 * 8, 2 * 16, 7 * 8, 16 }, - "ICAO24:" - }; SymField sym_icao { { 10 * 8, 2 * 16 }, 6, SymField::SYMFIELD_HEX }; - Text text_callsign { - { 2 * 8, 3 * 16 + 8, 3 * 8, 16 }, - "ID:" - }; Button button_callsign { { 6 * 8, 3 * 16 + 4, 10 * 8, 24 }, "" }; - Text text_altitude { - { 2 * 8, 5 * 16, 20 * 8, 16 }, - "Altitude: feet" - }; NumberField field_altitude { { 12 * 8, 5 * 16 }, 5, @@ -119,10 +113,6 @@ private: ' ' }; - Text text_latitude { - { 2 * 8, 6 * 16, 20 * 8, 16 }, - "Latitude: * ' \"" // No ° symbol in 8x16 font - }; NumberField field_lat_degrees { { 12 * 8, 6 * 16 }, 3, { -90, 90 }, 1, ' ' }; @@ -132,10 +122,7 @@ private: NumberField field_lat_seconds { { 19 * 8, 6 * 16 }, 2, { 0, 59 }, 1, ' ' }; - Text text_longitude { - { 2 * 8, 7 * 16, 20 * 8, 16 }, - "Longitude: * ' \"" // No ° symbol in 8x16 font - }; + NumberField field_lon_degrees { { 12 * 8, 7 * 16 }, 3, { -90, 90 }, 1, ' ' }; @@ -152,10 +139,7 @@ private: "Emergency", false }; - Text text_squawk { - { 15 * 8, 9 * 16, 6 * 8, 16 }, - "Squawk" - }; + SymField field_squawk { { 22 * 8, 9 * 16 }, 4, diff --git a/firmware/application/ui_bht_tx.cpp b/firmware/application/ui_bht_tx.cpp index ba312798..80b0b25b 100644 --- a/firmware/application/ui_bht_tx.cpp +++ b/firmware/application/ui_bht_tx.cpp @@ -119,28 +119,22 @@ BHTView::BHTView(NavigationView& nav) { //baseband::run_image(portapack::spi_flash::image_tag_encoders); add_children({ + &labels, &options_mode, - &text_header, &header_code_a, &header_code_b, &checkbox_speaker, &bmp_speaker, - &text_city, &city_code_xy, - &text_family, &family_code_xy, - &text_subfamily, &subfamily_code, &checkbox_wcsubfamily, - &text_receiver, &receiver_code, &checkbox_wcid, - &text_relais, &progressbar, &text_message, &checkbox_cligno, &tempo_cligno, - &text_cligno, &tx_view }); @@ -163,17 +157,14 @@ BHTView::BHTView(NavigationView& nav) { if (_mode) { // EP layout remove_children({ - &text_header, &header_code_a, &header_code_b, &checkbox_speaker, &bmp_speaker, &city_code_xy, &family_code_xy, - &text_subfamily, &subfamily_code, &checkbox_wcsubfamily, - &text_receiver, &receiver_code, &checkbox_wcid, &relay_states[2], @@ -191,17 +182,14 @@ BHTView::BHTView(NavigationView& nav) { &family_code_ep }); add_children({ - &text_header, &header_code_a, &header_code_b, &checkbox_speaker, &bmp_speaker, &city_code_xy, &family_code_xy, - &text_subfamily, &subfamily_code, &checkbox_wcsubfamily, - &text_receiver, &receiver_code, &checkbox_wcid, &relay_states[2], @@ -238,12 +226,8 @@ BHTView::BHTView(NavigationView& nav) { checkbox_wcsubfamily.on_select = [this](Checkbox&, bool v) { if (v) { subfamily_code.set_focusable(false); - subfamily_code.set_style(&style_grey); - text_subfamily.set_style(&style_grey); } else { subfamily_code.set_focusable(true); - subfamily_code.set_style(&style()); - text_subfamily.set_style(&style()); } generate_message(); }; @@ -251,12 +235,8 @@ BHTView::BHTView(NavigationView& nav) { checkbox_wcid.on_select = [this](Checkbox&, bool v) { if (v) { receiver_code.set_focusable(false); - receiver_code.set_style(&style_grey); - text_receiver.set_style(&style_grey); } else { receiver_code.set_focusable(true); - receiver_code.set_style(&style()); - text_receiver.set_style(&style()); } generate_message(); }; diff --git a/firmware/application/ui_bht_tx.hpp b/firmware/application/ui_bht_tx.hpp index 330b6e88..fec2dca9 100644 --- a/firmware/application/ui_bht_tx.hpp +++ b/firmware/application/ui_bht_tx.hpp @@ -81,6 +81,15 @@ private: .foreground = Color::grey(), }; + Labels labels { + { { 8 * 8, 3 * 8 }, "Header:", Color::light_grey() }, + { { 4 * 8, 5 * 8 }, "Code ville:", Color::light_grey() }, + { { 7 * 8, 7 * 8 }, "Famille:", Color::light_grey() }, + { { 2 * 8, 9 * 8 + 2 }, "Sous-famille:", Color::light_grey() }, + { { 2 * 8, 13 * 8 }, "ID recepteur:", Color::light_grey() }, + { { 1 * 8, 17 * 8 }, "Relais:", Color::light_grey() }, + { { 27 * 8 + 4, 20 * 8 + 4 }, "s.", Color::light_grey() } + }; OptionsField options_mode { { 10 * 8, 4 }, @@ -103,10 +112,6 @@ private: ui::Color::black() }; - Text text_header { - { 8 * 8, 3 * 8, 7 * 8, 16 }, - "Header:" - }; NumberField header_code_a { { 16 * 8, 3 * 8 }, 2, @@ -122,10 +127,6 @@ private: '0' }; - Text text_city { - { 4 * 8, 5 * 8, 11 * 8, 16 }, - "Code ville:" - }; NumberField city_code_xy { { 16 * 8, 5 * 8 }, 2, @@ -141,10 +142,6 @@ private: ' ' }; - Text text_family { - { 7 * 8, 7 * 8, 8 * 8, 16 }, - "Famille:" - }; NumberField family_code_xy { { 16 * 8, 7 * 8 }, 1, @@ -163,10 +160,6 @@ private: } }; - Text text_subfamily { - { 2 * 8, 9 * 8 + 2, 13 * 8, 16 }, - "Sous-famille:" - }; NumberField subfamily_code { { 16 * 8, 9 * 8 + 2 }, 1, @@ -180,10 +173,6 @@ private: "Toutes" }; - Text text_receiver { - { 2 * 8, 13 * 8, 13 * 8, 16 }, - "ID recepteur:" - }; NumberField receiver_code { { 16 * 8, 13 * 8 }, 2, @@ -197,11 +186,6 @@ private: "Tous" }; - Text text_relais { - { 1 * 8, 8 * 16 + 8, 7 * 8, 16 }, - "Relais:" - }; - std::array relay_states { }; ImageOptionsField::options_t relay_options = { @@ -230,10 +214,6 @@ private: 1, ' ' }; - Text text_cligno { - { 27 * 8 + 4, 10 * 16 + 4, 2 * 8, 16 }, - "s." - }; TransmitterView tx_view { 16 * 16, diff --git a/firmware/application/ui_closecall.cpp b/firmware/application/ui_closecall.cpp index 3257f3c0..c664ea47 100644 --- a/firmware/application/ui_closecall.cpp +++ b/firmware/application/ui_closecall.cpp @@ -288,9 +288,7 @@ CloseCallView::CloseCallView( baseband::run_image(portapack::spi_flash::image_tag_wideband_spectrum); add_children({ - &text_labels_a, - &text_labels_b, - &text_labels_c, + &labels, &field_frequency_min, &field_frequency_max, &field_lna, @@ -306,9 +304,6 @@ CloseCallView::CloseCallView( &button_exit }); - text_labels_a.set_style(&style_grey); - text_labels_b.set_style(&style_grey); - text_labels_c.set_style(&style_grey); text_slices.set_style(&style_grey); text_rate.set_style(&style_grey); text_mhz.set_style(&style_grey); diff --git a/firmware/application/ui_closecall.hpp b/firmware/application/ui_closecall.hpp index 0827c8b7..7558f6d0 100644 --- a/firmware/application/ui_closecall.hpp +++ b/firmware/application/ui_closecall.hpp @@ -62,25 +62,25 @@ private: .foreground = Color::green(), }; - rf::Frequency f_min, f_max; + rf::Frequency f_min { 0 }, f_max { 0 }; Coord last_pos { 0 }; ChannelSpectrumFIFO* fifo { nullptr }; uint8_t detect_counter { 0 }, release_counter { 0 }; - uint8_t slice_trim; + uint8_t slice_trim { 0 }; uint32_t mean { 0 }; uint32_t min_threshold { 80 }; // Todo: Put this in persistent / settings - rf::Frequency slice_start; - rf::Frequency slice_frequency; - uint8_t slices_max; - uint8_t slices_counter; - int16_t last_channel; + rf::Frequency slice_start { 0 }; + rf::Frequency slice_frequency { 0 }; + uint8_t slices_max { 0 }; + uint8_t slices_counter { 0 }; + int16_t last_channel { 0 }; uint32_t weight { 0 }; uint64_t frequency_acc { 0 }; - rf::Frequency scan_span, resolved_frequency; - uint16_t locked_imax; + rf::Frequency scan_span { 0 }, resolved_frequency { 0 }; + uint16_t locked_imax { 0 }; uint8_t slicemax_pow[32]; // Todo: Cap max slices ! int16_t slicemax_idx[32]; - uint8_t scan_counter; + uint8_t scan_counter { 0 }; SignalToken signal_token_tick_second { }; bool ignore { true }; bool slicing { false }; @@ -101,17 +101,10 @@ private: * | * */ - Text text_labels_a { - { 1 * 8, 0 * 16, 28 * 8, 16 }, - "Min: Max: LNA VGA" - }; - Text text_labels_b { - { 1 * 8, 2 * 16, 10 * 8, 16 }, - "Threshold:" - }; - Text text_labels_c { - { 1 * 8, 3 * 16, 28 * 8, 16 }, - "Slices: Rate: Hz" + Labels labels { + { { 1 * 8, 0 }, "Min: Max: LNA VGA", Color::light_grey() }, + { { 1 * 8, 4 * 8 }, "Threshold:", Color::light_grey() }, + { { 1 * 8, 6 * 8 }, "Slices: Rate: Hz", Color::light_grey() } }; NumberField field_threshold { diff --git a/firmware/application/ui_encoders.cpp b/firmware/application/ui_encoders.cpp index 2785b5bf..650bab10 100644 --- a/firmware/application/ui_encoders.cpp +++ b/firmware/application/ui_encoders.cpp @@ -265,23 +265,15 @@ EncodersView::EncodersView(NavigationView& nav) { encoder_def = &encoder_defs[0]; add_children({ - &text_enctype, + &labels, &options_enctype, - &text_clk, &numberfield_clk, - &text_kHz, - &text_bitduration, &numberfield_bitduration, - &text_us1, - &text_wordduration, &numberfield_wordduration, - &text_us2, - &text_symfield, &symfield_word, &text_format, //&text_format_a, // DEBUG //&text_format_d, // DEBUG - &text_waveform, &waveform, &text_status, &progress, diff --git a/firmware/application/ui_encoders.hpp b/firmware/application/ui_encoders.hpp index 82354a58..14508630 100644 --- a/firmware/application/ui_encoders.hpp +++ b/firmware/application/ui_encoders.hpp @@ -99,21 +99,25 @@ private: .foreground = Color::blue(), }; - Text text_enctype { - { 1 * 8, 32, 5 * 8, 16 }, - "Type:" + Labels labels { + { { 1 * 8, 4 * 8 }, "Type:", Color::light_grey() }, + { { 16 * 8, 4 * 8 }, "Clk:", Color::light_grey() }, + { { 24 * 8, 4 * 8 }, "kHz", Color::light_grey() }, + { { 16 * 8, 6 * 8 }, "Bit:", Color::light_grey() }, + { { 25 * 8, 6 * 8 }, "us", Color::light_grey() }, + { { 15 * 8, 8 * 8 }, "Word:", Color::light_grey() }, + { { 26 * 8, 8 * 8 }, "us", Color::light_grey() }, + { { 2 * 8, 10 * 8 }, "Word:", Color::light_grey() }, + { { 1 * 8, 17 * 8 }, "Waveform:", Color::light_grey() } }; + OptionsField options_enctype { // Options are loaded at runtime { 6 * 8, 32 }, 7, { } }; - - Text text_clk { - { 16 * 8, 4 * 8, 4 * 8, 16 }, - "Clk:" - }; + NumberField numberfield_clk { { 21 * 8, 4 * 8 }, 3, @@ -121,15 +125,7 @@ private: 1, ' ' }; - Text text_kHz { - { 24 * 8, 4 * 8, 3 * 8, 16 }, - "kHz" - }; - - Text text_bitduration { - { 16 * 8, 6 * 8, 4 * 8, 16 }, - "Bit:" - }; + NumberField numberfield_bitduration { { 21 * 8, 6 * 8 }, 4, @@ -137,15 +133,7 @@ private: 1, ' ' }; - Text text_us1 { - { 25 * 8, 6 * 8, 2 * 8, 16 }, - "us" - }; - - Text text_wordduration { - { 15 * 8, 8 * 8, 5 * 8, 16 }, - "Word:" - }; + NumberField numberfield_wordduration { { 21 * 8, 8 * 8 }, 5, @@ -153,15 +141,7 @@ private: 100, ' ' }; - Text text_us2 { - { 26 * 8, 8 * 8, 2 * 8, 16 }, - "us" - }; - Text text_symfield { - { 2 * 8, 10 * 8, 5 * 8, 16 }, - "Word:" - }; SymField symfield_word { { 2 * 8, 12 * 8 }, 20, @@ -175,11 +155,6 @@ private: //Text text_format_a; // DEBUG //Text text_format_d; // DEBUG - Text text_waveform { - { 1 * 8, 136, 9 * 8, 16 }, - "Waveform:" - }; - Waveform waveform { { 0, 160, 240, 32 }, waveform_buffer, @@ -193,6 +168,7 @@ private: { 2 * 8, 13 * 16, 128, 16 }, "Ready" }; + ProgressBar progress { { 2 * 8, 13 * 16 + 20, 208, 16 } }; diff --git a/firmware/application/ui_freqman.cpp b/firmware/application/ui_freqman.cpp index 8d2d4260..13e00c1f 100644 --- a/firmware/application/ui_freqman.cpp +++ b/firmware/application/ui_freqman.cpp @@ -280,10 +280,8 @@ FreqManView::FreqManView( add_children({ &menu_view, - &text_edit, &button_edit_freq, &button_edit_desc, - &text_category, &options_category, &button_del, &button_exit diff --git a/firmware/application/ui_freqman.hpp b/firmware/application/ui_freqman.hpp index 49d62192..5f3abdf0 100644 --- a/firmware/application/ui_freqman.hpp +++ b/firmware/application/ui_freqman.hpp @@ -153,11 +153,12 @@ private: { 0, 0, 240, 168 }, true }; - - Text text_edit { - { 2 * 8, 24 * 8, 5 * 8, 16 }, - "Edit:" + + Labels label { + { { 2 * 8, 24 * 8 }, "Edit:", Color::light_grey() }, + { { 2 * 8, 35 * 8 }, "Category:", Color::light_grey() } }; + Button button_edit_freq { { 2 * 8, 26 * 8, 14 * 8, 32 }, "Frequency" @@ -166,10 +167,7 @@ private: { 2 * 8, 30 * 8 + 4, 14 * 8, 32 }, "Description" }; - Text text_category { - { 2 * 8, 35 * 8, 9 * 8, 16 }, - "Category:", - }; + OptionsField options_category { { 12 * 8, 35 * 8 }, 8, diff --git a/firmware/application/ui_jammer.cpp b/firmware/application/ui_jammer.cpp index 869e3719..90f60fc7 100644 --- a/firmware/application/ui_jammer.cpp +++ b/firmware/application/ui_jammer.cpp @@ -32,10 +32,8 @@ #include #include -#define JAMMER_CH_WIDTH 1000000 -#define JAMMER_MAX_CH 24 - using namespace portapack; +using namespace jammer; namespace ui { @@ -126,18 +124,14 @@ JammerView::JammerView(NavigationView& nav) { JammerChannel * jammer_channels = (JammerChannel*)shared_memory.bb_data.data; add_children({ - &text_type, + &labels, &options_type, &text_range_number, &text_range_total, - &text_speed, &options_speed, - &text_preset, &options_preset, - &text_hop, &options_hop, - &button_transmit, - &button_exit + &button_transmit }); const auto button_freq_fn = [this, &nav](Button& button) { @@ -219,8 +213,8 @@ JammerView::JammerView(NavigationView& nav) { }; - options_type.set_selected_index(1); // Noise - options_speed.set_selected_index(2); // 10kHz + options_type.set_selected_index(2); // Sweep + options_speed.set_selected_index(3); // 10kHz options_preset.set_selected_index(8); // ISM 868 options_hop.set_selected_index(1); // 50ms button_transmit.set_style(&style_val); @@ -236,7 +230,7 @@ JammerView::JammerView(NavigationView& nav) { button_transmit.set_text("START"); transmitter_model.disable(); radio::disable(); - baseband::set_jammer(false, 0, 0); + baseband::set_jammer(false, JammerType::TYPE_FSK, 0); jamming = false; } else { @@ -303,16 +297,12 @@ JammerView::JammerView(NavigationView& nav) { transmitter_model.set_tx_gain(47); transmitter_model.enable(); - baseband::set_jammer(true, options_type.selected_index(), options_speed.selected_index()); + baseband::set_jammer(true, (JammerType)options_type.selected_index(), options_speed.selected_index_value()); } else { - nav.display_modal("Error", "Jamming bandwidth too large."); + nav.display_modal("Error", "Jamming bandwidth too large.\nMust be less than 24MHz."); } } }; - - button_exit.on_select = [&nav](Button&){ - nav.pop(); - }; } } /* namespace ui */ diff --git a/firmware/application/ui_jammer.hpp b/firmware/application/ui_jammer.hpp index 33e0d20b..9d0e0e40 100644 --- a/firmware/application/ui_jammer.hpp +++ b/firmware/application/ui_jammer.hpp @@ -24,8 +24,9 @@ #include "ui_widget.hpp" #include "ui_font_fixed_8x16.hpp" #include "ui_navigation.hpp" -#include "message.hpp" #include "transmitter_model.hpp" +#include "message.hpp" +#include "jammer.hpp" namespace ui { @@ -157,19 +158,22 @@ private: }; - bool jamming = false; + bool jamming { false }; - Text text_type { - { 3 * 8, 4, 5 * 8, 16 }, - "Type:" + Labels labels { + { { 3 * 8, 4 }, "Type:", Color::light_grey() }, + { { 2 * 8, 20 }, "Speed:", Color::light_grey() }, + { { 1 * 8, 36 }, "Preset:", Color::light_grey() }, + { { 5 * 8, 52 }, "Hop:", Color::light_grey() } }; + OptionsField options_type { { 9 * 8, 4 }, 5, { - { "Ramp ", 0 }, - { "Noise", 1 }, - { "Tones", 2 } + { "FSK ", 0 }, + { "Tone ", 1 }, + { "Sweep", 2 } } }; @@ -182,26 +186,18 @@ private: "/--" }; - Text text_speed { - { 2 * 8, 20, 6 * 8, 16 }, - "Speed:" - }; OptionsField options_speed { { 9 * 8, 20 }, 6, { - { "10Hz ", 0 }, - { "100Hz ", 1 }, - { "1kHz ", 2 }, - { "10kHz ", 3 }, - { "100kHz", 4 } + { "10Hz ", 10 }, + { "100Hz ", 100 }, + { "1kHz ", 1000 }, + { "10kHz ", 10000 }, + { "100kHz", 100000 } } }; - Text text_preset { - { 1 * 8, 36, 7 * 8, 16 }, - "Preset:" - }; OptionsField options_preset { { 9 * 8, 36 }, 16, @@ -232,10 +228,6 @@ private: } }; - Text text_hop { - { 5 * 8, 52, 10 * 8, 16 }, - "Hop:" - }; OptionsField options_hop { { 9 * 8, 52 }, 5, @@ -259,11 +251,6 @@ private: "START" }; - Button button_exit { - { 19 * 8, 16 * 16, 80, 48 }, - "Exit" - }; - MessageHandlerRegistration message_handler_retune { Message::ID::Retune, [this](Message* const p) { diff --git a/firmware/application/ui_rds.cpp b/firmware/application/ui_rds.cpp index b33e8bd9..4f646e8f 100644 --- a/firmware/application/ui_rds.cpp +++ b/firmware/application/ui_rds.cpp @@ -77,24 +77,19 @@ RDSView::RDSView(NavigationView& nav) { strcpy(RadioText, "Radiotext test ABCD1234"); add_children({ - &text_pty, + &labels, &options_pty, - &text_countrycode, &options_countrycode, - &text_coverage, &options_coverage, - &text_tx, &options_tx, &check_mono_stereo, &check_TA, &check_TP, &check_MS, - &text_pi_code, &sym_pi_code, &button_editpsn, &text_psn, &button_editradiotext, - &text_radiotext, &text_radiotexta, &text_radiotextb, &tx_view, diff --git a/firmware/application/ui_rds.hpp b/firmware/application/ui_rds.hpp index 1b9cc430..5349033e 100644 --- a/firmware/application/ui_rds.hpp +++ b/firmware/application/ui_rds.hpp @@ -55,10 +55,15 @@ private: void start_tx(); void on_tuning_frequency_changed(rf::Frequency f); - Text text_pty { - { 1 * 8, 16 + 8, 4 * 8, 16 }, - "PTY:" + Labels labels { + { { 1 * 8, 16 + 8 }, "PTY:", Color::light_grey() }, + { { 14 * 8, 16 + 8 }, "CC:", Color::light_grey() }, + { { 1 * 8, 32 + 8 }, "PI:", Color::light_grey() }, + { { 13 * 8, 32 + 8 }, "Cov:", Color::light_grey() }, + { { 2 * 8, 8 * 16 }, "RadioText:", Color::light_grey() }, + { { 2 * 8, 14 * 16 }, "TX:", Color::light_grey() } }; + OptionsField options_pty { { 5 * 8, 16 + 8 }, 8, @@ -98,10 +103,6 @@ private: } }; - Text text_countrycode { - { 14 * 8, 16 + 8, 4 * 8, 16 }, - "CC:" - }; OptionsField options_countrycode { { 17 * 8, 16 + 8 }, 11, @@ -171,20 +172,12 @@ private: } }; - Text text_pi_code { - { 1 * 8, 32 + 8, 3 * 8, 16 }, - "PI:" - }; SymField sym_pi_code { { 4 * 8, 32 + 8 }, 4, SymField::SYMFIELD_HEX }; - Text text_coverage { - { 13 * 8, 32 + 8, 9 * 8, 16 }, - "Cov:" - }; OptionsField options_coverage { { 17 * 8, 32 + 8 }, 12, @@ -229,19 +222,15 @@ private: "MS" }; - Text text_psn { - { 2 * 8, 6 * 16, 12 * 8, 16 }, - "PSN:" - }; Button button_editpsn { { 22 * 8, 5 * 16 + 12, 48, 24 }, "Set" }; - - Text text_radiotext { - { 2 * 8, 8 * 16, 10 * 8, 16 }, - "RadioText:" + Text text_psn { + { 2 * 8, 6 * 16, 4 * 8, 16 }, + "PSN:" }; + Text text_radiotexta { { 2 * 8, 9 * 16, 19 * 8, 16 }, "-" @@ -255,10 +244,6 @@ private: "Set" }; - Text text_tx { - { 2 * 8, 14 * 16, 3 * 8, 16 }, - "TX:" - }; OptionsField options_tx { { 5 * 8, 14 * 16 }, 11, diff --git a/firmware/application/ui_whipcalc.cpp b/firmware/application/ui_whipcalc.cpp index bc7c8e4e..9c99a556 100644 --- a/firmware/application/ui_whipcalc.cpp +++ b/firmware/application/ui_whipcalc.cpp @@ -74,9 +74,8 @@ WhipCalcView::WhipCalcView( ) { add_children({ - &text_frequency, + &labels, &field_frequency, - &text_type, &options_type, &text_result_metric, &text_result_imperial, diff --git a/firmware/application/ui_whipcalc.hpp b/firmware/application/ui_whipcalc.hpp index 94c7f501..00a691af 100644 --- a/firmware/application/ui_whipcalc.hpp +++ b/firmware/application/ui_whipcalc.hpp @@ -47,18 +47,15 @@ private: void update_result(); - Text text_frequency { - { 2 * 8, 2 * 16, 10 * 16, 16 }, - "Frequency:" + Labels labels { + { { 2 * 8, 2 * 16 }, "Frequency:", Color::light_grey() }, + { { 2 * 8, 3 * 16 }, "Type:", Color::light_grey() } }; + FrequencyField field_frequency { { 13 * 8, 2 * 16 }, }; - - Text text_type { - { 2 * 8, 3 * 16, 5 * 16, 16 }, - "Type:" - }; + OptionsField options_type { { 8 * 8, 3 * 16 }, 12, diff --git a/firmware/baseband/proc_jammer.cpp b/firmware/baseband/proc_jammer.cpp index c7e6e36e..e6cc81e8 100644 --- a/firmware/baseband/proc_jammer.cpp +++ b/firmware/baseband/proc_jammer.cpp @@ -36,11 +36,11 @@ void JammerProcessor::execute(const buffer_c8_t& buffer) { // Find next enabled range do { current_range++; - if (current_range == 24) current_range = 0; // Warning ! Should match JAMMER_MAX_CH + if (current_range == JAMMER_MAX_CH) current_range = 0; } while (!jammer_channels[current_range].enabled); jammer_duration = jammer_channels[current_range].duration; - jammer_bw = jammer_channels[current_range].width / 5; // TODO: Exact value + jammer_bw = jammer_channels[current_range].width / 2; // TODO: Exact value // Ask for retune message.freq = jammer_channels[current_range].center; @@ -50,29 +50,30 @@ void JammerProcessor::execute(const buffer_c8_t& buffer) { jammer_duration--; } - // Ramp - /*if (r >= 10) { - if (sample < 128) - sample++; - else - sample = -127; - r = 0; - } else { - r++; - }*/ - // Phase noise - if (r >= 10) { - aphase += ((aphase >> 4) ^ 0x4573) << 20; - r = 0; + if (!period_counter) { + period_counter = noise_period; + + if (noise_type == JammerType::TYPE_FSK) { + sample = (sample + lfsr) >> 1; + } else if (noise_type == JammerType::TYPE_TONE) { + tone_delta = 150000 + (lfsr >> 9); // Approx 100Hz to 6kHz + } else if (noise_type == JammerType::TYPE_SWEEP) { + sample++; // This is like saw wave FM + } + + feedback = ((lfsr >> 31) ^ (lfsr >> 29) ^ (lfsr >> 15) ^ (lfsr >> 11)) & 1; + lfsr = (lfsr << 1) | feedback; + if (!lfsr) lfsr = 0x1337; // Shouldn't do this :( } else { - r++; + period_counter--; } - aphase += 8830; - sample = sine_table_i8[(aphase & 0xFF000000) >> 24]; + if (noise_type == JammerType::TYPE_TONE) { + aphase += tone_delta; + sample = sine_table_i8[(aphase & 0xFF000000) >> 24]; + } - // FM delta = sample * jammer_bw; phase += delta; @@ -92,9 +93,13 @@ void JammerProcessor::on_message(const Message* const msg) { if (message.run) { jammer_channels = (JammerChannel*)shared_memory.bb_data.data; noise_type = message.type; - noise_speed = message.speed; + noise_period = 3072000 / message.speed; + if (noise_type == JammerType::TYPE_SWEEP) + noise_period >>= 8; + period_counter = 0; jammer_duration = 0; current_range = 0; + lfsr = 0xDEAD0012; configured = true; } else { diff --git a/firmware/baseband/proc_jammer.hpp b/firmware/baseband/proc_jammer.hpp index 50282e6a..15e57fb2 100644 --- a/firmware/baseband/proc_jammer.hpp +++ b/firmware/baseband/proc_jammer.hpp @@ -26,6 +26,9 @@ #include "baseband_processor.hpp" #include "baseband_thread.hpp" #include "portapack_shared_memory.hpp" +#include "jammer.hpp" + +using namespace jammer; class JammerProcessor : public BasebandProcessor { public: @@ -34,21 +37,21 @@ public: void on_message(const Message* const msg) override; private: - bool configured = false; + bool configured { false }; BasebandThread baseband_thread { 3072000, this, NORMALPRIO + 20, baseband::Direction::Transmit }; JammerChannel * jammer_channels { }; - uint32_t noise_type { 0 }; - uint32_t noise_speed { 0 }; + JammerType noise_type { }; + uint32_t tone_delta { 0 }, lfsr { }, feedback { }; + uint32_t noise_period { 0 }, period_counter { 0 }; uint32_t jammer_duration { 0 }; - int8_t r { 0 }, ir { 0 }; uint32_t current_range { 0 }; - int64_t jammer_center { 0 }; + int64_t jammer_center { 0 }, jammer_bw { 0 }; uint32_t sample_count { 0 }; uint32_t aphase { 0 }, phase { 0 }, delta { 0 }, sphase { 0 }; - int32_t sample { 0 }, jammer_bw { 0 }; + int8_t sample { 0 }; int8_t re { 0 }, im { 0 }; RetuneMessage message { }; }; diff --git a/firmware/baseband/proc_rds.cpp b/firmware/baseband/proc_rds.cpp index 2ddccde6..6692e867 100644 --- a/firmware/baseband/proc_rds.cpp +++ b/firmware/baseband/proc_rds.cpp @@ -91,7 +91,7 @@ void RDSProcessor::execute(const buffer_c8_t& buffer) { re = (sine_table_i8[(sphase & 0x03FF0000) >> 18]); im = (sine_table_i8[(phase & 0x03FF0000) >> 18]); - buffer.p[i] = {(int8_t)re, (int8_t)im}; + buffer.p[i] = {re, im}; } } diff --git a/firmware/baseband/proc_rds.hpp b/firmware/baseband/proc_rds.hpp index 53e84663..169b2cc2 100644 --- a/firmware/baseband/proc_rds.hpp +++ b/firmware/baseband/proc_rds.hpp @@ -37,25 +37,25 @@ public: void on_message(const Message* const msg) override; private: - uint32_t * rdsdata; + uint32_t * rdsdata { }; BasebandThread baseband_thread { 2280000, this, NORMALPRIO + 20, baseband::Direction::Transmit }; - uint16_t message_length; - int8_t re, im; - uint8_t mphase, s; - uint32_t bit_pos; + uint16_t message_length { 0 }; + int8_t re { 0 }, im { 0 }; + uint8_t mphase { 0 }, s { 0 }; + uint32_t bit_pos { 0 }; int32_t sample_buffer[SAMPLE_BUFFER_SIZE] = {0}; - int32_t val; - uint8_t prev_output = 0; - uint8_t cur_output = 0; - uint8_t cur_bit = 0; + int32_t val { 0 }; + uint8_t prev_output { 0 }; + uint8_t cur_output { 0 }; + uint8_t cur_bit { 0 }; int sample_count = SAMPLES_PER_BIT; int in_sample_index = 0; - int32_t sample; + int32_t sample { 0 }; int out_sample_index = SAMPLE_BUFFER_SIZE - 1; - uint32_t phase, sphase; - int32_t delta; + uint32_t phase { 0 }, sphase { 0 }; + int32_t delta { 0 }; bool configured { false }; diff --git a/firmware/common/jammer.cpp b/firmware/common/jammer.cpp new file mode 100644 index 00000000..97d2168c --- /dev/null +++ b/firmware/common/jammer.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. + * Copyright (C) 2016 Furrtek + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "jammer.hpp" + +#include "baseband_api.hpp" +#include "portapack.hpp" +using namespace portapack; + +#include "string_format.hpp" +#include "utility.hpp" + +namespace jammer { + +} /* namespace jammer */ diff --git a/firmware/common/jammer.hpp b/firmware/common/jammer.hpp new file mode 100644 index 00000000..8f8639ab --- /dev/null +++ b/firmware/common/jammer.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. + * Copyright (C) 2016 Furrtek + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#define JAMMER_CH_WIDTH 1000000 +#define JAMMER_MAX_CH 24 + +#ifndef __JAMMER_H__ +#define __JAMMER_H__ + +namespace jammer { + +enum JammerType : uint32_t { + TYPE_FSK = 0, + TYPE_TONE = 1, + TYPE_SWEEP = 2 +}; + +} /* namespace jammer */ + +#endif/*__JAMMER_H__*/ diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index 31868356..8b9ef9eb 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -35,6 +35,7 @@ #include "ert_packet.hpp" #include "tpms_packet.hpp" #include "pocsag_packet.hpp" +#include "jammer.hpp" #include "dsp_fir_taps.hpp" #include "dsp_iir.hpp" #include "fifo.hpp" @@ -745,7 +746,7 @@ class JammerConfigureMessage : public Message { public: constexpr JammerConfigureMessage( const bool run, - const uint32_t type, + const jammer::JammerType type, const uint32_t speed ) : Message { ID::JammerConfigure }, run(run), @@ -755,7 +756,7 @@ public: } const bool run; - const uint32_t type; + const jammer::JammerType type; const uint32_t speed; };