mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-10-16 08:30:01 +00:00
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:
83
firmware/application/external/coasterp/main.cpp
vendored
Normal file
83
firmware/application/external/coasterp/main.cpp
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Bernd Herzog
|
||||
*
|
||||
* 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_coasterp.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "external_app.hpp"
|
||||
|
||||
namespace ui::external_app::coasterp {
|
||||
void initialize_app(ui::NavigationView& nav) {
|
||||
nav.push<CoasterPagerView>();
|
||||
}
|
||||
} // namespace ui::external_app::coasterp
|
||||
|
||||
extern "C" {
|
||||
|
||||
__attribute__((section(".external_app.app_coasterp.application_information"), used)) application_information_t _application_information_coasterp = {
|
||||
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||
/*.externalAppEntry = */ ui::external_app::coasterp::initialize_app,
|
||||
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||
/*.app_version = */ VERSION_MD5,
|
||||
|
||||
/*.app_name = */ "BurgerPgr",
|
||||
/*.bitmap_data = */ {
|
||||
|
||||
0x00,
|
||||
0x00,
|
||||
0xE0,
|
||||
0x07,
|
||||
0xF8,
|
||||
0x1F,
|
||||
0xFC,
|
||||
0x3F,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x00,
|
||||
0x00,
|
||||
0x55,
|
||||
0x55,
|
||||
0xAA,
|
||||
0xAA,
|
||||
0x55,
|
||||
0x55,
|
||||
0x00,
|
||||
0x00,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFE,
|
||||
0x7F,
|
||||
0x00,
|
||||
0x00,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::yellow().v,
|
||||
/*.menu_location = */ app_location_t::TX,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_fsktx */ {'P', 'F', 'S', 'K'},
|
||||
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||
};
|
||||
}
|
134
firmware/application/external/coasterp/ui_coasterp.cpp
vendored
Normal file
134
firmware/application/external/coasterp/ui_coasterp.cpp
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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::external_app::coasterp {
|
||||
|
||||
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::external_app::coasterp */
|
103
firmware/application/external/coasterp/ui_coasterp.hpp
vendored
Normal file
103
firmware/application/external/coasterp/ui_coasterp.hpp
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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_language.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::external_app::coasterp {
|
||||
|
||||
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}, LanguageHelper::currentMessages[LANG_DATADP], Color::light_grey()}};
|
||||
|
||||
SymField sym_data{
|
||||
{7 * 8, 8 * 8},
|
||||
16,
|
||||
SymField::Type::Hex};
|
||||
|
||||
Checkbox checkbox_scan{
|
||||
{10 * 8, 14 * 8},
|
||||
4,
|
||||
LanguageHelper::currentMessages[LANG_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::external_app::coasterp */
|
Reference in New Issue
Block a user