2016-08-02 22:53:51 -04: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
2016-11-30 01:41:55 -05:00
|
|
|
#include "ui_navigation.hpp"
|
|
|
|
#include "ui_font_fixed_8x16.hpp"
|
2017-01-08 21:45:29 -05:00
|
|
|
#include "ui_receiver.hpp"
|
2017-02-07 17:12:20 -05:00
|
|
|
#include "ui_transmitter.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "encoders.hpp"
|
2016-08-02 22:53:51 -04:00
|
|
|
#include "message.hpp"
|
|
|
|
#include "transmitter_model.hpp"
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
using namespace encoders;
|
2016-08-02 22:53:51 -04:00
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
namespace ui {
|
2016-08-06 02:49:45 -04:00
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
class EncodersView : public View {
|
|
|
|
public:
|
|
|
|
EncodersView(NavigationView& nav);
|
|
|
|
~EncodersView();
|
|
|
|
|
2017-01-16 03:40:17 -05:00
|
|
|
EncodersView(const EncodersView&) = delete;
|
|
|
|
EncodersView(EncodersView&&) = delete;
|
|
|
|
EncodersView& operator=(const EncodersView&) = delete;
|
|
|
|
EncodersView& operator=(EncodersView&&) = delete;
|
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
void focus() override;
|
|
|
|
void on_show() override;
|
|
|
|
|
|
|
|
std::string title() const override { return "Encoders TX"; };
|
|
|
|
|
|
|
|
private:
|
2017-01-08 21:45:29 -05:00
|
|
|
void on_tuning_frequency_changed(rf::Frequency f);
|
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
enum tx_modes {
|
|
|
|
IDLE = 0,
|
|
|
|
SINGLE,
|
|
|
|
SCAN
|
|
|
|
};
|
|
|
|
|
|
|
|
uint8_t enc_type = 0;
|
2017-02-07 17:12:20 -05:00
|
|
|
const encoder_def_t * encoder_def { };
|
2016-08-02 22:53:51 -04:00
|
|
|
tx_modes tx_mode = IDLE;
|
|
|
|
//bool abort_scan = false;
|
|
|
|
//uint8_t scan_count;
|
|
|
|
//double scan_progress;
|
|
|
|
//unsigned int scan_index;
|
|
|
|
std::string debug_text = "0";
|
2017-02-07 17:12:20 -05:00
|
|
|
uint8_t repeat_index { 0 };
|
2017-01-08 21:45:29 -05:00
|
|
|
int8_t waveform_buffer[512];
|
2016-08-02 22:53:51 -04:00
|
|
|
|
2016-08-06 02:49:45 -04:00
|
|
|
void draw_waveform();
|
2016-08-02 22:53:51 -04:00
|
|
|
void on_bitfield();
|
|
|
|
void on_type_change(size_t index);
|
|
|
|
void generate_frame();
|
|
|
|
void update_progress();
|
|
|
|
void start_tx(const bool scan);
|
2017-01-08 16:52:54 -05:00
|
|
|
void on_txdone(int n, const bool txdone);
|
2016-08-02 22:53:51 -04:00
|
|
|
|
|
|
|
const Style style_val {
|
|
|
|
.font = font::fixed_8x16,
|
2016-12-08 20:35:50 -05:00
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::green(),
|
2016-08-02 22:53:51 -04:00
|
|
|
};
|
|
|
|
const Style style_cancel {
|
|
|
|
.font = font::fixed_8x16,
|
2016-12-08 20:35:50 -05:00
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::red(),
|
2016-08-02 22:53:51 -04:00
|
|
|
};
|
|
|
|
|
2016-08-03 02:53:50 -04:00
|
|
|
const Style style_address {
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::red(),
|
|
|
|
};
|
|
|
|
const Style style_data {
|
|
|
|
.font = font::fixed_8x16,
|
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::blue(),
|
|
|
|
};
|
|
|
|
|
2017-02-13 00:35:13 -05:00
|
|
|
Labels labels {
|
|
|
|
{ { 1 * 8, 4 * 8 }, "Type:", Color::light_grey() },
|
|
|
|
{ { 16 * 8, 4 * 8 }, "Clk:", Color::light_grey() },
|
|
|
|
{ { 24 * 8, 4 * 8 }, "kHz", Color::light_grey() },
|
|
|
|
{ { 16 * 8, 6 * 8 }, "Bit:", Color::light_grey() },
|
|
|
|
{ { 25 * 8, 6 * 8 }, "us", Color::light_grey() },
|
|
|
|
{ { 15 * 8, 8 * 8 }, "Word:", Color::light_grey() },
|
|
|
|
{ { 26 * 8, 8 * 8 }, "us", Color::light_grey() },
|
|
|
|
{ { 2 * 8, 10 * 8 }, "Word:", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 17 * 8 }, "Waveform:", Color::light_grey() }
|
2016-08-02 22:53:51 -04:00
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2016-09-26 21:06:14 -04:00
|
|
|
OptionsField options_enctype { // Options are loaded at runtime
|
2017-01-08 21:45:29 -05:00
|
|
|
{ 6 * 8, 32 },
|
2016-08-06 06:55:39 -04:00
|
|
|
7,
|
2016-08-02 22:53:51 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
NumberField numberfield_clk {
|
2017-01-08 21:45:29 -05:00
|
|
|
{ 21 * 8, 4 * 8 },
|
2016-08-02 22:53:51 -04:00
|
|
|
3,
|
2016-08-03 02:53:50 -04:00
|
|
|
{ 1, 500 },
|
2016-08-02 22:53:51 -04:00
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
NumberField numberfield_bitduration {
|
2017-01-08 21:45:29 -05:00
|
|
|
{ 21 * 8, 6 * 8 },
|
2016-08-02 22:53:51 -04:00
|
|
|
4,
|
2016-08-03 02:53:50 -04:00
|
|
|
{ 50, 9999 },
|
2016-08-02 22:53:51 -04:00
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
NumberField numberfield_wordduration {
|
2017-01-08 21:45:29 -05:00
|
|
|
{ 21 * 8, 8 * 8 },
|
2016-08-02 22:53:51 -04:00
|
|
|
5,
|
|
|
|
{ 300, 99999 },
|
|
|
|
100,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
2016-09-26 21:06:14 -04:00
|
|
|
SymField symfield_word {
|
2017-01-08 21:45:29 -05:00
|
|
|
{ 2 * 8, 12 * 8 },
|
2017-01-31 19:21:13 -05:00
|
|
|
20,
|
|
|
|
SymField::SYMFIELD_DEF
|
2016-09-26 21:06:14 -04:00
|
|
|
};
|
|
|
|
Text text_format {
|
2017-01-08 21:45:29 -05:00
|
|
|
{ 2 * 8, 14 * 8, 24 * 8, 16 },
|
2016-09-26 21:06:14 -04:00
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2016-08-06 02:49:45 -04:00
|
|
|
//Text text_format_a; // DEBUG
|
|
|
|
//Text text_format_d; // DEBUG
|
2016-08-02 22:53:51 -04:00
|
|
|
|
2017-01-08 21:45:29 -05:00
|
|
|
Waveform waveform {
|
|
|
|
{ 0, 160, 240, 32 },
|
|
|
|
waveform_buffer,
|
|
|
|
0,
|
|
|
|
0,
|
2017-01-17 02:00:42 -05:00
|
|
|
true,
|
2017-01-08 21:45:29 -05:00
|
|
|
Color::yellow()
|
|
|
|
};
|
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
Text text_status {
|
2017-02-07 17:12:20 -05:00
|
|
|
{ 2 * 8, 13 * 16, 128, 16 },
|
2016-08-02 22:53:51 -04:00
|
|
|
"Ready"
|
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
ProgressBar progress {
|
2017-02-07 17:12:20 -05:00
|
|
|
{ 2 * 8, 13 * 16 + 20, 208, 16 }
|
2016-08-02 22:53:51 -04:00
|
|
|
};
|
|
|
|
|
2017-02-07 17:12:20 -05:00
|
|
|
TransmitterView tx_view {
|
|
|
|
16 * 16,
|
|
|
|
50000,
|
|
|
|
9
|
2016-08-02 22:53:51 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_tx_done {
|
|
|
|
Message::ID::TXDone,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
const auto message = *reinterpret_cast<const TXDoneMessage*>(p);
|
2017-01-08 16:52:54 -05:00
|
|
|
this->on_txdone(message.progress, message.done);
|
2016-08-02 22:53:51 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|