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) {
const pocsag::BitRate bitrates[3] = {
pocsag::BitRate::FSK512,
pocsag::BitRate::FSK1200,
pocsag::BitRate::FSK2400
};
baseband::set_pocsag(bitrates[new_bitrate]);
baseband::set_pocsag(pocsag_bitrates[new_bitrate]);
}
void POCSAGAppView::on_band_changed(const uint32_t new_band_frequency) {

View File

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

View File

@ -527,11 +527,10 @@ ModalMessageView::ModalMessageView(
const modal_t type,
const std::function<void(bool)> on_choice
) : title_ { title },
message_ { message },
type_ { type },
on_choice_ { on_choice }
{
add_child(&text_message);
if (type == INFO) {
add_child(&button_ok);
@ -574,17 +573,28 @@ ModalMessageView::ModalMessageView(
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&) {
portapack::display.drawBMP({ 100, 64 }, modal_warning_bmp, false);
void ModalMessageView::paint(Painter& painter) {
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() {

View File

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

View File

@ -56,16 +56,15 @@ void POCSAGTXView::on_tx_progress(const int progress, const bool done) {
}
void POCSAGTXView::start_tx() {
uint32_t total_frames, i, codeword, b, bi, address;
std::string test_string = "PORTAPACK !";
uint32_t total_frames, i, codeword, bi, address;
pocsag::BitRate bitrate;
std::vector<uint32_t> codewords;
uint8_t byte = 0;
address = address_field.value_dec_u32();
if (address > 0x7FFFFFU)
if (address > 0x1FFFFFU)
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;
@ -82,13 +81,6 @@ void POCSAGTXView::start_tx() {
bi = 0;
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];
data_ptr[bi++] = (codeword >> 24) & 0xFF;
data_ptr[bi++] = (codeword >> 16) & 0xFF;
@ -98,29 +90,46 @@ void POCSAGTXView::start_tx() {
text_debug_a.set("Codewords: " + to_string_dec_uint(codewords.size()));
bitrate = pocsag_bitrates[options_bitrate.selected_index()];
baseband::set_fsk_data(
codewords.size() * 32,
228000 / 1200,
2280000 / bitrate,
4500,
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) {
//size_t i;
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
add_children({
&text_debug_a,
&text_debug_b,
&text_debug_c,
&text_address,
&address_field,
&options_bitrate,
&text_message,
&button_message,
&progressbar,
&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]() {
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {

View File

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

View File

@ -44,7 +44,7 @@ void WipeSDView::focus() {
dummy.focus();
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)
confirmed = true;
}

View File

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

View File

@ -36,33 +36,27 @@ void FSKProcessor::execute(const buffer_c8_t& buffer) {
for (size_t i = 0; i < buffer.count; i++) {
// Synthesis at 2.28M/10 = 228kHz
if (!s) {
s = 10 - 1;
if (sample_count >= samples_per_bit) {
if (bit_pos >= length) {
// End of data
cur_bit = 0;
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;
if (sample_count >= samples_per_bit) {
if (bit_pos >= length) {
// End of data
cur_bit = 0;
txdone_message.done = true;
shared_memory.application_queue.push(txdone_message);
configured = false;
} 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 {
s--;
sample_count++;
}
if (configured) {
@ -96,7 +90,6 @@ void FSKProcessor::on_message(const Message* const p) {
progress_notice = message.progress_notice;
s = 0;
sample_count = samples_per_bit;
progress_count = 0;
bit_pos = 0;

View File

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

View File

@ -59,6 +59,12 @@ struct POCSAGState {
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 flag_str(PacketFlag packetflag);

Binary file not shown.