diff --git a/firmware/application/CMakeLists.txt b/firmware/application/CMakeLists.txt index 7b49448a3..5fad90a25 100644 --- a/firmware/application/CMakeLists.txt +++ b/firmware/application/CMakeLists.txt @@ -144,6 +144,7 @@ set(CPPSRC protocols/ax25.cpp protocols/bht.cpp protocols/dcs.cpp + protocols/encoders.cpp protocols/lcr.cpp protocols/rds.cpp serializer.cpp diff --git a/firmware/application/protocols/bht.cpp b/firmware/application/protocols/bht.cpp index b54b151e1..787ce2bec 100644 --- a/firmware/application/protocols/bht.cpp +++ b/firmware/application/protocols/bht.cpp @@ -21,74 +21,56 @@ */ #include "bht.hpp" - -#include "portapack.hpp" #include "portapack_persistent_memory.hpp" -#include -#include - -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 gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_number, uint32_t relay_state) { size_t c; const encoder_def_t * um3750_def; - uint8_t bit[12]; - std::string ep_symbols; - char ook_bitstream[256]; - char ep_message[13] = { 0 }; + uint8_t bits[12]; + std::string ep_fragments; + //char ep_message[13] = { 0 }; - (void)relay_state_B; - - // EP frame // Repeated 2x 26 times // 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++) - bit[c] = (city_code >> c) & 1; + bits[c] = (city_code >> c) & 1; - bit[8] = family_code_ep >> 1; - bit[9] = family_code_ep & 1; - bit[10] = 0; // R1 first - if (relay_state_A) - bit[11] = relay_state_A - 1; - else - bit[11] = 0; + bits[8] = (family_code_ep >> 1) & 1; + bits[9] = family_code_ep & 1; + bits[10] = relay_number & 1; + bits[11] = relay_state ? 1 : 0; - for (c = 0; c < 12; c++) - ep_message[c] = bit[c] + '0'; - - //text_message.set(ep_message); + // Text for display + //for (c = 0; c < 12; c++) + // ep_message[c] = bits[c] + '0'; c = 0; for (auto ch : um3750_def->word_format) { if (ch == 'S') - ep_symbols += um3750_def->sync; + ep_fragments += um3750_def->sync; else - ep_symbols += um3750_def->bit_format[bit[c++]]; + ep_fragments += um3750_def->bit_format[bits[c++]]; } - c = 0; - for (auto ch : ep_symbols) { - if (ch != '0') - ook_bitstream[c >> 3] |= (1 << (7 - (c & 7))); - c++; - } - - return ep_message; + // Return bitstream length + return make_bitstream(ep_fragments); } std::string gen_message_xy(const std::string& ascii_code) { std::string local_code = ascii_code; - uint8_t ccir_message[20]; + uint8_t ccir_message[XY_TONE_COUNT]; uint8_t translate; uint32_t c; // 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'; - for (c = 0; c < 20; c++) { + for (c = 0; c < XY_TONE_COUNT; c++) { if (local_code[c] <= '9') translate = local_code[c] - '0'; else @@ -97,7 +79,7 @@ std::string gen_message_xy(const std::string& ascii_code) { } // 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 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, 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) { - uint8_t ccir_message[20]; + uint8_t ccir_message[XY_TONE_COUNT]; size_t c; - - // Xy CCIR frame // Header 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; if (subfamily_wc) - ccir_message[7] = 10; // Wildcard + ccir_message[7] = 0xA; // Wildcard else ccir_message[7] = subfamily_code; if (id_wc) { - ccir_message[8] = 10; // Wildcard - ccir_message[9] = 10; // Wildcard + ccir_message[8] = 0xA; // Wildcard + ccir_message[9] = 0xA; // Wildcard } else { ccir_message[8] = (receiver_code / 10); ccir_message[9] = (receiver_code % 10); } - ccir_message[10] = 11; // B + ccir_message[10] = 0xB; // Relay states 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[14] = relay_state_D; - ccir_message[15] = 11; // B + ccir_message[15] = 0xB; // End - for (c = 16; c < 20; c++) + for (c = 16; c < XY_TONE_COUNT; c++) ccir_message[c] = 0; // Replace repeats with E code - for (c = 1; c < 20; c++) - if (ccir_message[c] == ccir_message[c - 1]) ccir_message[c] = 14; + for (c = 1; c < XY_TONE_COUNT; c++) + if (ccir_message[c] == ccir_message[c - 1]) ccir_message[c] = 0xE; // 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 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 ascii; - for (size_t c = 0; c < 20; c++) { + for (size_t c = 0; c < XY_TONE_COUNT; c++) { if (ccir[c] > 9) ascii += (char)(ccir[c] - 10 + 'A'); else diff --git a/firmware/application/protocols/bht.hpp b/firmware/application/protocols/bht.hpp index 192ddb6ed..31ff1b9d0 100644 --- a/firmware/application/protocols/bht.hpp +++ b/firmware/application/protocols/bht.hpp @@ -21,17 +21,16 @@ */ #include "ui.hpp" -#include "ui_widget.hpp" #include "ui_navigation.hpp" #include "tonesets.hpp" #include "encoders.hpp" -#include "portapack.hpp" using namespace encoders; #define XY_TONE_LENGTH ((TONES_SAMPLERATE * 0.1) - 1) // 100ms #define XY_SILENCE (TONES_SAMPLERATE * 0.4) // 400ms +#define XY_TONE_COUNT 20 struct bht_city { std::string name; @@ -39,9 +38,7 @@ struct bht_city { bool recent; }; -//const rf::Frequency bht_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 88000000 }; - -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 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(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, diff --git a/firmware/application/protocols/encoders.cpp b/firmware/application/protocols/encoders.cpp new file mode 100644 index 000000000..409a91a1d --- /dev/null +++ b/firmware/application/protocols/encoders.cpp @@ -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 */ diff --git a/firmware/application/protocols/encoders.hpp b/firmware/application/protocols/encoders.hpp index 0d51a37a7..1da137f10 100644 --- a/firmware/application/protocols/encoders.hpp +++ b/firmware/application/protocols/encoders.hpp @@ -20,6 +20,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include #include @@ -29,7 +30,11 @@ namespace encoders { #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 { std::string name; // Encoder chip ref/name @@ -151,9 +156,9 @@ namespace encoders { 96, 32, { "011", "001" }, 12, "SAAAAAAAAAAAA", - "1", + "001", 100000, 4, - 0 // ? + (3 * 12) - 6 // Compensates for pause delay bug in proc_ook }, // UM3758 diff --git a/firmware/application/ui_bht_tx.cpp b/firmware/application/ui_bht_tx.cpp index 5494644e0..b65c79681 100644 --- a/firmware/application/ui_bht_tx.cpp +++ b/firmware/application/ui_bht_tx.cpp @@ -21,13 +21,11 @@ */ #include "ui_bht_tx.hpp" +#include "string_format.hpp" #include "baseband_api.hpp" #include "portapack_persistent_memory.hpp" -#include -#include - using namespace portapack; namespace ui { @@ -36,57 +34,98 @@ void BHTView::focus() { tx_view.focus(); } -BHTView::~BHTView() { - transmitter_model.disable(); - baseband::shutdown(); -} - void BHTView::start_tx() { - uint8_t c; + baseband::shutdown(); - view_xylos.generate_message(); - view_EPAR.generate_message(); - - if (view_xylos.tx_mode == XylosView::tx_modes::SINGLE) - progressbar.set_max(20); - else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE) - progressbar.set_max(20 * XY_SEQ_COUNT); - - transmitter_model.set_sampling_rate(1536000); - transmitter_model.set_rf_amp(true); - transmitter_model.set_baseband_bandwidth(1750000); - transmitter_model.enable(); - - // Setup tones for Xy - for (c = 0; c < 16; c++) - baseband::set_tone(c, ccir_deltas[c], XY_TONE_LENGTH); - - baseband::set_tones_config(transmitter_model.channel_bandwidth(), XY_SILENCE, 20, false, false); + if (tx_type == XYLOS) { + + baseband::run_image(portapack::spi_flash::image_tag_tones); + + view_xylos.generate_message(); + + //if (view_xylos.tx_mode == XylosView::tx_modes::SINGLE) + progressbar.set_max(20); + //else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE) + // progressbar.set_max(20 * XY_SEQ_COUNT); + + transmitter_model.set_sampling_rate(TONES_SAMPLERATE); + transmitter_model.set_rf_amp(true); + transmitter_model.set_baseband_bandwidth(1750000); + transmitter_model.enable(); + + // Setup tones + 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) { - 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) { - transmitter_model.disable(); - progressbar.set_value(0); - if (!checkbox_cligno.value()) { view_xylos.tx_mode = XylosView::tx_modes::IDLE; tx_view.set_transmitting(false); + progressbar.set_value(0); } else { chThdSleepMilliseconds(field_tempo.value() * 1000); // Dirty :( - view_EPAR.flip_relays(); view_xylos.flip_relays(); start_tx(); } - } else { + } else progressbar.set_value(progress); - } - } else if (view_xylos.tx_mode == XylosView::tx_modes::SEQUENCE) { + } else if (tx_type == EPAR) { + 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) { transmitter_model.disable(); @@ -105,7 +144,59 @@ void BHTView::on_tx_progress(const int progress, const bool done) { } else { 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(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() { @@ -113,25 +204,23 @@ void EPARView::flip_relays() { relay_states[0].set_selected_index(relay_states[0].selected_index() ^ 1); } -void EPARView::generate_message() { - //text_message.set( - gen_message_ep(field_city.value(), field_group.selected_index_value(), - relay_states[0].selected_index(), relay_states[1].selected_index()); - //); +size_t EPARView::generate_message() { + // R2, then R1 + return gen_message_ep(field_city.value(), field_group.selected_index_value(), + 1 - half, relay_states[half].selected_index()); } -EPARView::EPARView() { - size_t n; +EPARView::EPARView( + Rect parent_rect +) : View(parent_rect) { hidden(true); - //baseband::run_image(portapack::spi_flash::image_tag_ook); - add_children({ &labels, &field_city, &field_group, - &button_scan + //&button_scan }); field_city.set_value(220); @@ -144,7 +233,7 @@ EPARView::EPARView() { this->generate_message(); }; - n = 0; + size_t n = 0; for (auto& relay_state : relay_states) { relay_state.on_change = relay_state_fn; relay_state.set_parent_rect({ @@ -163,35 +252,34 @@ void EPARView::focus() { } 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 - rs = relay_states[0].selected_index(); - if (rs > 0) relay_states[0].set_selected_index(rs ^ 3); + if (rs > 0) + relay_states[0].set_selected_index(rs ^ 3); } void XylosView::generate_message() { - if (tx_mode == SINGLE) { + //if (tx_mode == SINGLE) { //text_message.set( 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(), relay_states[0].selected_index(), relay_states[1].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( gen_message_xy(sequence_matin[seq_index].code); //); - } + }*/ } -XylosView::XylosView() { - size_t n; +XylosView::XylosView( + Rect parent_rect +) : View(parent_rect) { hidden(true); - //baseband::run_image(portapack::spi_flash::image_tag_tones); - add_children({ &labels, &field_header_a, @@ -202,7 +290,7 @@ XylosView::XylosView() { &checkbox_wcsubfamily, &field_receiver, &checkbox_wcid, - &button_seq, + //&button_seq, }); field_header_a.set_value(0); @@ -236,7 +324,7 @@ XylosView::XylosView() { this->generate_message(); }; - n = 0; + size_t n = 0; for (auto& relay_state : relay_states) { relay_state.on_change = relay_state_fn; relay_state.set_parent_rect({ @@ -254,57 +342,4 @@ void XylosView::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(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 */ diff --git a/firmware/application/ui_bht_tx.hpp b/firmware/application/ui_bht_tx.hpp index f11ff58ec..cac62b118 100644 --- a/firmware/application/ui_bht_tx.hpp +++ b/firmware/application/ui_bht_tx.hpp @@ -40,7 +40,7 @@ namespace ui { class XylosView : public View { public: - XylosView(); + XylosView(Rect parent_rect); void focus() override; @@ -163,13 +163,15 @@ private: class EPARView : public View { public: - EPARView(); + EPARView(Rect parent_rect); void focus() override; void flip_relays(); - void generate_message(); + size_t generate_message(); + size_t half { 0 }; + private: Labels labels { { { 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 start_tx(); - XylosView view_xylos { }; - EPARView view_EPAR { }; + enum tx_type_t { + 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 { { "Xylos", Color::cyan(), &view_xylos }, diff --git a/firmware/application/ui_encoders.cpp b/firmware/application/ui_encoders.cpp index dd9f214fe..b003dd396 100644 --- a/firmware/application/ui_encoders.cpp +++ b/firmware/application/ui_encoders.cpp @@ -126,10 +126,10 @@ void EncodersConfigView::on_show() { } void EncodersConfigView::draw_waveform() { - size_t length = frame_symbols.length(); + size_t length = frame_fragments.length(); for (size_t n = 0; n < length; n++) { - if (frame_symbols[n] == '0') + if (frame_fragments[n] == '0') waveform_buffer[n] = 0; else waveform_buffer[n] = 1; @@ -142,13 +142,13 @@ void EncodersConfigView::draw_waveform() { void EncodersConfigView::generate_frame() { size_t i = 0; - frame_symbols.clear(); + frame_fragments.clear(); for (auto c : encoder_def->word_format) { if (c == 'S') - frame_symbols += encoder_def->sync; + frame_fragments += encoder_def->sync; 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(); @@ -285,9 +285,7 @@ void EncodersView::on_txdone(int n, const bool txdone) { void EncodersView::start_tx(const bool scan) { (void)scan; - uint8_t byte = 0; - size_t bitstream_length =0; - uint8_t * bitstream = shared_memory.bb_data.data; + size_t bitstream_length = 0; repeat_min = view_config.repeat_min(); @@ -311,14 +309,7 @@ void EncodersView::start_tx(const bool scan) { view_config.generate_frame(); - for (auto c : view_config.frame_symbols) { - byte <<= 1; - if (c != '0') - byte |= 1; - if ((bitstream_length & 7) == 7) - bitstream[bitstream_length >> 3] = byte; - bitstream_length++; - } + bitstream_length = make_bitstream(view_config.frame_fragments); transmitter_model.set_sampling_rate(OOK_SAMPLERATE); transmitter_model.set_rf_amp(true); diff --git a/firmware/application/ui_encoders.hpp b/firmware/application/ui_encoders.hpp index c7521da87..be1d8352f 100644 --- a/firmware/application/ui_encoders.hpp +++ b/firmware/application/ui_encoders.hpp @@ -48,7 +48,7 @@ public: uint32_t pause_symbols(); void generate_frame(); - std::string frame_symbols = "0"; + std::string frame_fragments = "0"; private: //bool abort_scan = false; diff --git a/firmware/application/ui_tabview.cpp b/firmware/application/ui_tabview.cpp index 91cb650b2..9f250bc6a 100644 --- a/firmware/application/ui_tabview.cpp +++ b/firmware/application/ui_tabview.cpp @@ -32,12 +32,12 @@ Tab::Tab() { }; void Tab::set( - uint16_t index, + uint32_t index, Dim width, std::string text, 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_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; if (index >= n_tabs) diff --git a/firmware/application/ui_tabview.hpp b/firmware/application/ui_tabview.hpp index 550a4e519..0fed8619e 100644 --- a/firmware/application/ui_tabview.hpp +++ b/firmware/application/ui_tabview.hpp @@ -41,12 +41,12 @@ public: bool on_key(const KeyEvent key) 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: std::string text_ { }; Color text_color_ { }; - uint16_t index_ { }; + uint32_t index_ { }; }; class TabView : public View { @@ -63,7 +63,10 @@ public: void focus() override; void on_show() override; - void set_selected(uint16_t index); + void set_selected(uint32_t index); + uint32_t selected() { + return current_tab; + }; private: size_t n_tabs { }; diff --git a/firmware/baseband/proc_ook.cpp b/firmware/baseband/proc_ook.cpp index da27720f4..4d2039328 100644 --- a/firmware/baseband/proc_ook.cpp +++ b/firmware/baseband/proc_ook.cpp @@ -100,7 +100,7 @@ void OOKProcessor::on_message(const Message* const p) { if (message.id == Message::ID::OOKConfigure) { samples_per_bit = message.samples_per_bit / 10; repeat = message.repeat - 1; - length = message.stream_length - 1; + length = message.stream_length; pause = message.pause_symbols + 1; pause_counter = 0; diff --git a/firmware/common/tonesets.hpp b/firmware/common/tonesets.hpp index 4f8450fb9..d1d9851f4 100644 --- a/firmware/common/tonesets.hpp +++ b/firmware/common/tonesets.hpp @@ -41,7 +41,7 @@ #define DTMF_R2 TONES_F2D(852) #define DTMF_R3 TONES_F2D(941) -const uint32_t ccir_deltas[16] = { +const std::array ccir_deltas = { TONES_F2D(1981), TONES_F2D(1124), TONES_F2D(1197), @@ -80,7 +80,7 @@ const uint32_t dtmf_deltas[16][2] = { { DTMF_C0, DTMF_R3 } }; -const uint32_t eia_deltas[16] = { +const std::array eia_deltas = { TONES_F2D(600), TONES_F2D(741), TONES_F2D(882), @@ -99,7 +99,7 @@ const uint32_t eia_deltas[16] = { TONES_F2D(1091) }; -const uint32_t zvei_deltas[16] = { +const std::array zvei_deltas = { TONES_F2D(2400), TONES_F2D(1060), TONES_F2D(1160), diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index d7b197140..c5e370880 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -491,7 +491,7 @@ void BigFrequency::paint(Painter& painter) { 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; diff --git a/firmware/portapack-h1-havoc.bin b/firmware/portapack-h1-havoc.bin index a8873f971..7bdb3fcd0 100644 Binary files a/firmware/portapack-h1-havoc.bin and b/firmware/portapack-h1-havoc.bin differ