mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-05-04 01:30:47 +00:00
Rework how spectrum and filter bandwidth is represented to UI.
Issue #13.
This commit is contained in:
parent
e571ca7f1c
commit
98bd9c54e4
@ -37,16 +37,11 @@ namespace spectrum {
|
|||||||
|
|
||||||
class FrequencyScale : public Widget {
|
class FrequencyScale : public Widget {
|
||||||
public:
|
public:
|
||||||
void set_scale(const uint32_t new_hz_per_pixel) {
|
void set_spectrum_bandwidth(const uint32_t new_bandwidth, const size_t new_spectrum_bins) {
|
||||||
if( hz_per_pixel != new_hz_per_pixel ) {
|
if( (spectrum_bandwidth != new_bandwidth) ||
|
||||||
hz_per_pixel = new_hz_per_pixel;
|
(spectrum_bins != new_spectrum_bins) ) {
|
||||||
set_dirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_spectrum_bandwidth(const uint32_t new_bandwidth) {
|
|
||||||
if( spectrum_bandwidth != new_bandwidth ) {
|
|
||||||
spectrum_bandwidth = new_bandwidth;
|
spectrum_bandwidth = new_bandwidth;
|
||||||
|
spectrum_bins = new_spectrum_bins;
|
||||||
set_dirty();
|
set_dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,7 +59,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void paint(Painter& painter) override {
|
void paint(Painter& painter) override {
|
||||||
if( !hz_per_pixel ) {
|
if( !spectrum_bandwidth || !spectrum_bins ) {
|
||||||
// Can't draw without non-zero scale.
|
// Can't draw without non-zero scale.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,8 +78,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if( channel_filter_pass_bandwidth ) {
|
if( channel_filter_pass_bandwidth ) {
|
||||||
const auto pass_width = channel_filter_pass_bandwidth / hz_per_pixel;
|
const auto pass_width = channel_filter_pass_bandwidth * spectrum_bins / spectrum_bandwidth;
|
||||||
const auto stop_width = channel_filter_stop_bandwidth / hz_per_pixel;
|
const auto stop_width = channel_filter_stop_bandwidth * spectrum_bins / spectrum_bandwidth;
|
||||||
|
|
||||||
const auto pass_x_lo = x_center - pass_width / 2;
|
const auto pass_x_lo = x_center - pass_width / 2;
|
||||||
const auto pass_x_hi = x_center + pass_width / 2;
|
const auto pass_x_hi = x_center + pass_width / 2;
|
||||||
@ -137,9 +132,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t spectrum_bandwidth { 0 };
|
uint32_t spectrum_bandwidth { 0 };
|
||||||
|
size_t spectrum_bins { 0 };
|
||||||
uint32_t channel_filter_pass_bandwidth { 0 };
|
uint32_t channel_filter_pass_bandwidth { 0 };
|
||||||
uint32_t channel_filter_stop_bandwidth { 0 };
|
uint32_t channel_filter_stop_bandwidth { 0 };
|
||||||
uint32_t hz_per_pixel { 0 };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WaterfallView : public Widget {
|
class WaterfallView : public Widget {
|
||||||
@ -230,11 +225,11 @@ private:
|
|||||||
|
|
||||||
void on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
void on_channel_spectrum(const ChannelSpectrum& spectrum) {
|
||||||
waterfall_view.on_channel_spectrum(spectrum);
|
waterfall_view.on_channel_spectrum(spectrum);
|
||||||
frequency_scale.set_scale(spectrum.bandwidth / spectrum.db_count);
|
frequency_scale.set_spectrum_bandwidth(spectrum.bandwidth, spectrum.db_count);
|
||||||
|
|
||||||
// TODO: Set with actual information.
|
// TODO: Set with actual information.
|
||||||
//taps_64_lp_042_078_tfilter
|
//taps_64_lp_042_078_tfilter
|
||||||
frequency_scale.set_channel_filter(spectrum.bandwidth * 42 / 1000, spectrum.bandwidth * 78 / 1000);
|
frequency_scale.set_channel_filter(spectrum.bandwidth * 2 * 42 / 1000, spectrum.bandwidth * 2 * 78 / 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ protected:
|
|||||||
if( !channel_spectrum_request_update ) {
|
if( !channel_spectrum_request_update ) {
|
||||||
channel_spectrum_request_update = true;
|
channel_spectrum_request_update = true;
|
||||||
std::copy(&data.p[0], &data.p[data.count], channel_spectrum.begin());
|
std::copy(&data.p[0], &data.p[data.count], channel_spectrum.begin());
|
||||||
channel_spectrum_bandwidth = data.sampling_rate * 2;
|
channel_spectrum_bandwidth = data.sampling_rate;
|
||||||
events_flag(EVT_MASK_SPECTRUM);
|
events_flag(EVT_MASK_SPECTRUM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user