added steps config and thus possibility to adjust config / see under 240 MHz

This commit is contained in:
GullCode 2023-03-16 10:33:36 +01:00
parent 62b9fa2b6a
commit 49bda24079
2 changed files with 220 additions and 176 deletions

View File

@ -184,6 +184,7 @@ namespace ui
&field_lna, &field_lna,
&field_vga, &field_vga,
&text_range, &text_range,
&steps_config,
&filter_config, &filter_config,
&field_rf_amp, &field_rf_amp,
&range_presets, &range_presets,
@ -194,21 +195,51 @@ namespace ui
load_Presets(); // Load available presets from TXT files (or default) load_Presets(); // Load available presets from TXT files (or default)
field_frequency_min.set_value(presets_db[0].min); // Defaults to first preset field_frequency_min.set_value(presets_db[0].min); // Defaults to first preset
field_frequency_min.set_step( steps );
field_frequency_min.on_change = [this](int32_t v) field_frequency_min.on_change = [this](int32_t v)
{ {
if (v >= field_frequency_max.value()) if( v > 7200 - steps )
field_frequency_max.set_value(v + 240); v = 7200 - steps ;
if (v >= (field_frequency_max.value() - steps ) )
field_frequency_max.set_value( v + steps );
this->on_range_changed(); this->on_range_changed();
}; };
field_frequency_min.on_select = [this, &nav](NumberField& field) {
auto new_view = nav_.push<FrequencyKeypadView>(field_frequency_min.value()*1000000);
new_view->on_changed = [this, &field](rf::Frequency f) {
int32_t freq = f / 1000000 ;
if( freq > (7200 - steps ) )
freq= 7200 - steps ;
field_frequency_min.set_value( freq );
if( field_frequency_max.value() < ( freq + steps ) )
field_frequency_max.set_value( freq + steps );
};
};
field_frequency_max.set_value(presets_db[0].max); // Defaults to first preset field_frequency_max.set_value(presets_db[0].max); // Defaults to first preset
field_frequency_max.set_step( steps );
field_frequency_max.on_change = [this](int32_t v) field_frequency_max.on_change = [this](int32_t v)
{ {
if (v <= field_frequency_min.value()) if( v < steps )
field_frequency_min.set_value(v - 240); v = steps ;
if (v < (field_frequency_min.value() + steps) )
field_frequency_min.set_value(v - steps);
this->on_range_changed(); this->on_range_changed();
}; };
field_frequency_max.on_select = [this, &nav](NumberField& field) {
auto new_view = nav_.push<FrequencyKeypadView>(field_frequency_max.value()*1000000);
new_view->on_changed = [this, &field](rf::Frequency f) {
int32_t freq = f / 1000000 ;
if( freq < steps )
freq= steps ;
field_frequency_max.set_value( freq );
if( field_frequency_min.value() > ( freq - steps) )
field_frequency_min.set_value( freq - steps );
};
};
field_lna.set_value(receiver_model.lna()); field_lna.set_value(receiver_model.lna());
field_lna.on_change = [this](int32_t v) field_lna.on_change = [this](int32_t v)
{ {
@ -221,11 +252,12 @@ namespace ui
this->on_vga_changed(v_db); this->on_vga_changed(v_db);
}; };
filter_config.set_selected_index(0); steps_config.set_selected_index(3); //default of 250 Mhz steps
filter_config.on_change = [this](size_t n, OptionsField::value_t v) steps_config.on_change = [this](size_t n, OptionsField::value_t v)
{ {
(void)n; (void)n;
min_color_power = v; field_frequency_min.set_step( v );
field_frequency_max.set_step( v );
}; };
range_presets.on_change = [this](size_t n, OptionsField::value_t v) range_presets.on_change = [this](size_t n, OptionsField::value_t v)

View File

@ -1,190 +1,202 @@
/* /*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2020 euquiq * Copyright (C) 2020 euquiq
* *
* This file is part of PortaPack. * This file is part of PortaPack.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option) * the Free Software Foundation; either version 2, or (at your option)
* any later version. * any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to * along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, * the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef _UI_GLASS #ifndef _UI_GLASS
#define _UI_GLASS #define _UI_GLASS
#include "ui.hpp" #include "ui.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "receiver_model.hpp" #include "receiver_model.hpp"
#include "ui_widget.hpp" #include "ui_widget.hpp"
#include "ui_navigation.hpp" #include "ui_navigation.hpp"
#include "ui_receiver.hpp" #include "ui_receiver.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "analog_audio_app.hpp" #include "analog_audio_app.hpp"
#include "spectrum_color_lut.hpp" #include "spectrum_color_lut.hpp"
namespace ui namespace ui
{ {
#define LOOKING_GLASS_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz #define LOOKING_GLASS_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz
#define MHZ_DIV 1000000 #define MHZ_DIV 1000000
#define X2_MHZ_DIV 2000000 #define X2_MHZ_DIV 2000000
class GlassView : public View class GlassView : public View
{ {
public: public:
GlassView(NavigationView &nav); GlassView(NavigationView &nav);
GlassView( const GlassView &); GlassView( const GlassView &);
GlassView& operator=(const GlassView &nav); GlassView& operator=(const GlassView &nav);
~GlassView(); ~GlassView();
std::string title() const override { return "Looking Glass"; }; std::string title() const override { return "Looking Glass"; };
void on_show() override; void on_show() override;
void on_hide() override; void on_hide() override;
void focus() override; void focus() override;
private: private:
NavigationView& nav_; NavigationView& nav_;
struct preset_entry struct preset_entry
{
rf::Frequency min{};
rf::Frequency max{};
std::string label{};
};
std::vector<preset_entry> presets_db{};
void on_channel_spectrum(const ChannelSpectrum& spectrum);
void do_timers();
void on_range_changed();
void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db);
void add_spectrum_pixel(Color color);
void PlotMarker(rf::Frequency pos);
void load_Presets();
void txtline_process(std::string& line);
void populate_Presets();
void presets_Default();
rf::Frequency f_min { 0 }, f_max { 0 };
rf::Frequency search_span { 0 };
rf::Frequency f_center { 0 };
rf::Frequency f_center_ini { 0 };
rf::Frequency marker_pixel_step { 0 };
rf::Frequency each_bin_size { LOOKING_GLASS_SLICE_WIDTH / 240 };
rf::Frequency bins_Hz_size { 0 };
uint8_t min_color_power { 0 };
uint32_t pixel_index { 0 };
std::array<Color, 240> spectrum_row = { 0 };
ChannelSpectrumFIFO* fifo { nullptr };
uint8_t max_power = 0;
Labels labels{
{{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()},
{{0, 1 * 16}, " RANGE: FILTER: AMP:", Color::light_grey()},
{{0, 2 * 16}, "PRESET:", Color::light_grey()},
{{0, 3 * 16}, "MARKER: MHz +/- MHz", Color::light_grey()},
{{0, 4 * 16}, "RESOLUTION: (fft trigger)", Color::light_grey()}
};
NumberField field_frequency_min {
{ 4 * 8, 0 * 16 },
4,
{ 0, 6960 },
240,
' '
};
NumberField field_frequency_max {
{ 13 * 8, 0 * 16 },
4,
{ 240, 7200 },
240,
' '
};
LNAGainField field_lna {
{ 21 * 8, 0 * 16 }
};
VGAGainField field_vga {
{ 27 * 8, 0 * 16 }
};
Text text_range{
{7 * 8, 1 * 16, 4 * 8, 16},
""};
OptionsField filter_config{
{19 * 8, 1 * 16},
4,
{ {
{"OFF ", 0}, rf::Frequency min{};
{"MID ", 118}, //85 +25 (110) + a bit more to kill all blue rf::Frequency max{};
{"HIGH", 202}, //168 + 25 (193) std::string label{};
}}; };
RFAmpField field_rf_amp{ std::vector<preset_entry> presets_db{};
{29 * 8, 1 * 16}};
OptionsField range_presets{ void on_channel_spectrum(const ChannelSpectrum& spectrum);
{7 * 8, 2 * 16}, void do_timers();
20, void on_range_changed();
{ void on_lna_changed(int32_t v_db);
{" NONE (WIFI 2.4GHz)", 0}, void on_vga_changed(int32_t v_db);
}}; void add_spectrum_pixel(Color color);
void PlotMarker(rf::Frequency pos);
void load_Presets();
void txtline_process(std::string& line);
void populate_Presets();
void presets_Default();
NumberField field_marker{ rf::Frequency f_min { 0 }, f_max { 0 };
{7 * 8, 3 * 16}, rf::Frequency search_span { 0 };
4, rf::Frequency f_center { 0 };
{0, 7200}, rf::Frequency f_center_ini { 0 };
25, rf::Frequency marker_pixel_step { 0 };
' '}; rf::Frequency each_bin_size { LOOKING_GLASS_SLICE_WIDTH / 240 };
rf::Frequency bins_Hz_size { 0 };
uint8_t min_color_power { 0 };
uint32_t pixel_index { 0 };
std::array<Color, 240> spectrum_row = { 0 };
ChannelSpectrumFIFO* fifo { nullptr };
uint8_t max_power = 0;
int32_t steps = 250 ; // default of 250 Mhz steps
Text text_marker_pm{ Labels labels{
{20 * 8, 3 * 16, 2 * 8, 16}, {{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()},
""}; {{0, 1 * 16}, " RANGE: FILTER: AMP:", Color::light_grey()},
{{0, 2 * 16}, "PRESET:", Color::light_grey()},
{{0, 3 * 16}, "MARKER: MHz +/- MHz", Color::light_grey()},
{{0, 4 * 16}, "RESOLUTION: STEPS:", Color::light_grey()}
};
NumberField field_trigger{ NumberField field_frequency_min {
{11 * 8, 4 * 16}, { 4 * 8, 0 * 16 },
3, 4,
{2, 128}, { 0, 7199 },
2, 1, // number of steps by encoder delta
' '}; ' '
};
NumberField field_frequency_max {
{ 13 * 8, 0 * 16 },
4,
{ 1, 7200 },
1, // number of steps by encoder delta
' '
};
LNAGainField field_lna {
{ 21 * 8, 0 * 16 }
};
VGAGainField field_vga {
{ 27 * 8, 0 * 16 }
};
Text text_range{
{7 * 8, 1 * 16, 4 * 8, 16},
""};
OptionsField steps_config{
{ 22 * 8, 4 * 16},
4,
{
{"1", 1},
{"50", 50},
{"100", 100},
{"250", 250},
{"500", 500},
{"1000", 1000},
}};
OptionsField filter_config{
{19 * 8, 1 * 16},
4,
{
{"OFF ", 0},
{"MID ", 118}, //85 +25 (110) + a bit more to kill all blue
{"HIGH", 202}, //168 + 25 (193)
}};
RFAmpField field_rf_amp{
{29 * 8, 1 * 16}};
OptionsField range_presets{
{7 * 8, 2 * 16},
20,
{
{" NONE (WIFI 2.4GHz)", 0},
}};
NumberField field_marker{
{7 * 8, 3 * 16},
4,
{0, 7200},
25,
' '};
Text text_marker_pm{
{20 * 8, 3 * 16, 2 * 8, 16},
""};
NumberField field_trigger{
{11 * 8, 4 * 16},
3,
{2, 128},
2,
' '};
MessageHandlerRegistration message_handler_spectrum_config { MessageHandlerRegistration message_handler_spectrum_config {
Message::ID::ChannelSpectrumConfig, Message::ID::ChannelSpectrumConfig,
[this](const Message* const p) { [this](const Message* const p) {
const auto message = *reinterpret_cast<const ChannelSpectrumConfigMessage*>(p); const auto message = *reinterpret_cast<const ChannelSpectrumConfigMessage*>(p);
this->fifo = message.fifo; this->fifo = message.fifo;
} }
}; };
MessageHandlerRegistration message_handler_frame_sync { MessageHandlerRegistration message_handler_frame_sync {
Message::ID::DisplayFrameSync, Message::ID::DisplayFrameSync,
[this](const Message* const) { [this](const Message* const) {
if( this->fifo ) { if( this->fifo ) {
ChannelSpectrum channel_spectrum; ChannelSpectrum channel_spectrum;
while( fifo->out(channel_spectrum) ) { while( fifo->out(channel_spectrum) ) {
this->on_channel_spectrum(channel_spectrum); this->on_channel_spectrum(channel_spectrum);
} }
} }
} }
}; };
};
}; }
}
#endif #endif