Move more apps + language module (#1643)

* CoasterP to ext (Burger pager)
* LGE to ext app
* Solve compiler literal removal with centralizing common string literals.
This commit is contained in:
Totoo 2023-12-12 16:55:50 +01:00 committed by GitHub
parent 5b9d898202
commit b58ee761a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 429 additions and 152 deletions

View file

@ -1,357 +0,0 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2019 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.
*/
// The UI for this app is in French because it concerns leisure centers
// only established in France. "LGE" stands for a trademark I'd rather
// not spell out completely here.
#include "lge_app.hpp"
#include "baseband_api.hpp"
#include "ui_textentry.hpp"
#include "string_format.hpp"
#include <cstring>
#include <stdio.h>
using namespace portapack;
namespace ui {
void LGEView::focus() {
options_frame.focus();
}
LGEView::~LGEView() {
transmitter_model.disable();
baseband::shutdown();
}
void LGEView::generate_lge_frame(const uint8_t command, const uint16_t address_a, const uint16_t address_b, std::vector<uint8_t>& data) {
std::array<uint8_t, 5> header = {
command,
(uint8_t)(address_a & 255),
(uint8_t)(address_a >> 8),
(uint8_t)(address_b & 255),
(uint8_t)(address_b >> 8),
};
data.insert(data.begin(), header.begin(), header.end());
frame_size = rfm69.gen_frame(data);
for (auto b : data)
console.write(to_string_hex(b, 2) + " ");
}
void LGEView::generate_frame_touche() {
// 0001.89s
// 0D 96 02 12 0E 00 46 28 01 45 27 01 44 23 66 30
std::vector<uint8_t> data{0x46, 0x28, 0x01, 0x45, 0x27, 0x01, 0x44, 0x23};
console.write("\n" STR_COLOR_LIGHT_GREY "Touche:");
generate_lge_frame(0x96, (field_player.value() << 8) | field_room.value(), 0x0001, data);
}
void LGEView::generate_frame_nickname() {
// 0040.48s:
// 30 02 1A 00 19 00 FF 00 02 19 42 52 45 42 49 53 20 00 00 00 00 00 00 00 00 00
// 04 01 B0 04 7F 1F 11 33 40 1F 22 01 07 00 00 01 07 00 00 63 05 00 00 99 A2
std::vector<uint8_t> data{};
std::array<uint8_t, 3> data_header = {0xFF, 0x00, 0x02};
std::array<uint8_t, 22> data_footer = {
0x01, 0xB0, 0x04, 0x7F,
0x1F, 0x11, 0x33, 0x40,
0x1F, 0x22, 0x01, 0x07,
0x00, 0x00, 0x01, 0x07,
0x00, 0x00, 0x63, 0x05,
0x00, 0x00};
uint32_t c;
// data_header[2] = field_room.value(); // ?
// data_footer[0] = field_room.value(); // ?
data.insert(data.begin(), data_header.begin(), data_header.end());
data.push_back(field_player.value());
c = 0;
for (auto& ch : nickname) {
data.push_back(ch);
c++;
}
// Space at the end, is this required ?
data.push_back(0x20);
// Pad with zeroes
while (++c < 16)
data.push_back(0x00);
data.push_back(field_team.value());
data.insert(data.end(), data_footer.begin(), data_footer.end());
console.write("\n" STR_COLOR_YELLOW "Set nickname:");
generate_lge_frame(0x02, 0x001A, field_player.value(), data);
}
void LGEView::generate_frame_team() {
// 0041.83s:
// 3D 03 FF FF FF FF 02 03 01 52 4F 55 47 45 00 00 00 00 00 00 00 00 00 00 00 00
// 02 56 45 52 54 45 00 00 00 00 00 00 00 00 00 00 00 01 03 42 4C 45 55 45 00 00
// 00 00 00 00 00 00 00 00 00 02 43 29
std::vector<uint8_t> data{};
std::array<uint8_t, 2> data_header = {0x02, 0x01};
uint32_t c;
data.insert(data.begin(), data_header.begin(), data_header.end());
data.push_back(field_team.value());
c = 0;
for (auto& ch : nickname) {
data.push_back(ch);
c++;
}
// Pad with zeroes
while (c++ < 16)
data.push_back(0x00);
data.push_back(field_team.value() - 1); // Color ?
console.write("\n" STR_COLOR_GREEN "Set team:");
generate_lge_frame(0x03, data);
}
void LGEView::generate_frame_broadcast_nickname() {
// 0043.86s:
// 3D 04 FF FF FF FF 02 03 19 42 52 45 42 49 53 20 00 00 00 00 00 00 00 00 00 04
// 07 50 4F 4E 45 59 20 00 00 00 00 00 00 00 00 00 00 05 1B 41 42 42 59 20 00 00
// 00 00 00 00 00 00 00 00 00 04 0A 02
std::vector<uint8_t> data{};
std::array<uint8_t, 2> data_header = {0x02, 0x01};
uint32_t c;
data.insert(data.begin(), data_header.begin(), data_header.end());
data.push_back(field_player.value());
c = 0;
for (auto& ch : nickname) {
data.push_back(ch);
c++;
}
// Space at the end, is this required ?
data.push_back(0x20);
// Pad with zeroes
while (++c < 16)
data.push_back(0x00);
data.push_back(field_team.value());
console.write("\n" STR_COLOR_BLUE "Broadcast nickname:");
generate_lge_frame(0x04, data);
}
void LGEView::generate_frame_start() {
// 0166.13s:
// 0A 05 FF FF FF FF 02 EC FF FF FF A3 35
std::vector<uint8_t> data{0x02, 0xEC, 0xFF, 0xFF, 0xFF};
// data[0] = field_room.value(); // ?
console.write("\n" STR_COLOR_MAGENTA "Start:");
generate_lge_frame(0x05, data);
}
void LGEView::generate_frame_gameover() {
std::vector<uint8_t> data{(uint8_t)field_room.value()};
console.write("\n" STR_COLOR_RED "Gameover:");
generate_lge_frame(0x0D, data);
}
void LGEView::generate_frame_collier() {
uint8_t flags = 0;
// Custom
// 0C 00 13 37 13 37 id flags channel playerid zapduty zaptime checksum CRC CRC
// channel: field_channel
// playerid: field_player
// zapduty: field_power
// zaptime: field_duration
if (checkbox_heartbeat.value())
flags |= 1;
if (checkbox_rxtick.value())
flags |= 2;
uint8_t checksum = 0;
uint8_t id = (uint8_t)field_id.value();
std::vector<uint8_t> data{
id,
flags,
(uint8_t)field_room.value(),
(uint8_t)field_player.value(),
(uint8_t)field_power.value(),
(uint8_t)(field_duration.value() * 10)};
for (auto& v : data)
checksum += v;
data.push_back(checksum - id);
console.write("\n" STR_COLOR_DARK_YELLOW "Config:");
generate_lge_frame(0x00, 0x3713, 0x3713, data);
}
void LGEView::start_tx() {
if (tx_mode == ALL) {
transmitter_model.set_target_frequency(channels[channel_index]);
tx_view.on_show(); // Refresh tuning frequency display
tx_view.set_dirty();
}
/* By experimental test, previous fw 1.7.4 seems to have setting , tx LPF = 5Mhz
This LGE - seems to be for controlling a "laser tag equipment" (Havoc app) , modulated FSK , low bauds,
and using max GUI fm dev 150k , we are still in NBFM, let's reduce slightly original TX LPF 5M ->2M5*/
transmitter_model.set_baseband_bandwidth(2'500'000);
transmitter_model.enable();
chThdSleep(100);
baseband::set_fsk_data(frame_size * 8, 2280000 / 9600, 4000, 256);
}
void LGEView::stop_tx() {
tx_mode = IDLE;
transmitter_model.disable();
tx_view.set_transmitting(false);
}
void LGEView::on_tx_progress(const uint32_t progress, const bool done) {
(void)progress;
if (!done) return;
transmitter_model.disable();
/*if (repeats < 2) {
chThdSleep(100);
repeats++;
start_tx();
} else {*/
if (tx_mode == ALL) {
if (channel_index < 2) {
channel_index++;
repeats = 0;
start_tx();
} else {
stop_tx();
}
} else {
stop_tx();
}
//}
}
LGEView::LGEView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
add_children({&labels,
&options_frame,
&field_room,
&button_text,
&field_team,
&field_player,
&field_id,
&field_power,
&field_duration,
&checkbox_heartbeat,
&checkbox_rxtick,
&checkbox_channels,
&console,
&tx_view});
field_room.set_value(1);
field_team.set_value(1);
field_player.set_value(1);
field_id.set_value(1);
field_power.set_value(1);
field_duration.set_value(2);
button_text.on_select = [this, &nav](Button&) {
text_prompt(
nav,
nickname,
15,
[this](std::string& buffer) {
button_text.set_text(buffer);
});
};
tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.target_frequency());
new_view->on_changed = [this](rf::Frequency f) {
transmitter_model.set_target_frequency(f);
};
};
tx_view.on_start = [this]() {
if (tx_mode == IDLE) {
auto i = options_frame.selected_index_value();
if (i == 0)
generate_frame_touche();
else if (i == 1)
generate_frame_nickname();
else if (i == 2)
generate_frame_team();
else if (i == 3)
generate_frame_broadcast_nickname();
else if (i == 4)
generate_frame_start();
else if (i == 5)
generate_frame_gameover();
else if (i == 6)
generate_frame_collier();
repeats = 0;
channel_index = 0;
tx_mode = checkbox_channels.value() ? ALL : SINGLE;
tx_view.set_transmitting(true);
start_tx();
}
};
tx_view.on_stop = [this]() {
stop_tx();
};
}
} /* namespace ui */

View file

@ -1,188 +0,0 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2019 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"
#include "ui_navigation.hpp"
#include "ui_transmitter.hpp"
#include "rfm69.hpp"
#include "message.hpp"
#include "transmitter_model.hpp"
#include "portapack.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
namespace ui {
class LGEView : public View {
public:
LGEView(NavigationView& nav);
~LGEView();
void focus() override;
std::string title() const override { return "LGE tool TX"; };
private:
enum tx_modes {
IDLE = 0,
SINGLE,
ALL
};
TxRadioState radio_state_{
868067000 /* frequency */,
1750000 /* bandwidth */,
2280000 /* sampling rate */
};
app_settings::SettingsManager settings_{
"tx_lge", app_settings::Mode::TX};
tx_modes tx_mode = IDLE;
RFM69 rfm69{5, 0x2DD4, true, true};
uint32_t frame_size{0};
uint32_t repeats{0};
uint32_t channel_index{0};
std::string nickname{"ABCDEF"};
rf::Frequency channels[3] = {868067000, 868183000, 868295000};
void start_tx();
void stop_tx();
void generate_lge_frame(const uint8_t command, std::vector<uint8_t>& data) {
generate_lge_frame(command, 0xFFFF, 0xFFFF, data);
}
void generate_lge_frame(const uint8_t command, const uint16_t address_a, const uint16_t address_b, std::vector<uint8_t>& data);
void generate_frame_touche();
void generate_frame_nickname();
void generate_frame_team();
void generate_frame_broadcast_nickname();
void generate_frame_start();
void generate_frame_gameover();
void generate_frame_collier();
void on_tx_progress(const uint32_t progress, const bool done);
Labels labels{
//{ { 7 * 8, 1 * 8 }, "NO FUN ALLOWED !", Color::red() },
{{1 * 8, 1 * 8}, "Frame:", Color::light_grey()},
{{2 * 8, 3 * 8}, "Room:", Color::light_grey()},
{{14 * 8, 3 * 8}, "Text:", Color::light_grey()},
{{2 * 8, 5 * 8}, "Team:", Color::light_grey()},
{{0 * 8, 7 * 8}, "Player:", Color::light_grey()},
{{0 * 8, 10 * 8}, "Vest:", Color::light_grey()},
{{4 * 8, 12 * 8}, "ID:", Color::light_grey()},
{{3 * 8, 14 * 8}, "Pow: /10", Color::light_grey()},
{{2 * 8, 16 * 8}, "Time: x100ms", Color::light_grey()}};
OptionsField options_frame{
{7 * 8, 1 * 8},
13,
{{"Key", 0},
{"Set nickname", 1},
{"Set team", 2},
{"Brdcst nick", 3},
{"Start", 4},
{"Game over", 5},
{"Set vest", 6}}};
Checkbox checkbox_channels{
{20 * 8, 1 * 8},
7,
"All ch.",
true};
NumberField field_room{
{7 * 8, 3 * 8},
1,
{1, 2},
1,
'0'};
Button button_text{
{14 * 8, 5 * 8, 16 * 8, 3 * 8},
"ABCDEF"};
NumberField field_team{
{7 * 8, 5 * 8},
1,
{1, 6},
1,
'0'};
NumberField field_player{
{7 * 8, 7 * 8},
2,
{1, 50},
1,
'0'};
Checkbox checkbox_heartbeat{
{17 * 8, 12 * 8},
9,
"Heartbeat",
true};
Checkbox checkbox_rxtick{
{17 * 8, 15 * 8},
7,
"RX tick",
true};
NumberField field_id{
{7 * 8, 12 * 8},
1,
{1, 2},
1,
'0'};
NumberField field_power{
{7 * 8, 14 * 8},
2,
{1, 10},
1,
'0'};
NumberField field_duration{
{7 * 8, 16 * 8},
2,
{1, 25},
1,
'0'};
Console console{
{0, 18 * 8, 30 * 8, 7 * 16}};
TransmitterView tx_view{
16 * 16,
10000,
12};
MessageHandlerRegistration message_handler_tx_progress{
Message::ID::TXProgress,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
this->on_tx_progress(message.progress, message.done);
}};
};
} /* namespace ui */

View file

@ -1,134 +0,0 @@
/*
* 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_coasterp.hpp"
#include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp"
#include <cstring>
#include <stdio.h>
using namespace portapack;
namespace ui {
void CoasterPagerView::focus() {
sym_data.focus();
}
CoasterPagerView::~CoasterPagerView() {
transmitter_model.disable();
baseband::shutdown();
}
void CoasterPagerView::generate_frame() {
constexpr uint8_t frame_bytes = 19;
uint8_t frame[frame_bytes];
// Preamble (8 bytes)
for (uint8_t c = 0; c < 8; c++)
frame[c] = 0x55;
// Sync word
frame[8] = 0x2D;
frame[9] = 0xD4;
// Data length
frame[10] = 8;
// Data
auto data_bytes = to_byte_array(sym_data.to_integer());
memcpy(&frame[11], data_bytes.data(), data_bytes.size());
// Copy for baseband
memcpy(shared_memory.bb_data.data, frame, frame_bytes);
}
void CoasterPagerView::start_tx() {
generate_frame();
transmitter_model.enable();
baseband::set_fsk_data(19 * 8, 2280000 / 1000, 5000, 32);
}
void CoasterPagerView::on_tx_progress(const uint32_t /*progress*/, const bool done) {
if (done) {
if (tx_mode == SINGLE) {
transmitter_model.disable();
tx_mode = IDLE;
tx_view.set_transmitting(false);
} else if (tx_mode == SCAN) {
// Increment address
uint64_t data = sym_data.to_integer();
uint16_t address = data & 0xFFFF;
address++;
data = (data & 0xFFFFFFFFFFFF0000) + address;
sym_data.set_value(data);
start_tx();
}
}
}
CoasterPagerView::CoasterPagerView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
add_children({&labels,
&sym_data,
&checkbox_scan,
&text_message,
&tx_view});
sym_data.set_value(0x44013B30303034BC);
checkbox_scan.set_value(false);
generate_frame();
tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.target_frequency());
new_view->on_changed = [this](rf::Frequency f) {
transmitter_model.set_target_frequency(f);
};
};
tx_view.on_start = [this]() {
if (tx_mode == IDLE) {
if (checkbox_scan.value())
tx_mode = SCAN;
else
tx_mode = SINGLE;
tx_view.set_transmitting(true);
start_tx();
}
};
tx_view.on_stop = [this]() {
tx_view.set_transmitting(false);
tx_mode = IDLE;
};
}
} /* namespace ui */

View file

@ -1,102 +0,0 @@
/*
* 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"
#include "ui_navigation.hpp"
#include "ui_transmitter.hpp"
#include "message.hpp"
#include "transmitter_model.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "portapack.hpp"
namespace ui {
class CoasterPagerView : public View {
public:
CoasterPagerView(NavigationView& nav);
~CoasterPagerView();
void focus() override;
std::string title() const override { return "BurgerPgrTX"; };
private:
enum tx_modes {
IDLE = 0,
SINGLE,
SCAN
};
tx_modes tx_mode = IDLE;
TxRadioState radio_state_{
433920000, /* frequency */
1750000 /* bandwidth */,
2280000 /* sampling rate */
};
app_settings::SettingsManager settings_{
"tx_burger", app_settings::Mode::TX};
void start_tx();
void generate_frame();
void on_tx_progress(const uint32_t progress, const bool done);
Labels labels{
{{1 * 8, 3 * 8}, "Syscall pager TX beta", Color::light_grey()},
{{1 * 8, 8 * 8}, "Data:", Color::light_grey()}};
SymField sym_data{
{7 * 8, 8 * 8},
16,
SymField::Type::Hex};
Checkbox checkbox_scan{
{10 * 8, 14 * 8},
4,
"Scan"};
/*
ProgressBar progressbar {
{ 5 * 8, 12 * 16, 20 * 8, 16 }};
*/
Text text_message{
{5 * 8, 13 * 16, 20 * 8, 16},
""};
TransmitterView tx_view{
16 * 16,
10000,
12};
MessageHandlerRegistration message_handler_tx_progress{
Message::ID::TXProgress,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
this->on_tx_progress(message.progress, message.done);
}};
};
} /* namespace ui */

View file

@ -1,272 +0,0 @@
/*
* 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_lcr.hpp"
#include "ui_modemsetup.hpp"
#include "lcr.hpp"
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "serializer.hpp"
using namespace portapack;
namespace ui {
void LCRView::focus() {
button_set_rgsb.focus();
}
LCRView::~LCRView() {
transmitter_model.disable();
baseband::shutdown();
}
/*
// Recap: frequency @ baudrate
final_str = to_string_short_freq(persistent_memory::tuned_frequency());
final_str += '@';
final_str += to_string_dec_int(persistent_memory::modem_baudrate(), 4);
final_str += "bps ";
//final_str += modem_defs[persistent_memory::modem_def_index()].name;
text_recap.set(final_str);*/
void LCRView::update_progress() {
if (tx_mode == IDLE) {
text_status.set("Ready");
progress.set_value(0);
} else {
std::string progress_str = to_string_dec_uint(repeat_index) + "/" + to_string_dec_uint(persistent_memory::modem_repeat()) +
" " + to_string_dec_uint(scan_index + 1) + "/" + to_string_dec_uint(scan_count);
text_status.set(progress_str);
if (tx_mode == SINGLE)
progress.set_value(repeat_index);
else if (tx_mode == SCAN)
progress.set_value(scan_progress);
}
}
void LCRView::on_tx_progress(const uint32_t progress, const bool done) {
if (!done) {
// Repeating...
repeat_index = progress + 1;
if (tx_mode == SCAN)
scan_progress++;
} else {
// Done transmitting
tx_view.set_transmitting(false);
transmitter_model.disable();
if ((tx_mode == SCAN) && (scan_index < (scan_count - 1))) {
// Next address
scan_index++;
scan_progress++;
repeat_index = 1;
start_tx(true);
} else {
tx_mode = IDLE;
}
}
update_progress();
}
void LCRView::start_tx(const bool scan) {
uint32_t repeats = persistent_memory::modem_repeat();
if (scan) {
if (tx_mode != SCAN) {
scan_index = 0;
scan_count = scan_list[options_scanlist.selected_index()].count;
scan_progress = 1;
repeat_index = 1;
tx_mode = SCAN;
progress.set_max(scan_count * repeats);
update_progress();
}
rgsb = scan_list[options_scanlist.selected_index()].addresses[scan_index];
button_set_rgsb.set_text(rgsb);
} else {
tx_mode = SINGLE;
repeat_index = 1;
scan_count = 1;
scan_index = 0;
progress.set_max(repeats);
update_progress();
}
std::vector<std::string> litterals_list;
for (size_t i = 0; i < LCR_MAX_AM; i++) {
if (checkboxes[i].value())
litterals_list.push_back(litteral[i]);
}
modems::generate_data(lcr::generate_message(rgsb, litterals_list, options_ec.selected_index()), lcr_message_data);
/* It is AFSK modulation , measuring original fw 1.7.4 spectrum BW is just around 30khz , NBFM */
transmitter_model.set_baseband_bandwidth(1'750'000); // Min TX LPF 1M75, same spectrum as previous fw 1.7.4
transmitter_model.enable();
memcpy(shared_memory.bb_data.data, lcr_message_data, sizeof(lcr_message_data));
baseband::set_afsk_data(
AFSK_TX_SAMPLERATE / persistent_memory::modem_baudrate(),
persistent_memory::afsk_mark_freq(),
persistent_memory::afsk_space_freq(),
repeats,
transmitter_model.channel_bandwidth(),
serializer::symbol_count(persistent_memory::serial_format()));
}
void LCRView::on_button_set_am(NavigationView& nav, int16_t button_id) {
text_prompt(
nav,
litteral[button_id],
7,
[this, button_id](std::string& buffer) {
texts[button_id].set(buffer);
});
}
LCRView::LCRView(NavigationView& nav) {
std::string label;
baseband::run_image(portapack::spi_flash::image_tag_afsk);
add_children({&labels,
&options_ec,
&button_set_rgsb,
&button_modem_setup,
&text_status,
&progress,
&options_scanlist,
&check_scan,
&button_clear,
&tx_view});
options_scanlist.set_selected_index(0);
const auto button_set_am_fn = [this, &nav](Button& button) {
on_button_set_am(nav, button.id);
};
for (size_t n = 0; n < LCR_MAX_AM; n++) {
Button* button = &buttons[n];
button->on_select = button_set_am_fn;
button->id = n;
button->set_text("AM " + to_string_dec_uint(n + 1));
button->set_parent_rect({static_cast<Coord>(40),
static_cast<Coord>(n * 32 + 64),
48, 24});
add_child(button);
Checkbox* checkbox = &checkboxes[n];
checkbox->set_parent_rect({static_cast<Coord>(8),
static_cast<Coord>(n * 32 + 64),
48, 24});
checkbox->set_value(false);
add_child(checkbox);
Rectangle* rectangle = &rectangles[n];
rectangle->set_parent_rect({static_cast<Coord>(98),
static_cast<Coord>(n * 32 + 66),
68, 20});
rectangle->set_color(ui::Color::grey());
rectangle->set_outline(true);
add_child(rectangle);
Text* text = &texts[n];
text->set_parent_rect({static_cast<Coord>(104),
static_cast<Coord>(n * 32 + 68),
7 * 8, 16});
add_child(text);
}
button_set_rgsb.set_text(rgsb);
options_ec.set_selected_index(0); // Auto
checkboxes[0].set_value(true);
button_set_rgsb.on_select = [this, &nav](Button&) {
text_prompt(
nav,
rgsb,
4,
[this](std::string& buffer) {
button_set_rgsb.set_text(buffer);
});
};
button_modem_setup.on_select = [this, &nav](Button&) {
if (tx_mode == IDLE)
nav.push<ModemSetupView>();
};
button_clear.on_select = [this, &nav](Button&) {
options_ec.set_selected_index(0); // Auto
for (size_t n = 0; n < LCR_MAX_AM; n++) {
litteral[n] = " ";
checkboxes[n].set_value(true);
}
};
tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.target_frequency());
new_view->on_changed = [this](rf::Frequency f) {
transmitter_model.set_target_frequency(f);
};
};
tx_view.on_start = [this]() {
if (check_scan.value()) {
if (tx_mode == IDLE) {
start_tx(true);
tx_view.set_transmitting(true);
} else {
// Kill scan process
baseband::kill_afsk();
tx_view.set_transmitting(false);
transmitter_model.disable();
text_status.set("Abort @" + rgsb);
progress.set_value(0);
tx_mode = IDLE;
}
} else {
if (tx_mode == IDLE) {
start_tx(false);
tx_view.set_transmitting(true);
}
}
};
tx_view.on_stop = [this]() {
tx_view.set_transmitting(false);
transmitter_model.disable();
tx_mode = IDLE;
};
}
} /* namespace ui */

View file

@ -1,161 +0,0 @@
/*
* 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"
#include "ui_textentry.hpp"
#include "ui_transmitter.hpp"
#include "message.hpp"
#include "modems.hpp"
#include "transmitter_model.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
namespace ui {
#define LCR_MAX_AM 5
class LCRView : public View {
public:
LCRView(NavigationView& nav);
~LCRView();
void focus() override;
std::string title() const override { return "TEDI/LCR TX"; };
private:
struct scan_list_t {
uint8_t count;
const std::string* addresses;
};
const scan_list_t scan_list[2] = {
{36, &RGSB_list_Lille[0]},
{20, &RGSB_list_Reims[0]}};
const std::string RGSB_list_Lille[36] = {
"AI10", "AI20", "AI30", "AI40",
"AI50", "AI60", "AI70", "AJ10",
"AJ20", "AJ30", "AJ40", "AJ50",
"AJ60", "AJ70", "AK10",
"EAA0", "EAB0", "EAC0", "EAD0",
"EbA0", "EbB0", "EbC0", "EbD0",
"EbE0", "EbF0", "EbG0", "EbH0",
"EbI0", "EbJ0", "EbK0", "EbL0",
"EbM0", "EbN0", "EbO0", "EbP0",
"EbS0"};
const std::string RGSB_list_Reims[20] = {
"AI10", "AI20", "AI30", "AI40",
"AI50", "AI60", "AI70",
"AJ10", "AJ20", "AJ30", "AJ40",
"AJ50", "AJ60", "AJ70",
"AK10", "AK20", "AK50", "AK60",
"AK70",
"AP10"};
enum tx_modes {
IDLE = 0,
SINGLE,
SCAN
};
TxRadioState radio_state_{
0 /* frequency */,
1750000 /* bandwidth */,
AFSK_TX_SAMPLERATE /* sampling rate */
};
app_settings::SettingsManager settings_{
"tx_lcr", app_settings::Mode::TX};
tx_modes tx_mode = IDLE;
uint8_t scan_count{0}, scan_index{0};
uint32_t scan_progress{0};
std::array<std::string, LCR_MAX_AM> litteral{{" "}};
std::string rgsb{"AI10"};
uint16_t lcr_message_data[256];
uint8_t repeat_index{0};
void update_progress();
void start_tx(const bool scan);
void on_tx_progress(const uint32_t progress, const bool done);
void on_button_set_am(NavigationView& nav, int16_t button_id);
Labels labels{
{{0, 8}, "EC: RGSB:", Color::light_grey()},
{{17 * 8, 4 * 8}, "List:", Color::light_grey()}};
std::array<Button, LCR_MAX_AM> buttons{};
std::array<Checkbox, LCR_MAX_AM> checkboxes{};
std::array<Rectangle, LCR_MAX_AM> rectangles{};
std::array<Text, LCR_MAX_AM> texts{};
OptionsField options_ec{
{3 * 8, 8},
4,
{{"Auto", 0},
{"Jour", 1},
{"Nuit", 2},
{"S ? ", 3}}};
Button button_set_rgsb{
{13 * 8, 4, 8 * 8, 24},
"RGSB"};
Checkbox check_scan{
{22 * 8, 4},
4,
"Scan"};
Button button_modem_setup{
{1 * 8, 4 * 8 + 2, 14 * 8, 24},
"Modem setup"};
OptionsField options_scanlist{
{22 * 8, 4 * 8},
6,
{{"Reims ", 1}}};
Button button_clear{
{22 * 8, 8 * 8, 7 * 8, 19 * 8},
"CLEAR"};
Text text_status{
{2 * 8, 27 * 8 + 4, 26 * 8, 16},
"Ready"};
ProgressBar progress{
{2 * 8, 29 * 8 + 4, 26 * 8, 16}};
TransmitterView tx_view{
16 * 16,
10000,
12};
MessageHandlerRegistration message_handler_tx_progress{
Message::ID::TXProgress,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
this->on_tx_progress(message.progress, message.done);
}};
};
} /* namespace ui */