Fixed xx2262 remote encoder def

SymField now shows symbol chars
This commit is contained in:
furrtek 2016-09-27 03:06:14 +02:00
parent 8276e5e311
commit 8c70ef08f8
5 changed files with 159 additions and 123 deletions

View File

@ -36,7 +36,7 @@ using namespace portapack;
namespace ui { namespace ui {
void EncodersView::focus() { void EncodersView::focus() {
bitfield.focus(); options_enctype.focus();
} }
EncodersView::~EncodersView() { EncodersView::~EncodersView() {
@ -54,8 +54,7 @@ void EncodersView::generate_frame() {
if (c == 'S') if (c == 'S')
debug_text += encoder_def->sync; debug_text += encoder_def->sync;
else else
debug_text += encoder_def->bit_format.at(bitfield.value(i)); debug_text += encoder_def->bit_format[symfield_word.value(i++)];
i++;
} }
draw_waveform(); draw_waveform();
@ -67,7 +66,7 @@ void EncodersView::draw_waveform() {
uint8_t prelude_length = 0; //encoder_def->sync.length(); uint8_t prelude_length = 0; //encoder_def->sync.length();
// Clear // Clear
painter_->fill_rectangle( { 0, 160, 240, 24 }, Color::black() ); painter_->fill_rectangle( { 0, 168, 240, 24 }, Color::black() );
x_inc = 230.0 / (debug_text.length() - prelude_length); x_inc = 230.0 / (debug_text.length() - prelude_length);
@ -78,9 +77,9 @@ void EncodersView::draw_waveform() {
y = 0; y = 0;
// Edge // Edge
if (prev_y != y) painter_->draw_rectangle( { (Coord)x, 160, 1, 24 }, Color::yellow() ); if (prev_y != y) painter_->draw_rectangle( { (Coord)x, 168, 1, 24 }, Color::yellow() );
// Level // Level
painter_->draw_rectangle( { (Coord)x, 160 + y, ceil(x_inc), 1 }, Color::yellow() ); painter_->draw_rectangle( { (Coord)x, 168 + y, (int)ceil(x_inc), 1 }, Color::yellow() );
prev_y = y; prev_y = y;
x += x_inc; x += x_inc;
@ -164,7 +163,7 @@ void EncodersView::on_txdone(int n) {
} }
void EncodersView::start_tx(const bool scan) { void EncodersView::start_tx(const bool scan) {
char ook_bitstream[64]; char ook_bitstream[256];
uint32_t ook_bitstream_length; uint32_t ook_bitstream_length;
/*if (scan) { /*if (scan) {
@ -188,7 +187,7 @@ void EncodersView::start_tx(const bool scan) {
generate_frame(); generate_frame();
// Clear bitstream // Clear bitstream
memset(ook_bitstream, 0, 64); memset(ook_bitstream, 0, 256);
size_t n = 0; size_t n = 0;
for (auto c : debug_text) { for (auto c : debug_text) {
@ -197,7 +196,7 @@ void EncodersView::start_tx(const bool scan) {
n++; n++;
} }
ook_bitstream_length = n; // - 1; ook_bitstream_length = n;
transmitter_model.set_tuning_frequency(433920000); // TODO: Make modifiable ! transmitter_model.set_tuning_frequency(433920000); // TODO: Make modifiable !
transmitter_model.set_baseband_configuration({ transmitter_model.set_baseband_configuration({
@ -211,22 +210,23 @@ void EncodersView::start_tx(const bool scan) {
transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.enable();
memcpy(shared_memory.tx_data, ook_bitstream, 64); memcpy(shared_memory.tx_data, ook_bitstream, 256);
baseband::set_ook_data( baseband::set_ook_data(
ook_bitstream_length, ook_bitstream_length,
// 2280000/2 = 1140000Hz = 0,877192982us // 2280000/2 = 1140000Hz = 0,877192982us
// numberfield_clk.value() / encoder_def->clk_per_symbol // numberfield_clk.value() / encoder_def->clk_per_fragment
// 455000 / 12 = 37917Hz = 26,37339452us // 455000 / 12 = 37917Hz = 26,37339452us
228000 / ((numberfield_clk.value() * 1000) / encoder_def->clk_per_symbol), 228000 / ((numberfield_clk.value() * 1000) / encoder_def->clk_per_fragment),
encoder_def->repeat_min, encoder_def->repeat_min,
encoder_def->pause_symbols encoder_def->pause_symbols
); );
} }
void EncodersView::on_type_change(size_t index) { void EncodersView::on_type_change(size_t index) {
std::string word_format; std::string word_format, format_string = "";
//size_t data_length; size_t word_length;
char symbol_type;
//size_t address_length; //size_t address_length;
enc_type = index; enc_type = index;
@ -235,8 +235,26 @@ void EncodersView::on_type_change(size_t index) {
numberfield_clk.set_value(encoder_def->default_frequency / 1000); numberfield_clk.set_value(encoder_def->default_frequency / 1000);
bitfield.set_length(encoder_def->word_length); // SymField setup
bitfield.set_range(0, encoder_def->address_bit_states - 1); word_length = encoder_def->word_length;
symfield_word.set_length(word_length);
size_t n = 0, i = 0;
while (n < word_length) {
symbol_type = encoder_def->word_format.at(i++);
if (symbol_type == 'A') {
symfield_word.set_symbol_list(n++, encoder_def->address_symbols);
format_string += 'A';
} else if (symbol_type == 'D') {
symfield_word.set_symbol_list(n++, encoder_def->data_symbols);
format_string += 'D';
}
}
// Ugly :( Pad to erase
while (format_string.length() < 24)
format_string += ' ';
text_format.set(format_string);
/*word_format = encoder_def->word_format; /*word_format = encoder_def->word_format;
size_t address_start = word_format.find_first_of("A"); size_t address_start = word_format.find_first_of("A");
@ -281,6 +299,7 @@ void EncodersView::on_type_change(size_t index) {
} }
void EncodersView::on_show() { void EncodersView::on_show() {
// TODO: Remove ?
options_enctype.set_selected_index(enc_type); options_enctype.set_selected_index(enc_type);
on_type_change(enc_type); on_type_change(enc_type);
} }
@ -295,6 +314,7 @@ EncodersView::EncodersView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_ook); baseband::run_image(portapack::spi_flash::image_tag_ook);
// Default encoder def
encoder_def = &encoder_defs[0]; encoder_def = &encoder_defs[0];
add_children({ { add_children({ {
@ -309,8 +329,9 @@ EncodersView::EncodersView(NavigationView& nav) {
&text_wordduration, &text_wordduration,
&numberfield_wordduration, &numberfield_wordduration,
&text_us2, &text_us2,
&text_bitfield, &text_symfield,
&bitfield, &symfield_word,
&text_format,
//&text_format_a, // DEBUG //&text_format_a, // DEBUG
//&text_format_d, // DEBUG //&text_format_d, // DEBUG
&text_waveform, &text_waveform,
@ -319,44 +340,50 @@ EncodersView::EncodersView(NavigationView& nav) {
&button_transmit &button_transmit
} }); } });
// Load encoder types
for (i = 0; i < ENC_TYPES_COUNT; i++) for (i = 0; i < ENC_TYPES_COUNT; i++)
enc_options.emplace_back(std::make_pair(encoder_defs[i].name, i)); enc_options.emplace_back(std::make_pair(encoder_defs[i].name, i));
options_enctype.set_options(enc_options);
options_enctype.set_selected_index(0);
bitfield.on_change = [this]() {
this->generate_frame();
};
button_transmit.set_style(&style_val);
options_enctype.on_change = [this](size_t index, int32_t value) { options_enctype.on_change = [this](size_t index, int32_t value) {
(void)value; (void)value;
this->on_type_change(index); this->on_type_change(index);
}; };
options_enctype.set_options(enc_options);
options_enctype.set_selected_index(0);
symfield_word.on_change = [this]() {
this->generate_frame();
};
button_transmit.set_style(&style_val);
// Selecting input clock changes symbol and word duration
numberfield_clk.on_change = [this](int32_t value) { numberfield_clk.on_change = [this](int32_t value) {
int32_t new_value = 1000000 / (((float)value * 1000) / encoder_def->clk_per_bit); //int32_t new_value = 1000000 / (((float)value * 1000) / encoder_def->clk_per_symbol);
// value is in kHz, new_value is in us
int32_t new_value = 1000000 / ((value * 1000) / encoder_def->clk_per_symbol);
if (new_value != numberfield_bitduration.value()) { if (new_value != numberfield_bitduration.value()) {
numberfield_bitduration.set_value(new_value, false); numberfield_bitduration.set_value(new_value, false);
numberfield_wordduration.set_value(new_value * encoder_def->word_length, false); numberfield_wordduration.set_value(new_value * encoder_def->word_length, false);
} }
}; };
// Selecting symbol duration changes input clock and word duration
numberfield_bitduration.on_change = [this](int32_t value) { numberfield_bitduration.on_change = [this](int32_t value) {
int32_t new_value = 1000000 / (((float)value * 1000) / encoder_def->clk_per_bit); int32_t new_value = 1000000 / (((float)value * 1000) / encoder_def->clk_per_symbol);
if (new_value != numberfield_clk.value()) { if (new_value != numberfield_clk.value()) {
numberfield_clk.set_value(new_value, false); numberfield_clk.set_value(new_value, false);
numberfield_wordduration.set_value(value * encoder_def->word_length, false); numberfield_wordduration.set_value(value * encoder_def->word_length, false);
} }
}; };
// Selecting word duration changes input clock and symbol duration
numberfield_wordduration.on_change = [this](int32_t value) { numberfield_wordduration.on_change = [this](int32_t value) {
int32_t new_value = value / encoder_def->word_length; int32_t new_value = value / encoder_def->word_length;
if (new_value != numberfield_bitduration.value()) { if (new_value != numberfield_bitduration.value()) {
numberfield_bitduration.set_value(new_value, false); numberfield_bitduration.set_value(new_value, false);
numberfield_clk.set_value(1000000 / (((float)new_value * 1000) / encoder_def->clk_per_bit), false); numberfield_clk.set_value(1000000 / (((float)new_value * 1000) / encoder_def->clk_per_symbol), false);
} }
}; };

View File

@ -43,63 +43,61 @@ public:
private: private:
struct encoder_def_t { struct encoder_def_t {
std::string name; std::string name; // Encoder chip ref/name
uint8_t address_bit_states; // Often 0, 1, [f, [4]] std::string address_symbols; // "01", "01F"...
uint8_t data_bit_states; // Often 0, 1 std::string data_symbols; // Same
uint16_t clk_per_bit; // Oscillator periods per bit uint16_t clk_per_symbol; // Oscillator periods per symbol
uint16_t clk_per_symbol; // Oscillator periods per bit fragment uint16_t clk_per_fragment; // Oscillator periods per symbol fragment (state)
std::vector<std::string> bit_format; std::vector<std::string> bit_format; // List of fragments for each symbol in previous *_symbols list order
uint8_t word_length; // Total # of bits uint8_t word_length; // Total # of symbols (not counting sync)
std::string word_format; std::string word_format; // A for Address, D for Data, S for sync
std::string sync; // Like bit_format std::string sync; // Like bit_format
uint32_t default_frequency; // Default encoder clk frequency uint32_t default_frequency; // Default encoder clk frequency (often set by shitty resistor)
uint8_t repeat_min; uint8_t repeat_min; // Minimum repeat count
uint32_t pause_symbols; uint16_t pause_symbols; // Length of pause between repeats in symbols
}; };
// S = Sync
// A/D = Address/data bits
const encoder_def_t encoder_defs[ENC_TYPES_COUNT] = { const encoder_def_t encoder_defs[ENC_TYPES_COUNT] = {
// PT2260-R2 // PT2260-R2
{ {
"2260-R2", "2260-R2",
3, 2, "01F", "01",
1024, 128, 1024, 128,
{ "10001000", "11101110", "10001110" }, { "10001000", "11101110", "10001110" },
12, "AAAAAAAAAADDS", 12, "AAAAAAAAAADDS",
"10000000000000000000000000000000", "10000000000000000000000000000000",
200000, 1, 150000, 2,
10 // ? 0
}, },
// PT2260-R4 // PT2260-R4
{ {
"2260-R4", "2260-R4",
3, 2, "01F", "01",
1024, 128, 1024, 128,
{ "10001000", "11101110", "10001110" }, { "10001000", "11101110", "10001110" },
12, "AAAAAAAADDDDS", 12, "AAAAAAAADDDDS",
"10000000000000000000000000000000", "10000000000000000000000000000000",
200000, 1, 150000, 2,
10 // ? 0
}, },
// PT2262 // PT2262
{ {
"2262 ", "2262 ",
3, 2, "01F", "01F",
1024, 128, 32, 4,
{ "10001000", "11101110", "10001110" }, { "10001000", "11101110", "10001110" },
12, "AAAAAAAAAAAAS", 12, "AAAAAAAAAAAAS",
"10000000000000000000000000000000", "10000000000000000000000000000000",
200000, 1, 20000, 4,
10 // ? 0
}, },
// 16-bit ? // 16-bit ?
{ {
"16-bit ", "16-bit ",
2, 2, "01", "01",
32, 8, 32, 8,
{ "1110", "1000" }, // Opposite ? { "1110", "1000" }, // Opposite ?
16, "AAAAAAAAAAAAAAAAS", 16, "AAAAAAAAAAAAAAAAS",
@ -111,7 +109,7 @@ private:
// RT1527 // RT1527
{ {
"1527 ", "1527 ",
2, 2, "01", "01",
128, 32, 128, 32,
{ "1000", "1110" }, { "1000", "1110" },
24, "SAAAAAAAAAAAAAAAAAAAADDDD", 24, "SAAAAAAAAAAAAAAAAAAAADDDD",
@ -123,7 +121,7 @@ private:
// HK526E // HK526E
{ {
"526 ", "526 ",
2, 2, "01", "01",
24, 8, 24, 8,
{ "110", "100" }, { "110", "100" },
12, "AAAAAAAAAAAA", 12, "AAAAAAAAAAAA",
@ -135,7 +133,7 @@ private:
// HT12E // HT12E
{ {
"12E ", "12E ",
2, 2, "01", "01",
3, 1, 3, 1,
{ "011", "001" }, { "011", "001" },
12, "SAAAAAAAADDDD", 12, "SAAAAAAAADDDD",
@ -147,7 +145,7 @@ private:
// VD5026 13 bits ? // VD5026 13 bits ?
{ {
"5026 ", "5026 ",
4, 4, "0123", "0123",
128, 8, 128, 8,
{ "1000000010000000", "1111111011111110", "1111111010000000", "1000000011111110" }, { "1000000010000000", "1111111011111110", "1111111010000000", "1000000011111110" },
12, "SAAAAAAAAAAAA", 12, "SAAAAAAAAAAAA",
@ -159,19 +157,19 @@ private:
// UM3750 // UM3750
{ {
"UM3750 ", "UM3750 ",
2, 2, "01", "01",
96, 32, 96, 32,
{ "011", "001" }, { "011", "001" },
12, "SAAAAAAAAAAAA", 12, "SAAAAAAAAAAAA",
"1", "1",
100000, 4, 100000, 4,
10 // ? 0 // ?
}, },
// UM3758 // UM3758
{ {
"UM3758 ", "UM3758 ",
3, 2, "01F", "01",
96, 16, 96, 16,
{ "011011", "001001", "011001" }, { "011011", "001001", "011001" },
18, "SAAAAAAAAAADDDDDDDD", 18, "SAAAAAAAAAADDDDDDDD",
@ -183,7 +181,7 @@ private:
// BA5104 // BA5104
{ {
"BA5104 ", "BA5104 ",
2, 2, "01", "01",
3072, 768, 3072, 768,
{ "1000", "1110" }, { "1000", "1110" },
9, "SDDAAAAAAA", 9, "SDDAAAAAAA",
@ -195,7 +193,7 @@ private:
// MC145026 // MC145026
{ {
"145026 ", "145026 ",
3, 2, "01F", "01",
16, 1, 16, 1,
{ "0111111101111111", "0100000001000000", "0111111101000000" }, { "0111111101111111", "0100000001000000", "0111111101000000" },
9, "SAAAAADDDD", 9, "SAAAAADDDD",
@ -207,7 +205,7 @@ private:
// HT6*** TODO: Add individual variations // HT6*** TODO: Add individual variations
{ {
"HT6*** ", "HT6*** ",
3, 2, "01F", "01",
198, 33, 198, 33,
{ "011011", "001001", "001011" }, { "011011", "001001", "001011" },
18, "SAAAAAAAAAAAADDDDDD", 18, "SAAAAAAAAAAAADDDDDD",
@ -219,7 +217,7 @@ private:
// TC9148 // TC9148
{ {
"TC9148 ", "TC9148 ",
2, 2, "01", "01",
48, 12, 48, 12,
{ "1000", "1110", }, { "1000", "1110", },
12, "AAAAAAAAAAAA", 12, "AAAAAAAAAAAA",
@ -277,25 +275,19 @@ private:
.foreground = Color::blue(), .foreground = Color::blue(),
}; };
SymField bitfield {
{ 16 + 8, 80 },
12,
{ 0, 1 }
};
Text text_enctype { Text text_enctype {
{ 2 * 8, 3 * 8, 8 * 8, 16 }, { 1 * 8, 24, 5 * 8, 16 },
"Encoder:" "Type:"
}; };
OptionsField options_enctype { OptionsField options_enctype { // Options are loaded at runtime
{ 2 * 8, 5 * 8 }, { 6 * 8, 24 },
7, 7,
{ {
} }
}; };
Text text_clk { Text text_clk {
{ 15 * 8, 3 * 8, 4 * 8, 16 }, { 16 * 8, 3 * 8, 4 * 8, 16 },
"Clk:" "Clk:"
}; };
NumberField numberfield_clk { NumberField numberfield_clk {
@ -311,46 +303,55 @@ private:
}; };
Text text_bitduration { Text text_bitduration {
{ 15 * 8, 5 * 8, 4 * 8, 16 }, { 16 * 8, 5 * 8, 4 * 8, 16 },
"Bit:" "Bit:"
}; };
NumberField numberfield_bitduration { NumberField numberfield_bitduration {
{ 20 * 8, 5 * 8 }, { 21 * 8, 5 * 8 },
4, 4,
{ 50, 9999 }, { 50, 9999 },
1, 1,
' ' ' '
}; };
Text text_us1 { Text text_us1 {
{ 24 * 8, 5 * 8, 2 * 8, 16 }, { 25 * 8, 5 * 8, 2 * 8, 16 },
"us" "us"
}; };
Text text_wordduration { Text text_wordduration {
{ 14 * 8, 7 * 8, 5 * 8, 16 }, { 15 * 8, 7 * 8, 5 * 8, 16 },
"Word:" "Word:"
}; };
NumberField numberfield_wordduration { NumberField numberfield_wordduration {
{ 20 * 8, 7 * 8 }, { 21 * 8, 7 * 8 },
5, 5,
{ 300, 99999 }, { 300, 99999 },
100, 100,
' ' ' '
}; };
Text text_us2 { Text text_us2 {
{ 25 * 8, 7 * 8, 2 * 8, 16 }, { 26 * 8, 7 * 8, 2 * 8, 16 },
"us" "us"
}; };
Text text_bitfield { Text text_symfield {
{ 2 * 8, 8 * 8, 5 * 8, 16 }, { 2 * 8, 9 * 8, 5 * 8, 16 },
"Word:" "Word:"
}; };
SymField symfield_word {
{ 2 * 8, 11 * 8 },
20
};
Text text_format {
{ 2 * 8, 13 * 8, 24 * 8, 16 },
""
};
//Text text_format_a; // DEBUG //Text text_format_a; // DEBUG
//Text text_format_d; // DEBUG //Text text_format_d; // DEBUG
Text text_waveform { Text text_waveform {
{ 1 * 8, 16 * 8, 9 * 8, 16 }, { 1 * 8, 136, 9 * 8, 16 },
"Waveform:" "Waveform:"
}; };

View File

@ -513,6 +513,7 @@ void Console::writeln(std::string message) {
} }
void Console::paint(Painter& painter) { void Console::paint(Painter& painter) {
(void)painter;
write(buffer); write(buffer);
} }
@ -990,7 +991,7 @@ void OptionsField::set_options(options_t new_options) {
void OptionsField::paint(Painter& painter) { void OptionsField::paint(Painter& painter) {
const auto paint_style = has_focus() ? style().invert() : style(); const auto paint_style = has_focus() ? style().invert() : style();
painter.fill_rectangle({screen_rect().pos, {length_ * 8, 16}}, ui::Color::black()); painter.fill_rectangle({screen_rect().pos, {(int)length_ * 8, 16}}, ui::Color::black());
if( selected_index() < options.size() ) { if( selected_index() < options.size() ) {
const auto text = options[selected_index()].first; const auto text = options[selected_index()].first;
@ -1108,24 +1109,26 @@ int32_t NumberField::clip_value(int32_t value) {
SymField::SymField( SymField::SymField(
Point parent_pos, Point parent_pos,
size_t length, size_t length
range_t range
) : Widget { { parent_pos, { static_cast<ui::Dim>(8 * length), 16 } } }, ) : Widget { { parent_pos, { static_cast<ui::Dim>(8 * length), 16 } } },
range { range },
length_ { length } length_ { length }
{ {
set_focusable(true); set_focusable(true);
} }
uint32_t SymField::value(const uint32_t index) { uint32_t SymField::value(const uint32_t index) {
if (index >= length_) return 0;
return values_[index]; return values_[index];
} }
void SymField::set_value(const uint32_t index, int32_t new_value) { void SymField::set_value(const uint32_t index, const uint32_t new_value) {
new_value = clip_value(new_value); if (index >= length_) return;
if( new_value != values_[index] ) { uint32_t clipped_value = clip_value(index, new_value);
values_[index] = new_value;
if (clipped_value != values_[index]) {
values_[index] = clipped_value;
if( on_change ) { if( on_change ) {
on_change(); on_change();
} }
@ -1134,34 +1137,38 @@ void SymField::set_value(const uint32_t index, int32_t new_value) {
} }
void SymField::set_length(const uint32_t new_length) { void SymField::set_length(const uint32_t new_length) {
if (new_length <= 30) { if ((new_length <= 32) && (new_length != length_)) {
prev_length_ = length_; prev_length_ = length_;
length_ = new_length; length_ = new_length;
// Clip eventual garbage from previous shorter word
for (size_t n = 0; n < length_; n++)
set_value(n, values_[n]);
erase_prev_ = true; erase_prev_ = true;
set_dirty(); set_dirty();
} }
} }
void SymField::set_range(const int32_t min, const int32_t max) { void SymField::set_symbol_list(const uint32_t index, const std::string symbol_list) {
size_t n; if (index >= length_) return;
range.first = min; symbol_list_[index] = symbol_list;
range.second = max;
for (n = 0; n < length_; n++) // Re-clip symbol's value
set_value(n, values_[n]); set_value(index, values_[index]);
} }
void SymField::paint(Painter& painter) { void SymField::paint(Painter& painter) {
size_t n;
Point pt_draw = screen_pos(); Point pt_draw = screen_pos();
if (erase_prev_) { if (erase_prev_) {
painter.fill_rectangle( { pt_draw, { prev_length_ * 8, 16 } }, Color::black() ); painter.fill_rectangle( { pt_draw, { (int)prev_length_ * 8, 16 } }, Color::black() );
erase_prev_ = false; erase_prev_ = false;
} }
for (n = 0; n < length_; n++) { for (size_t n = 0; n < length_; n++) {
const auto text = to_string_dec_uint(values_[n], 1); const auto text = symbol_list_[n].substr(values_[n], 1);
const auto paint_style = (has_focus() && (n == selected_)) ? style().invert() : style(); const auto paint_style = (has_focus() && (n == selected_)) ? style().invert() : style();
@ -1208,7 +1215,11 @@ bool SymField::on_key(const KeyEvent key) {
} }
bool SymField::on_encoder(const EncoderEvent delta) { bool SymField::on_encoder(const EncoderEvent delta) {
int32_t new_value = (int)values_[selected_] + delta;
if (new_value >= 0)
set_value(selected_, values_[selected_] + delta); set_value(selected_, values_[selected_] + delta);
return true; return true;
} }
@ -1219,13 +1230,12 @@ bool SymField::on_touch(const TouchEvent event) {
return true; return true;
} }
int32_t SymField::clip_value(int32_t value) { int32_t SymField::clip_value(const uint32_t index, const uint32_t value) {
if( value > range.second ) { size_t symbol_count = symbol_list_[index].length() - 1;
value = range.second;
} if (value > symbol_count)
if( value < range.first ) { return symbol_count;
value = range.first; else
}
return value; return value;
} }

View File

@ -446,17 +446,15 @@ public:
std::function<void(SymField&)> on_select; std::function<void(SymField&)> on_select;
std::function<void()> on_change; std::function<void()> on_change;
using range_t = std::pair<int32_t, int32_t>; SymField(Point parent_pos, size_t length);
SymField(Point parent_pos, size_t length, range_t range);
SymField(const SymField&) = delete; SymField(const SymField&) = delete;
SymField(SymField&&) = delete; SymField(SymField&&) = delete;
uint32_t value(const uint32_t index); uint32_t value(const uint32_t index);
void set_value(const uint32_t index, int32_t new_value); void set_value(const uint32_t index, const uint32_t new_value);
void set_length(const uint32_t new_length); void set_length(const uint32_t new_length);
void set_range(const int32_t min, const int32_t max); void set_symbol_list(const uint32_t index, const std::string symbol_list);
void paint(Painter& painter) override; void paint(Painter& painter) override;
@ -465,13 +463,13 @@ public:
bool on_touch(const TouchEvent event) override; bool on_touch(const TouchEvent event) override;
private: private:
range_t range; std::string symbol_list_[32] = { "01" }; // Failsafe init
int32_t values_[30] = { 0 }; uint32_t values_[32] = { 0 };
uint32_t selected_ = 0; uint32_t selected_ = 0;
size_t length_, prev_length_; size_t length_, prev_length_;
bool erase_prev_ = false; bool erase_prev_ = false;
int32_t clip_value(int32_t value); int32_t clip_value(const uint32_t index, const uint32_t value);
}; };
} /* namespace ui */ } /* namespace ui */

Binary file not shown.