2016-01-29 18:28:05 -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.
|
|
|
|
*/
|
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
#ifndef __UI_NUMBERS_H__
|
|
|
|
#define __UI_NUMBERS_H__
|
|
|
|
|
2016-01-29 18:28:05 -05:00
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
2016-12-06 07:31:38 -05:00
|
|
|
#include "ui_receiver.hpp"
|
2016-01-29 18:28:05 -05:00
|
|
|
#include "ui_navigation.hpp"
|
|
|
|
#include "ui_font_fixed_8x16.hpp"
|
2017-01-15 22:45:44 -05:00
|
|
|
#include "rtc_time.hpp"
|
2016-01-29 18:28:05 -05:00
|
|
|
#include "clock_manager.hpp"
|
2016-12-05 06:56:41 -05:00
|
|
|
#include "baseband_api.hpp"
|
2016-12-07 14:49:42 -05:00
|
|
|
#include "utility.hpp"
|
|
|
|
#include "message.hpp"
|
2017-03-21 23:21:06 -04:00
|
|
|
#include "file.hpp"
|
2017-01-15 22:45:44 -05:00
|
|
|
#include "io_wave.hpp"
|
2016-01-29 18:28:05 -05:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
class NumbersStationView : public View {
|
|
|
|
public:
|
2016-12-05 06:56:41 -05:00
|
|
|
NumbersStationView(NavigationView& nav);
|
2016-01-29 18:28:05 -05:00
|
|
|
~NumbersStationView();
|
|
|
|
|
|
|
|
void focus() override;
|
2016-12-06 07:31:38 -05:00
|
|
|
|
2016-12-05 06:56:41 -05:00
|
|
|
std::string title() const override { return "Numbers station"; };
|
|
|
|
|
2016-01-29 18:28:05 -05:00
|
|
|
private:
|
2017-03-21 23:21:06 -04:00
|
|
|
NavigationView& nav_;
|
|
|
|
|
2016-12-06 07:31:38 -05:00
|
|
|
// Sequencing state machine
|
|
|
|
enum segments {
|
2017-03-21 23:21:06 -04:00
|
|
|
IDLE = 0,
|
|
|
|
ANNOUNCE,
|
2016-12-06 07:31:38 -05:00
|
|
|
MESSAGE,
|
|
|
|
SIGNOFF
|
2016-12-05 06:56:41 -05:00
|
|
|
};
|
|
|
|
|
2016-12-06 07:31:38 -05:00
|
|
|
Style style_red {
|
|
|
|
.font = font::fixed_8x16,
|
2016-12-08 20:35:50 -05:00
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::red()
|
2016-12-06 07:31:38 -05:00
|
|
|
};
|
|
|
|
|
2017-03-21 23:21:06 -04:00
|
|
|
struct voice_t {
|
|
|
|
std::string dir;
|
|
|
|
bool accent;
|
|
|
|
bool announce;
|
|
|
|
};
|
2016-12-06 07:31:38 -05:00
|
|
|
|
2017-03-21 23:21:06 -04:00
|
|
|
segments segment { IDLE };
|
|
|
|
bool armed { false };
|
|
|
|
bool file_error { false };
|
|
|
|
std::vector<voice_t> voices;
|
2016-12-05 06:56:41 -05:00
|
|
|
|
2016-12-06 07:31:38 -05:00
|
|
|
const std::vector<std::string> file_names = {
|
|
|
|
{ "0" },
|
|
|
|
{ "1" },
|
|
|
|
{ "2" },
|
|
|
|
{ "3" },
|
|
|
|
{ "4" },
|
|
|
|
{ "5" },
|
|
|
|
{ "6" },
|
|
|
|
{ "7" },
|
|
|
|
{ "8" },
|
|
|
|
{ "9" },
|
|
|
|
{ "announce" }
|
2016-12-05 06:56:41 -05:00
|
|
|
};
|
2016-01-29 18:28:05 -05:00
|
|
|
|
2016-12-07 14:49:42 -05:00
|
|
|
// const uint8_t month_table[12] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
|
|
|
|
// const char * day_of_week[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
|
|
|
|
|
2017-03-21 23:21:06 -04:00
|
|
|
std::unique_ptr<WAVFileReader> reader { };
|
2016-12-07 14:49:42 -05:00
|
|
|
|
|
|
|
uint8_t code_index, announce_loop;
|
|
|
|
uint32_t sample_counter;
|
2016-12-05 06:56:41 -05:00
|
|
|
uint32_t sample_duration;
|
|
|
|
int8_t audio_buffer[1024];
|
2016-12-06 07:31:38 -05:00
|
|
|
uint32_t pause = 0;
|
2017-03-21 23:21:06 -04:00
|
|
|
bool armed_blink { false };
|
|
|
|
SignalToken signal_token_tick_second { };
|
2016-12-07 14:49:42 -05:00
|
|
|
|
2017-03-21 23:21:06 -04:00
|
|
|
void on_voice_changed(size_t index);
|
2016-12-07 14:49:42 -05:00
|
|
|
void on_tick_second();
|
2016-12-05 06:56:41 -05:00
|
|
|
void on_tuning_frequency_changed(rf::Frequency f);
|
|
|
|
void prepare_audio();
|
2016-12-06 07:31:38 -05:00
|
|
|
void start_tx();
|
2016-12-05 06:56:41 -05:00
|
|
|
|
2016-01-29 18:28:05 -05:00
|
|
|
// Schedule: save on sd card
|
|
|
|
// For each day of the week, max 8 messages ?
|
|
|
|
// For each message: Normal, accent. Can chose accent on first or last digit
|
|
|
|
// Prelude with number of repeats
|
|
|
|
// Message 1 with number of repeats
|
|
|
|
// Interlude ?
|
|
|
|
// Message 2 with number of repeats
|
|
|
|
// End
|
|
|
|
// Frequency list and sequence
|
|
|
|
|
2017-03-21 23:21:06 -04:00
|
|
|
Labels labels {
|
|
|
|
{ { 2 * 8, 5 * 8 }, "Voice: Flags:", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 8 * 8 }, "Code:", Color::light_grey() }
|
2016-01-29 18:28:05 -05:00
|
|
|
};
|
|
|
|
|
2017-03-21 23:21:06 -04:00
|
|
|
OptionsField options_voices {
|
|
|
|
{ 8 * 8, 1 * 8 },
|
|
|
|
4,
|
|
|
|
{ }
|
2016-12-06 07:31:38 -05:00
|
|
|
};
|
2017-03-21 23:21:06 -04:00
|
|
|
Text text_voice_flags {
|
|
|
|
{ 19 * 8, 1 * 8, 2 * 8, 16 },
|
|
|
|
""
|
2016-12-07 14:49:42 -05:00
|
|
|
};
|
2017-03-21 23:21:06 -04:00
|
|
|
|
2016-12-06 07:31:38 -05:00
|
|
|
SymField symfield_code {
|
2017-03-21 23:21:06 -04:00
|
|
|
{ 1 * 8, 10 * 8 },
|
2016-12-07 14:49:42 -05:00
|
|
|
25,
|
2017-01-31 19:21:13 -05:00
|
|
|
SymField::SYMFIELD_DEF
|
2016-12-06 07:31:38 -05:00
|
|
|
};
|
|
|
|
|
2016-12-07 14:49:42 -05:00
|
|
|
Checkbox check_armed {
|
|
|
|
{ 2 * 8, 13 * 16 },
|
|
|
|
5,
|
|
|
|
"Armed"
|
|
|
|
};
|
2017-03-21 23:21:06 -04:00
|
|
|
/*Button button_tx_now {
|
2016-12-07 14:49:42 -05:00
|
|
|
{ 18 * 8, 13 * 16, 10 * 8, 32 },
|
|
|
|
"TX now"
|
2017-03-21 23:21:06 -04:00
|
|
|
};*/
|
2016-01-29 18:28:05 -05:00
|
|
|
Button button_exit {
|
|
|
|
{ 21 * 8, 16 * 16, 64, 32 },
|
|
|
|
"Exit"
|
|
|
|
};
|
2016-12-05 06:56:41 -05:00
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_fifo_signal {
|
2017-03-14 03:24:04 -04:00
|
|
|
Message::ID::RequestSignal,
|
2016-12-05 06:56:41 -05:00
|
|
|
[this](const Message* const p) {
|
2017-03-14 03:24:04 -04:00
|
|
|
const auto message = static_cast<const RequestSignalMessage*>(p);
|
|
|
|
if (message->signal == RequestSignalMessage::Signal::FillRequest) {
|
2016-12-05 06:56:41 -05:00
|
|
|
this->prepare_audio();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-01-29 18:28:05 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|
2016-12-05 06:56:41 -05:00
|
|
|
|
|
|
|
#endif/*__UI_NUMBERS_H__*/
|