mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-23 16:41:09 +00:00
Added channel centering cursor in waterfall view
Added more samplerate choices in capture Updated binary
This commit is contained in:
@@ -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) {
|
||||
const auto r = screen_rect();
|
||||
|
||||
@@ -73,6 +86,17 @@ void FrequencyScale::paint(Painter& painter) {
|
||||
|
||||
draw_filter_ranges(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() {
|
||||
@@ -226,13 +250,24 @@ void WaterfallView::clear() {
|
||||
|
||||
/* WaterfallWidget *******************************************************/
|
||||
|
||||
WaterfallWidget::WaterfallWidget() {
|
||||
WaterfallWidget::WaterfallWidget(const bool cursor) {
|
||||
set_focusable(cursor);
|
||||
|
||||
add_children({
|
||||
&waterfall_view,
|
||||
&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() {
|
||||
baseband::spectrum_streaming_start();
|
||||
}
|
||||
@@ -241,6 +276,41 @@ void WaterfallWidget::on_hide() {
|
||||
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) {
|
||||
constexpr Dim scale_height = 20;
|
||||
|
||||
@@ -260,7 +330,8 @@ void WaterfallWidget::paint(Painter& painter) {
|
||||
|
||||
void WaterfallWidget::on_channel_spectrum(const ChannelSpectrum& 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(
|
||||
spectrum.channel_filter_pass_frequency,
|
||||
spectrum.channel_filter_stop_frequency
|
||||
|
@@ -41,12 +41,16 @@ public:
|
||||
|
||||
void set_spectrum_sampling_rate(const int new_sampling_rate);
|
||||
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;
|
||||
|
||||
private:
|
||||
static constexpr int filter_band_height = 4;
|
||||
|
||||
bool _show_cursor { false };
|
||||
int32_t cursor_position { 0 };
|
||||
int spectrum_sampling_rate { 0 };
|
||||
const int spectrum_bins = std::tuple_size<decltype(ChannelSpectrum::db)>::value;
|
||||
int channel_filter_pass_frequency { 0 };
|
||||
@@ -74,7 +78,10 @@ private:
|
||||
|
||||
class WaterfallWidget : public View {
|
||||
public:
|
||||
WaterfallWidget();
|
||||
std::function<void(int32_t offset)> on_select { };
|
||||
|
||||
WaterfallWidget(const bool cursor = false);
|
||||
~WaterfallWidget();
|
||||
|
||||
WaterfallWidget(const WaterfallWidget&) = delete;
|
||||
WaterfallWidget(WaterfallWidget&&) = delete;
|
||||
@@ -83,15 +90,27 @@ public:
|
||||
|
||||
void on_show() 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 paint(Painter& painter) override;
|
||||
|
||||
private:
|
||||
void on_tick_second();
|
||||
|
||||
WaterfallView waterfall_view { };
|
||||
FrequencyScale frequency_scale { };
|
||||
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 {
|
||||
Message::ID::ChannelSpectrumConfig,
|
||||
|
Reference in New Issue
Block a user