2015-09-10 18:36:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
2016-12-09 17:21:47 +00:00
|
|
|
* Copyright (C) 2016 Furrtek
|
2015-09-10 18:36:39 +00: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.
|
|
|
|
*/
|
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
#include "ui_siggen.hpp"
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
#include "tonesets.hpp"
|
|
|
|
#include "portapack.hpp"
|
2017-04-18 11:55:49 +00:00
|
|
|
#include "baseband_api.hpp"
|
2015-09-10 18:36:39 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-04-18 11:55:49 +00:00
|
|
|
using namespace portapack;
|
2015-09-10 18:36:39 +00:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
void SigGenView::focus() {
|
2023-05-18 20:16:05 +00:00
|
|
|
options_shape.focus();
|
2017-07-18 18:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SigGenView::~SigGenView() {
|
2023-05-18 20:16:05 +00:00
|
|
|
transmitter_model.disable();
|
|
|
|
baseband::shutdown();
|
2017-07-18 18:31:05 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 17:34:53 +00:00
|
|
|
void SigGenView::update_config() {
|
2023-05-18 20:16:05 +00:00
|
|
|
if (checkbox_stop.value())
|
|
|
|
baseband::set_siggen_config(transmitter_model.channel_bandwidth(), options_shape.selected_index_value(), field_stop.value());
|
|
|
|
else
|
|
|
|
baseband::set_siggen_config(transmitter_model.channel_bandwidth(), options_shape.selected_index_value(), 0);
|
2019-02-06 17:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SigGenView::update_tone() {
|
2023-05-18 20:16:05 +00:00
|
|
|
baseband::set_siggen_tone(symfield_tone.value_dec_u32());
|
2019-02-06 17:34:53 +00:00
|
|
|
}
|
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
void SigGenView::start_tx() {
|
2023-05-18 20:16:05 +00:00
|
|
|
transmitter_model.enable();
|
|
|
|
|
|
|
|
update_tone();
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2023-05-18 20:16:05 +00:00
|
|
|
/*auto duration = field_stop.value();
|
|
|
|
if (!checkbox_auto.value())
|
|
|
|
duration = 0;*/
|
|
|
|
update_config();
|
|
|
|
}
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-09-24 19:05:42 +00:00
|
|
|
void SigGenView::on_tx_progress(const uint32_t progress, const bool done) {
|
2023-05-18 20:16:05 +00:00
|
|
|
(void)progress;
|
|
|
|
|
|
|
|
if (done) {
|
|
|
|
transmitter_model.disable();
|
|
|
|
tx_view.set_transmitting(false);
|
|
|
|
}
|
2017-04-18 11:55:49 +00:00
|
|
|
}
|
2015-09-10 18:36:39 +00:00
|
|
|
|
2017-07-18 18:31:05 +00:00
|
|
|
SigGenView::SigGenView(
|
2023-05-18 20:16:05 +00:00
|
|
|
NavigationView& nav) {
|
|
|
|
baseband::run_image(portapack::spi_flash::image_tag_siggen);
|
|
|
|
|
|
|
|
add_children({&labels,
|
|
|
|
&options_shape,
|
|
|
|
&text_shape,
|
|
|
|
&symfield_tone,
|
|
|
|
&button_update,
|
|
|
|
&checkbox_auto,
|
|
|
|
&checkbox_stop,
|
|
|
|
&field_stop,
|
|
|
|
&tx_view});
|
|
|
|
|
|
|
|
options_shape.on_change = [this](size_t, OptionsField::value_t v) {
|
|
|
|
text_shape.set(shape_strings[v]);
|
|
|
|
if (auto_update)
|
|
|
|
update_config();
|
|
|
|
};
|
|
|
|
options_shape.set_selected_index(0);
|
|
|
|
text_shape.set(shape_strings[0]);
|
|
|
|
|
|
|
|
field_stop.set_value(1);
|
|
|
|
|
|
|
|
symfield_tone.set_sym(1, 1); // Default: 1000 Hz
|
|
|
|
symfield_tone.on_change = [this]() {
|
|
|
|
if (auto_update)
|
|
|
|
update_tone();
|
|
|
|
};
|
|
|
|
|
|
|
|
button_update.on_select = [this](Button&) {
|
|
|
|
update_tone();
|
|
|
|
update_config();
|
|
|
|
};
|
|
|
|
|
|
|
|
checkbox_auto.on_select = [this](Checkbox&, bool v) {
|
|
|
|
auto_update = v;
|
|
|
|
};
|
|
|
|
|
|
|
|
tx_view.on_edit_frequency = [this, &nav]() {
|
2023-06-11 18:47:13 +00:00
|
|
|
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.target_frequency());
|
2023-05-18 20:16:05 +00:00
|
|
|
new_view->on_changed = [this](rf::Frequency f) {
|
2023-06-11 18:47:13 +00:00
|
|
|
transmitter_model.set_target_frequency(f);
|
2023-05-18 20:16:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
tx_view.on_start = [this]() {
|
|
|
|
start_tx();
|
|
|
|
tx_view.set_transmitting(true);
|
|
|
|
};
|
2017-07-18 18:31:05 +00:00
|
|
|
|
2023-05-18 20:16:05 +00:00
|
|
|
tx_view.on_stop = [this]() {
|
|
|
|
transmitter_model.disable();
|
|
|
|
tx_view.set_transmitting(false);
|
|
|
|
};
|
2015-09-10 18:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|