mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-23 18:24:58 +00:00
Added more SSTV modes
A bit more work done on Replay (still not enabled)
This commit is contained in:
@@ -39,13 +39,17 @@ void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||
//const auto& decimator_out = decim_1_out;
|
||||
//const auto& channel = decimator_out;
|
||||
|
||||
//if( stream ) {
|
||||
// const size_t bytes_to_write = sizeof(*decimator_out.p) * decimator_out.count;
|
||||
// const auto result = stream->write(decimator_out.p, bytes_to_write);
|
||||
//}
|
||||
if( stream ) {
|
||||
const size_t bytes_to_read = buffer.count; // ?
|
||||
const auto result = stream->read(iq_buffer.p, bytes_to_read);
|
||||
}
|
||||
|
||||
//feed_channel_stats(channel);
|
||||
|
||||
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
buffer.p[i] = { iq_buffer.p[i].real() >> 8, iq_buffer.p[i].imag() >> 8};
|
||||
}
|
||||
|
||||
/*spectrum_samples += channel.count;
|
||||
if( spectrum_samples >= spectrum_interval_samples ) {
|
||||
spectrum_samples -= spectrum_interval_samples;
|
||||
@@ -60,7 +64,7 @@ void ReplayProcessor::on_message(const Message* const message) {
|
||||
channel_spectrum.on_message(message);
|
||||
break;*/
|
||||
|
||||
case Message::ID::ReplayConfig:
|
||||
case Message::ID::CaptureConfig:
|
||||
replay_config(*reinterpret_cast<const ReplayConfigMessage*>(message));
|
||||
break;
|
||||
|
||||
|
@@ -52,13 +52,13 @@ private:
|
||||
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
||||
//RSSIThread rssi_thread { NORMALPRIO + 10 };
|
||||
|
||||
std::array<complex16_t, 512> dst;
|
||||
const buffer_c16_t dst_buffer {
|
||||
dst.data(),
|
||||
dst.size()
|
||||
std::array<complex16_t, 2048> iq { };
|
||||
const buffer_c16_t iq_buffer {
|
||||
iq.data(),
|
||||
iq.size()
|
||||
};
|
||||
|
||||
std::unique_ptr<StreamOutput> stream;
|
||||
std::unique_ptr<StreamOutput> stream { };
|
||||
|
||||
/*SpectrumCollector channel_spectrum;
|
||||
size_t spectrum_interval_samples = 0;
|
||||
|
@@ -40,7 +40,7 @@ void SSTVTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
// of the scanline. Todo: simplify !
|
||||
|
||||
if (state == STATE_CALIBRATION) {
|
||||
// Once per scanline
|
||||
// Once per picture
|
||||
tone_delta = calibration_sequence[substep].first;
|
||||
sample_count = calibration_sequence[substep].second;
|
||||
if (substep == 2) {
|
||||
@@ -49,17 +49,15 @@ void SSTVTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
} else
|
||||
substep++;
|
||||
} else if (state == STATE_VIS) {
|
||||
// Once per scanline
|
||||
// Once per picture
|
||||
if (substep == 10) {
|
||||
current_scanline = &scanline_buffer[buffer_flip];
|
||||
buffer_flip ^= 1;
|
||||
if (asked == false) {
|
||||
// Ask application for a new scanline
|
||||
shared_memory.application_queue.push(sig_message);
|
||||
asked = true;
|
||||
}
|
||||
// Ask application for a new scanline
|
||||
shared_memory.application_queue.push(sig_message);
|
||||
// Do we have to transmit a start tone ?
|
||||
if (current_scanline->start_tone.duration) {
|
||||
state = STATE_START;
|
||||
state = STATE_SYNC;
|
||||
tone_delta = current_scanline->start_tone.frequency;
|
||||
sample_count = current_scanline->start_tone.duration;
|
||||
} else {
|
||||
@@ -69,23 +67,19 @@ void SSTVTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
}
|
||||
} else {
|
||||
tone_delta = vis_code_sequence[substep];
|
||||
sample_count = SSTV_MS2S(30); // VIS code bit is 30ms
|
||||
sample_count = SSTV_MS2S(30); // A VIS code bit is 30ms
|
||||
substep++;
|
||||
}
|
||||
} else if (state == STATE_START) {
|
||||
} else if (state == STATE_SYNC) {
|
||||
// Once per scanline, optional
|
||||
state = STATE_PIXELS;
|
||||
tone_delta = current_scanline->gap_tone.frequency;
|
||||
sample_count = current_scanline->gap_tone.duration;
|
||||
} else if (state == STATE_PIXELS) {
|
||||
// Many times per scanline
|
||||
pixel_luma = current_scanline->luma[pixel_index];
|
||||
|
||||
pixel_index++;
|
||||
|
||||
tone_delta = SSTV_F2D(1500 + ((pixel_luma * 800) / 256));
|
||||
|
||||
tone_delta = SSTV_F2D(1500 + ((current_scanline->luma[pixel_index] * 800) / 256));
|
||||
sample_count = pixel_duration;
|
||||
pixel_index++;
|
||||
|
||||
if (pixel_index >= 320) {
|
||||
// Scanline done, (dirty) state jump
|
||||
@@ -98,6 +92,7 @@ void SSTVTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
sample_count--;
|
||||
}
|
||||
|
||||
// Tone synth
|
||||
tone_sample = (sine_table_i8[(tone_phase & 0xFF000000U) >> 24]);
|
||||
tone_phase += tone_delta;
|
||||
|
||||
@@ -116,29 +111,27 @@ void SSTVTXProcessor::execute(const buffer_c8_t& buffer) {
|
||||
|
||||
void SSTVTXProcessor::on_message(const Message* const msg) {
|
||||
const auto message = *reinterpret_cast<const SSTVConfigureMessage*>(msg);
|
||||
uint8_t vis_code;
|
||||
|
||||
switch(msg->id) {
|
||||
case Message::ID::SSTVConfigure:
|
||||
pixel_duration = message.pixel_duration;
|
||||
|
||||
if (!pixel_duration) {
|
||||
configured = false;
|
||||
configured = false; // Shutdown
|
||||
return;
|
||||
}
|
||||
|
||||
vis_code = message.vis_code;
|
||||
|
||||
// VIS code:
|
||||
// 1200
|
||||
// 00011101 (0=1300, 1=1100)
|
||||
// 1200
|
||||
// 1200, (0=1300, 1=1100), 1200
|
||||
vis_code_sequence[0] = SSTV_VIS_SS;
|
||||
for (uint32_t c = 0; c < 8; c++) {
|
||||
vis_code_sequence[c + 1] = ((vis_code << c) & 0x80) ? SSTV_VIS_ONE : SSTV_VIS_ZERO;
|
||||
}
|
||||
for (uint32_t c = 0; c < 8; c++)
|
||||
vis_code_sequence[c + 1] = ((vis_code >> c) & 1) ? SSTV_VIS_ONE : SSTV_VIS_ZERO;
|
||||
vis_code_sequence[9] = SSTV_VIS_SS;
|
||||
|
||||
fm_delta = 9000 * (0xFFFFFFULL / 3072000); // Fixed for now
|
||||
fm_delta = 9000 * (0xFFFFFFULL / 3072000); // Fixed bw for now
|
||||
|
||||
pixel_index = 0;
|
||||
sample_count = 0;
|
||||
@@ -151,7 +144,6 @@ void SSTVTXProcessor::on_message(const Message* const msg) {
|
||||
|
||||
case Message::ID::FIFOData:
|
||||
memcpy(&scanline_buffer[buffer_flip], static_cast<const FIFODataMessage*>(msg)->data, sizeof(sstv_scanline));
|
||||
asked = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -50,7 +50,7 @@ private:
|
||||
enum state_t {
|
||||
STATE_CALIBRATION = 0,
|
||||
STATE_VIS,
|
||||
STATE_START,
|
||||
STATE_SYNC,
|
||||
STATE_PIXELS
|
||||
};
|
||||
|
||||
@@ -63,8 +63,6 @@ private:
|
||||
uint32_t vis_code_sequence[10] { };
|
||||
sstv_scanline scanline_buffer[2] { };
|
||||
uint8_t buffer_flip { 0 }, substep { 0 };
|
||||
|
||||
uint8_t vis_code { };
|
||||
uint32_t pixel_duration { };
|
||||
|
||||
sstv_scanline * current_scanline { };
|
||||
@@ -77,9 +75,7 @@ private:
|
||||
uint32_t sample_count { 0 };
|
||||
uint32_t phase { 0 }, sphase { 0 };
|
||||
int32_t tone_sample { 0 }, delta { 0 };
|
||||
int8_t re { 0 }, im { 0 };
|
||||
|
||||
bool asked { false };
|
||||
int8_t re { }, im { };
|
||||
|
||||
RequestSignalMessage sig_message { RequestSignalMessage::Signal::FillRequest };
|
||||
};
|
||||
|
@@ -40,7 +40,7 @@ StreamOutput::StreamOutput(ReplayConfig* const config) :
|
||||
}
|
||||
}
|
||||
|
||||
size_t StreamOutput::write(const void* const data, const size_t length) {
|
||||
size_t StreamOutput::read(const void* const data, const size_t length) {
|
||||
const uint8_t* p = static_cast<const uint8_t*>(data);
|
||||
size_t written = 0;
|
||||
|
||||
|
@@ -34,8 +34,13 @@
|
||||
class StreamOutput {
|
||||
public:
|
||||
StreamOutput(ReplayConfig* const config);
|
||||
|
||||
StreamOutput(const StreamOutput&) = delete;
|
||||
StreamOutput(StreamOutput&&) = delete;
|
||||
StreamOutput& operator=(const StreamOutput&) = delete;
|
||||
StreamOutput& operator=(StreamOutput&&) = delete;
|
||||
|
||||
size_t write(const void* const data, const size_t length);
|
||||
size_t read(const void* const data, const size_t length);
|
||||
|
||||
private:
|
||||
static constexpr size_t buffer_count_max_log2 = 3;
|
||||
|
Reference in New Issue
Block a user