Fixed mic tx not working the first time it was entered

Fixed SD card FAT wipe (buffer size too big)
Cleared some warnings from ADSB rx
Updated binary
This commit is contained in:
furrtek
2018-02-01 11:17:51 +00:00
parent 441a266dc4
commit 57c759627d
17 changed files with 75 additions and 76 deletions

View File

@@ -97,7 +97,7 @@ void AudioOutput::on_block(
}
bool AudioOutput::is_squelched() {
return ~audio_present;
return !audio_present;
}
void AudioOutput::fill_audio_buffer(const buffer_f32_t& audio, const bool send_to_fifo) {

View File

@@ -34,8 +34,9 @@ void ADSBRXProcessor::execute(const buffer_c8_t& buffer) {
int8_t re, im;
float mag;
uint32_t c;
uint8_t level, bit, byte;
bool confidence, first_in_window, last_in_window;
uint8_t level, bit, byte { };
//bool confidence;
bool first_in_window, last_in_window;
// This is called at 2M/2048 = 977Hz
// One pulse = 500ns = 2 samples
@@ -62,10 +63,6 @@ void ADSBRXProcessor::execute(const buffer_c8_t& buffer) {
if ((prev_mag < threshold_low) && (mag < threshold_low)) {
// Both under window, silence.
if (null_count > 3) {
//text_debug_b.set("Bits:" + bits.substr(0, 25));
//text_debug_c.set("Hex:" + hex_str.substr(0, 26));
//text_debug_d.set("DF=" + to_string_dec_uint(frame.get_DF()) + " ICAO=" + to_string_hex(frame.get_ICAO_address(), 6));
const ADSBFrameMessage message(frame);
shared_memory.application_queue.push(message);
@@ -73,7 +70,7 @@ void ADSBRXProcessor::execute(const buffer_c8_t& buffer) {
} else
null_count++;
confidence = false;
//confidence = false;
if (prev_mag > mag)
bit = 1;
else
@@ -87,13 +84,13 @@ void ADSBRXProcessor::execute(const buffer_c8_t& buffer) {
last_in_window = ((mag >= threshold_low) && (mag <= threshold_high));
if ((first_in_window && !last_in_window) || (!first_in_window && last_in_window)) {
confidence = true;
//confidence = true;
if (prev_mag > mag)
bit = 1;
else
bit = 0;
} else {
confidence = false;
//confidence = false;
if (prev_mag > mag)
bit = 1;
else

View File

@@ -50,8 +50,8 @@ private:
ADSBFrame frame { };
bool configured { false };
float prev_mag { 0 };
float threshold, threshold_low, threshold_high;
size_t null_count, bit_count, sample_count;
float threshold { }, threshold_low { }, threshold_high { };
size_t null_count { 0 }, bit_count { 0 }, sample_count { 0 };
std::pair<float, uint8_t> shifter[ADSB_PREAMBLE_LENGTH];
bool decoding { };
bool preamble { }, active { };

View File

@@ -74,7 +74,7 @@ void AudioTXProcessor::on_message(const Message* const msg) {
switch(msg->id) {
case Message::ID::AudioTXConfig:
fm_delta = message.fm_delta * (0xFFFFFFULL / 1536000);
fm_delta = message.deviation_hz * (0xFFFFFFULL / baseband_fs);
divider = message.divider;
as = 0;

View File

@@ -35,9 +35,11 @@ public:
void on_message(const Message* const msg) override;
private:
static constexpr size_t baseband_fs = 1536000U;
bool configured = false;
BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Transmit };
int8_t audio_fifo_data[2048] { };
FIFO<int8_t> audio_fifo = { audio_fifo_data, 11 }; // 43ms @ 48000Hz

View File

@@ -21,9 +21,9 @@
*/
#include "proc_mictx.hpp"
#include "tonesets.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table_int8.hpp"
#include "tonesets.hpp"
#include "event_m4.hpp"
#include <cstdint>
@@ -40,7 +40,7 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
if (!play_beep) {
sample = audio_buffer.p[i >> 6] >> 8; // 1536000 / 64 = 24000
sample = (sample * (int32_t)gain_x10) / 10;
sample *= audio_gain;
power_acc += (sample < 0) ? -sample : sample; // Power average for UI vu-meter
@@ -60,7 +60,6 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
if (beep_index == BEEP_TONES_NB) {
configured = false;
fm_delta = 0; // Zero-out the IQ output for the rest of the buffer
shared_memory.application_queue.push(txprogress_message);
} else {
beep_gen.configure(beep_deltas[beep_index], 1.0);
@@ -74,20 +73,20 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
sample = tone_gen.process(sample);
// FM
if (fm_delta) {
if (configured) {
delta = sample * fm_delta;
phase += delta;
sphase = phase + (64 << 24);
sphase = phase >> 24;
re = (sine_table_i8[(sphase & 0xFF000000U) >> 24]);
im = (sine_table_i8[(phase & 0xFF000000U) >> 24]);
re = (sine_table_i8[(sphase + 64) & 255]);
im = (sine_table_i8[sphase]);
} else {
re = 0;
im = 0;
}
buffer.p[i] = {re, im};
buffer.p[i] = { re, im };
}
}
@@ -97,8 +96,9 @@ void MicTXProcessor::on_message(const Message* const msg) {
switch(msg->id) {
case Message::ID::AudioTXConfig:
fm_delta = config_message.fm_delta * (0xFFFFFFULL / baseband_fs);
gain_x10 = config_message.gain_x10;
fm_delta = config_message.deviation_hz * (0xFFFFFFUL / baseband_fs);
audio_gain = config_message.audio_gain;
divider = config_message.divider;
power_acc_count = 0;

View File

@@ -51,7 +51,7 @@ private:
ToneGen tone_gen { };
ToneGen beep_gen { };
uint32_t divider { }, gain_x10 { };
uint32_t divider { }, audio_gain { };
uint64_t power_acc { 0 };
uint32_t power_acc_count { 0 };
bool play_beep { false };