mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-12 00:20:03 -04:00
WeFax rx ext app (#2566)
* wf3
* Ookbrute (#2354)
* Revert "Ookbrute (#2354)"
This reverts commit abb8143eec
.
* fix
* test edition
* re enable ble
* re enable ert
* steal amfm stuff
* something happens
* save bmp on start btn
* kinda works
* exit crash fixed
* redline, remove some hardcoded
* removed cpu killer red line, and some fixes
* simplify #1
* seems ok. time to improve
* added hidden freq offset to receiver model, so wefax can be set to the "correct" freq without users needs to substract 300 hz
* badly implemented sync detection, and disabled it.
* fix for fix
* fixes
* fix offset to real life off
* no line on freq enter
* fixes
This commit is contained in:
parent
717d615f4f
commit
4aa5fc1fbe
16 changed files with 752 additions and 2 deletions
6
firmware/application/external/external.cmake
vendored
6
firmware/application/external/external.cmake
vendored
|
@ -115,6 +115,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
|
||||
|
@ -215,6 +220,7 @@ set(EXTAPPLIST
|
|||
#acars_rx
|
||||
ookbrute
|
||||
ook_editor
|
||||
wefax_rx
|
||||
shoppingcart_lock
|
||||
flippertx
|
||||
remote
|
||||
|
|
8
firmware/application/external/external.ld
vendored
8
firmware/application/external/external.ld
vendored
|
@ -67,6 +67,7 @@ MEMORY
|
|||
ram_external_app_breakout(rwx) : org = 0xADDA0000, len = 32k
|
||||
ram_external_app_snake(rwx) : org = 0xADDB0000, len = 32k
|
||||
ram_external_app_stopwatch(rwx) : org = 0xADDC0000, len = 32k
|
||||
ram_external_app_wefax_rx(rwx) : org = 0xADDD0000, len = 32k
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
|
@ -334,4 +335,11 @@ SECTIONS
|
|||
KEEP(*(.external_app.app_stopwatch.application_information));
|
||||
*(*ui*external_app*stopwatch*);
|
||||
} > ram_external_app_stopwatch
|
||||
.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
|
||||
|
||||
|
||||
}
|
||||
|
|
83
firmware/application/external/wefax_rx/main.cpp
vendored
Normal file
83
firmware/application/external/wefax_rx/main.cpp
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (C) 2025 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,
|
||||
/*.desired_menu_position = */ -1,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_wefaxrx */ {'P', 'W', 'F', 'X'},
|
||||
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||
};
|
||||
}
|
152
firmware/application/external/wefax_rx/ui_wefax_rx.cpp
vendored
Normal file
152
firmware/application/external/wefax_rx/ui_wefax_rx.cpp
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* Copyright (C) 2025 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
TODOS LATER:
|
||||
- add load data from wav file (maybe to a separate app, not this)
|
||||
- AGC?!?
|
||||
- fix and enable sync detection
|
||||
- auto start / stop bmp save on each image
|
||||
*/
|
||||
|
||||
#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_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,
|
||||
&button_ss});
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
field_frequency.set_step(100);
|
||||
field_frequency.on_edit_shown = [this]() {
|
||||
paused = true;
|
||||
};
|
||||
field_frequency.on_edit_hidden = [this]() {
|
||||
paused = false;
|
||||
};
|
||||
audio::output::start();
|
||||
receiver_model.set_hidden_offset(WEFAX_FREQ_OFFSET);
|
||||
receiver_model.enable();
|
||||
|
||||
txt_status.set("Waiting for signal.");
|
||||
|
||||
button_ss.on_select = [this](Button&) {
|
||||
if (bmp.is_loaded()) {
|
||||
bmp.close();
|
||||
button_ss.set_text(LanguageHelper::currentMessages[LANG_START]);
|
||||
return;
|
||||
}
|
||||
ensure_directory("/BMP");
|
||||
bmp.create("/BMP/wefax_" + to_string_timestamp(rtc_time::now()) + ".bmp", WEFAX_PX_SIZE, 1);
|
||||
button_ss.set_text(LanguageHelper::currentMessages[LANG_STOP]);
|
||||
};
|
||||
|
||||
options_lpm.set_selected_index(lpm_index, false);
|
||||
options_ioc.set_selected_index(ioc_index, true);
|
||||
}
|
||||
|
||||
WeFaxRxView::~WeFaxRxView() {
|
||||
stopping = true;
|
||||
receiver_model.set_hidden_offset(0);
|
||||
bmp.close();
|
||||
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) {
|
||||
(void)msg;
|
||||
std::string tmp = "";
|
||||
if (msg.state == 0) {
|
||||
tmp = "Waiting for signal.";
|
||||
} else if (msg.state == 1) {
|
||||
tmp = "Synced.";
|
||||
} else if (msg.state == 2) {
|
||||
tmp = "Image arriving.";
|
||||
}
|
||||
txt_status.set(tmp);
|
||||
}
|
||||
|
||||
// this stores and displays the image. keep it as simple as you can. a bit more complexity will kill the sync
|
||||
void WeFaxRxView::on_image(WeFaxRxImageDataMessage msg) {
|
||||
if ((line_num) >= 320 - 4 * 16) line_num = 0; // for draw reset
|
||||
|
||||
for (uint16_t i = 0; i < msg.cnt; i += 1) {
|
||||
Color pxl = {msg.image[i], msg.image[i], msg.image[i]};
|
||||
bmp.write_next_px(pxl);
|
||||
line_in_part++;
|
||||
if (line_in_part == WEFAX_PX_SIZE) {
|
||||
line_in_part = 0;
|
||||
line_num++;
|
||||
bmp.expand_y_delta(1);
|
||||
}
|
||||
|
||||
uint16_t xpos = line_in_part / (WEFAX_PX_SIZE / 240);
|
||||
if (xpos >= 240) xpos = 239;
|
||||
line_buffer[xpos] = pxl;
|
||||
if ((line_in_part == 0)) {
|
||||
portapack::display.render_line({0, line_num + 4 * 16}, 240, line_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::wefax_rx
|
153
firmware/application/external/wefax_rx/ui_wefax_rx.hpp
vendored
Normal file
153
firmware/application/external/wefax_rx/ui_wefax_rx.hpp
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* Copyright (C) 2025 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"
|
||||
#include "ui_fileman.hpp"
|
||||
#include "bmpfile.hpp"
|
||||
#include "file_path.hpp"
|
||||
|
||||
using namespace ui;
|
||||
|
||||
namespace ui::external_app::wefax_rx {
|
||||
|
||||
#define WEFAX_PX_SIZE 840
|
||||
// 1.900Hz is the usual center FM freq. , but as I added 300-Hz margin, + the truncated filter extended effect , in our case, we got better S/N if we use -2200 offset area. @Brumi
|
||||
#define WEFAX_FREQ_OFFSET -2200
|
||||
|
||||
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);
|
||||
|
||||
bool stopping = false;
|
||||
|
||||
uint8_t ioc_index{0};
|
||||
uint8_t lpm_index{0};
|
||||
uint16_t line_num = 0; // nth line
|
||||
uint16_t line_in_part = 0; // got multiple parts of a line, so keep track of it
|
||||
uint8_t delayer = 0;
|
||||
ui::Color line_buffer[240];
|
||||
std::filesystem::path filetohandle = "";
|
||||
|
||||
bool paused = false; // when freq field is shown for example, we need to pause
|
||||
|
||||
BMPFile bmp{};
|
||||
|
||||
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, 20 * 8, 16},
|
||||
};
|
||||
|
||||
Button button_ss{
|
||||
{190, 2 * 16, 5 * 8, 16},
|
||||
LanguageHelper::currentMessages[LANG_START]};
|
||||
|
||||
MessageHandlerRegistration message_handler_stats{
|
||||
Message::ID::WeFaxRxStatusData,
|
||||
[this](const Message* const p) {
|
||||
if (stopping || paused) return;
|
||||
const auto message = *reinterpret_cast<const WeFaxRxStatusDataMessage*>(p);
|
||||
on_status(message);
|
||||
}};
|
||||
|
||||
MessageHandlerRegistration message_handler_image{
|
||||
Message::ID::WeFaxRxImageData,
|
||||
[this](const Message* const p) {
|
||||
if (stopping || paused) return;
|
||||
const auto message = *reinterpret_cast<const WeFaxRxImageDataMessage*>(p);
|
||||
on_image(message);
|
||||
}};
|
||||
};
|
||||
|
||||
} // namespace ui::external_app::wefax_rx
|
||||
|
||||
#endif /*__UI_WEFAX_RX_H__*/
|
Loading…
Add table
Add a link
Reference in a new issue