mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-23 06:07:55 +00:00
Restoring jammer and RDS functionalities, please wait...
Started work on frequency manager and numbers station simulator
This commit is contained in:
Binary file not shown.
@@ -50,9 +50,12 @@ void ADSBTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
if (!bit_part) {
|
||||
if (bit_pos >= 112) {
|
||||
// Stop
|
||||
message.n = 200;
|
||||
shared_memory.application_queue.push(message);
|
||||
configured = false;
|
||||
cur_bit = 0;
|
||||
} else {
|
||||
cur_bit = shared_memory.tx_data[bit_pos];
|
||||
cur_bit = 0; //shared_memory.tx_data[bit_pos];
|
||||
bit_pos++;
|
||||
bit_part = 1;
|
||||
}
|
||||
@@ -66,7 +69,7 @@ void ADSBTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// 1001010110100110 0110010110010101
|
||||
|
||||
if (cur_bit) {
|
||||
phase = (phase + 0x1FE0000); // What ?
|
||||
phase = (phase + 0x1FE00); // What ?
|
||||
sphase = phase + (64 << 18);
|
||||
|
||||
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
|
||||
@@ -78,17 +81,13 @@ void ADSBTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
buffer.p[i] = {(int8_t)re, (int8_t)im};
|
||||
}
|
||||
|
||||
// TEST
|
||||
message.n = 200;
|
||||
shared_memory.application_queue.push(message);
|
||||
configured = false;
|
||||
}
|
||||
|
||||
void ADSBTXProcessor::on_message(const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const ADSBConfigureMessage*>(p);
|
||||
|
||||
if (message.id == Message::ID::ADSBConfigure) {
|
||||
bit_part = 0;
|
||||
bit_pos = 0;
|
||||
cur_bit = 0;
|
||||
preamble = true;
|
||||
|
@@ -93,7 +93,7 @@ void DTMFTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
}
|
||||
|
||||
void DTMFTXProcessor::on_message(const Message* const msg) {
|
||||
char * tone_ptr;
|
||||
uint8_t * tone_ptr;
|
||||
const auto message = *reinterpret_cast<const DTMFTXConfigMessage*>(msg);
|
||||
|
||||
if (message.id == Message::ID::DTMFTXConfig) {
|
||||
|
@@ -40,11 +40,11 @@ void JammerProcessor::execute(const buffer_c8_t& buffer) {
|
||||
for (;;) {
|
||||
ir++;
|
||||
if (ir > 15) ir = 0;
|
||||
if (shared_memory.jammer_ranges[ir].active == true) break;
|
||||
if (jammer_ranges[ir].enabled == true) break;
|
||||
}
|
||||
jammer_bw = shared_memory.jammer_ranges[ir].width / 2;
|
||||
jammer_bw = jammer_ranges[ir].width / 2;
|
||||
|
||||
message.freq = shared_memory.jammer_ranges[ir].center;
|
||||
message.freq = jammer_ranges[ir].center;
|
||||
shared_memory.application_queue.push(message);
|
||||
} else {
|
||||
s++;
|
||||
@@ -73,9 +73,9 @@ void JammerProcessor::execute(const buffer_c8_t& buffer) {
|
||||
sample = sine_table_i8[(sphase & 0x03FC0000) >> 18];
|
||||
|
||||
// FM
|
||||
frq = sample * jammer_bw;
|
||||
delta = sample * jammer_bw;
|
||||
|
||||
phase = (phase + frq);
|
||||
phase = (phase + delta);
|
||||
sphase = phase + (64 << 18);
|
||||
|
||||
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
|
||||
@@ -86,6 +86,9 @@ void JammerProcessor::execute(const buffer_c8_t& buffer) {
|
||||
};
|
||||
|
||||
void JammerProcessor::on_message(const Message* const msg) {
|
||||
|
||||
jammer_ranges = (JammerRange*)shared_memory.tx_data;
|
||||
|
||||
/*const auto message = *reinterpret_cast<const DTMFTXConfigMessage*>(msg);
|
||||
|
||||
if (message.id == Message::ID::DTMFTXConfig) {
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "baseband_processor.hpp"
|
||||
#include "baseband_thread.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
class JammerProcessor : public BasebandProcessor {
|
||||
public:
|
||||
@@ -37,6 +38,8 @@ private:
|
||||
|
||||
BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
||||
|
||||
JammerRange * jammer_ranges;
|
||||
|
||||
int32_t lfsr32 = 0xABCDE;
|
||||
uint32_t s;
|
||||
int8_t r, ir, re, im;
|
||||
@@ -45,7 +48,7 @@ private:
|
||||
int32_t lfsr;
|
||||
uint32_t sample_count;
|
||||
uint32_t aphase, phase, sphase;
|
||||
int32_t sample, frq;
|
||||
int32_t sample, delta;
|
||||
RetuneMessage message;
|
||||
};
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "proc_rds.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "sine_table.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
#include "event_m4.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -31,18 +31,18 @@ void RDSProcessor::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
|
||||
//Sample generation 2.28M/10=228kHz
|
||||
if(s >= 9) {
|
||||
// Sample generation at 2.28M / 10 = 228kHz
|
||||
if (s >= 9) {
|
||||
s = 0;
|
||||
if(sample_count >= SAMPLES_PER_BIT) {
|
||||
if (sample_count >= SAMPLES_PER_BIT) {
|
||||
cur_bit = (rdsdata[(bit_pos / 26) & 15] >> (25 - (bit_pos % 26))) & 1;
|
||||
prev_output = cur_output;
|
||||
cur_output = prev_output ^ cur_bit;
|
||||
|
||||
const int32_t *src = waveform_biphase; // const ok ?
|
||||
const int32_t * src = waveform_biphase;
|
||||
int idx = in_sample_index;
|
||||
|
||||
for(int j = 0; j < FILTER_SIZE; j++) {
|
||||
for (int j = 0; j < FILTER_SIZE; j++) {
|
||||
val = (*src++);
|
||||
if (cur_output) val = -val;
|
||||
sample_buffer[idx++] += val;
|
||||
@@ -52,10 +52,11 @@ void RDSProcessor::execute(const buffer_c8_t& buffer) {
|
||||
in_sample_index += SAMPLES_PER_BIT;
|
||||
if (in_sample_index >= SAMPLE_BUFFER_SIZE) in_sample_index -= SAMPLE_BUFFER_SIZE;
|
||||
|
||||
if (bit_pos < shared_memory.bit_length)
|
||||
if (bit_pos < message_length)
|
||||
bit_pos++;
|
||||
else
|
||||
bit_pos = 0;
|
||||
|
||||
sample_count = 0;
|
||||
}
|
||||
|
||||
@@ -64,38 +65,39 @@ void RDSProcessor::execute(const buffer_c8_t& buffer) {
|
||||
out_sample_index++;
|
||||
if (out_sample_index >= SAMPLE_BUFFER_SIZE) out_sample_index = 0;
|
||||
|
||||
//AM @ 228k/4 = 57kHz
|
||||
switch (mphase) {
|
||||
// AM @ 228k/4 = 57kHz
|
||||
// 0, sample, 0, -sample...
|
||||
switch (mphase & 3) {
|
||||
case 0:
|
||||
case 2: sample = 0; break;
|
||||
case 1: break;
|
||||
case 3: sample = -sample; break;
|
||||
case 3: sample = -sample; // break;
|
||||
}
|
||||
mphase++;
|
||||
if (mphase >= 4) mphase = 0;
|
||||
|
||||
sample_count++;
|
||||
} else {
|
||||
s++;
|
||||
}
|
||||
|
||||
//FM
|
||||
frq = (sample>>16) * 386760;
|
||||
// FM
|
||||
delta = (sample >> 16) * 386760; // ?
|
||||
|
||||
phase = (phase + frq);
|
||||
sphase = phase + (256<<16);
|
||||
phase += delta;
|
||||
sphase = phase + (64 << 18);
|
||||
|
||||
re = (sine_table_f32[(sphase & 0x03FF0000)>>18]*127);
|
||||
im = (sine_table_f32[(phase & 0x03FF0000)>>18]*127);
|
||||
re = (sine_table_i8[(sphase & 0x03FF0000) >> 18]);
|
||||
im = (sine_table_i8[(phase & 0x03FF0000) >> 18]);
|
||||
|
||||
buffer.p[i] = {(int8_t)re,(int8_t)im};
|
||||
buffer.p[i] = {(int8_t)re, (int8_t)im};
|
||||
}
|
||||
}
|
||||
|
||||
void RDSProcessor::on_message(const Message* const msg) {
|
||||
if (msg->id == Message::ID::RDSConfigure) {
|
||||
//const auto message = *reinterpret_cast<const RDSConfigureMessage*>(p);
|
||||
const auto message = *reinterpret_cast<const RDSConfigureMessage*>(msg);
|
||||
rdsdata = (uint32_t*)shared_memory.tx_data;
|
||||
message_length = message.length;
|
||||
configured = true;
|
||||
}
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@ private:
|
||||
|
||||
BasebandThread baseband_thread { 2280000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
||||
|
||||
uint16_t message_length;
|
||||
int8_t re, im;
|
||||
uint8_t mphase, s;
|
||||
uint32_t bit_pos;
|
||||
@@ -54,8 +55,7 @@ private:
|
||||
int32_t sample;
|
||||
int out_sample_index = SAMPLE_BUFFER_SIZE - 1;
|
||||
uint32_t phase, sphase;
|
||||
int32_t sig, frq, frq_im, rdsc;
|
||||
int32_t k;
|
||||
int32_t delta;
|
||||
|
||||
bool configured { false };
|
||||
|
||||
|
@@ -55,7 +55,7 @@ void XylosProcessor::execute(const buffer_c8_t& buffer) {
|
||||
message.n = 25; // End of message code
|
||||
shared_memory.application_queue.push(message);
|
||||
} else {
|
||||
message.n = byte_pos; // Inform UI about progress (just as eye candy)
|
||||
message.n = byte_pos; // Inform UI about progress (just as eye candy)
|
||||
shared_memory.application_queue.push(message);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ void XylosProcessor::execute(const buffer_c8_t& buffer) {
|
||||
re = 0;
|
||||
im = 0;
|
||||
} else {
|
||||
tone_sample = (sine_table_i8[(tone_phase & 0x03FC0000)>>18]);
|
||||
tone_sample = (sine_table_i8[(tone_phase & 0x03FC0000) >> 18]);
|
||||
|
||||
// Audio preview sample generation: 1536000/48000 = 32
|
||||
/*if (as >= 31) {
|
||||
@@ -87,16 +87,16 @@ void XylosProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// FM
|
||||
// 1<<18 = 262144
|
||||
// m = (262144 * BW) / 1536000 / 2
|
||||
frq = tone_sample * 853; // 10kHz BW
|
||||
delta = tone_sample * 853; // 10kHz BW
|
||||
|
||||
phase = (phase + frq);
|
||||
sphase = phase + (64<<18);
|
||||
phase += delta;
|
||||
sphase = phase + (64 << 18);
|
||||
|
||||
re = (sine_table_i8[(sphase & 0x03FC0000)>>18]);
|
||||
im = (sine_table_i8[(phase & 0x03FC0000)>>18]);
|
||||
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
|
||||
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]);
|
||||
}
|
||||
|
||||
buffer.p[i] = {(int8_t)re,(int8_t)im};
|
||||
buffer.p[i] = {(int8_t)re, (int8_t)im};
|
||||
}
|
||||
|
||||
//audio_output.write(audio_buffer);
|
||||
|
@@ -68,7 +68,7 @@ private:
|
||||
uint8_t digit = 0;
|
||||
uint32_t sample_count = 0;
|
||||
uint32_t tone_phase, phase, sphase;
|
||||
int32_t tone_sample, frq;
|
||||
int32_t tone_sample, delta;
|
||||
bool silence = true;
|
||||
TXDoneMessage message;
|
||||
|
||||
|
Reference in New Issue
Block a user