2016-12-09 17:21:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Keying speed: 60 or 75 PARIS
|
|
|
|
Continuous (Fox-oring)
|
|
|
|
12s transmit, 48s space (Sprint 1/5th)
|
|
|
|
60s transmit, 240s space (Classic 1/5 min)
|
|
|
|
60s transmit, 360s space (Classic 1/7 min)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ui_morse.hpp"
|
|
|
|
|
|
|
|
#include "portapack.hpp"
|
|
|
|
#include "baseband_api.hpp"
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
using namespace portapack;
|
2017-02-13 23:24:42 +00:00
|
|
|
using namespace morse;
|
2016-12-09 17:21:47 +00:00
|
|
|
|
|
|
|
// TODO: Live keying mode: Dit on left key, dah on right ?
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
void MorseView::focus() {
|
2017-02-13 23:24:42 +00:00
|
|
|
tx_view.focus();
|
2016-12-09 17:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MorseView::~MorseView() {
|
|
|
|
transmitter_model.disable();
|
|
|
|
baseband::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MorseView::paint(Painter& painter) {
|
|
|
|
(void)painter;
|
|
|
|
}
|
|
|
|
|
2017-02-13 23:24:42 +00:00
|
|
|
bool MorseView::start_tx() {
|
|
|
|
size_t symbol_count;
|
|
|
|
std::string message;
|
2016-12-09 17:21:47 +00:00
|
|
|
|
2017-02-13 23:24:42 +00:00
|
|
|
if (checkbox_foxhunt.value()) {
|
|
|
|
message = foxhunt_codes[options_foxhunt.selected_index_value()];
|
|
|
|
} else {
|
|
|
|
message = "ABCDEFGHIJKLMN";
|
|
|
|
}
|
2016-12-09 17:21:47 +00:00
|
|
|
|
2017-02-13 23:24:42 +00:00
|
|
|
symbol_count = morse_encode(message, field_time_unit.value(), field_tone.value());
|
2016-12-09 17:21:47 +00:00
|
|
|
|
2017-02-13 23:24:42 +00:00
|
|
|
if (!symbol_count) {
|
|
|
|
nav_.display_modal("Error", "Message too long.", INFO, nullptr);
|
|
|
|
return false;
|
2016-12-09 17:21:47 +00:00
|
|
|
}
|
|
|
|
|
2017-02-13 23:24:42 +00:00
|
|
|
progressbar.set_max(symbol_count);
|
2016-12-09 17:21:47 +00:00
|
|
|
|
2017-01-16 03:45:44 +00:00
|
|
|
transmitter_model.set_sampling_rate(1536000U);
|
2017-01-09 02:45:29 +00:00
|
|
|
transmitter_model.set_rf_amp(true);
|
|
|
|
transmitter_model.set_lna(40);
|
|
|
|
transmitter_model.set_vga(40);
|
|
|
|
transmitter_model.set_baseband_bandwidth(1750000);
|
|
|
|
transmitter_model.enable();
|
|
|
|
|
2017-02-13 23:24:42 +00:00
|
|
|
baseband::set_tones_data(transmitter_model.bandwidth(), 0, symbol_count, false, false);
|
|
|
|
|
|
|
|
return true;
|
2016-12-09 17:21:47 +00:00
|
|
|
}
|
|
|
|
|
2017-02-13 23:24:42 +00:00
|
|
|
void MorseView::on_tx_progress(const int progress, const bool done) {
|
|
|
|
if (done) {
|
|
|
|
transmitter_model.disable();
|
|
|
|
progressbar.set_value(0);
|
|
|
|
tx_view.set_transmitting(false);
|
|
|
|
} else
|
|
|
|
progressbar.set_value(progress);
|
2017-01-09 02:45:29 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 17:21:47 +00:00
|
|
|
MorseView::MorseView(
|
|
|
|
NavigationView& nav
|
2017-02-13 23:24:42 +00:00
|
|
|
) : nav_ (nav)
|
2016-12-09 17:21:47 +00:00
|
|
|
{
|
2017-02-13 23:24:42 +00:00
|
|
|
baseband::run_image(portapack::spi_flash::image_tag_tones);
|
|
|
|
|
2017-01-16 03:45:44 +00:00
|
|
|
add_children({
|
2016-12-26 19:33:38 +00:00
|
|
|
&checkbox_foxhunt,
|
2016-12-09 17:21:47 +00:00
|
|
|
&options_foxhunt,
|
2017-02-13 23:24:42 +00:00
|
|
|
&text_time_unit,
|
|
|
|
&field_time_unit,
|
|
|
|
&text_tone,
|
|
|
|
&field_tone,
|
|
|
|
&progressbar,
|
|
|
|
&tx_view
|
2017-01-16 03:45:44 +00:00
|
|
|
});
|
2016-12-09 17:21:47 +00:00
|
|
|
|
2017-02-13 23:24:42 +00:00
|
|
|
field_time_unit.set_value(50); // 50ms
|
|
|
|
field_tone.set_value(700); // 700Hz
|
|
|
|
|
|
|
|
tx_view.on_edit_frequency = [this, &nav]() {
|
|
|
|
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
|
|
|
|
new_view->on_changed = [this](rf::Frequency f) {
|
|
|
|
receiver_model.set_tuning_frequency(f);
|
|
|
|
};
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
2017-02-13 23:24:42 +00:00
|
|
|
|
|
|
|
tx_view.on_start = [this]() {
|
|
|
|
if (start_tx())
|
|
|
|
tx_view.set_transmitting(true);
|
|
|
|
};
|
|
|
|
|
|
|
|
tx_view.on_stop = [this]() {
|
|
|
|
tx_view.set_transmitting(false);
|
2016-12-09 17:21:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace ui */
|