Fixed EPAR transmit

This commit is contained in:
furrtek 2017-09-21 09:18:17 +01:00
parent c0f51c2690
commit a6d2b766f4
15 changed files with 289 additions and 208 deletions

View File

@ -144,6 +144,7 @@ set(CPPSRC
protocols/ax25.cpp protocols/ax25.cpp
protocols/bht.cpp protocols/bht.cpp
protocols/dcs.cpp protocols/dcs.cpp
protocols/encoders.cpp
protocols/lcr.cpp protocols/lcr.cpp
protocols/rds.cpp protocols/rds.cpp
serializer.cpp serializer.cpp

View File

@ -21,74 +21,56 @@
*/ */
#include "bht.hpp" #include "bht.hpp"
#include "portapack.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include <cstring> size_t gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_number, uint32_t relay_state) {
#include <stdio.h>
std::string gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_state_A, uint32_t relay_state_B) {
size_t c; size_t c;
const encoder_def_t * um3750_def; const encoder_def_t * um3750_def;
uint8_t bit[12]; uint8_t bits[12];
std::string ep_symbols; std::string ep_fragments;
char ook_bitstream[256]; //char ep_message[13] = { 0 };
char ep_message[13] = { 0 };
(void)relay_state_B;
// EP frame
// Repeated 2x 26 times // Repeated 2x 26 times
// Whole frame + space = 128ms, data only = 64ms // Whole frame + space = 128ms, data only = 64ms
um3750_def = &encoder_defs[8]; um3750_def = &encoder_defs[ENCODER_UM3750];
// City code is bit-reversed
for (c = 0; c < 8; c++) for (c = 0; c < 8; c++)
bit[c] = (city_code >> c) & 1; bits[c] = (city_code >> c) & 1;
bit[8] = family_code_ep >> 1; bits[8] = (family_code_ep >> 1) & 1;
bit[9] = family_code_ep & 1; bits[9] = family_code_ep & 1;
bit[10] = 0; // R1 first bits[10] = relay_number & 1;
if (relay_state_A) bits[11] = relay_state ? 1 : 0;
bit[11] = relay_state_A - 1;
else
bit[11] = 0;
for (c = 0; c < 12; c++) // Text for display
ep_message[c] = bit[c] + '0'; //for (c = 0; c < 12; c++)
// ep_message[c] = bits[c] + '0';
//text_message.set(ep_message);
c = 0; c = 0;
for (auto ch : um3750_def->word_format) { for (auto ch : um3750_def->word_format) {
if (ch == 'S') if (ch == 'S')
ep_symbols += um3750_def->sync; ep_fragments += um3750_def->sync;
else else
ep_symbols += um3750_def->bit_format[bit[c++]]; ep_fragments += um3750_def->bit_format[bits[c++]];
} }
c = 0; // Return bitstream length
for (auto ch : ep_symbols) { return make_bitstream(ep_fragments);
if (ch != '0')
ook_bitstream[c >> 3] |= (1 << (7 - (c & 7)));
c++;
}
return ep_message;
} }
std::string gen_message_xy(const std::string& ascii_code) { std::string gen_message_xy(const std::string& ascii_code) {
std::string local_code = ascii_code; std::string local_code = ascii_code;
uint8_t ccir_message[20]; uint8_t ccir_message[XY_TONE_COUNT];
uint8_t translate; uint8_t translate;
uint32_t c; uint32_t c;
// Replace repeats with E code // Replace repeats with E code
for (c = 1; c < 20; c++) for (c = 1; c < XY_TONE_COUNT; c++)
if (local_code[c] == local_code[c - 1]) local_code[c] = 'E'; if (local_code[c] == local_code[c - 1]) local_code[c] = 'E';
for (c = 0; c < 20; c++) { for (c = 0; c < XY_TONE_COUNT; c++) {
if (local_code[c] <= '9') if (local_code[c] <= '9')
translate = local_code[c] - '0'; translate = local_code[c] - '0';
else else
@ -97,7 +79,7 @@ std::string gen_message_xy(const std::string& ascii_code) {
} }
// Copy for baseband // Copy for baseband
memcpy(shared_memory.bb_data.tones_data.message, ccir_message, 20); memcpy(shared_memory.bb_data.tones_data.message, ccir_message, XY_TONE_COUNT);
// Return as text for display // Return as text for display
return local_code; return local_code;
@ -106,10 +88,8 @@ std::string gen_message_xy(const std::string& ascii_code) {
std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t city_code, size_t family_code, std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t city_code, size_t family_code,
bool subfamily_wc, size_t subfamily_code, bool id_wc, size_t receiver_code, bool subfamily_wc, size_t subfamily_code, bool id_wc, size_t receiver_code,
size_t relay_state_A, size_t relay_state_B, size_t relay_state_C, size_t relay_state_D) { size_t relay_state_A, size_t relay_state_B, size_t relay_state_C, size_t relay_state_D) {
uint8_t ccir_message[20]; uint8_t ccir_message[XY_TONE_COUNT];
size_t c; size_t c;
// Xy CCIR frame
// Header // Header
ccir_message[0] = (header_code_a / 10); ccir_message[0] = (header_code_a / 10);
@ -123,19 +103,19 @@ std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t ci
ccir_message[6] = family_code; ccir_message[6] = family_code;
if (subfamily_wc) if (subfamily_wc)
ccir_message[7] = 10; // Wildcard ccir_message[7] = 0xA; // Wildcard
else else
ccir_message[7] = subfamily_code; ccir_message[7] = subfamily_code;
if (id_wc) { if (id_wc) {
ccir_message[8] = 10; // Wildcard ccir_message[8] = 0xA; // Wildcard
ccir_message[9] = 10; // Wildcard ccir_message[9] = 0xA; // Wildcard
} else { } else {
ccir_message[8] = (receiver_code / 10); ccir_message[8] = (receiver_code / 10);
ccir_message[9] = (receiver_code % 10); ccir_message[9] = (receiver_code % 10);
} }
ccir_message[10] = 11; // B ccir_message[10] = 0xB;
// Relay states // Relay states
ccir_message[11] = relay_state_A; ccir_message[11] = relay_state_A;
@ -143,18 +123,18 @@ std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t ci
ccir_message[13] = relay_state_C; ccir_message[13] = relay_state_C;
ccir_message[14] = relay_state_D; ccir_message[14] = relay_state_D;
ccir_message[15] = 11; // B ccir_message[15] = 0xB;
// End // End
for (c = 16; c < 20; c++) for (c = 16; c < XY_TONE_COUNT; c++)
ccir_message[c] = 0; ccir_message[c] = 0;
// Replace repeats with E code // Replace repeats with E code
for (c = 1; c < 20; c++) for (c = 1; c < XY_TONE_COUNT; c++)
if (ccir_message[c] == ccir_message[c - 1]) ccir_message[c] = 14; if (ccir_message[c] == ccir_message[c - 1]) ccir_message[c] = 0xE;
// Copy for baseband // Copy for baseband
memcpy(shared_memory.bb_data.tones_data.message, ccir_message, 20); memcpy(shared_memory.bb_data.tones_data.message, ccir_message, XY_TONE_COUNT);
// Return as text for display // Return as text for display
return ccir_to_ascii(ccir_message); return ccir_to_ascii(ccir_message);
@ -163,7 +143,7 @@ std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t ci
std::string ccir_to_ascii(uint8_t * ccir) { std::string ccir_to_ascii(uint8_t * ccir) {
std::string ascii; std::string ascii;
for (size_t c = 0; c < 20; c++) { for (size_t c = 0; c < XY_TONE_COUNT; c++) {
if (ccir[c] > 9) if (ccir[c] > 9)
ascii += (char)(ccir[c] - 10 + 'A'); ascii += (char)(ccir[c] - 10 + 'A');
else else

View File

@ -21,17 +21,16 @@
*/ */
#include "ui.hpp" #include "ui.hpp"
#include "ui_widget.hpp"
#include "ui_navigation.hpp" #include "ui_navigation.hpp"
#include "tonesets.hpp" #include "tonesets.hpp"
#include "encoders.hpp" #include "encoders.hpp"
#include "portapack.hpp"
using namespace encoders; using namespace encoders;
#define XY_TONE_LENGTH ((TONES_SAMPLERATE * 0.1) - 1) // 100ms #define XY_TONE_LENGTH ((TONES_SAMPLERATE * 0.1) - 1) // 100ms
#define XY_SILENCE (TONES_SAMPLERATE * 0.4) // 400ms #define XY_SILENCE (TONES_SAMPLERATE * 0.4) // 400ms
#define XY_TONE_COUNT 20
struct bht_city { struct bht_city {
std::string name; std::string name;
@ -39,9 +38,7 @@ struct bht_city {
bool recent; bool recent;
}; };
//const rf::Frequency bht_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 88000000 }; size_t gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_state_A, uint32_t relay_state_B);
std::string gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_state_A, uint32_t relay_state_B);
std::string gen_message_xy(const std::string& code); std::string gen_message_xy(const std::string& code);
std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t city_code, size_t family_code, std::string gen_message_xy(size_t header_code_a, size_t header_code_b, size_t city_code, size_t family_code,
bool subfamily_wc, size_t subfamily_code, bool id_wc, size_t receiver_code, bool subfamily_wc, size_t subfamily_code, bool id_wc, size_t receiver_code,

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2017 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_navigation.hpp"
#include "encoders.hpp"
using namespace portapack;
namespace encoders {
size_t make_bitstream(std::string& fragments) {
uint8_t byte = 0;
size_t bitstream_length = 0;
uint8_t * bitstream = shared_memory.bb_data.data;
for (auto c : fragments) {
byte <<= 1;
if (c != '0')
byte |= 1;
if ((bitstream_length & 7) == 7)
bitstream[bitstream_length >> 3] = byte;
bitstream_length++;
}
// Finish last byte if needed
size_t padding = 8 - (bitstream_length & 7);
if (padding != 8) {
byte <<= padding;
bitstream[(bitstream_length + padding - 1) >> 3] = byte;
padding++;
}
return bitstream_length;
}
} /* namespace encoders */

View File

@ -20,6 +20,7 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#include <vector>
#include <cstring> #include <cstring>
#include <string> #include <string>
@ -29,7 +30,11 @@
namespace encoders { namespace encoders {
#define ENC_TYPES_COUNT 14 #define ENC_TYPES_COUNT 14
#define OOK_SAMPLERATE 2280000U #define OOK_SAMPLERATE 2280000U
#define ENCODER_UM3750 8
size_t make_bitstream(std::string& fragments);
struct encoder_def_t { struct encoder_def_t {
std::string name; // Encoder chip ref/name std::string name; // Encoder chip ref/name
@ -151,9 +156,9 @@ namespace encoders {
96, 32, 96, 32,
{ "011", "001" }, { "011", "001" },
12, "SAAAAAAAAAAAA", 12, "SAAAAAAAAAAAA",
"1", "001",
100000, 4, 100000, 4,
0 // ? (3 * 12) - 6 // Compensates for pause delay bug in proc_ook
}, },
// UM3758 // UM3758

View File

@ -21,13 +21,11 @@
*/ */
#include "ui_bht_tx.hpp" #include "ui_bht_tx.hpp"
#include "string_format.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include <cstring>
#include <stdio.h>
using namespace portapack; using namespace portapack;
namespace ui { namespace ui {
@ -36,57 +34,98 @@ void BHTView::focus() {
tx_view.focus(); tx_view.focus();
} }
BHTView::~BHTView() {
transmitter_model.disable();
baseband::shutdown();
}
void BHTView::start_tx() { void BHTView::start_tx() {
uint8_t c; baseband::shutdown();
view_xylos.generate_message(); if (tx_type == XYLOS) {
view_EPAR.generate_message();
baseband::run_image(portapack::spi_flash::image_tag_tones);
if (view_xylos.tx_mode == XylosView::tx_modes::SINGLE)
progressbar.set_max(20); view_xylos.generate_message();
else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE)
progressbar.set_max(20 * XY_SEQ_COUNT); //if (view_xylos.tx_mode == XylosView::tx_modes::SINGLE)
progressbar.set_max(20);
transmitter_model.set_sampling_rate(1536000); //else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE)
transmitter_model.set_rf_amp(true); // progressbar.set_max(20 * XY_SEQ_COUNT);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable(); transmitter_model.set_sampling_rate(TONES_SAMPLERATE);
transmitter_model.set_rf_amp(true);
// Setup tones for Xy transmitter_model.set_baseband_bandwidth(1750000);
for (c = 0; c < 16; c++) transmitter_model.enable();
baseband::set_tone(c, ccir_deltas[c], XY_TONE_LENGTH);
// Setup tones
baseband::set_tones_config(transmitter_model.channel_bandwidth(), XY_SILENCE, 20, false, false); for (size_t c = 0; c < ccir_deltas.size(); c++)
baseband::set_tone(c, ccir_deltas[c], XY_TONE_LENGTH);
baseband::set_tones_config(transmitter_model.channel_bandwidth(), XY_SILENCE, XY_TONE_COUNT, false, false);
} else if (tx_type == EPAR) {
baseband::run_image(portapack::spi_flash::image_tag_ook);
size_t bitstream_length = view_EPAR.generate_message();
progressbar.set_max(2 * 26);
transmitter_model.set_sampling_rate(OOK_SAMPLERATE);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable();
baseband::set_ook_data(
bitstream_length,
OOK_SAMPLERATE / 580,
26,
encoder_defs[ENCODER_UM3750].pause_symbols
);
}
} }
void BHTView::on_tx_progress(const int progress, const bool done) { void BHTView::on_tx_progress(const int progress, const bool done) {
uint8_t c; //if (view_xylos.tx_mode == XylosView::tx_modes::SINGLE) {
if (view_xylos.tx_mode == XylosView::tx_modes::SINGLE) { if (done) {
transmitter_model.disable();
view_xylos.tx_mode = XylosView::tx_modes::IDLE;
tx_view.set_transmitting(false);
}
if (tx_type == XYLOS) {
if (done) { if (done) {
transmitter_model.disable();
progressbar.set_value(0);
if (!checkbox_cligno.value()) { if (!checkbox_cligno.value()) {
view_xylos.tx_mode = XylosView::tx_modes::IDLE; view_xylos.tx_mode = XylosView::tx_modes::IDLE;
tx_view.set_transmitting(false); tx_view.set_transmitting(false);
progressbar.set_value(0);
} else { } else {
chThdSleepMilliseconds(field_tempo.value() * 1000); // Dirty :( chThdSleepMilliseconds(field_tempo.value() * 1000); // Dirty :(
view_EPAR.flip_relays();
view_xylos.flip_relays(); view_xylos.flip_relays();
start_tx(); start_tx();
} }
} else { } else
progressbar.set_value(progress); progressbar.set_value(progress);
} } else if (tx_type == EPAR) {
} else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE) { if (done) {
if (!view_EPAR.half) {
view_EPAR.half = 1;
start_tx(); // Start second half of transmission
} else {
view_EPAR.half = 0;
progressbar.set_value(0);
if (checkbox_cligno.value()) {
chThdSleepMilliseconds(field_tempo.value() * 1000); // Dirty :(
view_EPAR.flip_relays();
start_tx();
}
}
} else
progressbar.set_value((26 * view_EPAR.half) + progress);
}
/*} else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE) {
if (done) { if (done) {
transmitter_model.disable(); transmitter_model.disable();
@ -105,7 +144,59 @@ void BHTView::on_tx_progress(const int progress, const bool done) {
} else { } else {
progressbar.set_value((view_xylos.seq_index * 20) + progress); progressbar.set_value((view_xylos.seq_index * 20) + progress);
} }
} }*/
}
BHTView::~BHTView() {
transmitter_model.disable();
baseband::shutdown();
}
BHTView::BHTView(NavigationView& nav) {
add_children({
&tab_view,
&labels,
&view_xylos,
&view_EPAR,
&checkbox_cligno,
&field_tempo,
&progressbar,
&text_message,
&tx_view
});
field_tempo.set_value(1);
tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
transmitter_model.set_tuning_frequency(f);
};
};
/*button_seq.on_select = [this, &nav](Button&) {
if (tx_mode == IDLE) {
seq_index = 0;
tx_mode = SEQUENCE;
tx_view.set_transmitting(true);
start_tx();
}
};*/
tx_view.on_start = [this]() {
if (view_xylos.tx_mode == XylosView::tx_modes::IDLE) {
view_xylos.tx_mode = XylosView::tx_modes::SINGLE;
tx_view.set_transmitting(true);
tx_type = (tx_type_t)tab_view.selected();
start_tx();
}
};
tx_view.on_stop = [this]() {
transmitter_model.disable();
tx_view.set_transmitting(false);
view_xylos.tx_mode = XylosView::tx_modes::IDLE;
};
} }
void EPARView::flip_relays() { void EPARView::flip_relays() {
@ -113,25 +204,23 @@ void EPARView::flip_relays() {
relay_states[0].set_selected_index(relay_states[0].selected_index() ^ 1); relay_states[0].set_selected_index(relay_states[0].selected_index() ^ 1);
} }
void EPARView::generate_message() { size_t EPARView::generate_message() {
//text_message.set( // R2, then R1
gen_message_ep(field_city.value(), field_group.selected_index_value(), return gen_message_ep(field_city.value(), field_group.selected_index_value(),
relay_states[0].selected_index(), relay_states[1].selected_index()); 1 - half, relay_states[half].selected_index());
//);
} }
EPARView::EPARView() { EPARView::EPARView(
size_t n; Rect parent_rect
) : View(parent_rect) {
hidden(true); hidden(true);
//baseband::run_image(portapack::spi_flash::image_tag_ook);
add_children({ add_children({
&labels, &labels,
&field_city, &field_city,
&field_group, &field_group,
&button_scan //&button_scan
}); });
field_city.set_value(220); field_city.set_value(220);
@ -144,7 +233,7 @@ EPARView::EPARView() {
this->generate_message(); this->generate_message();
}; };
n = 0; size_t n = 0;
for (auto& relay_state : relay_states) { for (auto& relay_state : relay_states) {
relay_state.on_change = relay_state_fn; relay_state.on_change = relay_state_fn;
relay_state.set_parent_rect({ relay_state.set_parent_rect({
@ -163,35 +252,34 @@ void EPARView::focus() {
} }
void XylosView::flip_relays() { void XylosView::flip_relays() {
size_t rs; // Invert first relay's state if not ignored
size_t rs = relay_states[0].selected_index();
// Invert first relay's state if (rs > 0)
rs = relay_states[0].selected_index(); relay_states[0].set_selected_index(rs ^ 3);
if (rs > 0) relay_states[0].set_selected_index(rs ^ 3);
} }
void XylosView::generate_message() { void XylosView::generate_message() {
if (tx_mode == SINGLE) { //if (tx_mode == SINGLE) {
//text_message.set( //text_message.set(
gen_message_xy(field_header_a.value(), field_header_b.value(), field_city.value(), field_family.value(), gen_message_xy(field_header_a.value(), field_header_b.value(), field_city.value(), field_family.value(),
checkbox_wcsubfamily.value(), field_subfamily.value(), checkbox_wcid.value(), field_receiver.value(), checkbox_wcsubfamily.value(), field_subfamily.value(), checkbox_wcid.value(), field_receiver.value(),
relay_states[0].selected_index(), relay_states[1].selected_index(), relay_states[0].selected_index(), relay_states[1].selected_index(),
relay_states[2].selected_index(), relay_states[3].selected_index()); relay_states[2].selected_index(), relay_states[3].selected_index());
//); //);
} else if (tx_mode == SEQUENCE) { /*} else if (tx_mode == SEQUENCE) {
//text_message.set( //text_message.set(
gen_message_xy(sequence_matin[seq_index].code); gen_message_xy(sequence_matin[seq_index].code);
//); //);
} }*/
} }
XylosView::XylosView() { XylosView::XylosView(
size_t n; Rect parent_rect
) : View(parent_rect) {
hidden(true); hidden(true);
//baseband::run_image(portapack::spi_flash::image_tag_tones);
add_children({ add_children({
&labels, &labels,
&field_header_a, &field_header_a,
@ -202,7 +290,7 @@ XylosView::XylosView() {
&checkbox_wcsubfamily, &checkbox_wcsubfamily,
&field_receiver, &field_receiver,
&checkbox_wcid, &checkbox_wcid,
&button_seq, //&button_seq,
}); });
field_header_a.set_value(0); field_header_a.set_value(0);
@ -236,7 +324,7 @@ XylosView::XylosView() {
this->generate_message(); this->generate_message();
}; };
n = 0; size_t n = 0;
for (auto& relay_state : relay_states) { for (auto& relay_state : relay_states) {
relay_state.on_change = relay_state_fn; relay_state.on_change = relay_state_fn;
relay_state.set_parent_rect({ relay_state.set_parent_rect({
@ -254,57 +342,4 @@ void XylosView::focus() {
field_city.focus(); field_city.focus();
} }
BHTView::BHTView(NavigationView& nav) {
Rect view_rect = { 0, 3 * 8, 240, 192 };
baseband::run_image(portapack::spi_flash::image_tag_tones);
add_children({
&tab_view,
&labels,
&view_xylos,
&view_EPAR,
&checkbox_cligno,
&field_tempo,
&progressbar,
&text_message,
&tx_view
});
view_xylos.set_parent_rect(view_rect);
view_EPAR.set_parent_rect(view_rect);
field_tempo.set_value(0);
tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
transmitter_model.set_tuning_frequency(f);
};
};
/*button_seq.on_select = [this, &nav](Button&) {
if (tx_mode == IDLE) {
seq_index = 0;
tx_mode = SEQUENCE;
tx_view.set_transmitting(true);
start_tx();
}
};*/
tx_view.on_start = [this]() {
if (view_xylos.tx_mode == XylosView::tx_modes::IDLE) {
view_xylos.tx_mode = XylosView::tx_modes::SINGLE;
tx_view.set_transmitting(true);
start_tx();
}
};
tx_view.on_stop = [this]() {
transmitter_model.disable();
tx_view.set_transmitting(false);
view_xylos.tx_mode = XylosView::tx_modes::IDLE;
};
}
} /* namespace ui */ } /* namespace ui */

View File

@ -40,7 +40,7 @@ namespace ui {
class XylosView : public View { class XylosView : public View {
public: public:
XylosView(); XylosView(Rect parent_rect);
void focus() override; void focus() override;
@ -163,13 +163,15 @@ private:
class EPARView : public View { class EPARView : public View {
public: public:
EPARView(); EPARView(Rect parent_rect);
void focus() override; void focus() override;
void flip_relays(); void flip_relays();
void generate_message(); size_t generate_message();
size_t half { 0 };
private: private:
Labels labels { Labels labels {
{ { 4 * 8, 1 * 8 }, "Code ville:", Color::light_grey() }, { { 4 * 8, 1 * 8 }, "Code ville:", Color::light_grey() },
@ -222,8 +224,17 @@ private:
void on_tx_progress(const int progress, const bool done); void on_tx_progress(const int progress, const bool done);
void start_tx(); void start_tx();
XylosView view_xylos { }; enum tx_type_t {
EPARView view_EPAR { }; XYLOS = 0,
EPAR = 1
};
tx_type_t tx_type = { };
Rect view_rect = { 0, 3 * 8, 240, 192 };
XylosView view_xylos { view_rect };
EPARView view_EPAR { view_rect };
TabView tab_view { TabView tab_view {
{ "Xylos", Color::cyan(), &view_xylos }, { "Xylos", Color::cyan(), &view_xylos },

View File

@ -126,10 +126,10 @@ void EncodersConfigView::on_show() {
} }
void EncodersConfigView::draw_waveform() { void EncodersConfigView::draw_waveform() {
size_t length = frame_symbols.length(); size_t length = frame_fragments.length();
for (size_t n = 0; n < length; n++) { for (size_t n = 0; n < length; n++) {
if (frame_symbols[n] == '0') if (frame_fragments[n] == '0')
waveform_buffer[n] = 0; waveform_buffer[n] = 0;
else else
waveform_buffer[n] = 1; waveform_buffer[n] = 1;
@ -142,13 +142,13 @@ void EncodersConfigView::draw_waveform() {
void EncodersConfigView::generate_frame() { void EncodersConfigView::generate_frame() {
size_t i = 0; size_t i = 0;
frame_symbols.clear(); frame_fragments.clear();
for (auto c : encoder_def->word_format) { for (auto c : encoder_def->word_format) {
if (c == 'S') if (c == 'S')
frame_symbols += encoder_def->sync; frame_fragments += encoder_def->sync;
else else
frame_symbols += encoder_def->bit_format[symfield_word.get_sym(i++)]; frame_fragments += encoder_def->bit_format[symfield_word.get_sym(i++)];
} }
draw_waveform(); draw_waveform();
@ -285,9 +285,7 @@ void EncodersView::on_txdone(int n, const bool txdone) {
void EncodersView::start_tx(const bool scan) { void EncodersView::start_tx(const bool scan) {
(void)scan; (void)scan;
uint8_t byte = 0; size_t bitstream_length = 0;
size_t bitstream_length =0;
uint8_t * bitstream = shared_memory.bb_data.data;
repeat_min = view_config.repeat_min(); repeat_min = view_config.repeat_min();
@ -311,14 +309,7 @@ void EncodersView::start_tx(const bool scan) {
view_config.generate_frame(); view_config.generate_frame();
for (auto c : view_config.frame_symbols) { bitstream_length = make_bitstream(view_config.frame_fragments);
byte <<= 1;
if (c != '0')
byte |= 1;
if ((bitstream_length & 7) == 7)
bitstream[bitstream_length >> 3] = byte;
bitstream_length++;
}
transmitter_model.set_sampling_rate(OOK_SAMPLERATE); transmitter_model.set_sampling_rate(OOK_SAMPLERATE);
transmitter_model.set_rf_amp(true); transmitter_model.set_rf_amp(true);

View File

@ -48,7 +48,7 @@ public:
uint32_t pause_symbols(); uint32_t pause_symbols();
void generate_frame(); void generate_frame();
std::string frame_symbols = "0"; std::string frame_fragments = "0";
private: private:
//bool abort_scan = false; //bool abort_scan = false;

View File

@ -32,12 +32,12 @@ Tab::Tab() {
}; };
void Tab::set( void Tab::set(
uint16_t index, uint32_t index,
Dim width, Dim width,
std::string text, std::string text,
Color text_color Color text_color
) { ) {
set_parent_rect({ index * width, 0, width, 24 }); set_parent_rect({ (Coord)(index * width), 0, width, 24 });
text_ = text.substr(0, (width - 8) / 8); text_ = text.substr(0, (width - 8) / 8);
text_color_ = text_color; text_color_ = text_color;
@ -99,7 +99,7 @@ bool Tab::on_touch(const TouchEvent event) {
} }
} }
void TabView::set_selected(uint16_t index) { void TabView::set_selected(uint32_t index) {
Tab * tab; Tab * tab;
if (index >= n_tabs) if (index >= n_tabs)

View File

@ -41,12 +41,12 @@ public:
bool on_key(const KeyEvent key) override; bool on_key(const KeyEvent key) override;
bool on_touch(const TouchEvent event) override; bool on_touch(const TouchEvent event) override;
void set(uint16_t index, Dim width, std::string text, Color text_color); void set(uint32_t index, Dim width, std::string text, Color text_color);
private: private:
std::string text_ { }; std::string text_ { };
Color text_color_ { }; Color text_color_ { };
uint16_t index_ { }; uint32_t index_ { };
}; };
class TabView : public View { class TabView : public View {
@ -63,7 +63,10 @@ public:
void focus() override; void focus() override;
void on_show() override; void on_show() override;
void set_selected(uint16_t index); void set_selected(uint32_t index);
uint32_t selected() {
return current_tab;
};
private: private:
size_t n_tabs { }; size_t n_tabs { };

View File

@ -100,7 +100,7 @@ void OOKProcessor::on_message(const Message* const p) {
if (message.id == Message::ID::OOKConfigure) { if (message.id == Message::ID::OOKConfigure) {
samples_per_bit = message.samples_per_bit / 10; samples_per_bit = message.samples_per_bit / 10;
repeat = message.repeat - 1; repeat = message.repeat - 1;
length = message.stream_length - 1; length = message.stream_length;
pause = message.pause_symbols + 1; pause = message.pause_symbols + 1;
pause_counter = 0; pause_counter = 0;

View File

@ -41,7 +41,7 @@
#define DTMF_R2 TONES_F2D(852) #define DTMF_R2 TONES_F2D(852)
#define DTMF_R3 TONES_F2D(941) #define DTMF_R3 TONES_F2D(941)
const uint32_t ccir_deltas[16] = { const std::array<uint32_t, 16> ccir_deltas = {
TONES_F2D(1981), TONES_F2D(1981),
TONES_F2D(1124), TONES_F2D(1124),
TONES_F2D(1197), TONES_F2D(1197),
@ -80,7 +80,7 @@ const uint32_t dtmf_deltas[16][2] = {
{ DTMF_C0, DTMF_R3 } { DTMF_C0, DTMF_R3 }
}; };
const uint32_t eia_deltas[16] = { const std::array<uint32_t, 16> eia_deltas = {
TONES_F2D(600), TONES_F2D(600),
TONES_F2D(741), TONES_F2D(741),
TONES_F2D(882), TONES_F2D(882),
@ -99,7 +99,7 @@ const uint32_t eia_deltas[16] = {
TONES_F2D(1091) TONES_F2D(1091)
}; };
const uint32_t zvei_deltas[16] = { const std::array<uint32_t, 16> zvei_deltas = {
TONES_F2D(2400), TONES_F2D(2400),
TONES_F2D(1060), TONES_F2D(1060),
TONES_F2D(1160), TONES_F2D(1160),

View File

@ -491,7 +491,7 @@ void BigFrequency::paint(Painter& painter) {
break; break;
} }
digit_pos = { (240 - ((7 * digit_width) + 8) - (i * digit_width)) / 2, rect.location().y() }; digit_pos = { (Coord)(240 - ((7 * digit_width) + 8) - (i * digit_width)) / 2, rect.location().y() };
} }
segment_color = style().foreground; segment_color = style().foreground;

Binary file not shown.