Compare commits

...

26 Commits

Author SHA1 Message Date
Brumi-2021
c0f368c978 Merge pull request #775 from Brumi-2021/Small_BW_Label_error_correction_Scanner_App
Scanner BW label corrections
2022-12-29 23:23:41 +01:00
Brumi-2021
75c2b69f19 Scanner BW label corrections 2022-12-30 00:38:54 +01:00
Brumi-2021
3291c7e2a0 Merge pull request #774 from Brumi-2021/Minor_ADSB_Compas_sinf32_array_value_correction_and_comments
Minor sin_f32_table correction and comments
2022-12-29 22:24:28 +01:00
Brumi-2021
64ca9f6a68 Minor sin_f32_table correction and comments 2022-12-29 23:27:15 +01:00
gullradriel
297063873f Merge pull request #767 from rusty-labs/scanner-manual-mode-unlimited-range
#765 Scanner app, unlimited range for manual mode
2022-12-29 17:41:00 +01:00
jLynx
2a38f386ab Update version.txt 2022-12-29 15:35:54 +13:00
jLynx
079a0506a4 Update past_version.txt 2022-12-29 15:35:45 +13:00
Brumi-2021
e8ad86cc94 Merge pull request #768 from rusty-labs/sin_function_180_fix
#755 fix, sin_f32 fails at 180
2022-12-28 16:34:38 +01:00
rusty.labs
e69c9bbc7b #755 fix, sin_f32 fails at 180
#755 fix, sin_f32 returns incorrect result at 180 degrees, clean up
2022-12-28 01:13:42 -05:00
rusty.labs
1f7b800c2a #765 unlimited range for manual mode
* fix for #765, manual mode has unlimited range now
* speedup for button_add.on_select (roughly x70 times faster)
* fix for random freezes while switching to Audio
2022-12-26 17:18:30 -05:00
Brumi-2021
25c267a3d9 Merge pull request #744 from strijar/spectrum_color
New spectrum color scheme Look at table (LUT) for the Waterfall FFT .
2022-12-17 16:02:54 +01:00
gullradriel
efbcd2aa9b Merge pull request #752 from lujji/fix-ook-bug
Fix OOK repeat bug
2022-12-17 12:44:19 +01:00
gullradriel
f32b55f66f Merge pull request #754 from lujji/ook-scan
Implement OOK scan
2022-12-17 12:43:34 +01:00
gullradriel
e9adc32421 Merge pull request #757 from gullradriel/next
Updated submodules
2022-12-14 22:18:43 +01:00
GullCode
a120a6344d Updated submodules 2022-12-14 22:17:25 +01:00
lujji
e3cea4c68b minor ui fix 2022-12-05 22:12:46 +02:00
lujji
0631f5d5ab implement ook scan 2022-12-05 16:51:23 +02:00
lujji
8986b65f94 fix ook repeat bug 2022-11-30 10:59:24 +02:00
gullradriel
7f64606fb2 Merge pull request #750 from gullradriel/recon-delete-retune-fix
Retune after delete fix
2022-11-20 20:14:47 +01:00
GullCode
7bfb54eee9 better order of events 2022-11-20 19:53:03 +01:00
GullCode
e0c1f7b45e Retune after delete fix 2022-11-20 19:46:01 +01:00
gullradriel
734f315266 Merge pull request #749 from gullradriel/updating-am-mode
Added/Renamed AM bandwidth modes
2022-11-20 18:36:43 +01:00
GullCode
7f6aebbe53 Fixed typos 2022-11-20 18:29:20 +01:00
GullCode
5f62926af3 Fixed typo 2022-11-20 18:02:54 +01:00
GullCode
17f6475506 Added/Renamed AM bandwidth modes 2022-11-20 17:44:11 +01:00
Belousov Oleg
f59437cf71 New spectrum color scheme 2022-11-10 02:17:04 +03:00
17 changed files with 753 additions and 588 deletions

View File

@@ -1 +1 @@
v1.5.3
v1.5.4

View File

@@ -1 +1 @@
v1.5.4
v1.6.0

View File

@@ -36,16 +36,17 @@ EncodersConfigView::EncodersConfigView(
using option_t = std::pair<std::string, int32_t>;
std::vector<option_t> enc_options;
size_t i;
set_parent_rect(parent_rect);
hidden(true);
// Default encoder def
encoder_def = &encoder_defs[0];
add_children({
&labels,
&options_enctype,
&field_repeat_min,
&field_clk,
&field_clk_step,
&field_frameduration,
@@ -58,18 +59,18 @@ EncodersConfigView::EncodersConfigView(
// Load encoder types in option field
for (i = 0; i < ENC_TYPES_COUNT; i++)
enc_options.emplace_back(std::make_pair(encoder_defs[i].name, i));
options_enctype.on_change = [this](size_t index, int32_t) {
on_type_change(index);
};
options_enctype.set_options(enc_options);
options_enctype.set_selected_index(0);
symfield_word.on_change = [this]() {
generate_frame();
};
// Selecting input clock changes symbol and word duration
field_clk.on_change = [this](int32_t value) {
// value is in kHz, new_value is in us
@@ -81,7 +82,7 @@ EncodersConfigView::EncodersConfigView(
field_clk_step.on_change = [this](size_t, int32_t value) {
field_clk.set_step(value);
};
// Selecting word duration changes input clock and symbol duration
field_frameduration.on_change = [this](int32_t value) {
// value is in us, new_value is in kHz
@@ -107,7 +108,8 @@ void EncodersConfigView::on_type_change(size_t index) {
encoder_def = &encoder_defs[index];
field_clk.set_value(encoder_def->default_speed / 1000);
field_repeat_min.set_value(encoder_def->repeat_min);
// SymField setup
word_length = encoder_def->word_length;
symfield_word.set_length(word_length);
@@ -122,10 +124,10 @@ void EncodersConfigView::on_type_change(size_t index) {
format_string += 'D';
}
}
// Ugly :( Pad to erase
format_string.append(24 - format_string.size(), ' ');
text_format.set(format_string);
generate_frame();
@@ -141,28 +143,28 @@ void EncodersConfigView::draw_waveform() {
for (size_t n = 0; n < length; n++)
waveform_buffer[n] = (frame_fragments[n] == '0') ? 0 : 1;
waveform.set_length(length);
waveform.set_dirty();
}
void EncodersConfigView::generate_frame() {
size_t i = 0;
frame_fragments.clear();
for (auto c : encoder_def->word_format) {
if (c == 'S')
frame_fragments += encoder_def->sync;
else
frame_fragments += encoder_def->bit_format[symfield_word.get_sym(i++)];
}
draw_waveform();
}
uint8_t EncodersConfigView::repeat_min() {
return encoder_def->repeat_min;
return field_repeat_min.value();
}
uint32_t EncodersConfigView::samples_per_bit() {
@@ -174,7 +176,7 @@ uint32_t EncodersConfigView::pause_symbols() {
}
void EncodersScanView::focus() {
field_debug.focus();
field_length.focus();
}
EncodersScanView::EncodersScanView(
@@ -182,31 +184,17 @@ EncodersScanView::EncodersScanView(
) {
set_parent_rect(parent_rect);
hidden(true);
add_children({
&labels,
&field_debug,
&text_debug,
&text_length
&field_length,
&bit_length_10,
&bit_length
});
// DEBUG
field_debug.on_change = [this](int32_t value) {
uint32_t l;
size_t length;
de_bruijn debruijn_seq;
length = debruijn_seq.init(value);
l = 1;
l <<= value;
l--;
if (l > 25)
l = 25;
text_debug.set(to_string_bin(debruijn_seq.compute(l), 25));
text_length.set(to_string_dec_uint(length));
};
field_length.set_value(8);
bit_length_10.set_value(40);
bit_length.set_value(0);
}
void EncodersView::focus() {
@@ -215,7 +203,7 @@ void EncodersView::focus() {
EncodersView::~EncodersView() {
// save app settings
app_settings.tx_frequency = transmitter_model.tuning_frequency();
app_settings.tx_frequency = transmitter_model.tuning_frequency();
settings.save("tx_ook", &app_settings);
transmitter_model.disable();
@@ -225,24 +213,11 @@ EncodersView::~EncodersView() {
void EncodersView::update_progress() {
std::string str_buffer;
// text_status.set(" ");
if (tx_mode == SINGLE) {
if (tx_mode == SINGLE || tx_mode == SCAN) {
str_buffer = to_string_dec_uint(repeat_index) + "/" + to_string_dec_uint(repeat_min);
text_status.set(str_buffer);
progressbar.set_value(repeat_index);
/*} else if (tx_mode == SCAN) {
strcpy(str, to_string_dec_uint(repeat_index).c_str());
strcat(str, "/");
strcat(str, to_string_dec_uint(portapack::persistent_memory::afsk_repeats()).c_str());
strcat(str, " ");
strcat(str, to_string_dec_uint(scan_index + 1).c_str());
strcat(str, "/");
strcat(str, to_string_dec_uint(scan_count).c_str());
text_status.set(str);
progress.set_value(scan_progress);*/
} else {
text_status.set("Ready");
progressbar.set_value(0);
@@ -250,89 +225,58 @@ void EncodersView::update_progress() {
}
void EncodersView::on_tx_progress(const uint32_t progress, const bool done) {
//char str[16];
if (!done) {
// Repeating...
repeat_index = progress + 1;
/*if (tx_mode == SCAN) {
scan_progress++;
update_progress();
} else {*/
update_progress();
//}
update_progress();
} else {
// make sure all samples are transmitted before disabling radio
chThdSleepMilliseconds(10);
// Done transmitting
/*if ((tx_mode == SCAN) && (scan_index < (scan_count - 1))) {
transmitter_model.disable();
if (abort_scan) {
// Kill scan process
strcpy(str, "Abort @");
strcat(str, rgsb);
text_status.set(str);
progress.set_value(0);
tx_mode = IDLE;
abort_scan = false;
button_scan.set_style(&style_val);
button_scan.set_text("SCAN");
} else {
// Next address
scan_index++;
strcpy(rgsb, &scan_list[options_scanlist.selected_index()].addresses[scan_index * 5]);
scan_progress++;
repeat_index = 1;
update_progress();
start_tx(true);
}
} else {*/
transmitter_model.disable();
tx_mode = IDLE;
text_status.set("Done");
progressbar.set_value(0);
tx_view.set_transmitting(false);
//}
transmitter_model.disable();
tx_mode = IDLE;
text_status.set("Done");
progressbar.set_value(0);
tx_view.set_transmitting(false);
}
}
void EncodersView::start_tx(const bool scan) {
(void)scan;
size_t bitstream_length = 0;
repeat_min = view_config.repeat_min();
/*if (scan) {
if (tx_mode != SCAN) {
scan_index = 0;
scan_count = scan_list[options_scanlist.selected_index()].count;
scan_progress = 1;
repeat_index = 1;
tx_mode = SCAN;
strcpy(rgsb, &scan_list[options_scanlist.selected_index()].addresses[0]);
progress.set_max(scan_count * afsk_repeats);
update_progress();
}
} else {*/
int scan_width = 0;
uint32_t samples_per_bit;
if (scan) {
tx_mode = SCAN;
scan_width = view_scan.field_length.value();
samples_per_bit =
((view_scan.bit_length_10.value() * 10 + view_scan.bit_length.value()) * OOK_SAMPLERATE) / 1000000UL;
const uint32_t seq_len = ((1 << (scan_width - 1)) * 2) * ((uint64_t) samples_per_bit) / 2048UL;
progressbar.set_max(seq_len);
repeat_min = seq_len;
} else {
tx_mode = SINGLE;
repeat_index = 1;
samples_per_bit = view_config.samples_per_bit();
view_config.generate_frame();
bitstream_length = make_bitstream(view_config.frame_fragments);
progressbar.set_max(repeat_min);
update_progress();
//}
view_config.generate_frame();
bitstream_length = make_bitstream(view_config.frame_fragments);
repeat_min = view_config.repeat_min();
}
repeat_index = 1;
update_progress();
transmitter_model.set_sampling_rate(OOK_SAMPLERATE);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable();
baseband::set_ook_data(
bitstream_length,
view_config.samples_per_bit(),
samples_per_bit,
repeat_min,
view_config.pause_symbols()
view_config.pause_symbols(),
scan_width
);
}
@@ -350,14 +294,14 @@ EncodersView::EncodersView(
&progressbar,
&tx_view
});
// load app settings
auto rc = settings.load("tx_ook", &app_settings);
if(rc == SETTINGS_OK) {
if (rc == SETTINGS_OK) {
transmitter_model.set_rf_amp(app_settings.tx_amp);
transmitter_model.set_channel_bandwidth(app_settings.channel_bandwidth);
transmitter_model.set_tuning_frequency(app_settings.tx_frequency);
transmitter_model.set_tx_gain(app_settings.tx_gain);
transmitter_model.set_tx_gain(app_settings.tx_gain);
}
tx_view.on_edit_frequency = [this, &nav]() {
@@ -366,14 +310,16 @@ EncodersView::EncodersView(
transmitter_model.set_tuning_frequency(f);
};
};
tx_view.on_start = [this]() {
tx_view.set_transmitting(true);
start_tx(false);
start_tx(tab_view.selected());
};
tx_view.on_stop = [this]() {
tx_view.set_transmitting(false);
baseband::kill_ook();
transmitter_model.disable();
};
}

View File

@@ -35,43 +35,39 @@ namespace ui {
class EncodersConfigView : public View {
public:
EncodersConfigView(NavigationView& nav, Rect parent_rect);
EncodersConfigView(const EncodersConfigView&) = delete;
EncodersConfigView(EncodersConfigView&&) = delete;
EncodersConfigView& operator=(const EncodersConfigView&) = delete;
EncodersConfigView& operator=(EncodersConfigView&&) = delete;
void focus() override;
void on_show() override;
uint8_t repeat_min();
uint32_t samples_per_bit();
uint32_t pause_symbols();
void generate_frame();
std::string frame_fragments = "0";
private:
//bool abort_scan = false;
//uint8_t scan_count;
//double scan_progress;
//unsigned int scan_index;
int16_t waveform_buffer[550];
const encoder_def_t * encoder_def { };
//uint8_t enc_type = 0;
void draw_waveform();
void on_bitfield();
void on_type_change(size_t index);
Labels labels {
{ { 1 * 8, 0 }, "Type:", Color::light_grey() },
{ { 17 * 8, 0 }, "Repeat:", Color::light_grey() },
{ { 1 * 8, 2 * 8 }, "Clk:", Color::light_grey() },
{ { 10 * 8, 2 * 8 }, "kHz", Color::light_grey() },
{ { 17 * 8, 2 * 8 }, "Step:", Color::light_grey() },
{ { 17 * 8, 2 * 8 }, "Step:", Color::light_grey() },
{ { 1 * 8, 4 * 8 }, "Frame:", Color::light_grey() },
{ { 13 * 8, 4 * 8 }, "us", Color::light_grey() },
{ { 17 * 8, 4 * 8 }, "Step", Color::light_grey() },
{ { 13 * 8, 4 * 8 }, "us", Color::light_grey() },
{ { 17 * 8, 4 * 8 }, "Step:", Color::light_grey() },
{ { 2 * 8, 7 * 8 }, "Symbols:", Color::light_grey() },
{ { 1 * 8, 14 * 8 }, "Waveform:", Color::light_grey() }
};
@@ -91,6 +87,14 @@ private:
' '
};
NumberField field_repeat_min {
{ 24 * 8, 0 },
2,
{ 1, 99 },
1,
' '
};
OptionsField field_clk_step {
{ 22 * 8, 2 * 8 },
7,
@@ -119,18 +123,18 @@ private:
{ "1000", 1000 }
}
};
SymField symfield_word {
{ 2 * 8, 9 * 8 },
20,
SymField::SYMFIELD_DEF
};
Text text_format {
{ 2 * 8, 11 * 8, 24 * 8, 16 },
""
};
Waveform waveform {
{ 0, 17 * 8, 240, 32 },
waveform_buffer,
@@ -145,33 +149,38 @@ private:
class EncodersScanView : public View {
public:
EncodersScanView(NavigationView& nav, Rect parent_rect);
NumberField field_length {
{ 8 * 8, 0 },
2,
{ 3, 24 },
1,
' '
};
NumberField bit_length_10 {
{ 12 * 8, 2 * 8 },
2,
{ 1, 88 },
1,
' '
};
NumberField bit_length {
{ 14 * 8, 2 * 8 },
1,
{ 0, 9 },
1,
' '
};
void focus() override;
private:
Labels labels {
{ { 1 * 8, 1 * 8 }, "Coming soon...", Color::light_grey() }
};
// DEBUG
NumberField field_debug {
{ 1 * 8, 6 * 8 },
2,
{ 3, 16 },
1,
' '
};
// DEBUG
Text text_debug {
{ 1 * 8, 8 * 8, 24 * 8, 16 },
""
};
// DEBUG
Text text_length {
{ 1 * 8, 10 * 8, 24 * 8, 16 },
""
{ { 1 * 8, 0 * 8 }, "Length:", Color::light_grey() },
{ { 1 * 8, 2 * 8 }, "Bit length:", Color::light_grey() },
{ { 16 * 8, 2 * 8 }, "us", Color::light_grey() },
};
};
@@ -179,9 +188,9 @@ class EncodersView : public View {
public:
EncodersView(NavigationView& nav);
~EncodersView();
void focus() override;
std::string title() const override { return "OOK TX"; };
private:
@@ -192,19 +201,19 @@ private:
SINGLE,
SCAN
};
// app save settings
std::app_settings settings { };
std::app_settings settings { };
std::app_settings::AppSettings app_settings { };
tx_modes tx_mode = IDLE;
uint8_t repeat_index { 0 };
uint8_t repeat_min { 0 };
uint32_t repeat_index { 0 };
uint32_t repeat_min { 0 };
void update_progress();
void start_tx(const bool scan);
void on_tx_progress(const uint32_t progress, const bool done);
/*const Style style_address {
.font = font::fixed_8x16,
.background = Color::black(),
@@ -215,32 +224,32 @@ private:
.background = Color::black(),
.foreground = Color::blue(),
};*/
Rect view_rect = { 0, 4 * 8, 240, 168 };
EncodersConfigView view_config { nav_, view_rect };
EncodersScanView view_scan { nav_, view_rect };
TabView tab_view {
{ "Config", Color::cyan(), &view_config },
{ "Scan", Color::green(), &view_scan },
{ "de Bruijn", Color::green(), &view_scan },
};
Text text_status {
{ 2 * 8, 13 * 16, 128, 16 },
"Ready"
};
ProgressBar progressbar {
{ 2 * 8, 13 * 16 + 20, 208, 16 }
};
TransmitterView tx_view {
16 * 16,
50000,
9
};
MessageHandlerRegistration message_handler_tx_progress {
Message::ID::TXProgress,
[this](const Message* const p) {

View File

@@ -1000,23 +1000,32 @@ namespace ui {
delete_file( "FREQMAN/"+output_file+".TXT" );
}
if( recon_thread )
{
recon_thread->set_freq_index( current_index );
timer = 0 ;
if( recon_thread )
{
timer = 0 ;
recon_thread->set_freq_index( current_index );
RetuneMessage message { };
receiver_model.set_tuning_frequency( frequency_list[ current_index ] . frequency_a ); // Retune
message.freq = frequency_list[ current_index ] . frequency_a ;
message.range = current_index ;
EventDispatcher::send_message(message);
chThdSleepMilliseconds( recon_lock_duration ); // give some time to Thread::Run to pause
if( previous_userpause )
{
user_pause();
}
else
{
user_resume();
}
if( previous_userpause )
{
user_pause();
}
else
{
user_resume();
}
recon_thread->set_recon( previous_is_recon );
recon_thread->set_freq_delete(false);
chThdSleepMilliseconds( recon_lock_duration ); // give some time to Thread::Run to pause
}
recon_thread->set_freq_delete(false);
recon_thread->set_recon( previous_is_recon );
}
};
button_remove.on_change = [this]() {
@@ -1690,7 +1699,7 @@ namespace ui {
break;
case WFM_MODULATION:
freqman_set_bandwidth_option( new_mod , field_bw );
//bw 16k (0) only/default
//bw 200k (0) only/default
field_bw.set_selected_index(0);
baseband::run_image(portapack::spi_flash::image_tag_wfm_audio);
receiver_model.set_modulation(ReceiverModel::Mode::WidebandFMAudio);

View File

@@ -207,7 +207,7 @@ namespace ui {
Labels labels
{
{ { 0 * 8 , 0 * 16 }, "LNA: VGA: AMP: VOL: ", Color::light_grey() },
{ { 0 * 8 , 1 * 16 }, "BW: SQ: W,L: , ", Color::light_grey() },
{ { 0 * 8 , 1 * 16 }, "BW: SQ: W,L: , ", Color::light_grey() },
{ { 3 * 8 , 10 * 16 }, "START END MANUAL", Color::light_grey() },
{ { 0 * 8 , (26 * 8) + 4 }, "MODE:", Color::light_grey() },
{ { 11 * 8 , (26 * 8) + 4 }, "STEP:", Color::light_grey() },
@@ -235,12 +235,12 @@ namespace ui {
OptionsField field_bw {
{ 3 * 8, 1 * 16 },
4,
6,
{ }
};
NumberField field_squelch {
{ 10 * 8, 1 * 16 },
{ 12 * 8, 1 * 16 },
3,
{ -90, 20 },
1,
@@ -248,7 +248,7 @@ namespace ui {
};
NumberField field_wait {
{ 18 * 8, 1 * 16 },
{ 20 * 8, 1 * 16 },
5,
{ -9000, 9000 },
100,
@@ -256,7 +256,7 @@ namespace ui {
};
NumberField field_lock_wait {
{ 24 * 8, 1 * 16 },
{ 26 * 8, 1 * 16 },
4,
{ 100 , 9000 },
100,

View File

@@ -31,13 +31,23 @@ ScannerThread::ScannerThread(
std::vector<rf::Frequency> frequency_list
) : frequency_list_ { std::move(frequency_list) }
{
thread = chThdCreateFromHeap(NULL, 1024, NORMALPRIO + 10, ScannerThread::static_fn, this);
create_thread();
}
ScannerThread::ScannerThread(const jammer::jammer_range_t& frequency_range, size_t def_step) : frequency_range_(frequency_range), def_step_(def_step)
{
create_thread();
}
ScannerThread::~ScannerThread() {
stop();
}
void ScannerThread::create_thread()
{
thread = chThdCreateFromHeap(NULL, 1024, NORMALPRIO + 10, ScannerThread::static_fn, this);
}
void ScannerThread::stop() {
if( thread ) {
chThdTerminate(thread);
@@ -102,12 +112,13 @@ void ScannerThread::run() {
else
restart_scan=false; //Effectively skipping first retuning, giving system time
}
message.freq = frequency_list_[frequency_index];
message.range = frequency_index; //Inform freq (for coloring purposes also!)
EventDispatcher::send_message(message);
}
else { //NOT scanning
if (_freq_del != 0) { //There is a frequency to delete
for (uint16_t i = 0; i < frequency_list_.size(); i++) { //Search for the freq to delete
for (uint32_t i = 0; i < frequency_list_.size(); i++) { //Search for the freq to delete
if (frequency_list_[i] == _freq_del)
{ //found: Erase it
frequency_list_.erase(frequency_list_.begin() + i);
@@ -126,16 +137,58 @@ void ScannerThread::run() {
}
chThdSleepMilliseconds(50); //Needed to (eventually) stabilize the receiver into new freq
}
}else if(def_step_ > 0) // manual mode
{
RetuneMessage message { };
int64_t frequency_index = 0;
int64_t size = (frequency_range_.max - frequency_range_.min) / def_step_;
bool restart_scan = false; //Flag whenever scanning is restarting after a pause
while( !chThdShouldTerminate() ) {
if (_scanning) { //Scanning
if (_freq_lock == 0) { //normal scanning (not performing freq_lock)
if (!restart_scan) { //looping at full speed
if (_fwd) { //forward
frequency_index++;
if (frequency_index >= size)
frequency_index = 0;
} else { //reverse
if (frequency_index < 1)
frequency_index = size;
frequency_index--;
}
receiver_model.set_tuning_frequency(frequency_range_.min + frequency_index * def_step_); // Retune
}
else
restart_scan=false; //Effectively skipping first retuning, giving system time
}
message.freq = frequency_range_.min + frequency_index * def_step_;
message.range = 0; //Inform freq (for coloring purposes also!)
EventDispatcher::send_message(message);
}
else { //NOT scanning
restart_scan=true; //Flag the need for skipping a cycle when restarting scan
}
chThdSleepMilliseconds(50); //Needed to (eventually) stabilize the receiver into new freq
}
}
}
void ScannerView::handle_retune(uint32_t i) {
void ScannerView::handle_retune(int64_t freq, uint32_t freq_idx) {
current_index = freq_idx; //since it is an ongoing scan, this is a new index
current_frequency = freq;
switch (scan_thread->is_freq_lock())
{
case 0: //NO FREQ LOCK, ONGOING STANDARD SCANNING
text_cycle.set( to_string_dec_uint(i + 1,3) );
current_index = i; //since it is an ongoing scan, this is a new index
if (description_list[current_index].size() > 0) desc_cycle.set( description_list[current_index] ); //Show new description
if (frequency_list.size() > 0) {
text_cycle.set( to_string_dec_uint(freq_idx + 1,3) );
}
if (freq_idx < description_list.size() && description_list[freq_idx].size() > 0) {
desc_cycle.set( description_list[freq_idx] ); //Show new description
}
break;
case 1: //STARTING LOCK FREQ
big_display.set_style(&style_yellow);
@@ -146,7 +199,7 @@ void ScannerView::handle_retune(uint32_t i) {
default: //freq lock is checking the signal, do not update display
return;
}
big_display.set(frequency_list[current_index]); //UPDATE the big Freq after 0, 1 or MAX_FREQ_LOCK (at least, for color synching)
big_display.set(freq); //UPDATE the big Freq after 0, 1 or MAX_FREQ_LOCK (at least, for color synching)
}
void ScannerView::focus() {
@@ -154,6 +207,8 @@ void ScannerView::focus() {
}
ScannerView::~ScannerView() {
// make sure to stop the thread before shutting down the receiver
scan_thread.reset();
audio::output::stop();
receiver_model.disable();
baseband::shutdown();
@@ -297,23 +352,15 @@ ScannerView::ScannerView(
description_list.clear();
def_step = step_mode.selected_index_value(); //Use def_step from manual selector
description_list.push_back(
"M" + to_string_short_freq(frequency_range.min) + ">"
+ to_string_short_freq(frequency_range.max) + "S"
+ to_string_short_freq(def_step).erase(0,1) //euquiq: lame kludge to reduce spacing in step freq
);
rf::Frequency frequency = frequency_range.min;
while (frequency_list.size() < FREQMAN_MAX_PER_FILE && frequency <= frequency_range.max) { //add manual range
frequency_list.push_back(frequency);
description_list.push_back(""); //If empty, will keep showing the last description
frequency+=def_step;
}
show_max();
desc_cycle.set("");
text_max.set("");
text_cycle.set("");
if ( userpause ) //If user-paused, resume
user_resume();
big_display.set_style(&style_grey); //Back to grey color
start_scan_thread(); //RESTART SCANNER THREAD
start_scan_thread(frequency_range, def_step); //RESTART SCANNER THREAD
}
};
@@ -333,35 +380,56 @@ ScannerView::ScannerView(
big_display.set_style(&style_grey); //Back to grey color
};
button_add.on_select = [this](Button&) { //frequency_list[current_index]
button_add.on_select = [this](Button&) { // current_frequency
File scanner_file;
std::string freq_file_path = "FREQMAN/" + loaded_file_name + ".TXT";
const std::string freq_file_path = "FREQMAN/" + loaded_file_name + ".TXT";
auto result = scanner_file.open(freq_file_path); //First search if freq is already in txt
if (!result.is_valid()) {
std::string frequency_to_add = "f="
+ to_string_dec_uint(frequency_list[current_index] / 1000)
+ to_string_dec_uint(frequency_list[current_index] % 1000UL, 3, '0');
char one_char[1]; //Read it char by char
std::string line; //and put read line in here
const std::string frequency_to_add = "f="
+ to_string_dec_uint(current_frequency / 1000)
+ to_string_dec_uint(current_frequency % 1000UL, 3, '0');
bool found=false;
for (size_t pointer=0; pointer < scanner_file.size();pointer++) {
constexpr size_t buffer_size = 1024;
char buffer[buffer_size];
for (size_t pointer = 0, freq_str_idx = 0; pointer < scanner_file.size(); pointer += buffer_size) {
size_t adjusted_buffer_size;
if (pointer + buffer_size >= scanner_file.size()) {
memset(buffer, 0, sizeof(buffer));
adjusted_buffer_size = scanner_file.size() - pointer;
}
else {
adjusted_buffer_size = buffer_size;
}
scanner_file.seek(pointer);
scanner_file.read(one_char, 1);
if ((int)one_char[0] > 31) { //ascii space upwards
line += one_char[0]; //Add it to the textline
}
else if (one_char[0] == '\n') { //New Line
if (line.compare(0, frequency_to_add.size(),frequency_to_add) == 0) {
found=true;
break;
scanner_file.read(buffer, adjusted_buffer_size);
for (size_t i = 0; i < adjusted_buffer_size; ++i) {
if (buffer[i] == frequency_to_add.data()[freq_str_idx]) {
++freq_str_idx;
if (freq_str_idx >= frequency_to_add.size()) {
found = true;
break;
}
}
else {
freq_str_idx = 0;
}
line.clear(); //Ready for next textline
}
}
if (found) {
break;
}
}
if (found) {
nav_.display_modal("Error", "Frequency already exists");
big_display.set(frequency_list[current_index]); //After showing an error
big_display.set(current_frequency); //After showing an error
}
else {
scanner_file.append(freq_file_path); //Second: append if it is not there
@@ -370,7 +438,7 @@ ScannerView::ScannerView(
} else
{
nav_.display_modal("Error", "Cannot open " + loaded_file_name + ".TXT\nfor appending freq.");
big_display.set(frequency_list[current_index]); //After showing an error
big_display.set(current_frequency); //After showing an error
}
};
@@ -516,9 +584,9 @@ size_t ScannerView::change_mode(uint8_t new_mod) { //Before this, do a scan_thre
switch (new_mod) {
case NFM: //bw 16k (2) default
bw.emplace_back("8k5", 0);
bw.emplace_back("11k", 0);
bw.emplace_back("16k", 0);
bw.emplace_back("8k5 ", 0);
bw.emplace_back("11k ", 0);
bw.emplace_back("16k ", 0);
field_bw.set_options(bw);
baseband::run_image(portapack::spi_flash::image_tag_nfm_audio);
@@ -529,10 +597,12 @@ size_t ScannerView::change_mode(uint8_t new_mod) { //Before this, do a scan_thre
receiver_model.set_sampling_rate(3072000); receiver_model.set_baseband_bandwidth(1750000);
break;
case AM:
bw.emplace_back("DSB", 0);
bw.emplace_back("USB", 0);
bw.emplace_back("LSB", 0);
bw.emplace_back("CW ", 0);
bw.emplace_back("DSB 9k" , 0 );
bw.emplace_back("DSB 6k" , 1 );
bw.emplace_back("USB+3k" , 2 );
bw.emplace_back("LSB-3k" , 3 );
bw.emplace_back("CW " , 4 );
field_bw.set_options(bw);
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
@@ -543,7 +613,7 @@ size_t ScannerView::change_mode(uint8_t new_mod) { //Before this, do a scan_thre
receiver_model.set_sampling_rate(3072000); receiver_model.set_baseband_bandwidth(1750000);
break;
case WFM:
bw.emplace_back("200k", 0);
bw.emplace_back("200k ", 0);
field_bw.set_options(bw);
baseband::run_image(portapack::spi_flash::image_tag_wfm_audio);
@@ -564,4 +634,10 @@ void ScannerView::start_scan_thread() {
scan_thread = std::make_unique<ScannerThread>(frequency_list);
}
void ScannerView::start_scan_thread(const jammer::jammer_range_t& frequency_range, size_t def_step) {
receiver_model.enable();
receiver_model.set_squelch_level(0);
scan_thread = std::make_unique<ScannerThread>(frequency_range, def_step);
}
} /* namespace ui */

View File

@@ -46,6 +46,7 @@ size_t const mod_step[3] = {9000, 100000, 12500 };
class ScannerThread {
public:
ScannerThread(std::vector<rf::Frequency> frequency_list);
ScannerThread(const jammer::jammer_range_t& frequency_range, size_t def_step);
~ScannerThread();
void set_scanning(const bool v);
@@ -67,6 +68,8 @@ public:
private:
std::vector<rf::Frequency> frequency_list_ { };
jammer::jammer_range_t frequency_range_ {false, 0, 0};
size_t def_step_ { 0 };
Thread* thread { nullptr };
bool _scanning { true };
@@ -75,6 +78,7 @@ private:
uint32_t _freq_del { 0 };
static msg_t static_fn(void* arg);
void run();
void create_thread();
};
class ScannerView : public View {
@@ -120,6 +124,7 @@ private:
NavigationView& nav_;
void start_scan_thread();
void start_scan_thread(const jammer::jammer_range_t& frequency_range, size_t def_step);
size_t change_mode(uint8_t mod_type);
void show_max();
void scan_pause();
@@ -129,7 +134,7 @@ private:
void on_statistics_update(const ChannelStatistics& statistics);
void on_headphone_volume_changed(int32_t v);
void handle_retune(uint32_t i);
void handle_retune(int64_t freq, uint32_t freq_idx);
jammer::jammer_range_t frequency_range { false, 0, 0 }; //perfect for manual scan task too...
int32_t squelch { 0 };
@@ -139,11 +144,12 @@ private:
freqman_db database { };
std::string loaded_file_name;
uint32_t current_index { 0 };
rf::Frequency current_frequency { 0 };
bool userpause { false };
Labels labels {
{ { 0 * 8, 0 * 16 }, "LNA: VGA: AMP: VOL:", Color::light_grey() },
{ { 0 * 8, 1* 16 }, "BW: SQUELCH: db WAIT:", Color::light_grey() },
{ { 0 * 8, 1* 16 }, "BW: SQLCH: db WAIT:", Color::light_grey() },
{ { 3 * 8, 10 * 16 }, "START END MANUAL", Color::light_grey() },
{ { 0 * 8, (26 * 8) + 4 }, "MODE:", Color::light_grey() },
{ { 11 * 8, (26 * 8) + 4 }, "STEP:", Color::light_grey() },
@@ -176,7 +182,7 @@ private:
};
NumberField field_squelch {
{ 15 * 8, 1 * 16 },
{ 18 * 8, 1 * 16 },
3,
{ -90, 20 },
1,
@@ -184,7 +190,7 @@ private:
};
NumberField field_wait {
{ 26 * 8, 1 * 16 },
{ 27 * 8, 1 * 16 },
2,
{ 0, 99 },
1,
@@ -295,7 +301,7 @@ private:
Message::ID::Retune,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const RetuneMessage*>(p);
this->handle_retune(message.range);
this->handle_retune(message.freq, message.range);
}
};

View File

@@ -146,7 +146,7 @@ void set_btle(const uint32_t baudrate, const uint32_t word_length, const uint32_
};
send_message(&message);
}
void set_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word) {
const NRFRxConfigureMessage message {
baudrate,
@@ -156,7 +156,7 @@ void set_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t
};
send_message(&message);
}
void set_afsk_data(const uint32_t afsk_samples_per_bit, const uint32_t afsk_phase_inc_mark, const uint32_t afsk_phase_inc_space,
const uint8_t afsk_repeat, const uint32_t afsk_bw, const uint8_t symbol_count) {
const AFSKTxConfigureMessage message {
@@ -183,7 +183,7 @@ void kill_afsk() {
}
void set_audiotx_config(const uint32_t divider, const float deviation_hz, const float audio_gain,
uint8_t audio_shift_bits_s16, const uint32_t tone_key_delta, const bool am_enabled,
uint8_t audio_shift_bits_s16, const uint32_t tone_key_delta, const bool am_enabled,
const bool dsb_enabled, const bool usb_enabled, const bool lsb_enabled) {
const AudioTXConfigMessage message {
divider,
@@ -212,16 +212,28 @@ void set_pitch_rssi(int32_t avg, bool enabled) {
enabled,
avg
};
send_message(&message);
send_message(&message);
}
void set_ook_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint8_t repeat,
const uint32_t pause_symbols) {
const uint32_t pause_symbols, const uint8_t de_bruijn_length) {
const OOKConfigureMessage message {
stream_length,
samples_per_bit,
repeat,
pause_symbols
pause_symbols,
de_bruijn_length
};
send_message(&message);
}
void kill_ook() {
const OOKConfigureMessage message {
0,
0,
0,
0,
0
};
send_message(&message);
}
@@ -251,7 +263,7 @@ void set_adsb() {
void set_jammer(const bool run, const jammer::JammerType type, const uint32_t speed) {
const JammerConfigureMessage message {
run,
run,
type,
speed
};
@@ -312,7 +324,7 @@ void shutdown() {
send_message(&message);
shared_memory.application_queue.reset();
baseband_image_running = false;
}

View File

@@ -62,7 +62,7 @@ void set_tones_config(const uint32_t bw, const uint32_t pre_silence, const uint1
void kill_tone();
void set_sstv_data(const uint8_t vis_code, const uint32_t pixel_duration);
void set_audiotx_config(const uint32_t divider, const float deviation_hz, const float audio_gain,
uint8_t audio_shift_bits_s16, const uint32_t tone_key_delta, const bool am_enabled,
uint8_t audio_shift_bits_s16, const uint32_t tone_key_delta, const bool am_enabled,
const bool dsb_enabled, const bool usb_enabled, const bool lsb_enabled);
void set_fifo_data(const int8_t * data);
void set_pitch_rssi(int32_t avg, bool enabled);
@@ -77,7 +77,8 @@ void set_btle(const uint32_t baudrate, const uint32_t word_length, const uint32_
void set_nrf(const uint32_t baudrate, const uint32_t word_length, const uint32_t trigger_value, const bool trigger_word);
void set_ook_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint8_t repeat,
const uint32_t pause_symbols);
const uint32_t pause_symbols, const uint8_t de_bruijn_length = 0);
void kill_ook();
void set_fsk_data(const uint32_t stream_length, const uint32_t samples_per_bit, const uint32_t shift,
const uint32_t progress_notice);
void set_pocsag();

View File

@@ -34,10 +34,11 @@ options_t freqman_entry_modulations = {
options_t freqman_entry_bandwidths[ 4 ] = {
{ //AM
{ "DSB", 0 },
{ "USB", 1 },
{ "LSB", 2 },
{ "CW" , 3 }
{ "DSB 9k" , 0 },
{ "DSB 6k" , 1 },
{ "USB+3k" , 2 },
{ "LSB-3k" , 3 },
{ "CW" , 4 }
},
{ //NFM
{ "8k5" , 0 },

View File

@@ -281,262 +281,262 @@ const std::array<ui::Color, 256> spectrum_rgb2_lut { {
} };
const std::array<ui::Color, 256> spectrum_rgb3_lut { {
{ 0, 0, 0 },
{ 0, 0, 3 },
{ 0, 0, 6 },
{ 0, 0, 9 },
{ 0, 0, 12 },
{ 0, 0, 15 },
{ 0, 0, 18 },
{ 0, 0, 21 },
{ 0, 0, 24 },
{ 0, 0, 27 },
{ 0, 0, 30 },
{ 0, 0, 33 },
{ 0, 0, 36 },
{ 0, 0, 39 },
{ 0, 0, 42 },
{ 0, 0, 45 },
{ 0, 0, 48 },
{ 0, 0, 51 },
{ 0, 0, 54 },
{ 0, 0, 57 },
{ 0, 0, 60 },
{ 0, 0, 63 },
{ 0, 0, 66 },
{ 0, 0, 69 },
{ 0, 0, 72 },
{ 0, 0, 75 },
{ 0, 0, 78 },
{ 0, 0, 81 },
{ 0, 0, 84 },
{ 0, 0, 87 },
{ 0, 0, 90 },
{ 0, 0, 93 },
{ 0, 0, 96 },
{ 0, 0, 99 },
{ 0, 0, 102 },
{ 0, 0, 105 },
{ 0, 0, 108 },
{ 0, 0, 111 },
{ 0, 0, 114 },
{ 0, 0, 117 },
{ 0, 0, 120 },
{ 0, 0, 123 },
{ 0, 0, 126 },
{ 0, 0, 129 },
{ 0, 0, 132 },
{ 0, 0, 135 },
{ 0, 0, 138 },
{ 0, 0, 141 },
{ 0, 0, 144 },
{ 0, 0, 147 },
{ 0, 0, 150 },
{ 0, 0, 153 },
{ 0, 0, 156 },
{ 0, 0, 159 },
{ 0, 0, 162 },
{ 0, 0, 165 },
{ 0, 0, 168 },
{ 0, 0, 171 },
{ 0, 0, 174 },
{ 0, 0, 177 },
{ 0, 0, 180 },
{ 0, 0, 183 },
{ 0, 0, 186 },
{ 0, 0, 189 },
{ 0, 0, 192 },
{ 0, 0, 195 },
{ 0, 0, 198 },
{ 0, 0, 201 },
{ 0, 0, 204 },
{ 0, 0, 207 },
{ 0, 0, 210 },
{ 0, 0, 213 },
{ 0, 0, 216 },
{ 0, 0, 219 },
{ 0, 0, 222 },
{ 0, 0, 225 },
{ 0, 0, 228 },
{ 0, 0, 231 },
{ 0, 0, 234 },
{ 0, 0, 237 },
{ 0, 0, 240 },
{ 0, 0, 243 },
{ 0, 0, 246 },
{ 0, 0, 249 },
{ 0, 0, 252 },
{ 0, 0, 255 },
{ 0, 3, 252 },
{ 0, 6, 249 },
{ 0, 9, 246 },
{ 0, 12, 243 },
{ 0, 15, 240 },
{ 0, 18, 237 },
{ 0, 21, 234 },
{ 0, 24, 231 },
{ 0, 27, 228 },
{ 0, 30, 225 },
{ 0, 33, 222 },
{ 0, 36, 219 },
{ 0, 39, 216 },
{ 0, 42, 213 },
{ 0, 45, 210 },
{ 0, 48, 207 },
{ 0, 51, 204 },
{ 0, 54, 201 },
{ 0, 57, 198 },
{ 0, 60, 195 },
{ 0, 63, 192 },
{ 0, 66, 189 },
{ 0, 69, 186 },
{ 0, 72, 183 },
{ 0, 75, 180 },
{ 0, 78, 177 },
{ 0, 81, 174 },
{ 0, 84, 171 },
{ 0, 87, 168 },
{ 0, 90, 165 },
{ 0, 93, 162 },
{ 0, 96, 159 },
{ 0, 99, 156 },
{ 0, 102, 153 },
{ 0, 105, 150 },
{ 0, 108, 147 },
{ 0, 111, 144 },
{ 0, 114, 141 },
{ 0, 117, 138 },
{ 0, 120, 135 },
{ 0, 123, 132 },
{ 0, 126, 129 },
{ 0, 129, 126 },
{ 0, 132, 123 },
{ 0, 135, 120 },
{ 0, 138, 117 },
{ 0, 141, 114 },
{ 0, 144, 111 },
{ 0, 147, 108 },
{ 0, 150, 105 },
{ 0, 153, 102 },
{ 0, 156, 99 },
{ 0, 159, 96 },
{ 0, 162, 93 },
{ 0, 165, 90 },
{ 0, 168, 87 },
{ 0, 171, 84 },
{ 0, 174, 81 },
{ 0, 177, 78 },
{ 0, 180, 75 },
{ 0, 183, 72 },
{ 0, 186, 69 },
{ 0, 189, 66 },
{ 0, 192, 63 },
{ 0, 195, 60 },
{ 0, 198, 57 },
{ 0, 201, 54 },
{ 0, 204, 51 },
{ 0, 207, 48 },
{ 0, 210, 45 },
{ 0, 213, 42 },
{ 0, 216, 39 },
{ 0, 219, 36 },
{ 0, 222, 33 },
{ 0, 225, 30 },
{ 0, 228, 27 },
{ 0, 231, 24 },
{ 0, 234, 21 },
{ 0, 237, 18 },
{ 0, 240, 15 },
{ 0, 243, 12 },
{ 0, 246, 9 },
{ 0, 249, 6 },
{ 0, 252, 3 },
{ 0, 255, 0 },
{ 3, 252, 0 },
{ 6, 249, 0 },
{ 9, 246, 0 },
{ 12, 243, 0 },
{ 15, 240, 0 },
{ 18, 237, 0 },
{ 21, 234, 0 },
{ 24, 231, 0 },
{ 27, 228, 0 },
{ 30, 225, 0 },
{ 33, 222, 0 },
{ 36, 219, 0 },
{ 39, 216, 0 },
{ 42, 213, 0 },
{ 45, 210, 0 },
{ 48, 207, 0 },
{ 51, 204, 0 },
{ 54, 201, 0 },
{ 57, 198, 0 },
{ 60, 195, 0 },
{ 63, 192, 0 },
{ 66, 189, 0 },
{ 69, 186, 0 },
{ 72, 183, 0 },
{ 75, 180, 0 },
{ 78, 177, 0 },
{ 81, 174, 0 },
{ 84, 171, 0 },
{ 87, 168, 0 },
{ 90, 165, 0 },
{ 93, 162, 0 },
{ 96, 159, 0 },
{ 99, 156, 0 },
{ 102, 153, 0 },
{ 105, 150, 0 },
{ 108, 147, 0 },
{ 111, 144, 0 },
{ 114, 141, 0 },
{ 117, 138, 0 },
{ 120, 135, 0 },
{ 123, 132, 0 },
{ 126, 129, 0 },
{ 129, 126, 0 },
{ 132, 123, 0 },
{ 135, 120, 0 },
{ 138, 117, 0 },
{ 141, 114, 0 },
{ 144, 111, 0 },
{ 147, 108, 0 },
{ 150, 105, 0 },
{ 153, 102, 0 },
{ 156, 99, 0 },
{ 159, 96, 0 },
{ 162, 93, 0 },
{ 165, 90, 0 },
{ 168, 87, 0 },
{ 171, 84, 0 },
{ 174, 81, 0 },
{ 177, 78, 0 },
{ 180, 75, 0 },
{ 183, 72, 0 },
{ 186, 69, 0 },
{ 189, 66, 0 },
{ 192, 63, 0 },
{ 195, 60, 0 },
{ 198, 57, 0 },
{ 201, 54, 0 },
{ 204, 51, 0 },
{ 207, 48, 0 },
{ 210, 45, 0 },
{ 213, 42, 0 },
{ 216, 39, 0 },
{ 219, 36, 0 },
{ 222, 33, 0 },
{ 225, 30, 0 },
{ 228, 27, 0 },
{ 231, 24, 0 },
{ 234, 21, 0 },
{ 237, 18, 0 },
{ 240, 15, 0 },
{ 243, 12, 0 },
{ 246, 9, 0 },
{ 249, 6, 0 },
{ 252, 3, 0 },
{ 255, 0, 0 },
{ 0x00, 0x00, 0x02 },
{ 0x00, 0x00, 0x04 },
{ 0x00, 0x00, 0x05 },
{ 0x00, 0x00, 0x07 },
{ 0x00, 0x00, 0x0a },
{ 0x00, 0x00, 0x0c },
{ 0x00, 0x00, 0x0e },
{ 0x00, 0x00, 0x10 },
{ 0x00, 0x00, 0x13 },
{ 0x00, 0x00, 0x15 },
{ 0x00, 0x00, 0x17 },
{ 0x00, 0x00, 0x19 },
{ 0x00, 0x00, 0x1b },
{ 0x00, 0x00, 0x1d },
{ 0x00, 0x00, 0x1f },
{ 0x00, 0x00, 0x21 },
{ 0x00, 0x00, 0x24 },
{ 0x00, 0x00, 0x25 },
{ 0x00, 0x00, 0x28 },
{ 0x00, 0x00, 0x29 },
{ 0x00, 0x00, 0x2c },
{ 0x00, 0x00, 0x2e },
{ 0x00, 0x00, 0x30 },
{ 0x00, 0x00, 0x33 },
{ 0x00, 0x00, 0x35 },
{ 0x00, 0x00, 0x37 },
{ 0x00, 0x00, 0x39 },
{ 0x00, 0x00, 0x3b },
{ 0x00, 0x00, 0x3d },
{ 0x00, 0x00, 0x3f },
{ 0x00, 0x00, 0x41 },
{ 0x00, 0x00, 0x43 },
{ 0x00, 0x00, 0x46 },
{ 0x00, 0x00, 0x48 },
{ 0x00, 0x00, 0x4a },
{ 0x00, 0x00, 0x4c },
{ 0x00, 0x00, 0x4e },
{ 0x00, 0x00, 0x50 },
{ 0x00, 0x00, 0x53 },
{ 0x00, 0x00, 0x55 },
{ 0x00, 0x00, 0x56 },
{ 0x00, 0x00, 0x59 },
{ 0x00, 0x00, 0x5b },
{ 0x00, 0x00, 0x5d },
{ 0x00, 0x00, 0x5f },
{ 0x00, 0x00, 0x62 },
{ 0x00, 0x00, 0x63 },
{ 0x00, 0x00, 0x66 },
{ 0x00, 0x00, 0x68 },
{ 0x00, 0x00, 0x6a },
{ 0x00, 0x00, 0x6c },
{ 0x00, 0x00, 0x6e },
{ 0x00, 0x00, 0x70 },
{ 0x00, 0x00, 0x73 },
{ 0x00, 0x00, 0x75 },
{ 0x00, 0x00, 0x77 },
{ 0x00, 0x00, 0x79 },
{ 0x00, 0x00, 0x7b },
{ 0x00, 0x00, 0x7d },
{ 0x00, 0x00, 0x7f },
{ 0x00, 0x00, 0x82 },
{ 0x00, 0x00, 0x84 },
{ 0x00, 0x00, 0x86 },
{ 0x00, 0x00, 0x88 },
{ 0x00, 0x00, 0x8a },
{ 0x00, 0x00, 0x8c },
{ 0x00, 0x00, 0x8e },
{ 0x00, 0x00, 0x91 },
{ 0x00, 0x00, 0x93 },
{ 0x00, 0x00, 0x95 },
{ 0x00, 0x00, 0x97 },
{ 0x00, 0x00, 0x99 },
{ 0x00, 0x00, 0x9b },
{ 0x00, 0x00, 0x9d },
{ 0x00, 0x00, 0x9f },
{ 0x00, 0x00, 0xa2 },
{ 0x00, 0x00, 0xa4 },
{ 0x00, 0x00, 0xa6 },
{ 0x00, 0x00, 0xa8 },
{ 0x00, 0x00, 0xaa },
{ 0x00, 0x00, 0xac },
{ 0x00, 0x00, 0xae },
{ 0x00, 0x00, 0xb1 },
{ 0x00, 0x00, 0xb3 },
{ 0x00, 0x00, 0xb5 },
{ 0x00, 0x00, 0xb7 },
{ 0x00, 0x00, 0xb9 },
{ 0x00, 0x00, 0xbb },
{ 0x00, 0x00, 0xbd },
{ 0x00, 0x00, 0xbf },
{ 0x00, 0x00, 0xc2 },
{ 0x00, 0x00, 0xc4 },
{ 0x00, 0x00, 0xc6 },
{ 0x00, 0x00, 0xc8 },
{ 0x00, 0x00, 0xca },
{ 0x00, 0x00, 0xcc },
{ 0x00, 0x00, 0xce },
{ 0x00, 0x00, 0xd1 },
{ 0x00, 0x00, 0xd3 },
{ 0x00, 0x00, 0xd5 },
{ 0x00, 0x00, 0xd7 },
{ 0x00, 0x00, 0xd9 },
{ 0x00, 0x00, 0xdb },
{ 0x00, 0x00, 0xdd },
{ 0x00, 0x00, 0xdf },
{ 0x00, 0x00, 0xe2 },
{ 0x00, 0x00, 0xe4 },
{ 0x00, 0x00, 0xe6 },
{ 0x00, 0x00, 0xe8 },
{ 0x00, 0x00, 0xea },
{ 0x00, 0x00, 0xec },
{ 0x00, 0x00, 0xee },
{ 0x00, 0x00, 0xf1 },
{ 0x00, 0x00, 0xf3 },
{ 0x00, 0x00, 0xf5 },
{ 0x00, 0x00, 0xf7 },
{ 0x00, 0x00, 0xf9 },
{ 0x00, 0x00, 0xfb },
{ 0x00, 0x00, 0xfd },
{ 0x01, 0x00, 0xfe },
{ 0x05, 0x00, 0xfa },
{ 0x09, 0x00, 0xf6 },
{ 0x0e, 0x00, 0xf2 },
{ 0x12, 0x00, 0xed },
{ 0x16, 0x00, 0xe9 },
{ 0x1b, 0x00, 0xe4 },
{ 0x1f, 0x00, 0xe0 },
{ 0x24, 0x00, 0xdc },
{ 0x27, 0x00, 0xd8 },
{ 0x2c, 0x00, 0xd3 },
{ 0x30, 0x00, 0xcf },
{ 0x35, 0x00, 0xcb },
{ 0x39, 0x00, 0xc6 },
{ 0x3d, 0x00, 0xc2 },
{ 0x42, 0x00, 0xbd },
{ 0x46, 0x00, 0xb9 },
{ 0x4b, 0x00, 0xb5 },
{ 0x4f, 0x00, 0xb0 },
{ 0x53, 0x00, 0xac },
{ 0x58, 0x00, 0xa7 },
{ 0x5c, 0x00, 0xa3 },
{ 0x61, 0x00, 0x9f },
{ 0x65, 0x00, 0x9a },
{ 0x69, 0x00, 0x96 },
{ 0x6e, 0x00, 0x91 },
{ 0x72, 0x00, 0x8d },
{ 0x77, 0x00, 0x89 },
{ 0x7b, 0x00, 0x84 },
{ 0x7f, 0x00, 0x80 },
{ 0x84, 0x00, 0x7b },
{ 0x88, 0x00, 0x77 },
{ 0x8d, 0x00, 0x73 },
{ 0x91, 0x00, 0x6e },
{ 0x95, 0x00, 0x6a },
{ 0x9a, 0x00, 0x65 },
{ 0x9e, 0x00, 0x61 },
{ 0xa3, 0x00, 0x5d },
{ 0xa7, 0x00, 0x58 },
{ 0xab, 0x00, 0x54 },
{ 0xb0, 0x00, 0x4f },
{ 0xb4, 0x00, 0x4b },
{ 0xb9, 0x00, 0x47 },
{ 0xbd, 0x00, 0x42 },
{ 0xc1, 0x00, 0x3e },
{ 0xc6, 0x00, 0x39 },
{ 0xca, 0x00, 0x35 },
{ 0xcf, 0x00, 0x31 },
{ 0xd3, 0x00, 0x2c },
{ 0xd7, 0x00, 0x28 },
{ 0xdc, 0x00, 0x23 },
{ 0xe0, 0x00, 0x1f },
{ 0xe5, 0x00, 0x1b },
{ 0xe9, 0x00, 0x16 },
{ 0xed, 0x00, 0x12 },
{ 0xf2, 0x00, 0x0d },
{ 0xf6, 0x00, 0x09 },
{ 0xfb, 0x00, 0x05 },
{ 0xfe, 0x01, 0x01 },
{ 0xff, 0x06, 0x00 },
{ 0xff, 0x0d, 0x00 },
{ 0xff, 0x13, 0x00 },
{ 0xff, 0x1a, 0x00 },
{ 0xff, 0x20, 0x00 },
{ 0xff, 0x26, 0x00 },
{ 0xff, 0x2d, 0x00 },
{ 0xff, 0x33, 0x00 },
{ 0xff, 0x3a, 0x00 },
{ 0xff, 0x40, 0x00 },
{ 0xff, 0x46, 0x00 },
{ 0xff, 0x4d, 0x00 },
{ 0xff, 0x53, 0x00 },
{ 0xff, 0x59, 0x00 },
{ 0xff, 0x60, 0x00 },
{ 0xff, 0x66, 0x00 },
{ 0xff, 0x6c, 0x00 },
{ 0xff, 0x73, 0x00 },
{ 0xff, 0x79, 0x00 },
{ 0xff, 0x80, 0x00 },
{ 0xff, 0x86, 0x00 },
{ 0xff, 0x8c, 0x00 },
{ 0xff, 0x93, 0x00 },
{ 0xff, 0x99, 0x00 },
{ 0xff, 0x9f, 0x00 },
{ 0xff, 0xa6, 0x00 },
{ 0xff, 0xac, 0x00 },
{ 0xff, 0xb3, 0x00 },
{ 0xff, 0xb9, 0x00 },
{ 0xff, 0xbf, 0x00 },
{ 0xff, 0xc6, 0x00 },
{ 0xff, 0xcc, 0x00 },
{ 0xff, 0xd2, 0x00 },
{ 0xff, 0xd9, 0x00 },
{ 0xff, 0xdf, 0x00 },
{ 0xff, 0xe6, 0x00 },
{ 0xff, 0xec, 0x00 },
{ 0xff, 0xf2, 0x00 },
{ 0xff, 0xf9, 0x00 },
{ 0xff, 0xfe, 0x01 },
{ 0xff, 0xff, 0x06 },
{ 0xff, 0xff, 0x0d },
{ 0xff, 0xff, 0x14 },
{ 0xff, 0xff, 0x1b },
{ 0xff, 0xff, 0x21 },
{ 0xff, 0xff, 0x28 },
{ 0xff, 0xff, 0x2f },
{ 0xff, 0xff, 0x35 },
{ 0xff, 0xff, 0x3c },
{ 0xff, 0xff, 0x42 },
{ 0xff, 0xff, 0x49 },
{ 0xff, 0xff, 0x4f },
{ 0xff, 0xff, 0x56 },
{ 0xff, 0xff, 0x5d },
{ 0xff, 0xff, 0x63 },
{ 0xff, 0xff, 0x6a },
{ 0xff, 0xff, 0x71 },
{ 0xff, 0xff, 0x77 },
{ 0xff, 0xff, 0x7e },
{ 0xff, 0xff, 0x84 },
{ 0xff, 0xff, 0x8b },
{ 0xff, 0xff, 0x92 },
{ 0xff, 0xff, 0x98 },
{ 0xff, 0xff, 0x9f },
{ 0xff, 0xff, 0xa6 },
{ 0xff, 0xff, 0xac },
{ 0xff, 0xff, 0xb3 },
{ 0xff, 0xff, 0xb9 },
{ 0xff, 0xff, 0xc0 },
{ 0xff, 0xff, 0xc7 },
{ 0xff, 0xff, 0xcd },
{ 0xff, 0xff, 0xd4 },
{ 0xff, 0xff, 0xdb },
{ 0xff, 0xff, 0xe1 },
{ 0xff, 0xff, 0xe8 },
{ 0xff, 0xff, 0xee },
{ 0xff, 0xff, 0xf5 },
{ 0xff, 0xff, 0xfb }
} };
const std::array<ui::Color, 256> spectrum_rgb4_lut { {

View File

@@ -27,15 +27,88 @@
#include <cstdint>
void OOKProcessor::execute(const buffer_c8_t& buffer) {
inline void OOKProcessor::write_sample(const buffer_c8_t& buffer, uint8_t bit_value, size_t i) {
int8_t re, im;
if (bit_value) {
phase = (phase + 200); // What ?
sphase = phase + (64 << 18);
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]);
} else {
re = 0;
im = 0;
}
buffer.p[i] = {re, im};
}
inline void OOKProcessor::duval_algo(const buffer_c8_t& buffer) {
size_t buf_ptr = 0;
const unsigned int w = de_bruijn_length;
// Duval's algorithm for generating de Bruijn sequence
while (idx) {
if (w % idx == 0) {
for (; k < idx; k++) {
size_t available_size = buffer.count - buf_ptr;
size_t len = (samples_per_bit > available_size) ? available_size : samples_per_bit;
for (; bit_ptr < len; bit_ptr++) {
write_sample(buffer, v[k], buf_ptr);
buf_ptr++;
}
if (buf_ptr == buffer.count) {
txprogress_message.done = false;
txprogress_message.progress = scan_progress++;
shared_memory.application_queue.push(txprogress_message);
return;
}
bit_ptr = 0;
}
k = 0;
}
for (unsigned int j = 0; j < w - idx; j++)
v[idx + j] = v[j];
for (idx = w; idx > 0 && v[idx - 1]; idx--) ;
if (idx)
v[idx - 1] = 1;
}
// clear the buffer in case we have any bytes left
if (buf_ptr < buffer.count) {
for (size_t i = buf_ptr; i < buffer.count; i++) {
buffer.p[i] = {0, 0};
}
}
if (!scan_done) {
txprogress_message.done = true;
shared_memory.application_queue.push(txprogress_message);
}
scan_done = 1;
}
void OOKProcessor::execute(const buffer_c8_t& buffer) {
// This is called at 2.28M/2048 = 1113Hz
if (!configured) return;
if (de_bruijn_length) {
duval_algo(buffer);
return;
}
for (size_t i = 0; i < buffer.count; i++) {
// Synthesis at 2.28M/10 = 228kHz
if (!s) {
s = 10 - 1;
@@ -49,11 +122,11 @@ void OOKProcessor::execute(const buffer_c8_t& buffer) {
} else if (pause_counter == 1) {
if (repeat_counter < repeat) {
// Repeat
bit_pos = 0;
cur_bit = shared_memory.bb_data.data[0] & 0x80;
txprogress_message.progress = repeat_counter + 1;
txprogress_message.done = false;
shared_memory.application_queue.push(txprogress_message);
bit_pos = 1;
repeat_counter++;
} else {
// Stop
@@ -71,7 +144,7 @@ void OOKProcessor::execute(const buffer_c8_t& buffer) {
bit_pos++;
}
}
sample_count = 0;
} else {
sample_count++;
@@ -79,31 +152,49 @@ void OOKProcessor::execute(const buffer_c8_t& buffer) {
} else {
s--;
}
if (cur_bit) {
phase = (phase + 200); // What ?
sphase = phase + (64 << 18);
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]);
} else {
re = 0;
im = 0;
}
buffer.p[i] = {re, im};
write_sample(buffer, cur_bit, i);
}
}
void OOKProcessor::on_message(const Message* const p) {
const auto message = *reinterpret_cast<const OOKConfigureMessage*>(p);
if (message.id == Message::ID::OOKConfigure) {
samples_per_bit = message.samples_per_bit / 10;
configured = false;
repeat = message.repeat - 1;
length = message.stream_length;
pause = message.pause_symbols + 1;
de_bruijn_length = message.de_bruijn_length;
samples_per_bit = message.samples_per_bit;
if (!length && !samples_per_bit) {
// shutdown
return;
}
if (de_bruijn_length) {
if (de_bruijn_length > sizeof(v)) {
return;
}
if (samples_per_bit > 2048) {
// can't handle more than dma::transfer_samples
return;
}
k = 0;
bit_ptr = 0;
idx = 1;
scan_done = false;
scan_progress = 0;
memset(v, 0, sizeof(v));
} else {
samples_per_bit /= 10;
}
pause_counter = 0;
s = 0;
sample_count = samples_per_bit;

View File

@@ -29,19 +29,20 @@
class OOKProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const p) override;
private:
bool configured = false;
BasebandThread baseband_thread { 2280000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
uint32_t samples_per_bit { 0 };
uint8_t repeat { 0 };
uint32_t length { 0 };
uint32_t pause { 0 };
uint8_t de_bruijn_length { 0 };
uint32_t pause_counter { 0 };
uint8_t repeat_counter { 0 };
uint8_t s { 0 };
@@ -50,8 +51,19 @@ private:
uint32_t sample_count { 0 };
uint32_t tone_phase { 0 }, phase { 0 }, sphase { 0 };
int32_t tone_sample { 0 }, sig { 0 }, frq { 0 };
TXProgressMessage txprogress_message { };
static constexpr auto MAX_DE_BRUIJN_ORDER = 24;
uint8_t v[MAX_DE_BRUIJN_ORDER];
unsigned int idx { 0 };
unsigned int k { 0 };
size_t bit_ptr{ 0 };
size_t scan_progress{ 0 };
uint8_t scan_done { true };
void write_sample(const buffer_c8_t& buffer, uint8_t bit_value, size_t i);
void duval_algo(const buffer_c8_t& buffer);
};
#endif

View File

@@ -306,7 +306,7 @@ using ChannelSpectrumFIFO = FIFO<ChannelSpectrum>;
class ChannelSpectrumConfigMessage : public Message {
public:
static constexpr size_t fifo_k = 2;
constexpr ChannelSpectrumConfigMessage(
ChannelSpectrumFIFO* fifo
) : Message { ID::ChannelSpectrumConfig },
@@ -352,7 +352,7 @@ public:
packet { packet }
{
}
pocsag::POCSAGPacket packet;
};
@@ -378,7 +378,7 @@ public:
amp(amp)
{
}
adsb::ADSBFrame frame;
uint32_t amp;
};
@@ -393,7 +393,7 @@ public:
value { value }
{
}
bool is_data;
uint32_t value;
};
@@ -406,7 +406,7 @@ public:
value { value }
{
}
uint32_t value;
};
@@ -584,7 +584,7 @@ public:
used_ += copy_size;
return copy_size;
}
size_t read(void* p, const size_t count) {
const auto copy_size = std::min(used_, count);
memcpy(p, &data_[capacity_ - used_], copy_size);
@@ -595,7 +595,7 @@ public:
bool is_full() const {
return used_ >= capacity_;
}
bool is_empty() const {
return used_ == 0;
}
@@ -607,7 +607,7 @@ public:
size_t size() const {
return used_;
}
size_t capacity() const {
return capacity_;
}
@@ -700,7 +700,7 @@ public:
) : Message { ID::TXProgress }
{
}
uint32_t progress = 0;
bool done = false;
};
@@ -719,7 +719,7 @@ public:
trigger_word(trigger_word)
{
}
const uint32_t baudrate;
const uint32_t word_length;
const uint32_t trigger_value;
@@ -734,7 +734,7 @@ public:
baudrate(baudrate)
{
}
const uint32_t baudrate;
};
@@ -788,7 +788,7 @@ public:
rssi(rssi)
{
}
const bool enabled;
const int32_t rssi;
};
@@ -825,7 +825,7 @@ public:
length(length)
{
}
const uint16_t length = 0;
};
@@ -835,7 +835,7 @@ public:
) : Message { ID::Retune }
{
}
int64_t freq = 0;
uint32_t range = 0;
};
@@ -848,7 +848,7 @@ public:
sample_rate(sample_rate)
{
}
const uint32_t sample_rate = 0;
};
@@ -858,7 +858,7 @@ public:
) : Message { ID::AudioLevelReport }
{
}
uint32_t value = 0;
};
@@ -964,12 +964,14 @@ public:
const uint32_t stream_length,
const uint32_t samples_per_bit,
const uint8_t repeat,
const uint32_t pause_symbols
const uint32_t pause_symbols,
const uint8_t de_bruijn_length
) : Message { ID::OOKConfigure },
stream_length(stream_length),
samples_per_bit(samples_per_bit),
repeat(repeat),
pause_symbols(pause_symbols)
pause_symbols(pause_symbols),
de_bruijn_length(de_bruijn_length)
{
}
@@ -977,6 +979,7 @@ public:
const uint32_t samples_per_bit;
const uint8_t repeat;
const uint32_t pause_symbols;
const uint8_t de_bruijn_length;
};
class SSTVConfigureMessage : public Message {
@@ -1017,7 +1020,7 @@ public:
class POCSAGConfigureMessage : public Message {
public:
constexpr POCSAGConfigureMessage()
constexpr POCSAGConfigureMessage()
: Message { ID::POCSAGConfigure }
{
}
@@ -1031,7 +1034,7 @@ public:
packet { packet }
{
}
aprs::APRSPacket packet;
};

View File

@@ -35,11 +35,12 @@ w = numpy.arange(length, dtype=numpy.float64) * (2 * numpy.pi / length)
v = numpy.sin(w)
print(v)
*/
constexpr size_t sine_table_f32_period_log2 = 8;
constexpr size_t sine_table_f32_period = 1 << sine_table_f32_period_log2;
constexpr uint32_t sine_table_f32_index_mask = sine_table_f32_period - 1;
constexpr uint16_t sine_table_f32_period = 256;
// periode is 256 . means sine_table_f32[0]= sine_table_f32[0+256], sine_table_f32[1]=sine_table_f32[1+256] (those two added manualy)
// Then table has 257 values , [0,..255] + [256] and [257], those two are used when we interpolate[255] with [255+1], and [256] with [256+1]
// [256] index is needed in the function sin_f32() when we are inputing very small radian values , example , sin_f32((-1e-14) in radians)
static constexpr std::array<float, sine_table_f32_period + 1> sine_table_f32 { {
static constexpr std::array<float, sine_table_f32_period + 2> sine_table_f32{
0.00000000e+00, 2.45412285e-02, 4.90676743e-02,
7.35645636e-02, 9.80171403e-02, 1.22410675e-01,
1.46730474e-01, 1.70961889e-01, 1.95090322e-01,
@@ -125,24 +126,22 @@ static constexpr std::array<float, sine_table_f32_period + 1> sine_table_f32 { {
-2.42980180e-01, -2.19101240e-01, -1.95090322e-01,
-1.70961889e-01, -1.46730474e-01, -1.22410675e-01,
-9.80171403e-02, -7.35645636e-02, -4.90676743e-02,
-2.45412285e-02, 0.00000000e+00,
} };
-2.45412285e-02, 0.00000000e+00, 2.45412285e-02
};
inline float sin_f32(const float w) {
constexpr float normalize = 1.0 / (2 * pi);
const float x = w * normalize;
const int32_t x_int = std::floor(x);
const float x_frac = x - x_int;
const float x = w / (2 * pi); // normalization
const float x_frac = x - std::floor(x); // [0, 1]
const float n = x_frac * sine_table_f32_period;
const int32_t n_int = static_cast<uint32_t>(n) & sine_table_f32_index_mask;
const uint16_t n_int = static_cast<uint16_t>(n);
const float n_frac = n - n_int;
const float p0 = sine_table_f32[n_int + 0];
const float p0 = sine_table_f32[n_int];
const float p1 = sine_table_f32[n_int + 1];
const float diff = p1 - p0;
const float result = p0 + n_frac * diff;
const float result = p0 + n_frac * diff; // linear interpolation
return result;
}

2
hackrf

Submodule hackrf updated: e3e406491d...eff4a20022