mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-10 03:38:50 -05:00
Added channel centering cursor in waterfall view
Added more samplerate choices in capture Updated binary
This commit is contained in:
parent
d0ce9610b5
commit
5636764226
@ -149,6 +149,10 @@ AnalogAudioView::AnalogAudioView(
|
|||||||
nav.display_modal("Error", message);
|
nav.display_modal("Error", message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
waterfall.on_select = [this](int32_t offset) {
|
||||||
|
field_frequency.set_value(receiver_model.tuning_frequency() + offset);
|
||||||
|
};
|
||||||
|
|
||||||
audio::output::start();
|
audio::output::start();
|
||||||
|
|
||||||
update_modulation(static_cast<ReceiverModel::Mode>(modulation));
|
update_modulation(static_cast<ReceiverModel::Mode>(modulation));
|
||||||
|
@ -104,6 +104,8 @@ public:
|
|||||||
|
|
||||||
void focus() override;
|
void focus() override;
|
||||||
|
|
||||||
|
std::string title() const override { return "Analog audio"; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr ui::Dim header_height = 3 * 16;
|
static constexpr ui::Dim header_height = 3 * 16;
|
||||||
|
|
||||||
@ -168,7 +170,7 @@ private:
|
|||||||
u"AUD_????", RecordView::FileType::WAV, 4096, 4
|
u"AUD_????", RecordView::FileType::WAV, 4096, 4
|
||||||
};
|
};
|
||||||
|
|
||||||
spectrum::WaterfallWidget waterfall { };
|
spectrum::WaterfallWidget waterfall { true };
|
||||||
|
|
||||||
void on_tuning_frequency_changed(rf::Frequency f);
|
void on_tuning_frequency_changed(rf::Frequency f);
|
||||||
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
|
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
* Copyright (C) 2018 Furrtek
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@ -68,8 +69,8 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
|
|||||||
this->field_frequency.set_step(v);
|
this->field_frequency.set_step(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
option_bandwidth.on_change = [this](size_t, uint32_t divider) {
|
option_bandwidth.on_change = [this](size_t, uint32_t base_rate) {
|
||||||
sampling_rate = 4000000 / divider;
|
sampling_rate = 8 * base_rate;
|
||||||
|
|
||||||
waterfall.on_hide();
|
waterfall.on_hide();
|
||||||
set_target_frequency(target_frequency());
|
set_target_frequency(target_frequency());
|
||||||
@ -88,7 +89,7 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
|
|||||||
static_cast<int8_t>(receiver_model.vga()),
|
static_cast<int8_t>(receiver_model.vga()),
|
||||||
});
|
});
|
||||||
|
|
||||||
option_bandwidth.set_selected_index(4); // 500k
|
option_bandwidth.set_selected_index(7); // 500k
|
||||||
|
|
||||||
record_view.on_error = [&nav](std::string message) {
|
record_view.on_error = [&nav](std::string message) {
|
||||||
nav.display_modal("Error", message);
|
nav.display_modal("Error", message);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
||||||
|
* Copyright (C) 2018 Furrtek
|
||||||
*
|
*
|
||||||
* This file is part of PortaPack.
|
* This file is part of PortaPack.
|
||||||
*
|
*
|
||||||
@ -93,13 +94,16 @@ private:
|
|||||||
|
|
||||||
OptionsField option_bandwidth {
|
OptionsField option_bandwidth {
|
||||||
{ 5 * 8, 1 * 16 },
|
{ 5 * 8, 1 * 16 },
|
||||||
4,
|
5,
|
||||||
{
|
{
|
||||||
{ " 25k", 20 },
|
{ " 8k5", 8500 },
|
||||||
{ " 50k", 10 },
|
{ " 11k ", 11000 },
|
||||||
{ "100k", 5 },
|
{ " 16k ", 16000 },
|
||||||
{ "250k", 2 },
|
{ " 25k ", 25000 },
|
||||||
{ "500k", 1 }
|
{ " 50k ", 50000 },
|
||||||
|
{ "100k ", 100000 },
|
||||||
|
{ "250k ", 250000 },
|
||||||
|
{ "500k ", 500000 }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,6 +61,19 @@ void FrequencyScale::set_channel_filter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrequencyScale::show_cursor(const bool v) {
|
||||||
|
if (v != _show_cursor) {
|
||||||
|
_show_cursor = v;
|
||||||
|
set_dirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrequencyScale::set_cursor_position(const int32_t value) {
|
||||||
|
_show_cursor = true;
|
||||||
|
cursor_position = value;
|
||||||
|
set_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
void FrequencyScale::paint(Painter& painter) {
|
void FrequencyScale::paint(Painter& painter) {
|
||||||
const auto r = screen_rect();
|
const auto r = screen_rect();
|
||||||
|
|
||||||
@ -73,6 +86,17 @@ void FrequencyScale::paint(Painter& painter) {
|
|||||||
|
|
||||||
draw_filter_ranges(painter, r);
|
draw_filter_ranges(painter, r);
|
||||||
draw_frequency_ticks(painter, r);
|
draw_frequency_ticks(painter, r);
|
||||||
|
|
||||||
|
if (_show_cursor) {
|
||||||
|
const Rect r_cursor {
|
||||||
|
120 + cursor_position, r.bottom() - filter_band_height,
|
||||||
|
2, filter_band_height
|
||||||
|
};
|
||||||
|
painter.fill_rectangle(
|
||||||
|
r_cursor,
|
||||||
|
Color::red()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrequencyScale::clear() {
|
void FrequencyScale::clear() {
|
||||||
@ -226,13 +250,24 @@ void WaterfallView::clear() {
|
|||||||
|
|
||||||
/* WaterfallWidget *******************************************************/
|
/* WaterfallWidget *******************************************************/
|
||||||
|
|
||||||
WaterfallWidget::WaterfallWidget() {
|
WaterfallWidget::WaterfallWidget(const bool cursor) {
|
||||||
|
set_focusable(cursor);
|
||||||
|
|
||||||
add_children({
|
add_children({
|
||||||
&waterfall_view,
|
&waterfall_view,
|
||||||
&frequency_scale,
|
&frequency_scale,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WaterfallWidget::~WaterfallWidget() {
|
||||||
|
rtc_time::signal_tick_second -= signal_token_tick_second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaterfallWidget::on_tick_second() {
|
||||||
|
frequency_scale.show_cursor(_blink);
|
||||||
|
_blink = !_blink;
|
||||||
|
}
|
||||||
|
|
||||||
void WaterfallWidget::on_show() {
|
void WaterfallWidget::on_show() {
|
||||||
baseband::spectrum_streaming_start();
|
baseband::spectrum_streaming_start();
|
||||||
}
|
}
|
||||||
@ -241,6 +276,41 @@ void WaterfallWidget::on_hide() {
|
|||||||
baseband::spectrum_streaming_stop();
|
baseband::spectrum_streaming_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaterfallWidget::on_focus() {
|
||||||
|
_blink = true;
|
||||||
|
signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
|
||||||
|
this->on_tick_second();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaterfallWidget::on_blur() {
|
||||||
|
frequency_scale.show_cursor(false);
|
||||||
|
rtc_time::signal_tick_second -= signal_token_tick_second;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WaterfallWidget::on_encoder(const EncoderEvent delta) {
|
||||||
|
cursor_position += delta;
|
||||||
|
|
||||||
|
cursor_position = std::min<int32_t>(cursor_position, 119);
|
||||||
|
cursor_position = std::max<int32_t>(cursor_position, -120);
|
||||||
|
|
||||||
|
frequency_scale.set_cursor_position(cursor_position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WaterfallWidget::on_key(const KeyEvent key) {
|
||||||
|
if( key == KeyEvent::Select ) {
|
||||||
|
if( on_select ) {
|
||||||
|
on_select((cursor_position * sampling_rate) / 240);
|
||||||
|
cursor_position = 0;
|
||||||
|
frequency_scale.set_cursor_position(cursor_position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void WaterfallWidget::set_parent_rect(const Rect new_parent_rect) {
|
void WaterfallWidget::set_parent_rect(const Rect new_parent_rect) {
|
||||||
constexpr Dim scale_height = 20;
|
constexpr Dim scale_height = 20;
|
||||||
|
|
||||||
@ -260,7 +330,8 @@ void WaterfallWidget::paint(Painter& painter) {
|
|||||||
|
|
||||||
void WaterfallWidget::on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
void WaterfallWidget::on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
||||||
waterfall_view.on_channel_spectrum(spectrum);
|
waterfall_view.on_channel_spectrum(spectrum);
|
||||||
frequency_scale.set_spectrum_sampling_rate(spectrum.sampling_rate);
|
sampling_rate = spectrum.sampling_rate;
|
||||||
|
frequency_scale.set_spectrum_sampling_rate(sampling_rate);
|
||||||
frequency_scale.set_channel_filter(
|
frequency_scale.set_channel_filter(
|
||||||
spectrum.channel_filter_pass_frequency,
|
spectrum.channel_filter_pass_frequency,
|
||||||
spectrum.channel_filter_stop_frequency
|
spectrum.channel_filter_stop_frequency
|
||||||
|
@ -41,12 +41,16 @@ public:
|
|||||||
|
|
||||||
void set_spectrum_sampling_rate(const int new_sampling_rate);
|
void set_spectrum_sampling_rate(const int new_sampling_rate);
|
||||||
void set_channel_filter(const int pass_frequency, const int stop_frequency);
|
void set_channel_filter(const int pass_frequency, const int stop_frequency);
|
||||||
|
void show_cursor(const bool v);
|
||||||
|
void set_cursor_position(const int32_t value);
|
||||||
|
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr int filter_band_height = 4;
|
static constexpr int filter_band_height = 4;
|
||||||
|
|
||||||
|
bool _show_cursor { false };
|
||||||
|
int32_t cursor_position { 0 };
|
||||||
int spectrum_sampling_rate { 0 };
|
int spectrum_sampling_rate { 0 };
|
||||||
const int spectrum_bins = std::tuple_size<decltype(ChannelSpectrum::db)>::value;
|
const int spectrum_bins = std::tuple_size<decltype(ChannelSpectrum::db)>::value;
|
||||||
int channel_filter_pass_frequency { 0 };
|
int channel_filter_pass_frequency { 0 };
|
||||||
@ -74,7 +78,10 @@ private:
|
|||||||
|
|
||||||
class WaterfallWidget : public View {
|
class WaterfallWidget : public View {
|
||||||
public:
|
public:
|
||||||
WaterfallWidget();
|
std::function<void(int32_t offset)> on_select { };
|
||||||
|
|
||||||
|
WaterfallWidget(const bool cursor = false);
|
||||||
|
~WaterfallWidget();
|
||||||
|
|
||||||
WaterfallWidget(const WaterfallWidget&) = delete;
|
WaterfallWidget(const WaterfallWidget&) = delete;
|
||||||
WaterfallWidget(WaterfallWidget&&) = delete;
|
WaterfallWidget(WaterfallWidget&&) = delete;
|
||||||
@ -83,16 +90,28 @@ public:
|
|||||||
|
|
||||||
void on_show() override;
|
void on_show() override;
|
||||||
void on_hide() override;
|
void on_hide() override;
|
||||||
|
void on_focus() override;
|
||||||
|
void on_blur() override;
|
||||||
|
|
||||||
|
bool on_encoder(const EncoderEvent delta) override;
|
||||||
|
bool on_key(const KeyEvent key) override;
|
||||||
|
|
||||||
void set_parent_rect(const Rect new_parent_rect) override;
|
void set_parent_rect(const Rect new_parent_rect) override;
|
||||||
|
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void on_tick_second();
|
||||||
|
|
||||||
WaterfallView waterfall_view { };
|
WaterfallView waterfall_view { };
|
||||||
FrequencyScale frequency_scale { };
|
FrequencyScale frequency_scale { };
|
||||||
ChannelSpectrumFIFO* fifo { nullptr };
|
ChannelSpectrumFIFO* fifo { nullptr };
|
||||||
|
|
||||||
|
bool _blink { false };
|
||||||
|
int sampling_rate { 0 };
|
||||||
|
int32_t cursor_position { 0 };
|
||||||
|
SignalToken signal_token_tick_second { };
|
||||||
|
|
||||||
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) {
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user