POCSAG TX text and bitrate can be changed

Modal view message can be multiline now
This commit is contained in:
furrtek 2017-02-07 19:54:18 +00:00
parent dc7fcbc6c3
commit fc8279aa30
12 changed files with 113 additions and 83 deletions

View File

@ -191,13 +191,7 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
} }
void POCSAGAppView::on_bitrate_changed(const uint32_t new_bitrate) { void POCSAGAppView::on_bitrate_changed(const uint32_t new_bitrate) {
const pocsag::BitRate bitrates[3] = { baseband::set_pocsag(pocsag_bitrates[new_bitrate]);
pocsag::BitRate::FSK512,
pocsag::BitRate::FSK1200,
pocsag::BitRate::FSK2400
};
baseband::set_pocsag(bitrates[new_bitrate]);
} }
void POCSAGAppView::on_band_changed(const uint32_t new_band_frequency) { void POCSAGAppView::on_band_changed(const uint32_t new_band_frequency) {

View File

@ -49,13 +49,13 @@ AlphanumView::AlphanumView(
static constexpr Style style_alpha { static constexpr Style style_alpha {
.font = font::fixed_8x16, .font = font::fixed_8x16,
.background = Color::black(), .background = Color::black(),
.foreground = Color(191,31,31) .foreground = Color(255, 63, 63)
}; };
static constexpr Style style_num { static constexpr Style style_num {
.font = font::fixed_8x16, .font = font::fixed_8x16,
.background = Color::black(), .background = Color::black(),
.foreground = Color(191,191,31) .foreground = Color(191, 191, 31)
}; };
txtidx = strlen(txt); txtidx = strlen(txt);

View File

@ -527,11 +527,10 @@ ModalMessageView::ModalMessageView(
const modal_t type, const modal_t type,
const std::function<void(bool)> on_choice const std::function<void(bool)> on_choice
) : title_ { title }, ) : title_ { title },
message_ { message },
type_ { type }, type_ { type },
on_choice_ { on_choice } on_choice_ { on_choice }
{ {
add_child(&text_message);
if (type == INFO) { if (type == INFO) {
add_child(&button_ok); add_child(&button_ok);
@ -574,17 +573,28 @@ ModalMessageView::ModalMessageView(
nav.pop_modal(); nav.pop_modal();
}; };
} }
const int text_message_width = message.size() * 8;
text_message.set_parent_rect({
(240 - text_message_width) / 2, 8 * 16,
text_message_width, 16
});
text_message.set(message);
} }
void ModalMessageView::paint(Painter&) { void ModalMessageView::paint(Painter& painter) {
portapack::display.drawBMP({ 100, 64 }, modal_warning_bmp, false); size_t pos, i = 0, start = 0;
portapack::display.drawBMP({ 100, 48 }, modal_warning_bmp, false);
// Terrible...
while ((pos = message_.find("\n", start)) != std::string::npos) {
painter.draw_string(
{ 1 * 8, (Coord)(120 + (i * 16)) },
style(),
message_.substr(start, pos)
);
i++;
start = pos + 1;
}
painter.draw_string(
{ 1 * 8, (Coord)(120 + (i * 16)) },
style(),
message_.substr(start, pos)
);
} }
void ModalMessageView::focus() { void ModalMessageView::focus() {

View File

@ -291,10 +291,9 @@ public:
private: private:
const std::string title_; const std::string title_;
const std::string message_;
const modal_t type_; const modal_t type_;
const std::function<void(bool)> on_choice_; const std::function<void(bool)> on_choice_;
Text text_message { };
Button button_ok { Button button_ok {
{ 10 * 8, 13 * 16, 10 * 8, 24 }, { 10 * 8, 13 * 16, 10 * 8, 24 },

View File

@ -56,16 +56,15 @@ void POCSAGTXView::on_tx_progress(const int progress, const bool done) {
} }
void POCSAGTXView::start_tx() { void POCSAGTXView::start_tx() {
uint32_t total_frames, i, codeword, b, bi, address; uint32_t total_frames, i, codeword, bi, address;
std::string test_string = "PORTAPACK !"; pocsag::BitRate bitrate;
std::vector<uint32_t> codewords; std::vector<uint32_t> codewords;
uint8_t byte = 0;
address = address_field.value_dec_u32(); address = address_field.value_dec_u32();
if (address > 0x7FFFFFU) if (address > 0x1FFFFFU)
address = 0; // Todo: Error screen address = 0; // Todo: Error screen
pocsag_encode(BCH_code, test_string, address, codewords); pocsag_encode(BCH_code, message, address, codewords);
total_frames = codewords.size() / 2; total_frames = codewords.size() / 2;
@ -82,13 +81,6 @@ void POCSAGTXView::start_tx() {
bi = 0; bi = 0;
for (i = 0; i < codewords.size(); i++) { for (i = 0; i < codewords.size(); i++) {
/*for (b = 0; b < 32; b++) {
byte |= ((((codewords[i] << b) & 0x80000000U) ? 1 : 0) << (7 - (b & 7)));
if ((b & 7) == 7) {
data_ptr[bi++] = byte;
byte = 0;
}
}*/
codeword = codewords[i]; codeword = codewords[i];
data_ptr[bi++] = (codeword >> 24) & 0xFF; data_ptr[bi++] = (codeword >> 24) & 0xFF;
data_ptr[bi++] = (codeword >> 16) & 0xFF; data_ptr[bi++] = (codeword >> 16) & 0xFF;
@ -98,28 +90,45 @@ void POCSAGTXView::start_tx() {
text_debug_a.set("Codewords: " + to_string_dec_uint(codewords.size())); text_debug_a.set("Codewords: " + to_string_dec_uint(codewords.size()));
bitrate = pocsag_bitrates[options_bitrate.selected_index()];
baseband::set_fsk_data( baseband::set_fsk_data(
codewords.size() * 32, codewords.size() * 32,
228000 / 1200, 2280000 / bitrate,
4500, 4500,
64 64
//228000 / ((numberfield_clk.value() * 1000) / encoder_def->clk_per_fragment),
); );
} }
void POCSAGTXView::paint(Painter&) {
message = buffer;
text_message.set("Message:" + message);
}
void POCSAGTXView::on_set_text(NavigationView& nav) {
textentry(nav, buffer, 16);
}
POCSAGTXView::POCSAGTXView(NavigationView& nav) { POCSAGTXView::POCSAGTXView(NavigationView& nav) {
//size_t i;
baseband::run_image(portapack::spi_flash::image_tag_fsktx); baseband::run_image(portapack::spi_flash::image_tag_fsktx);
add_children({ add_children({
&text_debug_a, &text_debug_a,
&text_debug_b, &text_address,
&text_debug_c,
&address_field, &address_field,
&options_bitrate,
&text_message,
&button_message,
&progressbar, &progressbar,
&tx_view &tx_view
}); });
options_bitrate.set_selected_index(1); // 1200bps
button_message.on_select = [this, &nav](Button&) {
this->on_set_text(nav);
};
tx_view.on_edit_frequency = [this, &nav]() { tx_view.on_edit_frequency = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency()); auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());

View File

@ -29,6 +29,7 @@
#include "ui_font_fixed_8x16.hpp" #include "ui_font_fixed_8x16.hpp"
#include "ui_receiver.hpp" #include "ui_receiver.hpp"
#include "ui_transmitter.hpp" #include "ui_transmitter.hpp"
#include "ui_textentry.hpp"
#include "bch_code.hpp" #include "bch_code.hpp"
#include "message.hpp" #include "message.hpp"
#include "transmitter_model.hpp" #include "transmitter_model.hpp"
@ -40,22 +41,26 @@ public:
POCSAGTXView(NavigationView& nav); POCSAGTXView(NavigationView& nav);
~POCSAGTXView(); ~POCSAGTXView();
/*POCSAGTXView(const EncodersView&) = delete; POCSAGTXView(const POCSAGTXView&) = delete;
POCSAGTXView(EncodersView&&) = delete; POCSAGTXView(POCSAGTXView&&) = delete;
POCSAGTXView& operator=(const EncodersView&) = delete; POCSAGTXView& operator=(const POCSAGTXView&) = delete;
POCSAGTXView& operator=(EncodersView&&) = delete;*/ POCSAGTXView& operator=(POCSAGTXView&&) = delete;
void focus() override; void focus() override;
void paint(Painter&) override;
std::string title() const override { return "POCSAG TX"; }; std::string title() const override { return "POCSAG TX"; };
private: private:
char buffer[17] = "PORTAPACK";
std::string message { };
BCHCode BCH_code { BCHCode BCH_code {
{ 1, 0, 1, 0, 0, 1 }, { 1, 0, 1, 0, 0, 1 },
5, 31, 21, 2 5, 31, 21, 2
}; };
void on_set_text(NavigationView& nav);
void on_tx_progress(const int progress, const bool done); void on_tx_progress(const int progress, const bool done);
void start_tx(); void start_tx();
@ -63,21 +68,36 @@ private:
{ 1 * 8, 4 * 8, 20 * 8, 16 }, { 1 * 8, 4 * 8, 20 * 8, 16 },
"-" "-"
}; };
Text text_debug_b {
{ 1 * 8, 6 * 8, 20 * 8, 16 }, Text text_address {
"-" { 3 * 8, 10 * 8, 20 * 8, 16 },
};
Text text_debug_c {
{ 1 * 8, 12 * 8, 20 * 8, 16 },
"Address:" "Address:"
}; };
SymField address_field { SymField address_field {
{ 9 * 8, 12 * 8 }, { 11 * 8, 10 * 8 },
7, 7,
SymField::SYMFIELD_DEC SymField::SYMFIELD_DEC
}; };
OptionsField options_bitrate {
{ 11 * 8, 12 * 8 },
8,
{
{ "512 bps ", 0 },
{ "1200 bps", 1 },
{ "2400 bps", 2 }
}
};
Text text_message {
{ 3 * 8, 14 * 8, 16 * 8, 16 },
""
};
Button button_message {
{ 3 * 8, 16 * 8, 8 * 8, 28 },
"Set"
};
ProgressBar progressbar { ProgressBar progressbar {
{ 16, 200, 208, 16 } { 16, 200, 208, 16 }
}; };

View File

@ -44,7 +44,7 @@ void WipeSDView::focus() {
dummy.focus(); dummy.focus();
if (!confirmed) { if (!confirmed) {
nav_.push<ModalMessageView>("Warning !", "Wipe first 32MB of SD card ?", YESCANCEL, [this](bool choice) { nav_.push<ModalMessageView>("Warning !", "Wipe first 32MB of SD card\n(filesystem included) ?", YESCANCEL, [this](bool choice) {
if (choice) if (choice)
confirmed = true; confirmed = true;
} }

View File

@ -20,8 +20,8 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __UI_SE_WIPE_H__ #ifndef __UI_SD_WIPE_H__
#define __UI_SE_WIPE_H__ #define __UI_SD_WIPE_H__
#include "ui_widget.hpp" #include "ui_widget.hpp"
#include "ui_navigation.hpp" #include "ui_navigation.hpp"
@ -89,4 +89,4 @@ private:
} /* namespace ui */ } /* namespace ui */
#endif/*__UI_SE_WIPE_H__*/ #endif/*__UI_SD_WIPE_H__*/

View File

@ -35,34 +35,28 @@ void FSKProcessor::execute(const buffer_c8_t& buffer) {
if (!configured) return; if (!configured) return;
for (size_t i = 0; i < buffer.count; i++) { for (size_t i = 0; i < buffer.count; i++) {
// Synthesis at 2.28M/10 = 228kHz if (sample_count >= samples_per_bit) {
if (!s) { if (bit_pos >= length) {
s = 10 - 1; // End of data
if (sample_count >= samples_per_bit) { cur_bit = 0;
if (bit_pos >= length) { txdone_message.done = true;
// End of data shared_memory.application_queue.push(txdone_message);
cur_bit = 0; configured = false;
txdone_message.done = true;
shared_memory.application_queue.push(txdone_message);
configured = false;
} else {
cur_bit = (shared_memory.bb_data.data[bit_pos >> 3] << (bit_pos & 7)) & 0x80;
bit_pos++;
if (progress_count >= progress_notice) {
progress_count = 0;
txdone_message.progress++;
shared_memory.application_queue.push(txdone_message);
} else {
progress_count++;
}
}
sample_count = 0;
} else { } else {
sample_count++; cur_bit = (shared_memory.bb_data.data[bit_pos >> 3] << (bit_pos & 7)) & 0x80;
bit_pos++;
if (progress_count >= progress_notice) {
progress_count = 0;
txdone_message.progress++;
shared_memory.application_queue.push(txdone_message);
} else {
progress_count++;
}
} }
sample_count = 0;
} else { } else {
s--; sample_count++;
} }
if (configured) { if (configured) {
@ -96,7 +90,6 @@ void FSKProcessor::on_message(const Message* const p) {
progress_notice = message.progress_notice; progress_notice = message.progress_notice;
s = 0;
sample_count = samples_per_bit; sample_count = samples_per_bit;
progress_count = 0; progress_count = 0;
bit_pos = 0; bit_pos = 0;

View File

@ -40,7 +40,6 @@ private:
uint32_t samples_per_bit { 0 }; uint32_t samples_per_bit { 0 };
uint32_t length { 0 }; uint32_t length { 0 };
uint8_t s { 0 };
uint32_t shift_zero { }, shift_one { }; uint32_t shift_zero { }, shift_one { };
uint32_t bit_pos { 0 }; uint32_t bit_pos { 0 };
uint32_t progress_notice { }, progress_count { 0 }; uint32_t progress_notice { }, progress_count { 0 };

View File

@ -59,6 +59,12 @@ struct POCSAGState {
std::string output; std::string output;
}; };
const pocsag::BitRate pocsag_bitrates[3] = {
pocsag::BitRate::FSK512,
pocsag::BitRate::FSK1200,
pocsag::BitRate::FSK2400
};
std::string bitrate_str(BitRate bitrate); std::string bitrate_str(BitRate bitrate);
std::string flag_str(PacketFlag packetflag); std::string flag_str(PacketFlag packetflag);

Binary file not shown.