mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-23 15:07:29 +00:00
"CW generator" and "Whistle" merged in "Signal generator"
Added wave shape selection and tone frequency auto-update Converted color icons to B&W
This commit is contained in:
@@ -387,6 +387,13 @@ set(MODE_CPPSRC
|
||||
)
|
||||
DeclareTargets(PREP replay)
|
||||
|
||||
### Signal generator
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_siggen.cpp
|
||||
)
|
||||
DeclareTargets(PSIG siggen)
|
||||
|
||||
### SSTV TX
|
||||
|
||||
set(MODE_CPPSRC
|
||||
|
@@ -39,8 +39,8 @@ CaptureProcessor::CaptureProcessor() {
|
||||
decim_0.configure(decim_0_filter.taps, 33554432);
|
||||
decim_1.configure(decim_1_filter.taps, 131072);
|
||||
|
||||
channel_filter_pass_f = decim_1_filter.pass_frequency_normalized * decim_1_input_fs;
|
||||
channel_filter_stop_f = decim_1_filter.stop_frequency_normalized * decim_1_input_fs;
|
||||
channel_filter_pass_f = decim_1_filter.pass_frequency_normalized * decim_1_input_fs; // 162760.416666667
|
||||
channel_filter_stop_f = decim_1_filter.stop_frequency_normalized * decim_1_input_fs; // 337239.583333333
|
||||
|
||||
spectrum_interval_samples = decim_1_output_fs / spectrum_rate_hz;
|
||||
spectrum_samples = 0;
|
||||
|
@@ -87,9 +87,9 @@ void JammerProcessor::execute(const buffer_c8_t& buffer) {
|
||||
};
|
||||
|
||||
void JammerProcessor::on_message(const Message* const msg) {
|
||||
const auto message = *reinterpret_cast<const JammerConfigureMessage*>(msg);
|
||||
|
||||
if (message.id == Message::ID::JammerConfigure) {
|
||||
if (msg->id == Message::ID::JammerConfigure) {
|
||||
const auto message = *reinterpret_cast<const JammerConfigureMessage*>(msg);
|
||||
|
||||
if (message.run) {
|
||||
jammer_channels = (JammerChannel*)shared_memory.bb_data.data;
|
||||
noise_type = message.type;
|
||||
|
124
firmware/baseband/proc_siggen.cpp
Normal file
124
firmware/baseband/proc_siggen.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "proc_siggen.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
#include "event_m4.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
void SigGenProcessor::execute(const buffer_c8_t& buffer) {
|
||||
if (!configured) return;
|
||||
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
|
||||
if (!sample_count && auto_off) {
|
||||
message.done = true;
|
||||
shared_memory.application_queue.push(message);
|
||||
} else
|
||||
sample_count--;
|
||||
|
||||
if (tone_shape == 0) {
|
||||
// CW
|
||||
re = 0;
|
||||
im = 0;
|
||||
} else {
|
||||
|
||||
if (tone_shape == 1) {
|
||||
// Sine
|
||||
sample = (sine_table_i8[(tone_phase & 0xFF000000) >> 24]);
|
||||
} else if (tone_shape == 2) {
|
||||
// Tri
|
||||
int8_t a = (tone_phase & 0xFF000000) >> 24;
|
||||
sample = (a & 0x80) ? ((a << 1) ^ 0xFF) - 0x80 : (a << 1) + 0x80;
|
||||
} else if (tone_shape == 3) {
|
||||
// Saw up
|
||||
sample = ((tone_phase & 0xFF000000) >> 24);
|
||||
} else if (tone_shape == 4) {
|
||||
// Saw down
|
||||
sample = ((tone_phase & 0xFF000000) >> 24) ^ 0xFF;
|
||||
} else if (tone_shape == 5) {
|
||||
// Square
|
||||
sample = (((tone_phase & 0xFF000000) >> 24) & 0x80) ? 127 : -128;
|
||||
} else if (tone_shape == 6) {
|
||||
// Noise
|
||||
sample = (lfsr & 0xFF000000) >> 24;
|
||||
feedback = ((lfsr >> 31) ^ (lfsr >> 29) ^ (lfsr >> 15) ^ (lfsr >> 11)) & 1;
|
||||
lfsr = (lfsr << 1) | feedback;
|
||||
if (!lfsr) lfsr = 0x1337; // Shouldn't do this :(
|
||||
}
|
||||
|
||||
tone_phase += tone_delta;
|
||||
|
||||
// Do FM
|
||||
delta = sample * fm_delta;
|
||||
|
||||
phase += delta;
|
||||
sphase = phase + (64 << 24);
|
||||
|
||||
re = (sine_table_i8[(sphase & 0xFF000000) >> 24]);
|
||||
im = (sine_table_i8[(phase & 0xFF000000) >> 24]);
|
||||
}
|
||||
|
||||
buffer.p[i] = {re, im};
|
||||
}
|
||||
};
|
||||
|
||||
void SigGenProcessor::on_message(const Message* const msg) {
|
||||
const auto message = *reinterpret_cast<const SigGenConfigMessage*>(msg);
|
||||
|
||||
switch(msg->id) {
|
||||
case Message::ID::SigGenConfig:
|
||||
if (!message.bw) {
|
||||
configured = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.duration) {
|
||||
sample_count = message.duration;
|
||||
auto_off = true;
|
||||
} else
|
||||
auto_off = false;
|
||||
|
||||
fm_delta = message.bw * (0xFFFFFFULL / 1536000);
|
||||
tone_shape = message.shape;
|
||||
|
||||
lfsr = 0x54DF0119;
|
||||
|
||||
configured = true;
|
||||
break;
|
||||
|
||||
case Message::ID::SigGenTone:
|
||||
tone_delta = reinterpret_cast<const SigGenToneMessage*>(msg)->tone_delta;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
EventDispatcher event_dispatcher { std::make_unique<SigGenProcessor>() };
|
||||
event_dispatcher.run();
|
||||
return 0;
|
||||
}
|
52
firmware/baseband/proc_siggen.hpp
Normal file
52
firmware/baseband/proc_siggen.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROC_SIGGEN_H__
|
||||
#define __PROC_SIGGEN_H__
|
||||
|
||||
#include "baseband_processor.hpp"
|
||||
#include "baseband_thread.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
class SigGenProcessor : public BasebandProcessor {
|
||||
public:
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
|
||||
void on_message(const Message* const msg) override;
|
||||
|
||||
private:
|
||||
bool configured { false };
|
||||
|
||||
BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
||||
|
||||
uint32_t tone_delta { 0 }, fm_delta { };
|
||||
uint32_t lfsr { }, feedback { }, tone_shape { };
|
||||
uint32_t sample_count { 0 };
|
||||
bool auto_off { };
|
||||
uint32_t tone_phase { 0 }, phase { 0 }, delta { 0 }, sphase { 0 };
|
||||
int8_t sample { 0 };
|
||||
int8_t re { 0 }, im { 0 };
|
||||
|
||||
TXDoneMessage message { };
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user