2016-08-03 02:53:51 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
2016-11-30 06:41:55 +00:00
|
|
|
#include "ui_navigation.hpp"
|
|
|
|
#include "ui_font_fixed_8x16.hpp"
|
2016-08-03 02:53:51 +00:00
|
|
|
#include "message.hpp"
|
|
|
|
#include "transmitter_model.hpp"
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2016-08-06 10:55:39 +00:00
|
|
|
#define ENC_TYPES_COUNT 14
|
2016-08-06 06:49:45 +00:00
|
|
|
|
2016-08-03 02:53:51 +00:00
|
|
|
class EncodersView : public View {
|
|
|
|
public:
|
|
|
|
EncodersView(NavigationView& nav);
|
|
|
|
~EncodersView();
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
void on_show() override;
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
|
|
|
|
std::string title() const override { return "Encoders TX"; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct encoder_def_t {
|
2016-09-27 01:06:14 +00:00
|
|
|
std::string name; // Encoder chip ref/name
|
|
|
|
std::string address_symbols; // "01", "01F"...
|
|
|
|
std::string data_symbols; // Same
|
|
|
|
uint16_t clk_per_symbol; // Oscillator periods per symbol
|
|
|
|
uint16_t clk_per_fragment; // Oscillator periods per symbol fragment (state)
|
|
|
|
std::vector<std::string> bit_format; // List of fragments for each symbol in previous *_symbols list order
|
|
|
|
uint8_t word_length; // Total # of symbols (not counting sync)
|
|
|
|
std::string word_format; // A for Address, D for Data, S for sync
|
|
|
|
std::string sync; // Like bit_format
|
|
|
|
uint32_t default_frequency; // Default encoder clk frequency (often set by shitty resistor)
|
|
|
|
uint8_t repeat_min; // Minimum repeat count
|
|
|
|
uint16_t pause_symbols; // Length of pause between repeats in symbols
|
2016-08-03 02:53:51 +00:00
|
|
|
};
|
|
|
|
|
2016-08-06 06:49:45 +00:00
|
|
|
const encoder_def_t encoder_defs[ENC_TYPES_COUNT] = {
|
2016-08-06 10:55:39 +00:00
|
|
|
// PT2260-R2
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"2260-R2",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01F", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
1024, 128,
|
2016-08-03 02:53:51 +00:00
|
|
|
{ "10001000", "11101110", "10001110" },
|
2016-08-06 10:55:39 +00:00
|
|
|
12, "AAAAAAAAAADDS",
|
|
|
|
"10000000000000000000000000000000",
|
2016-09-27 01:06:14 +00:00
|
|
|
150000, 2,
|
|
|
|
0
|
2016-08-06 10:55:39 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// PT2260-R4
|
|
|
|
{
|
|
|
|
"2260-R4",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01F", "01",
|
2016-08-06 10:55:39 +00:00
|
|
|
1024, 128,
|
|
|
|
{ "10001000", "11101110", "10001110" },
|
|
|
|
12, "AAAAAAAADDDDS",
|
2016-08-03 06:53:50 +00:00
|
|
|
"10000000000000000000000000000000",
|
2016-09-27 01:06:14 +00:00
|
|
|
150000, 2,
|
|
|
|
0
|
2016-08-06 06:49:45 +00:00
|
|
|
},
|
2016-08-03 02:53:51 +00:00
|
|
|
|
|
|
|
// PT2262
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"2262 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01F", "01F",
|
|
|
|
32, 4,
|
2016-08-03 02:53:51 +00:00
|
|
|
{ "10001000", "11101110", "10001110" },
|
2016-08-06 10:55:39 +00:00
|
|
|
12, "AAAAAAAAAAAAS",
|
2016-08-06 06:49:45 +00:00
|
|
|
"10000000000000000000000000000000",
|
2016-09-27 01:06:14 +00:00
|
|
|
20000, 4,
|
|
|
|
0
|
2016-08-06 06:49:45 +00:00
|
|
|
},
|
|
|
|
|
2016-08-06 10:55:39 +00:00
|
|
|
// 16-bit ?
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"16-bit ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
32, 8,
|
|
|
|
{ "1110", "1000" }, // Opposite ?
|
2016-08-06 10:55:39 +00:00
|
|
|
16, "AAAAAAAAAAAAAAAAS",
|
|
|
|
"100000000000000000000",
|
|
|
|
25000, 50,
|
|
|
|
0 // ?
|
2016-08-06 06:49:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// RT1527
|
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"1527 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
128, 32,
|
|
|
|
{ "1000", "1110" },
|
2016-08-06 10:55:39 +00:00
|
|
|
24, "SAAAAAAAAAAAAAAAAAAAADDDD",
|
2016-08-06 06:49:45 +00:00
|
|
|
"10000000000000000000000000000000",
|
|
|
|
100000, 4,
|
|
|
|
10 // ?
|
|
|
|
},
|
2016-08-03 02:53:51 +00:00
|
|
|
|
|
|
|
// HK526E
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"526 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
24, 8,
|
2016-08-03 02:53:51 +00:00
|
|
|
{ "110", "100" },
|
2016-08-06 10:55:39 +00:00
|
|
|
12, "AAAAAAAAAAAA",
|
2016-08-03 06:53:50 +00:00
|
|
|
"",
|
2016-08-06 06:49:45 +00:00
|
|
|
20000, 4,
|
|
|
|
10 // ?
|
|
|
|
},
|
2016-08-03 02:53:51 +00:00
|
|
|
|
|
|
|
// HT12E
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"12E ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
3, 1,
|
2016-08-03 02:53:51 +00:00
|
|
|
{ "011", "001" },
|
2016-08-06 10:55:39 +00:00
|
|
|
12, "SAAAAAAAADDDD",
|
2016-08-03 06:53:50 +00:00
|
|
|
"0000000000000000000000000000000000001",
|
2016-08-06 06:49:45 +00:00
|
|
|
3000, 4,
|
|
|
|
10 // ?
|
|
|
|
},
|
2016-08-03 02:53:51 +00:00
|
|
|
|
|
|
|
// VD5026 13 bits ?
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"5026 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"0123", "0123",
|
2016-08-06 06:49:45 +00:00
|
|
|
128, 8,
|
2016-08-03 02:53:51 +00:00
|
|
|
{ "1000000010000000", "1111111011111110", "1111111010000000", "1000000011111110" },
|
2016-08-06 10:55:39 +00:00
|
|
|
12, "SAAAAAAAAAAAA",
|
2016-08-03 06:53:50 +00:00
|
|
|
"000000000000000000000000000000000000000000000001", // ?
|
2016-08-06 06:49:45 +00:00
|
|
|
100000, 4,
|
|
|
|
10 // ?
|
|
|
|
},
|
2016-08-03 06:53:50 +00:00
|
|
|
|
2016-08-03 02:53:51 +00:00
|
|
|
// UM3750
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"UM3750 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
96, 32,
|
2016-08-03 02:53:51 +00:00
|
|
|
{ "011", "001" },
|
2016-08-06 10:55:39 +00:00
|
|
|
12, "SAAAAAAAAAAAA",
|
2016-08-03 06:53:50 +00:00
|
|
|
"1",
|
2016-08-06 06:49:45 +00:00
|
|
|
100000, 4,
|
2016-09-27 01:06:14 +00:00
|
|
|
0 // ?
|
2016-08-06 06:49:45 +00:00
|
|
|
},
|
2016-08-03 02:53:51 +00:00
|
|
|
|
|
|
|
// UM3758
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"UM3758 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01F", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
96, 16,
|
2016-08-03 02:53:51 +00:00
|
|
|
{ "011011", "001001", "011001" },
|
2016-08-06 10:55:39 +00:00
|
|
|
18, "SAAAAAAAAAADDDDDDDD",
|
2016-08-03 06:53:50 +00:00
|
|
|
"1",
|
2016-08-06 06:49:45 +00:00
|
|
|
160000, 4,
|
|
|
|
10 // ?
|
|
|
|
},
|
2016-08-03 06:53:50 +00:00
|
|
|
|
|
|
|
// BA5104
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"BA5104 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
3072, 768,
|
2016-08-03 06:53:50 +00:00
|
|
|
{ "1000", "1110" },
|
2016-08-06 10:55:39 +00:00
|
|
|
9, "SDDAAAAAAA",
|
2016-08-03 06:53:50 +00:00
|
|
|
"",
|
2016-08-06 06:49:45 +00:00
|
|
|
455000, 4,
|
|
|
|
10 // ?
|
|
|
|
},
|
2016-08-03 06:53:50 +00:00
|
|
|
|
|
|
|
// MC145026
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"145026 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01F", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
16, 1,
|
2016-08-03 06:53:50 +00:00
|
|
|
{ "0111111101111111", "0100000001000000", "0111111101000000" },
|
2016-08-06 10:55:39 +00:00
|
|
|
9, "SAAAAADDDD",
|
2016-08-03 06:53:50 +00:00
|
|
|
"000000000000000000",
|
2016-08-06 06:49:45 +00:00
|
|
|
455000, 2,
|
2016-11-30 06:41:55 +00:00
|
|
|
2
|
2016-08-06 06:49:45 +00:00
|
|
|
},
|
2016-08-03 06:53:50 +00:00
|
|
|
|
2016-08-06 10:55:39 +00:00
|
|
|
// HT6*** TODO: Add individual variations
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"HT6*** ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01F", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
198, 33,
|
2016-08-03 06:53:50 +00:00
|
|
|
{ "011011", "001001", "001011" },
|
2016-08-06 10:55:39 +00:00
|
|
|
18, "SAAAAAAAAAAAADDDDDD",
|
2016-08-03 06:53:50 +00:00
|
|
|
"0000000000000000000000000000000000001011001011001",
|
2016-11-30 06:41:55 +00:00
|
|
|
80000, 3,
|
2016-08-06 06:49:45 +00:00
|
|
|
10 // ?
|
|
|
|
},
|
2016-08-03 06:53:50 +00:00
|
|
|
|
|
|
|
// TC9148
|
2016-08-06 06:49:45 +00:00
|
|
|
{
|
2016-08-06 10:55:39 +00:00
|
|
|
"TC9148 ",
|
2016-09-27 01:06:14 +00:00
|
|
|
"01", "01",
|
2016-08-06 06:49:45 +00:00
|
|
|
48, 12,
|
2016-08-03 06:53:50 +00:00
|
|
|
{ "1000", "1110", },
|
2016-08-06 10:55:39 +00:00
|
|
|
12, "AAAAAAAAAAAA",
|
2016-08-03 06:53:50 +00:00
|
|
|
"",
|
2016-08-06 06:49:45 +00:00
|
|
|
455000, 3,
|
|
|
|
10 // ?
|
|
|
|
}
|
2016-08-03 02:53:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum tx_modes {
|
|
|
|
IDLE = 0,
|
|
|
|
SINGLE,
|
|
|
|
SCAN
|
|
|
|
};
|
|
|
|
|
2016-08-06 06:49:45 +00:00
|
|
|
Painter * painter_;
|
2016-08-03 02:53:51 +00:00
|
|
|
uint8_t enc_type = 0;
|
2016-08-03 06:53:50 +00:00
|
|
|
const encoder_def_t * encoder_def;
|
2016-08-03 02:53:51 +00: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";
|
|
|
|
//rf::Frequency f;
|
2016-08-03 06:53:50 +00:00
|
|
|
uint8_t repeat_index;
|
2016-08-03 02:53:51 +00:00
|
|
|
|
2016-08-06 06:49:45 +00:00
|
|
|
void draw_waveform();
|
2016-08-03 02:53:51 +00:00
|
|
|
void on_bitfield();
|
|
|
|
void on_type_change(size_t index);
|
|
|
|
void generate_frame();
|
|
|
|
void update_progress();
|
|
|
|
void start_tx(const bool scan);
|
|
|
|
void on_txdone(int n);
|
|
|
|
|
|
|
|
const Style style_val {
|
|
|
|
.font = font::fixed_8x16,
|
2016-12-09 01:35:50 +00:00
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::green(),
|
2016-08-03 02:53:51 +00:00
|
|
|
};
|
|
|
|
const Style style_cancel {
|
|
|
|
.font = font::fixed_8x16,
|
2016-12-09 01:35:50 +00:00
|
|
|
.background = Color::black(),
|
|
|
|
.foreground = Color::red(),
|
2016-08-03 02:53:51 +00:00
|
|
|
};
|
|
|
|
|
2016-08-03 06:53:50 +00: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(),
|
|
|
|
};
|
|
|
|
|
2016-08-03 02:53:51 +00:00
|
|
|
Text text_enctype {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 1 * 8, 24, 5 * 8, 16 },
|
|
|
|
"Type:"
|
2016-08-03 02:53:51 +00:00
|
|
|
};
|
2016-09-27 01:06:14 +00:00
|
|
|
OptionsField options_enctype { // Options are loaded at runtime
|
|
|
|
{ 6 * 8, 24 },
|
2016-08-06 10:55:39 +00:00
|
|
|
7,
|
2016-08-03 02:53:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_clk {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 16 * 8, 3 * 8, 4 * 8, 16 },
|
2016-08-03 02:53:51 +00:00
|
|
|
"Clk:"
|
|
|
|
};
|
|
|
|
NumberField numberfield_clk {
|
|
|
|
{ 21 * 8, 3 * 8 },
|
|
|
|
3,
|
2016-08-03 06:53:50 +00:00
|
|
|
{ 1, 500 },
|
2016-08-03 02:53:51 +00:00
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
Text text_kHz {
|
|
|
|
{ 24 * 8, 3 * 8, 3 * 8, 16 },
|
|
|
|
"kHz"
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_bitduration {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 16 * 8, 5 * 8, 4 * 8, 16 },
|
2016-08-03 02:53:51 +00:00
|
|
|
"Bit:"
|
|
|
|
};
|
|
|
|
NumberField numberfield_bitduration {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 21 * 8, 5 * 8 },
|
2016-08-03 02:53:51 +00:00
|
|
|
4,
|
2016-08-03 06:53:50 +00:00
|
|
|
{ 50, 9999 },
|
2016-08-03 02:53:51 +00:00
|
|
|
1,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
Text text_us1 {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 25 * 8, 5 * 8, 2 * 8, 16 },
|
2016-08-03 02:53:51 +00:00
|
|
|
"us"
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_wordduration {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 15 * 8, 7 * 8, 5 * 8, 16 },
|
2016-08-03 02:53:51 +00:00
|
|
|
"Word:"
|
|
|
|
};
|
|
|
|
NumberField numberfield_wordduration {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 21 * 8, 7 * 8 },
|
2016-08-03 02:53:51 +00:00
|
|
|
5,
|
|
|
|
{ 300, 99999 },
|
|
|
|
100,
|
|
|
|
' '
|
|
|
|
};
|
|
|
|
Text text_us2 {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 26 * 8, 7 * 8, 2 * 8, 16 },
|
2016-08-03 02:53:51 +00:00
|
|
|
"us"
|
|
|
|
};
|
|
|
|
|
2016-09-27 01:06:14 +00:00
|
|
|
Text text_symfield {
|
|
|
|
{ 2 * 8, 9 * 8, 5 * 8, 16 },
|
2016-08-03 02:53:51 +00:00
|
|
|
"Word:"
|
|
|
|
};
|
2016-09-27 01:06:14 +00:00
|
|
|
SymField symfield_word {
|
|
|
|
{ 2 * 8, 11 * 8 },
|
|
|
|
20
|
|
|
|
};
|
|
|
|
Text text_format {
|
|
|
|
{ 2 * 8, 13 * 8, 24 * 8, 16 },
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2016-08-06 06:49:45 +00:00
|
|
|
//Text text_format_a; // DEBUG
|
|
|
|
//Text text_format_d; // DEBUG
|
2016-08-03 02:53:51 +00:00
|
|
|
|
|
|
|
Text text_waveform {
|
2016-09-27 01:06:14 +00:00
|
|
|
{ 1 * 8, 136, 9 * 8, 16 },
|
2016-08-03 02:53:51 +00:00
|
|
|
"Waveform:"
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_status {
|
|
|
|
{ 2 * 8, 224, 128, 16 },
|
|
|
|
"Ready"
|
|
|
|
};
|
|
|
|
ProgressBar progress {
|
|
|
|
{ 16, 224 + 20, 208, 16 }
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_transmit {
|
|
|
|
{ 16, 270, 80, 32 },
|
|
|
|
"TX"
|
|
|
|
};
|
|
|
|
|
|
|
|
MessageHandlerRegistration message_handler_tx_done {
|
|
|
|
Message::ID::TXDone,
|
|
|
|
[this](const Message* const p) {
|
|
|
|
const auto message = *reinterpret_cast<const TXDoneMessage*>(p);
|
|
|
|
this->on_txdone(message.n);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|