portapack-mayhem/firmware/application/ui_spectrum.hpp

96 lines
2.4 KiB
C++
Raw Normal View History

2015-07-08 15:39:24 +00:00
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
*
* This file is part of PortaPack.
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef __UI_SPECTRUM_H__
#define __UI_SPECTRUM_H__
#include "ui.hpp"
#include "ui_widget.hpp"
2015-07-08 15:39:24 +00:00
#include "message.hpp"
#include <cstdint>
2015-12-17 03:33:30 +00:00
#include <cstddef>
2015-07-08 15:39:24 +00:00
namespace ui {
namespace spectrum {
class FrequencyScale : public Widget {
public:
2015-12-17 03:33:30 +00:00
void on_show() override;
2015-07-08 15:39:24 +00:00
void set_spectrum_sampling_rate(const int new_sampling_rate);
void set_channel_filter(const int pass_frequency, const int stop_frequency);
2015-12-17 03:33:30 +00:00
void paint(Painter& painter) override;
private:
static constexpr int filter_band_height = 4;
int spectrum_sampling_rate { 0 };
const int spectrum_bins = std::tuple_size<decltype(ChannelSpectrum::db)>::value;
int channel_filter_pass_frequency { 0 };
int channel_filter_stop_frequency { 0 };
2015-12-17 03:33:30 +00:00
void clear();
void clear_background(Painter& painter, const Rect r);
2015-07-08 15:39:24 +00:00
2015-12-17 03:33:30 +00:00
void draw_frequency_ticks(Painter& painter, const Rect r);
void draw_filter_ranges(Painter& painter, const Rect r);
2015-07-08 15:39:24 +00:00
};
class WaterfallView : public Widget {
public:
2015-12-17 03:33:30 +00:00
void on_show() override;
void on_hide() override;
2015-07-08 15:39:24 +00:00
2015-12-17 03:33:30 +00:00
void paint(Painter& painter) override;
2015-07-08 15:39:24 +00:00
2015-12-17 03:33:30 +00:00
void on_channel_spectrum(const ChannelSpectrum& spectrum);
private:
2015-12-17 03:33:30 +00:00
void clear();
2015-07-08 15:39:24 +00:00
};
class WaterfallWidget : public View {
public:
2015-12-17 03:33:30 +00:00
WaterfallWidget();
2015-07-08 15:39:24 +00:00
2015-12-17 03:33:30 +00:00
void on_show() override;
void on_hide() override;
2015-07-08 15:39:24 +00:00
2015-12-17 03:33:30 +00:00
void set_parent_rect(const Rect new_parent_rect) override;
2015-07-08 15:39:24 +00:00
2015-12-17 03:33:30 +00:00
void paint(Painter& painter) override;
2015-07-08 15:39:24 +00:00
private:
WaterfallView waterfall_view;
FrequencyScale frequency_scale;
ChannelSpectrumFIFO* fifo { nullptr };
2015-07-08 15:39:24 +00:00
2015-12-17 03:33:30 +00:00
void on_channel_spectrum(const ChannelSpectrum& spectrum);
2015-07-08 15:39:24 +00:00
};
} /* namespace spectrum */
} /* namespace ui */
#endif/*__UI_SPECTRUM_H__*/