From 1b3359b050d2c21609a28abf8f2760556d774238 Mon Sep 17 00:00:00 2001 From: Totoo Date: Tue, 15 Oct 2024 20:38:18 +0200 Subject: [PATCH] fix pocsag tx char limit (#2303) * fix pocsag tx display * set max to 40, and add 2nd line * up to 80 chars * max pocsag to 80 via serial too * fix amp override --- firmware/application/apps/ui_pocsag_tx.cpp | 21 ++++++++++++++++----- firmware/application/apps/ui_pocsag_tx.hpp | 9 ++++++--- firmware/application/usb_serial_shell.cpp | 6 +++--- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/firmware/application/apps/ui_pocsag_tx.cpp b/firmware/application/apps/ui_pocsag_tx.cpp index b9bc06d7..2efed265 100644 --- a/firmware/application/apps/ui_pocsag_tx.cpp +++ b/firmware/application/apps/ui_pocsag_tx.cpp @@ -33,6 +33,8 @@ using namespace pocsag; namespace ui { +#define MAX_POCSAG_LENGTH 80 + void POCSAGTXView::focus() { field_address.focus(); } @@ -57,6 +59,7 @@ void POCSAGTXView::on_remote(const PocsagTosendMessage data) { options_phase.set_selected_index(data.phase == 'P' ? 0 : 1); field_address.set_value(data.addr); message = (char*)data.msg; + buffer = message; text_message.set(message); options_bitrate.dirty(); options_type.dirty(); @@ -105,9 +108,9 @@ bool POCSAGTXView::start_tx() { progressbar.set_max(total_frames); - transmitter_model.set_rf_amp(true); - transmitter_model.set_tx_gain(40); - // We left exactly same TX LPF settings as previous fw 1.7.4, TX LPF= 1M75 (min). It is fine even in max FM dev. 150khz and 2400 bauds. + // transmitter_model.set_rf_amp(true); + // transmitter_model.set_tx_gain(40); + // We left exactly same TX LPF settings as previous fw 1.7.4, TX LPF= 1M75 (min). It is fine even in max FM dev. 150khz and 2400 bauds. transmitter_model.set_baseband_bandwidth(1'750'000); // Min TX LPF . Pocsag is NBFM , using BW channel 25khz or 12khz transmitter_model.enable(); @@ -139,11 +142,18 @@ bool POCSAGTXView::start_tx() { void POCSAGTXView::paint(Painter&) { message = buffer; - text_message.set(message); + text_message.set(message); // the whole message, but it may not fit. + if (message.length() > 30 && message.length() <= 60) { + text_message_l2.set(message.substr(29)); // remaining to 2nd line + } else if (message.length() > 60) { + text_message_l2.set(message.substr(29, 27) + "..."); + } else { + text_message_l2.set(""); + } } void POCSAGTXView::on_set_text(NavigationView& nav) { - text_prompt(nav, buffer, 30); + text_prompt(nav, buffer, MAX_POCSAG_LENGTH); } POCSAGTXView::POCSAGTXView( @@ -158,6 +168,7 @@ POCSAGTXView::POCSAGTXView( &options_function, &options_phase, &text_message, + &text_message_l2, &button_message, &progressbar, &tx_view}); diff --git a/firmware/application/apps/ui_pocsag_tx.hpp b/firmware/application/apps/ui_pocsag_tx.hpp index de0240ae..f4eb242c 100644 --- a/firmware/application/apps/ui_pocsag_tx.hpp +++ b/firmware/application/apps/ui_pocsag_tx.hpp @@ -122,15 +122,18 @@ class POCSAGTXView : public View { }}; Text text_message{ - {0 * 8, 16 * 8, 16 * 8, 16}, + {0 * 8, 16 * 8, 30 * 8, 16}, + ""}; + Text text_message_l2{ + {0 * 8, 18 * 8, 30 * 8, 16}, ""}; Button button_message{ - {0 * 8, 18 * 8, 14 * 8, 32}, + {0 * 8, 20 * 8, 14 * 8, 32}, "Set message"}; ProgressBar progressbar{ - {16, 200, 208, 16}}; + {16, 210, 208, 16}}; TransmitterView tx_view{ 16 * 16, diff --git a/firmware/application/usb_serial_shell.cpp b/firmware/application/usb_serial_shell.cpp index 8a107b15..c99e3e30 100644 --- a/firmware/application/usb_serial_shell.cpp +++ b/firmware/application/usb_serial_shell.cpp @@ -1079,8 +1079,8 @@ static void cmd_sendpocsag(BaseSequentialStream* chp, int argc, char* argv[]) { } uint64_t addr = atol(argv[0]); int msglen = atoi(argv[1]); // without minimum limit, since addr only don't send anything - if (msglen > 30 || msglen < 0) { - chprintf(chp, "error, msglen max is 30\r\n"); + if (msglen > 80 || msglen < 0) { + chprintf(chp, "error, msglen max is 80\r\n"); return; } @@ -1120,7 +1120,7 @@ static void cmd_sendpocsag(BaseSequentialStream* chp, int argc, char* argv[]) { } } - uint8_t msg[31] = {0}; + uint8_t msg[81] = {0}; if (msglen > 0) { chprintf(chp, "send %d bytes\r\n", msglen); do {