This commit is contained in:
HTotoo
2024-11-10 18:52:37 +01:00
parent 458a6634bf
commit 491cb667cc
12 changed files with 659 additions and 0 deletions
+6
View File
@@ -107,6 +107,11 @@ set(EXTCPPSRC
external/acars_rx/main.cpp
external/acars_rx/acars_app.cpp
#wefax_rx
external/wefax_rx/main.cpp
external/wefax_rx/ui_wefax_rx.cpp
#shoppingcart_lock
external/shoppingcart_lock/main.cpp
external/shoppingcart_lock/shoppingcart_lock.cpp
@@ -143,5 +148,6 @@ set(EXTAPPLIST
sstvtx
random_password
#acars_rx
wefax_rx
shoppingcart_lock
)
+8
View File
@@ -50,6 +50,7 @@ MEMORY
ram_external_app_acars_rx(rwx) : org = 0xADC90000, len = 32k
ram_external_app_shoppingcart_lock(rwx) : org = 0xADCA0000, len = 32k
ram_external_app_cvs_spam(rwx) : org = 0xADCB0000, len = 32k
ram_external_app_wefax_rx(rwx) : org = 0xADCC0000, len = 32k
}
SECTIONS
@@ -217,4 +218,11 @@ SECTIONS
*(*ui*external_app*cvs_spam*);
} > ram_external_app_cvs_spam
.external_app_wefax_rx : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_wefax_rx.application_information));
*(*ui*external_app*wefax_rx*);
} > ram_external_app_wefax_rx
}
+82
View File
@@ -0,0 +1,82 @@
/*
* Copyright (C) 2024 HTotoo
*
* 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_wefax_rx.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::wefax_rx {
void initialize_app(ui::NavigationView& nav) {
nav.push<WeFaxRxView>();
}
} // namespace ui::external_app::wefax_rx
extern "C" {
__attribute__((section(".external_app.app_wefax_rx.application_information"), used)) application_information_t _application_information_wefax_rx = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::wefax_rx::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "WeFax",
/*.bitmap_data = */ {
0x00,
0x00,
0xFC,
0x07,
0x04,
0x0C,
0x04,
0x1C,
0x04,
0x3C,
0x84,
0x21,
0x84,
0x21,
0x84,
0x21,
0xF4,
0x2F,
0xF4,
0x2F,
0x84,
0x21,
0x84,
0x21,
0x84,
0x21,
0x04,
0x20,
0xFC,
0x3F,
0x00,
0x00,
},
/*.icon_color = */ ui::Color::orange().v,
/*.menu_location = */ app_location_t::RX,
/*.m4_app_tag = portapack::spi_flash::image_tag_wefaxrx */ {'P', 'W', 'F', 'X'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+104
View File
@@ -0,0 +1,104 @@
/*
* Copyright (C) 2024 HTotoo
*
* 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_wefax_rx.hpp"
#include "audio.hpp"
#include "rtc_time.hpp"
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
#include "lcd_ili9341.hpp"
using namespace portapack;
using namespace modems;
using namespace ui;
namespace ui::external_app::wefax_rx {
void WeFaxRxView::focus() {
field_frequency.focus();
}
WeFaxRxView::WeFaxRxView(NavigationView& nav)
: nav_{nav} {
// baseband::run_image(portapack::spi_flash::image_tag_wefaxrx);
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
add_children({&rssi,
&field_rf_amp,
&field_lna,
&field_vga,
&field_volume,
&field_frequency,
&txt_status,
&labels,
&options_lpm,
&options_ioc});
options_lpm.on_change = [this](size_t index, int32_t v) {
lpm_index = (uint8_t)index;
(void)v;
on_settings_changed();
};
options_ioc.on_change = [this](size_t index, int32_t v) {
ioc_index = (uint8_t)index;
(void)v;
on_settings_changed();
};
options_lpm.set_selected_index(lpm_index, false);
options_ioc.set_selected_index(ioc_index, true);
field_frequency.set_step(10);
audio::set_rate(audio::Rate::Hz_24000);
audio::output::start();
receiver_model.enable();
txt_status.set("Waiting for signal.");
}
WeFaxRxView::~WeFaxRxView() {
receiver_model.disable();
baseband::shutdown();
audio::output::stop();
}
void WeFaxRxView::on_settings_changed() {
baseband::set_wefax_config(options_lpm.selected_index_value(), options_ioc.selected_index_value());
}
void WeFaxRxView::on_status(WeFaxRxStatusDataMessage msg) {
std::string tmp = to_string_dec_int(msg.freq) + " " + to_string_dec_int(msg.freqavg) + " " + to_string_dec_int(msg.freqmin) + " " + to_string_dec_int(msg.freqmax);
txt_status.set(tmp);
}
void WeFaxRxView::on_image(WeFaxRxImageDataMessage msg) {
line_num++;
if (line_num >= 320 - 4 * 16) line_num = 0;
ui::Color line_buffer[240];
for (uint16_t i = 0; i < 480; i += 2) {
uint8_t px = (msg.image[i] + msg.image[i + 1]) / 2;
line_buffer[i / 2] = {px, px, px};
}
portapack::display.render_line({0, line_num + 4 * 16}, 240, line_buffer);
}
} // namespace ui::external_app::wefax_rx
+131
View File
@@ -0,0 +1,131 @@
/*
* Copyright (C) 2024 HTotoo
*
* 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.
*/
#ifndef __UI_WEFAX_RX_H__
#define __UI_WEFAX_RX_H__
#include "ui.hpp"
#include "ui_language.hpp"
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "ui_geomap.hpp"
#include "ui_freq_field.hpp"
#include "ui_record_view.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "log_file.hpp"
#include "utility.hpp"
using namespace ui;
namespace ui::external_app::wefax_rx {
class WeFaxRxView : public View {
public:
WeFaxRxView(NavigationView& nav);
~WeFaxRxView();
void focus() override;
std::string title() const override { return "WeFax"; };
private:
void on_settings_changed();
void on_status(WeFaxRxStatusDataMessage msg);
void on_image(WeFaxRxImageDataMessage msg);
uint8_t ioc_index{0};
uint8_t lpm_index{0};
uint16_t line_num = 0;
uint8_t txtDec = 0;
NavigationView& nav_;
RxRadioState radio_state_{};
app_settings::SettingsManager settings_{
"rx_wefax",
app_settings::Mode::RX,
{
{"ioc_index"sv, &ioc_index},
{"lpm_index"sv, &lpm_index},
}};
RFAmpField field_rf_amp{
{13 * 8, 0 * 16}};
LNAGainField field_lna{
{15 * 8, 0 * 16}};
VGAGainField field_vga{
{18 * 8, 0 * 16}};
RSSI rssi{
{21 * 8, 0, 6 * 8, 4}};
AudioVolumeField field_volume{
{28 * 8, 0 * 16}};
RxFrequencyField field_frequency{
{0 * 8, 0 * 16},
nav_};
Labels labels{
{{1 * 8, 1 * 16}, "LPM:", Theme::getInstance()->fg_light->foreground},
{{13 * 8, 1 * 16}, "IOC:", Theme::getInstance()->fg_light->foreground},
};
OptionsField options_lpm{
{6 * 8, 1 * 16},
4,
{
{"60", 60},
{"90", 90},
{"100", 100},
{"120", 120},
{"180", 180},
{"240", 240},
}};
OptionsField options_ioc{
{18 * 8, 1 * 16},
4,
{
{"576", 0},
{"228", 1},
}};
Text txt_status{
{0 * 8, 2 * 16, 30 * 8, 16},
};
MessageHandlerRegistration message_handler_stats{
Message::ID::WeFaxRxStatusData,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const WeFaxRxStatusDataMessage*>(p);
on_status(message);
}};
MessageHandlerRegistration message_handler_image{
Message::ID::WeFaxRxImageData,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const WeFaxRxImageDataMessage*>(p);
on_image(message);
}};
};
} // namespace ui::external_app::wefax_rx
#endif /*__UI_WEFAX_RX_H__*/