Reduced audio tx FIFO refill size

Last received POCSAG address is auto loaded in POCSAG tx
This commit is contained in:
furrtek 2017-03-05 15:37:56 +00:00
parent aec41cab91
commit 446efa8fc0
12 changed files with 44 additions and 28 deletions

View File

@ -50,10 +50,6 @@ int WAVFileReader::open(const std::filesystem::path& path) {
}
}
size_t WAVFileReader::read(void * const data, const size_t bytes_to_read) {
return file.read(data, bytes_to_read).value();
}
void WAVFileReader::rewind() {
file.seek(data_start);
}
@ -62,14 +58,14 @@ uint32_t WAVFileReader::ms_duration() {
return ((data_size_ * 1000) / sample_rate_) / bytes_per_sample;
}
int WAVFileReader::seek_mss(const uint16_t minutes, const uint8_t seconds, const uint32_t samples) {
/*int WAVFileReader::seek_mss(const uint16_t minutes, const uint8_t seconds, const uint32_t samples) {
const auto result = file.seek(data_start + ((((minutes * 60) + seconds) * sample_rate_) + samples) * bytes_per_sample);
if (result.is_error())
return 0;
return 1;
}
}*/
uint16_t WAVFileReader::channels() {
return header.fmt.nChannels;

View File

@ -93,8 +93,7 @@ public:
int open(const std::filesystem::path& path);
void rewind();
uint32_t ms_duration();
size_t read(void * const data, const size_t bytes_to_read);
int seek_mss(const uint16_t minutes, const uint8_t seconds, const uint32_t samples);
//int seek_mss(const uint16_t minutes, const uint8_t seconds, const uint32_t samples);
uint16_t channels();
uint32_t sample_rate();
uint32_t data_size();
@ -127,7 +126,6 @@ private:
header_t header { };
File file { };
uint32_t data_start { };
uint32_t bytes_per_sample { };
uint32_t data_size_ { 0 };

View File

@ -155,6 +155,8 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage * message) {
console_info += pocsag::bitrate_str(message->packet.bitrate());
console_info += " ADDR:" + to_string_dec_uint(pocsag_state.address);
console_info += " F" + to_string_dec_uint(pocsag_state.function);
portapack::persistent_memory::set_pocsag_address(pocsag_state.address);
if (pocsag_state.out_type == ADDRESS) {
// Address only

View File

@ -27,7 +27,6 @@
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "ui_rssi.hpp"
//#include "ui_channel.hpp"
#include "event_m0.hpp"
@ -103,20 +102,20 @@ private:
};
Button button_setfreq {
{ 0, 20, 12 * 8, 20 },
{ 0, 20, 11 * 8, 20 },
"----.----"
};
OptionsField options_bitrate {
{ 13 * 8, 22 },
8,
{ 12 * 8, 22 },
7,
{
{ "512 bps ", 0 },
{ "1200 bps", 1 },
{ "2400 bps", 2 }
{ "512bps ", 0 },
{ "1200bps", 1 },
{ "2400bps", 2 }
}
};
Checkbox check_log {
{ 22 * 8, 22 },
{ 20 * 8, 22 },
3,
"LOG",
true

View File

@ -90,7 +90,7 @@ void NumbersStationView::prepare_audio() {
}
if (!pause) {
size_t bytes_read = reader->read(audio_buffer, 1024);
auto bytes_read = reader->read(audio_buffer, 1024).value();
// Unsigned to signed, pretty stupid :/
for (size_t n = 0; n < bytes_read; n++)

View File

@ -131,7 +131,9 @@ POCSAGTXView::POCSAGTXView(
NavigationView& nav
) : nav_ (nav)
{
uint32_t reload_address;
uint32_t c;
baseband::run_image(portapack::spi_flash::image_tag_fsktx);
add_children({
@ -146,7 +148,14 @@ POCSAGTXView::POCSAGTXView(
});
options_bitrate.set_selected_index(1); // 1200bps
options_type.set_selected_index(2); // Alphanumeric
options_type.set_selected_index(0); // Address only
// TODO: set_value for whole symfield
reload_address = portapack::persistent_memory::pocsag_address();
for (c = 0; c < 7; c++) {
field_address.set_value(6 - c, reload_address % 10);
reload_address /= 10;
}
button_message.on_select = [this, &nav](Button&) {
this->on_set_text(nav);

View File

@ -75,15 +75,15 @@ void SoundBoardView::prepare_audio() {
pbar.set_value(sample_counter);
size_t bytes_read = reader->read(audio_buffer, 1024);
auto bytes_read = reader->read(audio_buffer, 512).value();
// Unsigned to signed, pretty stupid :/
for (size_t n = 0; n < bytes_read; n++)
audio_buffer[n] -= 0x80;
for (size_t n = bytes_read; n < 1024; n++)
for (size_t n = bytes_read; n < 512; n++)
audio_buffer[n] = 0;
sample_counter += 1024;
sample_counter += 512;
baseband::set_fifo_data(audio_buffer);
}

View File

@ -81,7 +81,7 @@ private:
uint32_t max_sound { };
uint8_t max_page { };
int8_t audio_buffer[1024];
int8_t audio_buffer[512];
Style style_a {
.font = font::fixed_8x16,

View File

@ -88,7 +88,7 @@ private:
bool transmitting_ { false };
FrequencyField field_frequency {
{ 0 * 8, 1 * 8 }
{ 4, 1 * 8 }
};
Text text_gain {

View File

@ -34,7 +34,6 @@ void AudioTXProcessor::execute(const buffer_c8_t& buffer){
if (!configured) return;
//ai = 0;
for (size_t i = 0; i<buffer.count; i++) {
// Audio preview sample generation @ 1536000/divider
@ -44,7 +43,7 @@ void AudioTXProcessor::execute(const buffer_c8_t& buffer){
sample = (int32_t)out_sample;
//preview_audio_buffer.p[ai++] = sample << 8;
if ((audio_fifo.len() < 1024) && (asked == false)) {
if ((audio_fifo.len() < 512) && (asked == false)) {
// Ask application to fill up fifo
sigmessage.signaltype = 1;
shared_memory.application_queue.push(sigmessage);
@ -92,7 +91,7 @@ void AudioTXProcessor::on_message(const Message* const msg) {
break;
case Message::ID::FIFOData:
audio_fifo.in(static_cast<const FIFODataMessage*>(msg)->data, 1024);
audio_fifo.in(static_cast<const FIFODataMessage*>(msg)->data, 512);
asked = false;
break;

View File

@ -77,6 +77,8 @@ struct data_t {
uint32_t playdead_sequence;
uint32_t ui_config;
uint32_t pocsag_address;
};
static_assert(sizeof(data_t) <= backup_ram.size(), "Persistent memory structure too large for VBAT-maintained region");
@ -239,5 +241,13 @@ void set_ui_config(const uint32_t new_value) {
data->ui_config = new_value;
}
uint32_t pocsag_address() {
return data->pocsag_address;
}
void set_pocsag_address(uint32_t address) {
data->pocsag_address = address;
}
} /* namespace persistent_memory */
} /* namespace portapack */

View File

@ -76,6 +76,9 @@ uint16_t ui_config_bloff();
uint8_t ui_config_textentry();
void set_config_textentry(uint8_t new_value);
uint32_t pocsag_address();
void set_pocsag_address(uint32_t address);
} /* namespace persistent_memory */
} /* namespace portapack */