Added DCS parity table and generator tool

This commit is contained in:
furrtek
2017-03-14 07:24:04 +00:00
parent b77b8b0f42
commit 37cfcd392d
17 changed files with 1107 additions and 24 deletions
+2 -1
View File
@@ -141,6 +141,7 @@ set(CPPSRC
${COMMON}/bch_code.cpp
bht.cpp
ctcss.cpp
dcs.cpp
encoder.cpp
freqman.cpp
rds.cpp
@@ -155,7 +156,7 @@ set(CPPSRC
ui_afsksetup.cpp
ui_alphanum.cpp
ui_audio.cpp
ui_audiotx.cpp
ui_mictx.cpp
ui_baseband_stats_view.cpp
ui_bht_tx.cpp
ui_channel.cpp
+5
View File
@@ -255,4 +255,9 @@ void replay_stop() {
send_message(&message);
}
void request_beep() {
RequestSignalMessage message { RequestSignalMessage::Signal::BeepRequest };
send_message(&message);
}
} /* namespace baseband */
+1
View File
@@ -72,6 +72,7 @@ void set_adsb();
void set_jammer(const bool run, const jammer::JammerType type, const uint32_t speed);
void set_rds_data(const uint16_t message_length);
void set_spectrum(const size_t sampling_rate, const size_t trigger);
void request_beep();
void run_image(const portapack::spi_flash::image_tag_t image_tag);
void shutdown();
File diff suppressed because it is too large Load Diff
+36
View File
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 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 __DCS_H_
#define __DCS_H_
#include <memory>
#define DCS_CODES_NB 512
namespace dcs {
uint32_t dcs_word(uint32_t code);
}
#endif/*__DCS_H_*/
+1 -1
View File
@@ -20,7 +20,7 @@
* Boston, MA 02110-1301, USA.
*/
#include "ui_audiotx.hpp"
#include "ui_mictx.hpp"
#include "baseband_api.hpp"
#include "hackrf_gpio.hpp"
+238
View File
@@ -0,0 +1,238 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 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 "ui_mictx.hpp"
#include "baseband_api.hpp"
#include "hackrf_gpio.hpp"
#include "audio.hpp"
#include "portapack.hpp"
#include "pins.hpp"
#include "string_format.hpp"
#include "irq_controls.hpp"
#include "portapack_shared_memory.hpp"
#include <cstring>
using namespace ctcss;
using namespace portapack;
using namespace hackrf::one;
namespace ui {
void MicTXView::focus() {
field_frequency.focus();
}
void MicTXView::update_vumeter() {
vumeter.set_value(audio_level);
}
void MicTXView::on_tx_done() {
// Roger beep transmitted, stop transmitting
transmitting = false;
set_tx(false);
}
void MicTXView::set_tx(bool enable) {
uint32_t ctcss_index;
bool ctcss_enabled;
if (enable) {
ctcss_index = options_ctcss.selected_index();
if (ctcss_index) {
ctcss_enabled = true;
ctcss_index--;
} else
ctcss_enabled = false;
baseband::set_audiotx_data(
1536000U / 20, // 20Hz level update
transmitter_model.bandwidth(),
mic_gain_x10,
ctcss_enabled,
(uint32_t)((ctcss_tones[ctcss_index].frequency / 1536000.0) * 0xFFFFFFFFULL)
);
gpio_tx.write(1);
led_tx.on();
transmitting = true;
} else {
if (transmitting && rogerbeep_enabled) {
baseband::request_beep();
} else {
baseband::set_audiotx_data(
1536000U / 20, // 20Hz level update
0, // BW 0 = TX off
mic_gain_x10,
false, // Ignore CTCSS
0
);
gpio_tx.write(0);
led_tx.off();
transmitting = false;
}
}
}
void MicTXView::do_timing() {
if (va_enabled) {
if (!transmitting) {
// Attack
if (audio_level >= va_level) {
if ((attack_timer >> 8) >= attack_ms) {
decay_timer = 0;
attack_timer = 0;
set_tx(true);
} else {
attack_timer += ((256 * 1000) / 60); // 1 frame @ 60fps in ms .8 fixed point
}
} else {
attack_timer = 0;
}
} else {
// Decay
if (audio_level < va_level) {
if ((decay_timer >> 8) >= decay_ms) {
decay_timer = 0;
attack_timer = 0;
set_tx(false);
} else {
decay_timer += ((256 * 1000) / 60); // 1 frame @ 60fps in ms .8 fixed point
}
} else {
decay_timer = 0;
}
}
} else {
// PTT disable :(
const auto switches_state = get_switches_state();
if (!switches_state[1]) // Left button
set_tx(false);
}
}
void MicTXView::on_tuning_frequency_changed(rf::Frequency f) {
transmitter_model.set_tuning_frequency(f);
}
MicTXView::MicTXView(
NavigationView& nav
)
{
pins[P6_2].mode(3); // Set P6_2 pin function to I2S0_RX_SDA
baseband::run_image(portapack::spi_flash::image_tag_mic_tx);
add_children({
&labels,
&vumeter,
&options_gain,
&check_va,
&field_va_level,
&field_va_attack,
&field_va_decay,
&field_bw,
&field_frequency,
&options_ctcss,
&check_rogerbeep,
&text_ptt,
&button_exit
});
ctcss_populate(options_ctcss);
options_ctcss.set_selected_index(0);
options_gain.on_change = [this](size_t, int32_t v) {
mic_gain_x10 = v;
};
options_gain.set_selected_index(1); // x1.0
field_frequency.set_value(transmitter_model.tuning_frequency());
field_frequency.set_step(receiver_model.frequency_step());
field_frequency.on_change = [this](rf::Frequency f) {
this->on_tuning_frequency_changed(f);
};
field_frequency.on_edit = [this, &nav]() {
// TODO: Provide separate modal method/scheme?
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
this->on_tuning_frequency_changed(f);
this->field_frequency.set_value(f);
};
};
field_bw.on_change = [this](uint32_t v) {
transmitter_model.set_bandwidth(v * 1000);
};
field_bw.set_value(10);
check_va.on_select = [this](Checkbox&, bool v) {
va_enabled = v;
text_ptt.hidden(v);
set_dirty();
};
check_va.set_value(false);
check_rogerbeep.on_select = [this](Checkbox&, bool v) {
rogerbeep_enabled = v;
};
check_rogerbeep.set_value(false);
field_va_level.on_change = [this](int32_t v) {
va_level = v;
vumeter.set_mark(v);
};
field_va_level.set_value(40);
field_va_attack.on_change = [this](int32_t v) {
attack_ms = v;
};
field_va_attack.set_value(500);
field_va_decay.on_change = [this](int32_t v) {
decay_ms = v;
};
field_va_decay.set_value(2000);
button_exit.on_select = [&nav](Button&){
nav.pop();
};
// Run baseband as soon as the app starts to get audio levels without transmitting (rf amp off)
transmitter_model.set_sampling_rate(1536000U);
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable();
set_tx(false);
audio::set_rate(audio::Rate::Hz_24000);
audio::input::start();
}
MicTXView::~MicTXView() {
transmitter_model.disable();
baseband::shutdown();
}
}
+197
View File
@@ -0,0 +1,197 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 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 __UI_MICTX_H__
#define __UI_MICTX_H__
#include "ui.hpp"
#include "hal.h"
#include "ui_widget.hpp"
#include "ui_navigation.hpp"
#include "ui_font_fixed_8x16.hpp"
#include "message.hpp"
#include "ui_receiver.hpp"
#include "transmitter_model.hpp"
#include "ctcss.hpp"
namespace ui {
class MicTXView : public View {
public:
MicTXView(NavigationView& nav);
~MicTXView();
MicTXView(const MicTXView&) = delete;
MicTXView(MicTXView&&) = delete;
MicTXView& operator=(const MicTXView&) = delete;
MicTXView& operator=(MicTXView&&) = delete;
void focus() override;
// PTT: Enable through KeyEvent (only works with presses), disable by polling :(
bool on_key(const KeyEvent key) {
if ((key == KeyEvent::Left) && (!va_enabled)) {
set_tx(true);
return true;
} else
return false;
};
std::string title() const override { return "Microphone TX"; };
private:
void update_vumeter();
void do_timing();
void set_tx(bool enable);
void on_tuning_frequency_changed(rf::Frequency f);
void on_ctcss_changed(uint32_t v);
void on_tx_done();
bool transmitting { false };
bool va_enabled { };
bool rogerbeep_enabled { };
uint32_t mic_gain_x10 { };
uint32_t audio_level { 0 };
uint32_t va_level { };
uint32_t attack_ms { };
uint32_t decay_ms { };
uint32_t attack_timer { 0 };
uint32_t decay_timer { 0 };
Labels labels {
{ { 7 * 8, 1 * 8 }, "Mic. gain:", Color::light_grey() },
{ { 7 * 8, 4 * 8 }, "Voice activation:", Color::light_grey() },
{ { 8 * 8, 9 * 8 }, "Level: /255", Color::light_grey() },
{ { 8 * 8, 11 * 8 }, "Attack: ms", Color::light_grey() },
{ { 8 * 8, 13 * 8 }, "Decay: ms", Color::light_grey() },
{ { 7 * 8, 17 * 8 }, "Bandwidth: kHz", Color::light_grey() },
{ { 7 * 8, 19 * 8 }, "Frequency:", Color::light_grey() },
{ { 11 * 8, 21 * 8 }, "CTCSS:", Color::light_grey() }
};
VuMeter vumeter {
{ 1 * 8, 2 * 8, 5 * 8, 26 * 8 },
16
};
OptionsField options_gain {
{ 17 * 8, 1 * 8 },
4,
{
{ "x0.5", 5 },
{ "x1.0", 10 },
{ "x1.5", 15 },
{ "x2.0", 20 }
}
};
Checkbox check_va {
{ 8 * 8, 6 * 8 },
7,
"Enabled",
false
};
NumberField field_va_level {
{ 14 * 8, 9 * 8 },
3,
{ 0, 255 },
2,
' '
};
NumberField field_va_attack {
{ 15 * 8, 11 * 8 },
3,
{ 0, 999 },
20,
' '
};
NumberField field_va_decay {
{ 14 * 8, 13 * 8 },
4,
{ 0, 9999 },
100,
' '
};
NumberField field_bw {
{ 17 * 8, 17 * 8 },
3,
{ 0, 150 },
1,
' '
};
FrequencyField field_frequency {
{ 17 * 8, 19 * 8 },
};
OptionsField options_ctcss {
{ 17 * 8, 21 * 8 },
8,
{ }
};
Checkbox check_rogerbeep {
{ 8 * 8, 23 * 8 },
10,
"Roger beep",
false
};
Text text_ptt {
{ 7 * 8, 28 * 8, 16 * 8, 16 },
"PTT: LEFT BUTTON"
};
Button button_exit {
{ 18 * 8, 32 * 8, 10 * 8, 40 },
"Exit"
};
MessageHandlerRegistration message_handler_lcd_sync {
Message::ID::DisplayFrameSync,
[this](const Message* const) {
this->update_vumeter();
this->do_timing();
}
};
MessageHandlerRegistration message_handler_audio_level {
Message::ID::AudioLevel,
[this](const Message* const p) {
const auto message = static_cast<const AudioLevelMessage*>(p);
this->audio_level = message->value;
}
};
MessageHandlerRegistration message_handler_tx_done {
Message::ID::TXDone,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXDoneMessage*>(p);
if (message.done) this->on_tx_done();
}
};
};
} /* namespace ui */
#endif/*__UI_MICTX_H__*/
+2 -2
View File
@@ -33,7 +33,7 @@
#include "ui_about.hpp"
#include "ui_adsbtx.hpp"
#include "ui_audiotx.hpp"
#include "ui_mictx.hpp"
#include "ui_bht_tx.hpp"
#include "ui_closecall.hpp"
#include "ui_cw.hpp"
@@ -323,7 +323,7 @@ TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) {
add_items<4>({ {
{ "Soundboard", ui::Color::green(), &bitmap_icon_soundboard, [&nav](){ nav.push<SoundBoardView>(); } },
{ "Numbers station", ui::Color::orange(),&bitmap_icon_numbers, [&nav](){ nav.push<NumbersStationView>(); } },
{ "Microphone", ui::Color::green(), &bitmap_icon_microphone, [&nav](){ nav.push<AudioTXView>(); } },
{ "Microphone", ui::Color::green(), &bitmap_icon_microphone, [&nav](){ nav.push<MicTXView>(); } },
{ "Whistle", ui::Color::yellow(),&bitmap_icon_whistle, [&nav](){ nav.push<WhistleView>(); } },
} });
on_left = [&nav](){ nav.pop(); };
+3 -3
View File
@@ -150,10 +150,10 @@ private:
};
MessageHandlerRegistration message_handler_fifo_signal {
Message::ID::FIFOSignal,
Message::ID::RequestSignal,
[this](const Message* const p) {
const auto message = static_cast<const FIFOSignalMessage*>(p);
if (message->signaltype == 1) {
const auto message = static_cast<const RequestSignalMessage*>(p);
if (message->signal == RequestSignalMessage::Signal::FillRequest) {
this->prepare_audio();
}
}
+3 -3
View File
@@ -176,10 +176,10 @@ private:
};
MessageHandlerRegistration message_handler_fifo_signal {
Message::ID::FIFOSignal,
Message::ID::RequestSignal,
[this](const Message* const p) {
const auto message = static_cast<const FIFOSignalMessage*>(p);
if (message->signaltype == 1) {
const auto message = static_cast<const RequestSignalMessage*>(p);
if (message->signal == RequestSignalMessage::Signal::FillRequest) {
this->prepare_audio();
}
}
+1 -2
View File
@@ -45,8 +45,7 @@ void AudioTXProcessor::execute(const buffer_c8_t& buffer){
if ((audio_fifo.len() < 512) && (asked == false)) {
// Ask application to fill up fifo
sigmessage.signaltype = 1;
shared_memory.application_queue.push(sigmessage);
shared_memory.application_queue.push(sig_message);
asked = true;
}
} else {
+1 -1
View File
@@ -60,7 +60,7 @@ private:
sizeof(int16_t)*64
};*/
FIFOSignalMessage sigmessage { };
RequestSignalMessage sig_message { RequestSignalMessage::Signal::FillRequest };
};
#endif
+14 -6
View File
@@ -78,18 +78,26 @@ void MicTXProcessor::execute(const buffer_c8_t& buffer){
}
void MicTXProcessor::on_message(const Message* const msg) {
const auto message = *reinterpret_cast<const AudioTXConfigMessage*>(msg);
const AudioTXConfigMessage config_message = *reinterpret_cast<const AudioTXConfigMessage*>(msg);
const RequestSignalMessage request_message = *reinterpret_cast<const RequestSignalMessage*>(msg);
switch(msg->id) {
case Message::ID::AudioTXConfig:
fm_delta = message.fm_delta * (0xFFFFFFULL / 1536000);
gain_x10 = message.gain_x10;
divider = message.divider;
ctcss_enabled = message.ctcss_enabled;
ctcss_phase_inc = message.ctcss_phase_inc;
fm_delta = config_message.fm_delta * (0xFFFFFFULL / 1536000);
gain_x10 = config_message.gain_x10;
divider = config_message.divider;
ctcss_enabled = config_message.ctcss_enabled;
ctcss_phase_inc = config_message.ctcss_phase_inc;
configured = true;
break;
case Message::ID::RequestSignal:
if (request_message.signal == RequestSignalMessage::Signal::BeepRequest) {
// TODO
txdone_message.done = true;
}
break;
default:
break;
+1
View File
@@ -58,6 +58,7 @@ private:
int8_t re { 0 }, im { 0 };
AudioLevelMessage level_message { };
TXDoneMessage txdone_message { };
};
#endif
+12 -5
View File
@@ -89,7 +89,7 @@ public:
POCSAGPacket = 50,
FIFOSignal = 52,
RequestSignal = 52,
FIFOData = 53,
AudioLevel = 54,
@@ -794,14 +794,21 @@ public:
};
// TODO: use streaming buffer instead
class FIFOSignalMessage : public Message {
class RequestSignalMessage : public Message {
public:
constexpr FIFOSignalMessage(
) : Message { ID::FIFOSignal }
enum class Signal : char {
FillRequest = 1,
BeepRequest = 2,
};
constexpr RequestSignalMessage(
Signal signal
) : Message { ID::RequestSignal },
signal ( signal )
{
}
char signaltype = 0;
Signal signal;
};
class FIFODataMessage : public Message {
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env python
# Copyright (C) 2016 Furrtek
#
# 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.
#
# From http://mmi-comm.tripod.com/dcs.html
import sys
import struct
cb = [0,0,0,0,0,0,0,0,0]
for c in range (0, 0x200): # DCS code is 9 bits
for bit in range(0, 9):
cb[bit] = (c >> bit) & 1
p1 = cb[0] ^ cb[1] ^ cb[2] ^ cb[3] ^ cb[4] ^ cb[7];
p2 = cb[1] ^ cb[2] ^ cb[3] ^ cb[4] ^ cb[5] ^ cb[8] ^ 1;
p3 = cb[0] ^ cb[1] ^ cb[5] ^ cb[6] ^ cb[7];
p4 = cb[1] ^ cb[2] ^ cb[6] ^ cb[7] ^ cb[8] ^ 1;
p5 = cb[0] ^ cb[1] ^ cb[4] ^ cb[8] ^ 1;
p6 = cb[0] ^ cb[3] ^ cb[4] ^ cb[5] ^ cb[7] ^ 1;
p7 = cb[0] ^ cb[2] ^ cb[3] ^ cb[5] ^ cb[6] ^ cb[7] ^ cb[8];
p8 = cb[1] ^ cb[3] ^ cb[4] ^ cb[6] ^ cb[7] ^ cb[8];
p9 = cb[2] ^ cb[4] ^ cb[5] ^ cb[7] ^ cb[8];
p10 = cb[3] ^ cb[5] ^ cb[6] ^ cb[8] ^ 1;
p11 = cb[0] ^ cb[1] ^ cb[2] ^ cb[3] ^ cb[6] ^ 1;
print ' 0b{0:011b}'.format((p11<<10) | (p10<<9) | (p9<<8) |(p8<<7) | (p7<<6) | (p6<<5) | (p5<<4) | (p4<<3) | (p3<<2) | (p2<<1) | (p1)) + ', // ' + str(c);