2016-12-09 12:21:47 -05: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.
|
|
|
|
*/
|
|
|
|
|
2017-02-13 18:24:42 -05:00
|
|
|
#ifndef __MORSE_TX_H__
|
|
|
|
#define __MORSE_TX_H__
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
|
|
|
#include "ui_navigation.hpp"
|
2017-02-13 18:24:42 -05:00
|
|
|
#include "ui_transmitter.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2017-02-13 18:24:42 -05:00
|
|
|
#include "portapack.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "message.hpp"
|
|
|
|
#include "volume.hpp"
|
|
|
|
#include "audio.hpp"
|
2017-02-13 18:24:42 -05:00
|
|
|
#include "morse.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2017-02-14 12:16:59 -05:00
|
|
|
#include <ch.h>
|
|
|
|
|
2017-02-13 18:24:42 -05:00
|
|
|
using namespace morse;
|
2016-12-09 12:21:47 -05:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
class MorseView : public View {
|
|
|
|
public:
|
|
|
|
MorseView(NavigationView& nav);
|
|
|
|
~MorseView();
|
|
|
|
|
2017-02-14 12:16:59 -05:00
|
|
|
MorseView(const MorseView&) = delete;
|
|
|
|
MorseView(MorseView&&) = delete;
|
|
|
|
MorseView& operator=(const MorseView&) = delete;
|
|
|
|
MorseView& operator=(MorseView&&) = delete;
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
void focus() override;
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
|
2017-02-14 12:16:59 -05:00
|
|
|
void on_tx_progress(const int progress, const bool done);
|
2017-02-14 22:05:38 -05:00
|
|
|
|
|
|
|
std::string title() const override { return "Morse TX"; };
|
|
|
|
|
2017-02-14 12:16:59 -05:00
|
|
|
uint32_t time_unit_ms { 0 };
|
|
|
|
size_t symbol_count { 0 };
|
2016-12-09 12:21:47 -05:00
|
|
|
private:
|
2017-02-13 18:24:42 -05:00
|
|
|
NavigationView& nav_;
|
2017-04-18 13:12:32 -04:00
|
|
|
std::string buffer { "PORTAPACK" };
|
2017-02-14 12:16:59 -05:00
|
|
|
std::string message { };
|
2017-02-14 23:27:51 -05:00
|
|
|
uint32_t time_units { 0 };
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2017-03-03 03:06:11 -05:00
|
|
|
enum modulation_t {
|
|
|
|
CW = 0,
|
|
|
|
FM = 1
|
|
|
|
};
|
|
|
|
modulation_t modulation { CW };
|
|
|
|
|
2017-02-13 18:24:42 -05:00
|
|
|
bool start_tx();
|
2017-02-14 23:27:51 -05:00
|
|
|
void update_tx_duration();
|
2017-02-14 12:16:59 -05:00
|
|
|
void on_set_text(NavigationView& nav);
|
2017-03-03 03:06:11 -05:00
|
|
|
void set_foxhunt(size_t i);
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2017-03-03 03:06:11 -05:00
|
|
|
Thread * ookthread { nullptr };
|
|
|
|
bool foxhunt_mode { false };
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2017-02-14 12:16:59 -05:00
|
|
|
Labels labels {
|
|
|
|
{ { 4 * 8, 6 * 8 }, "Time unit: ms", Color::light_grey() },
|
|
|
|
{ { 4 * 8, 8 * 8 }, "Tone: Hz", Color::light_grey() },
|
|
|
|
{ { 4 * 8, 10 * 8 }, "Modulation:", Color::light_grey() },
|
2017-03-03 03:06:11 -05:00
|
|
|
{ { 1 * 8, 25 * 8 }, "TX will last", Color::light_grey() }
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
|
|
|
|
2016-12-26 14:33:38 -05:00
|
|
|
Checkbox checkbox_foxhunt {
|
2017-02-13 18:24:42 -05:00
|
|
|
{ 4 * 8, 16 },
|
2016-12-26 14:33:38 -05:00
|
|
|
8,
|
|
|
|
"Foxhunt:"
|
|
|
|
};
|
2016-12-09 12:21:47 -05:00
|
|
|
OptionsField options_foxhunt {
|
2017-02-13 18:24:42 -05:00
|
|
|
{ 17 * 8, 16 + 4 },
|
2016-12-09 12:21:47 -05:00
|
|
|
7,
|
|
|
|
{
|
2017-03-03 03:06:11 -05:00
|
|
|
{ "1 (MOE)", 0 },
|
|
|
|
{ "2 (MOI)", 1 },
|
|
|
|
{ "3 (MOS)", 2 },
|
|
|
|
{ "4 (MOH)", 3 },
|
|
|
|
{ "5 (MO5)", 4 },
|
|
|
|
{ "6 (MON)", 5 },
|
|
|
|
{ "7 (MOD)", 6 },
|
|
|
|
{ "8 (MOB)", 7 },
|
|
|
|
{ "9 (MO6)", 8 },
|
|
|
|
{ "X (MO) ", 9 },
|
|
|
|
{ "T (S) ", 10 }
|
2016-12-09 12:21:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-14 12:16:59 -05:00
|
|
|
NumberField field_time_unit {
|
|
|
|
{ 14 * 8, 6 * 8 },
|
|
|
|
3,
|
|
|
|
{ 10, 999 },
|
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
|
|
|
NumberField field_tone {
|
|
|
|
{ 9 * 8, 8 * 8 },
|
|
|
|
4,
|
|
|
|
{ 100, 9999 },
|
|
|
|
20,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
|
|
|
OptionsField options_modulation {
|
|
|
|
{ 15 * 8, 10 * 8 },
|
|
|
|
2,
|
|
|
|
{
|
|
|
|
{ "CW", 0 },
|
|
|
|
{ "FM", 1 }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-14 23:27:51 -05:00
|
|
|
Text text_tx_duration {
|
2017-03-03 03:06:11 -05:00
|
|
|
{ 14 * 8, 25 * 8, 4 * 8, 16 },
|
2017-02-14 23:27:51 -05:00
|
|
|
"-"
|
|
|
|
};
|
|
|
|
|
2017-02-14 12:16:59 -05:00
|
|
|
Text text_message {
|
2017-03-03 03:06:11 -05:00
|
|
|
{ 1 * 8, 15 * 8, 28 * 8, 16 },
|
2017-02-14 12:16:59 -05:00
|
|
|
""
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_message {
|
2017-03-03 03:06:11 -05:00
|
|
|
{ 1 * 8, 17 * 8, 12 * 8, 28 },
|
2017-02-14 12:16:59 -05:00
|
|
|
"Set message"
|
|
|
|
};
|
|
|
|
|
2017-02-13 18:24:42 -05:00
|
|
|
ProgressBar progressbar {
|
2017-02-14 23:27:51 -05:00
|
|
|
{ 2 * 8, 28 * 8, 208, 16 }
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
|
|
|
|
2017-02-13 18:24:42 -05:00
|
|
|
TransmitterView tx_view {
|
|
|
|
16 * 16,
|
|
|
|
10000,
|
|
|
|
12
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
2017-01-08 21:45:29 -05:00
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_tx_done {
|
|
|
|
Message::ID::TXDone,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
const auto message = *reinterpret_cast<const TXDoneMessage*>(p);
|
2017-02-13 18:24:42 -05:00
|
|
|
this->on_tx_progress(message.progress, message.done);
|
2017-01-08 21:45:29 -05:00
|
|
|
}
|
|
|
|
};
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|
2017-02-13 18:24:42 -05:00
|
|
|
|
|
|
|
#endif/*__MORSE_TX_H__*/
|