2016-07-25 10:21:27 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
2023-07-11 16:48:36 -04:00
|
|
|
* Copyright (C) 2023 Kyle Reed
|
2016-07-25 10:21:27 -04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
#include "freqman.hpp"
|
|
|
|
#include "freqman_db.hpp"
|
2016-07-25 10:21:27 -04:00
|
|
|
#include "ui.hpp"
|
2023-07-11 16:48:36 -04:00
|
|
|
#include "ui_freqlist.hpp"
|
2016-07-25 10:21:27 -04:00
|
|
|
#include "ui_menu.hpp"
|
|
|
|
#include "ui_navigation.hpp"
|
2023-07-11 16:48:36 -04:00
|
|
|
#include "ui_painter.hpp"
|
2016-12-25 19:31:38 -05:00
|
|
|
#include "ui_receiver.hpp"
|
|
|
|
#include "ui_textentry.hpp"
|
2023-07-11 16:48:36 -04:00
|
|
|
#include "ui_widget.hpp"
|
2016-07-25 10:21:27 -04:00
|
|
|
|
|
|
|
namespace ui {
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
class FreqManBaseView : public View {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
2023-07-14 21:46:39 -04:00
|
|
|
FreqManBaseView(NavigationView& nav);
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
2023-07-14 21:46:39 -04:00
|
|
|
static constexpr size_t desc_edit_max = 0x80;
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
protected:
|
2023-07-11 16:48:36 -04:00
|
|
|
using options_t = OptionsField::options_t;
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
NavigationView& nav_;
|
|
|
|
freqman_error error_{NO_ERROR};
|
2023-07-14 21:46:39 -04:00
|
|
|
std::function<void(void)> on_select_frequency{};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
void change_category(size_t new_index);
|
|
|
|
/* Access the categories directly from the OptionsField.
|
|
|
|
* This avoids holding multiple copies of the file list. */
|
|
|
|
const options_t& categories() const { return options_category.options(); }
|
|
|
|
const auto& current_category() const { return options_category.selected_index_name(); }
|
|
|
|
auto current_index() const { return freqlist_view.get_index(); }
|
|
|
|
freqman_entry current_entry() const { return db_[current_index()]; }
|
|
|
|
void refresh_categories();
|
|
|
|
void refresh_list(int delta_selected = 0);
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
FreqmanDB db_{};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
/* The top section (category) is 20px tall. */
|
2023-05-18 16:16:05 -04:00
|
|
|
Labels label_category{
|
2023-07-11 16:48:36 -04:00
|
|
|
{{0, 2}, "Category:", Color::light_grey()}};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
OptionsField options_category{
|
2023-07-11 16:48:36 -04:00
|
|
|
{9 * 8, 2},
|
|
|
|
14 /* length */,
|
2023-05-18 16:16:05 -04:00
|
|
|
{}};
|
|
|
|
|
2023-06-22 11:34:20 -04:00
|
|
|
FreqManUIList freqlist_view{
|
2023-07-11 16:48:36 -04:00
|
|
|
{0, 3 * 8, screen_width, 12 * 16 + 2 /* 2 Keeps text out of border. */}};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
Button button_exit{
|
2023-07-11 16:48:36 -04:00
|
|
|
{15 * 8, 17 * 16, 15 * 8, 2 * 16},
|
2023-05-18 16:16:05 -04:00
|
|
|
"Exit"};
|
2023-06-07 04:17:55 -04:00
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
protected:
|
|
|
|
/* Static so selected category is persisted across UI instances. */
|
|
|
|
static size_t current_category_index;
|
2017-06-22 04:08:37 -04:00
|
|
|
};
|
2016-07-25 10:21:27 -04:00
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
// TODO: support for new category.
|
2017-06-22 04:08:37 -04:00
|
|
|
class FrequencySaveView : public FreqManBaseView {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
FrequencySaveView(NavigationView& nav, const rf::Frequency value);
|
2023-07-14 21:46:39 -04:00
|
|
|
std::string title() const override { return "Save freq"; }
|
2023-10-01 12:04:37 -04:00
|
|
|
void focus() override;
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
private:
|
2023-07-11 16:48:36 -04:00
|
|
|
freqman_entry entry_{};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
void refresh_ui();
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
BigFrequency big_display{
|
2023-07-11 16:48:36 -04:00
|
|
|
{0, 2 * 16, 28 * 8, 4 * 16},
|
2023-05-18 16:16:05 -04:00
|
|
|
0};
|
|
|
|
|
|
|
|
Labels labels{
|
2023-07-11 16:48:36 -04:00
|
|
|
{{0 * 8, 6 * 16}, "Description:", Color::white()}};
|
|
|
|
|
2023-10-01 12:04:37 -04:00
|
|
|
TextField field_description{
|
|
|
|
{0 * 8, 7 * 16, 30 * 8, 1 * 16},
|
|
|
|
""};
|
2023-07-11 16:48:36 -04:00
|
|
|
|
|
|
|
Button button_save{
|
|
|
|
{0 * 8, 17 * 16, 15 * 8, 2 * 16},
|
|
|
|
"Save"};
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
class FrequencyLoadView : public FreqManBaseView {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
std::function<void(rf::Frequency)> on_frequency_loaded{};
|
|
|
|
std::function<void(rf::Frequency, rf::Frequency)> on_range_loaded{};
|
|
|
|
|
|
|
|
FrequencyLoadView(NavigationView& nav);
|
2023-07-14 21:46:39 -04:00
|
|
|
std::string title() const override { return "Load freq"; }
|
2016-12-06 07:31:38 -05:00
|
|
|
};
|
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
class FrequencyManagerView : public FreqManBaseView {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
FrequencyManagerView(NavigationView& nav);
|
2023-07-14 21:46:39 -04:00
|
|
|
std::string title() const override { return "Freqman"; }
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
private:
|
2023-07-11 16:48:36 -04:00
|
|
|
std::string temp_buffer_{};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-07-14 21:46:39 -04:00
|
|
|
void on_edit_entry();
|
2023-07-11 16:48:36 -04:00
|
|
|
void on_edit_freq();
|
|
|
|
void on_edit_desc();
|
|
|
|
void on_add_category();
|
|
|
|
void on_del_category();
|
|
|
|
void on_add_entry();
|
|
|
|
void on_del_entry();
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
NewButton button_add_category{
|
|
|
|
{23 * 8, 0 * 16, 7 * 4, 20},
|
|
|
|
{},
|
|
|
|
&bitmap_icon_new_file,
|
|
|
|
Color::white(),
|
|
|
|
true};
|
|
|
|
|
|
|
|
NewButton button_del_category{
|
|
|
|
{26 * 8 + 4, 0 * 16, 7 * 4, 20},
|
|
|
|
{},
|
|
|
|
&bitmap_icon_trash,
|
|
|
|
Color::red(),
|
|
|
|
true};
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-07-14 21:46:39 -04:00
|
|
|
Button button_edit_entry{
|
|
|
|
{0 * 8, 14 * 16 - 4, 15 * 8, 1 * 16 + 4},
|
|
|
|
"Edit"};
|
|
|
|
|
|
|
|
Rectangle rect_padding{
|
|
|
|
{15 * 8, 14 * 16 - 4, 15 * 8, 1 * 16 + 4},
|
|
|
|
Color::grey()};
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
Button button_edit_freq{
|
2023-07-11 16:48:36 -04:00
|
|
|
{0 * 8, 15 * 16, 15 * 8, 2 * 16},
|
2023-05-18 16:16:05 -04:00
|
|
|
"Frequency"};
|
2023-07-11 16:48:36 -04:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
Button button_edit_desc{
|
2023-07-11 16:48:36 -04:00
|
|
|
{0 * 8, 17 * 16, 15 * 8, 2 * 16},
|
2023-05-18 16:16:05 -04:00
|
|
|
"Description"};
|
|
|
|
|
2023-07-11 16:48:36 -04:00
|
|
|
NewButton button_add_entry{
|
|
|
|
{15 * 8, 15 * 16, 7 * 8 + 4, 2 * 16},
|
|
|
|
{},
|
|
|
|
&bitmap_icon_add,
|
|
|
|
Color::white(),
|
|
|
|
true};
|
|
|
|
|
|
|
|
NewButton button_del_entry{
|
|
|
|
{22 * 8 + 4, 15 * 16, 7 * 8 + 4, 2 * 16},
|
|
|
|
{},
|
|
|
|
&bitmap_icon_delete,
|
|
|
|
Color::red(),
|
|
|
|
true};
|
2016-07-25 10:21:27 -04:00
|
|
|
};
|
|
|
|
|
2023-07-14 21:46:39 -04:00
|
|
|
class FrequencyEditView : public View {
|
|
|
|
public:
|
|
|
|
std::function<void(const freqman_entry&)> on_save{};
|
|
|
|
|
|
|
|
FrequencyEditView(
|
|
|
|
NavigationView& nav,
|
|
|
|
freqman_entry entry);
|
|
|
|
std::string title() const override { return "Freqman Edit"; }
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
NavigationView& nav_;
|
|
|
|
freqman_entry entry_;
|
|
|
|
std::string temp_buffer_{};
|
|
|
|
|
|
|
|
void refresh_ui();
|
|
|
|
void populate_bandwidth_options();
|
|
|
|
void populate_step_options();
|
|
|
|
void populate_tone_options();
|
|
|
|
|
|
|
|
Labels labels{
|
|
|
|
{{5 * 8, 1 * 16}, "Edit Frequency Entry", Color::white()},
|
|
|
|
{{0 * 8, 3 * 16}, "Entry Type :", Color::light_grey()},
|
|
|
|
{{0 * 8, 4 * 16}, "Frequency A:", Color::light_grey()},
|
|
|
|
{{0 * 8, 5 * 16}, "Frequency B:", Color::light_grey()},
|
|
|
|
{{0 * 8, 6 * 16}, "Modulation :", Color::light_grey()},
|
|
|
|
{{0 * 8, 7 * 16}, "Bandwidth :", Color::light_grey()},
|
|
|
|
{{0 * 8, 8 * 16}, "Step :", Color::light_grey()},
|
|
|
|
{{0 * 8, 9 * 16}, "Tone Freq :", Color::light_grey()},
|
|
|
|
{{0 * 8, 10 * 16}, "Description:", Color::light_grey()},
|
|
|
|
};
|
|
|
|
|
2023-07-29 18:36:00 -04:00
|
|
|
OptionsField field_type{
|
|
|
|
{13 * 8, 3 * 16},
|
|
|
|
8,
|
|
|
|
{
|
|
|
|
{"Single", 0},
|
|
|
|
{"Range", 1},
|
|
|
|
{"HamRadio", 2},
|
|
|
|
{"Raw", 3},
|
|
|
|
}};
|
2023-07-14 21:46:39 -04:00
|
|
|
|
|
|
|
FrequencyField field_freq_a{{13 * 8, 4 * 16}};
|
|
|
|
|
|
|
|
FrequencyField field_freq_b{{13 * 8, 5 * 16}};
|
|
|
|
|
|
|
|
OptionsField field_modulation{{13 * 8, 6 * 16}, 5, {}};
|
|
|
|
|
|
|
|
OptionsField field_bandwidth{{13 * 8, 7 * 16}, 7, {}};
|
|
|
|
|
|
|
|
OptionsField field_step{{13 * 8, 8 * 16}, 12, {}};
|
|
|
|
|
|
|
|
OptionsField field_tone{{13 * 8, 9 * 16}, 13, {}};
|
|
|
|
|
|
|
|
TextField field_description{
|
|
|
|
{13 * 8, 10 * 16, 17 * 8, 1 * 16},
|
|
|
|
{}};
|
|
|
|
|
|
|
|
Text text_validation{
|
|
|
|
{12 * 8, 12 * 16, 5 * 8, 1 * 16},
|
|
|
|
{}};
|
|
|
|
|
|
|
|
Button button_save{
|
|
|
|
{0 * 8, 17 * 16, 15 * 8, 2 * 16},
|
|
|
|
"Save"};
|
|
|
|
|
|
|
|
Button button_cancel{
|
|
|
|
{15 * 8, 17 * 16, 15 * 8, 2 * 16},
|
|
|
|
"Cancel"};
|
|
|
|
};
|
|
|
|
|
2016-07-25 10:21:27 -04:00
|
|
|
} /* namespace ui */
|
2023-07-17 14:43:37 -04:00
|
|
|
|
|
|
|
void freqman_set_bandwidth_option(freqman_index_t modulation, ui::OptionsField& option);
|
|
|
|
void freqman_set_modulation_option(ui::OptionsField& option);
|
|
|
|
void freqman_set_step_option(ui::OptionsField& option);
|
|
|
|
void freqman_set_step_option_short(ui::OptionsField& option);
|
|
|
|
void freqman_set_tone_option(ui::OptionsField& option);
|