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"
|
2017-08-28 17:17:02 -04:00
|
|
|
#include "ui_tabview.hpp"
|
2017-02-07 17:12:20 -05:00
|
|
|
#include "ui_transmitter.hpp"
|
2017-08-28 17:17:02 -04:00
|
|
|
#include "transmitter_model.hpp"
|
2016-12-09 12:21:47 -05:00
|
|
|
#include "encoders.hpp"
|
2017-07-20 11:48:59 -04:00
|
|
|
#include "de_bruijn.hpp"
|
2022-05-13 08:38:04 -04:00
|
|
|
#include "app_settings.hpp"
|
2016-08-02 22:53:51 -04:00
|
|
|
|
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
|
|
|
|
2017-08-28 17:17:02 -04:00
|
|
|
class EncodersConfigView : public View {
|
2016-08-02 22:53:51 -04:00
|
|
|
public:
|
2017-08-28 17:17:02 -04:00
|
|
|
EncodersConfigView(NavigationView& nav, Rect parent_rect);
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-08-28 17:17:02 -04:00
|
|
|
EncodersConfigView(const EncodersConfigView&) = delete;
|
|
|
|
EncodersConfigView(EncodersConfigView&&) = delete;
|
|
|
|
EncodersConfigView& operator=(const EncodersConfigView&) = delete;
|
|
|
|
EncodersConfigView& operator=(EncodersConfigView&&) = delete;
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2016-08-02 22:53:51 -04:00
|
|
|
void focus() override;
|
|
|
|
void on_show() override;
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-08-28 17:17:02 -04:00
|
|
|
uint8_t repeat_min();
|
|
|
|
uint32_t samples_per_bit();
|
|
|
|
uint32_t pause_symbols();
|
|
|
|
void generate_frame();
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-09-21 04:18:17 -04:00
|
|
|
std::string frame_fragments = "0";
|
2016-08-02 22:53:51 -04:00
|
|
|
|
|
|
|
private:
|
2020-05-26 05:45:48 -04:00
|
|
|
int16_t waveform_buffer[550];
|
2017-08-28 17:17:02 -04:00
|
|
|
const encoder_def_t * encoder_def { };
|
|
|
|
|
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);
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-02-13 00:35:13 -05:00
|
|
|
Labels labels {
|
2017-08-28 17:17:02 -04:00
|
|
|
{ { 1 * 8, 0 }, "Type:", Color::light_grey() },
|
2022-12-05 09:51:23 -05:00
|
|
|
{ { 17 * 8, 0 }, "Repeat:", Color::light_grey() },
|
2022-08-01 02:38:35 -04:00
|
|
|
{ { 1 * 8, 2 * 8 }, "Clk:", Color::light_grey() },
|
|
|
|
{ { 10 * 8, 2 * 8 }, "kHz", Color::light_grey() },
|
2022-12-05 09:51:23 -05:00
|
|
|
{ { 17 * 8, 2 * 8 }, "Step:", Color::light_grey() },
|
2022-08-01 02:38:35 -04:00
|
|
|
{ { 1 * 8, 4 * 8 }, "Frame:", Color::light_grey() },
|
2022-12-05 09:51:23 -05:00
|
|
|
{ { 13 * 8, 4 * 8 }, "us", Color::light_grey() },
|
|
|
|
{ { 17 * 8, 4 * 8 }, "Step:", Color::light_grey() },
|
2022-08-01 02:38:35 -04:00
|
|
|
{ { 2 * 8, 7 * 8 }, "Symbols:", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 14 * 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-08-28 17:17:02 -04:00
|
|
|
{ 6 * 8, 0 },
|
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
|
|
|
|
2017-08-29 04:42:04 -04:00
|
|
|
NumberField field_clk {
|
2022-08-01 02:38:35 -04:00
|
|
|
{ 5 * 8, 2 * 8 },
|
2022-08-01 01:49:09 -04:00
|
|
|
4,
|
|
|
|
{ 1, 1000 },
|
2016-08-02 22:53:51 -04:00
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2022-12-05 09:51:23 -05:00
|
|
|
NumberField field_repeat_min {
|
|
|
|
{ 24 * 8, 0 },
|
|
|
|
2,
|
|
|
|
{ 1, 99 },
|
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
|
2022-08-01 02:38:35 -04:00
|
|
|
OptionsField field_clk_step {
|
|
|
|
{ 22 * 8, 2 * 8 },
|
|
|
|
7,
|
|
|
|
{
|
|
|
|
{ "1", 1 },
|
|
|
|
{ "10", 10 },
|
|
|
|
{ "100", 100 }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-29 04:42:04 -04:00
|
|
|
NumberField field_frameduration {
|
2022-08-01 02:38:35 -04:00
|
|
|
{ 7 * 8, 4 * 8 },
|
2016-08-02 22:53:51 -04:00
|
|
|
5,
|
|
|
|
{ 300, 99999 },
|
|
|
|
100,
|
|
|
|
' '
|
|
|
|
};
|
2022-08-01 02:38:35 -04:00
|
|
|
|
|
|
|
OptionsField field_frameduration_step {
|
|
|
|
{ 22 * 8, 4 * 8 },
|
|
|
|
7,
|
|
|
|
{
|
|
|
|
{ "1", 1 },
|
|
|
|
{ "10", 10 },
|
|
|
|
{ "100", 100 },
|
|
|
|
{ "1000", 1000 }
|
|
|
|
}
|
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2016-09-26 21:06:14 -04:00
|
|
|
SymField symfield_word {
|
2022-08-01 02:38:35 -04:00
|
|
|
{ 2 * 8, 9 * 8 },
|
2017-01-31 19:21:13 -05:00
|
|
|
20,
|
|
|
|
SymField::SYMFIELD_DEF
|
2016-09-26 21:06:14 -04:00
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2016-09-26 21:06:14 -04:00
|
|
|
Text text_format {
|
2022-08-01 02:38:35 -04:00
|
|
|
{ 2 * 8, 11 * 8, 24 * 8, 16 },
|
2016-09-26 21:06:14 -04:00
|
|
|
""
|
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-01-08 21:45:29 -05:00
|
|
|
Waveform waveform {
|
2022-08-01 02:38:35 -04:00
|
|
|
{ 0, 17 * 8, 240, 32 },
|
2017-01-08 21:45:29 -05:00
|
|
|
waveform_buffer,
|
|
|
|
0,
|
|
|
|
0,
|
2017-01-17 02:00:42 -05:00
|
|
|
true,
|
2017-01-08 21:45:29 -05:00
|
|
|
Color::yellow()
|
|
|
|
};
|
2017-08-28 17:17:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class EncodersScanView : public View {
|
|
|
|
public:
|
|
|
|
EncodersScanView(NavigationView& nav, Rect parent_rect);
|
|
|
|
|
2022-12-05 09:51:23 -05:00
|
|
|
NumberField field_length {
|
|
|
|
{ 8 * 8, 0 },
|
|
|
|
2,
|
|
|
|
{ 3, 24 },
|
|
|
|
1,
|
|
|
|
' '
|
2017-08-28 17:17:02 -04:00
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
|
|
|
NumberField bit_length_10 {
|
|
|
|
{ 12 * 8, 2 * 8 },
|
2017-08-28 17:17:02 -04:00
|
|
|
2,
|
2022-12-05 09:51:23 -05:00
|
|
|
{ 1, 88 },
|
2017-08-28 17:17:02 -04:00
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
|
|
|
NumberField bit_length {
|
|
|
|
{ 14 * 8, 2 * 8 },
|
|
|
|
1,
|
|
|
|
{ 0, 9 },
|
|
|
|
1,
|
|
|
|
' '
|
2017-08-28 17:17:02 -04:00
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Labels labels {
|
|
|
|
{ { 1 * 8, 0 * 8 }, "Length:", Color::light_grey() },
|
|
|
|
{ { 1 * 8, 2 * 8 }, "Bit length:", Color::light_grey() },
|
|
|
|
{ { 16 * 8, 2 * 8 }, "us", Color::light_grey() },
|
2017-08-29 04:42:04 -04:00
|
|
|
};
|
2017-08-28 17:17:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class EncodersView : public View {
|
|
|
|
public:
|
|
|
|
EncodersView(NavigationView& nav);
|
|
|
|
~EncodersView();
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-08-28 17:17:02 -04:00
|
|
|
void focus() override;
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2022-04-26 17:09:24 -04:00
|
|
|
std::string title() const override { return "OOK TX"; };
|
2017-08-28 17:17:02 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
NavigationView& nav_;
|
|
|
|
|
|
|
|
enum tx_modes {
|
|
|
|
IDLE = 0,
|
|
|
|
SINGLE,
|
|
|
|
SCAN
|
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2022-05-13 08:38:04 -04:00
|
|
|
// app save settings
|
2022-12-05 09:51:23 -05:00
|
|
|
std::app_settings settings { };
|
2022-05-13 08:38:04 -04:00
|
|
|
std::app_settings::AppSettings app_settings { };
|
|
|
|
|
2017-08-28 17:17:02 -04:00
|
|
|
tx_modes tx_mode = IDLE;
|
2022-12-05 09:51:23 -05:00
|
|
|
uint32_t repeat_index { 0 };
|
|
|
|
uint32_t repeat_min { 0 };
|
|
|
|
|
2017-08-28 17:17:02 -04:00
|
|
|
void update_progress();
|
|
|
|
void start_tx(const bool scan);
|
2017-09-24 15:05:42 -04:00
|
|
|
void on_tx_progress(const uint32_t progress, const bool done);
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-09-02 03:28:29 -04:00
|
|
|
/*const Style style_address {
|
2017-08-28 17:17:02 -04:00
|
|
|
.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-09-02 03:28:29 -04:00
|
|
|
};*/
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-08-29 04:42:04 -04:00
|
|
|
Rect view_rect = { 0, 4 * 8, 240, 168 };
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-08-28 17:17:02 -04:00
|
|
|
EncodersConfigView view_config { nav_, view_rect };
|
|
|
|
EncodersScanView view_scan { nav_, view_rect };
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-08-28 17:17:02 -04:00
|
|
|
TabView tab_view {
|
|
|
|
{ "Config", Color::cyan(), &view_config },
|
2022-12-05 09:51:23 -05:00
|
|
|
{ "de Bruijn", Color::green(), &view_scan },
|
2017-08-28 17:17:02 -04:00
|
|
|
};
|
|
|
|
|
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"
|
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-09-24 15:05:42 -04:00
|
|
|
ProgressBar progressbar {
|
2017-02-07 17:12:20 -05:00
|
|
|
{ 2 * 8, 13 * 16 + 20, 208, 16 }
|
2016-08-02 22:53:51 -04:00
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-02-07 17:12:20 -05:00
|
|
|
TransmitterView tx_view {
|
|
|
|
16 * 16,
|
|
|
|
50000,
|
|
|
|
9
|
2016-08-02 22:53:51 -04:00
|
|
|
};
|
2022-12-05 09:51:23 -05:00
|
|
|
|
2017-09-24 15:05:42 -04:00
|
|
|
MessageHandlerRegistration message_handler_tx_progress {
|
|
|
|
Message::ID::TXProgress,
|
2016-08-02 22:53:51 -04:00
|
|
|
[this](const Message* const p) {
|
2017-09-24 15:05:42 -04:00
|
|
|
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
|
|
|
this->on_tx_progress(message.progress, message.done);
|
2016-08-02 22:53:51 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|