Added EPAR transmit (slow FSK), bit bug for now

This commit is contained in:
furrtek
2016-05-13 09:34:15 +02:00
parent 9149508c83
commit 7267de234d
20 changed files with 548 additions and 12 deletions

View File

@@ -161,6 +161,7 @@ CPPSRC = main.cpp \
ui_closecall.cpp \
ui_console.cpp \
ui_debug.cpp \
ui_epar.cpp \
ui_focus.cpp \
ui_font_fixed_8x16.cpp \
ui_handwrite.cpp \

View File

@@ -0,0 +1,207 @@
/*
* 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_epar.hpp"
#include "ch.h"
#include "hackrf_hal.hpp"
#include "event_m0.hpp"
#include "ff.h"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
#include "portapack_persistent_memory.hpp"
#include <cstring>
#include <stdio.h>
using namespace portapack;
namespace ui {
void EPARView::focus() {
city_code.focus();
}
EPARView::~EPARView() {
transmitter_model.disable();
}
void EPARView::update_message() {
uint8_t c;
// Start bit
epar_bits[0] = 1;
// To binary
for (c = 0; c < 8; c++)
epar_bits[c + 1] = ((city_code.value() >> c) & 1);
epar_bits[9] = options_group.selected_index_value() & 1;
epar_bits[10] = (options_group.selected_index_value() >> 1) & 1;
if (checkbox_ra.value())
epar_bits[11] = 1; // Bit 11 is relay 1 state
else
epar_bits[11] = 0;
if (checkbox_rb.value())
epar_bits[12] = 1; // Bit 12 is relay 2 state
else
epar_bits[12] = 0;
// DEBUG
char debug_binary[14];
for (c = 0; c < 13; c++)
debug_binary[c] = 0x30 + epar_bits[c];
debug_binary[13] = 0;
text_debug.set(debug_binary);
}
void EPARView::journuit() {
chThdSleepMilliseconds(1000);
// Invert relay states
checkbox_ra.set_value(~checkbox_ra.value());
checkbox_rb.set_value(~checkbox_rb.value());
update_message();
shared_memory.transmit_done = false;
memcpy(shared_memory.epardata, epar_bits, 13);
transmitter_model.enable();
}
EPARView::EPARView(
NavigationView& nav
)
{
static constexpr Style style_val {
.font = font::fixed_8x16,
.background = Color::green(),
.foreground = Color::black(),
};
static constexpr Style style_cancel {
.font = font::fixed_8x16,
.background = Color::red(),
.foreground = Color::black(),
};
transmitter_model.set_baseband_configuration({
.mode = 4,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
add_children({ {
&text_city,
&city_code,
&text_group,
&options_group,
&checkbox_ra,
&checkbox_rb,
&text_freq,
&options_freq,
&progressbar,
&text_debug,
&button_transmit,
&checkbox_cligno,
&button_exit
} });
city_code.set_value(220);
options_group.set_selected_index(3); // TP
options_freq.set_selected_index(6); // 5 ! DEBUG
checkbox_ra.set_value(true);
checkbox_rb.set_value(true);
city_code.on_change = [this](int32_t v) {
(void)v;
EPARView::update_message();
};
options_group.on_change = [this](size_t n, OptionsField::value_t v) {
(void)n;
(void)v;
EPARView::update_message();
};
checkbox_ra.on_select = [this](Checkbox&) {
EPARView::update_message();
};
checkbox_rb.on_select = [this](Checkbox&) {
EPARView::update_message();
};
button_transmit.set_style(&style_val);
EPARView::update_message();
button_transmit.on_select = [this](Button&) {
if (txing == false) {
update_message();
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this](Message* const p) {
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n == 100) {
transmitter_model.disable();
progressbar.set_value(0);
if (checkbox_cligno.value() == false) {
txing = false;
button_transmit.set_style(&style_val);
button_transmit.set_text("START");
} else {
journuit();
}
} else {
progressbar.set_value(message->n * 2); // 100/52
}
}
);
shared_memory.transmit_done = false;
memcpy(shared_memory.epardata, epar_bits, 13);
transmitter_model.set_tuning_frequency(epar_freqs[options_freq.selected_index()]);
txing = true;
button_transmit.set_style(&style_cancel);
button_transmit.set_text("Wait");
transmitter_model.enable();
}
};
button_exit.on_select = [&nav](Button&){
nav.pop();
};
}
} /* namespace ui */

View File

@@ -0,0 +1,142 @@
/*
* 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.hpp"
#include "ui_widget.hpp"
#include "ui_painter.hpp"
#include "ui_menu.hpp"
#include "ui_navigation.hpp"
#include "ui_font_fixed_8x16.hpp"
#include "clock_manager.hpp"
#include "message.hpp"
#include "rf_path.hpp"
#include "max2837.hpp"
#include "volume.hpp"
#include "transmitter_model.hpp"
#include "receiver_model.hpp"
namespace ui {
class EPARView : public View {
public:
EPARView(NavigationView& nav);
~EPARView();
std::string title() const override { return "EPAR transmit"; };
void journuit();
void talk();
void update_message();
void focus() override;
private:
bool txing = false;
const rf::Frequency epar_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 88000000 };
char epar_bits[13];
/* |012345678901234567890123456789|
* | Code ville: 000 |
* | Groupe: 00 |
* */
Text text_city {
{ 6 * 8, 1 * 16, 11 * 8, 16 },
"Code ville:"
};
NumberField city_code {
{ 18 * 8, 1 * 16 },
3,
{ 0, 255 },
0,
' '
};
Text text_group {
{ 10 * 8, 2 * 16, 7 * 8, 16 },
"Groupe:"
};
OptionsField options_group {
{ 18 * 8, 2 * 16 },
4,
{
{ "A ", 2 }, // See receiver PCB
{ "B ", 1 },
{ "C ", 0 },
{ "TP", 3 }
}
};
Text text_freq {
{ 5 * 8, 4 * 16, 10 * 8, 16 },
"Frequence:"
};
OptionsField options_freq {
{ 16 * 8, 4 * 16},
7,
{
{ "31.3250", 0 },
{ "31.3875", 1 },
{ "31.4375", 2 },
{ "31.4750", 3 },
{ "31.6875", 4 },
{ "31.9750", 5 },
{ "TEST 88", 6 }
}
};
Checkbox checkbox_ra {
{ 7 * 8, 6 * 16 },
8,
"Relais 1"
};
Checkbox checkbox_rb {
{ 7 * 8, 8 * 16 },
8,
"Relais 2"
};
ProgressBar progressbar {
{ 2 * 8, 12 * 16, 26 * 8, 20 },
};
Text text_debug {
{ 5 * 8, 14 * 16, 13 * 8, 16 },
"-------------"
};
Button button_transmit {
{ 2 * 8, 16 * 16, 64, 32 },
"START"
};
Checkbox checkbox_cligno {
{ 96, 16 * 16 + 4},
3,
"J/N"
};
Button button_exit {
{ 21 * 8, 16 * 16, 64, 32 },
"Exit"
};
};
} /* namespace ui */

View File

@@ -34,6 +34,7 @@
#include "ui_rds.hpp"
#include "ui_xylos.hpp"
#include "ui_epar.hpp"
#include "ui_lcr.hpp"
#include "analog_audio_app.hpp"
#include "ui_soundboard.hpp"
@@ -166,6 +167,7 @@ LoadModuleView::LoadModuleView(
if (_mod_loaded == true) {
if (viewid == AudioTX) nav.push<AudioTXView>();
if (viewid == Xylos) nav.push<XylosView>();
if (viewid == EPAR) nav.push<EPARView>();
if (viewid == LCR) nav.push<LCRView>();
if (viewid == SoundBoard) nav.push<SoundBoardView>();
if (viewid == AnalogAudio) nav.push<AnalogAudioView>();

View File

@@ -35,6 +35,7 @@ enum ViewID {
AudioTX,
CloseCall,
Xylos,
EPAR,
LCR,
SoundBoard,
AnalogAudio,

View File

@@ -187,7 +187,8 @@ SystemMenuView::SystemMenuView(NavigationView& nav) {
{ "Receiver RX", ui::Color::cyan(), [&nav](){ nav.push<LoadModuleView>(md5_baseband, Receiver); } },
{ "Close Call RX", ui::Color::cyan(), [&nav](){ nav.push<LoadModuleView>(md5_baseband, CloseCall); } },
{ "Soundboard TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, SoundBoard); } },
{ "Audio TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, AudioTX); } },
//{ "Audio TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, AudioTX); } },
{ "EPAR TX", ui::Color::green(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, EPAR); } },
{ "Xylos TX", ui::Color::orange(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, Xylos); } },
{ "TEDI/LCR TX", ui::Color::orange(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, LCR); } },
{ "RDS TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, RDS); } },

View File

@@ -206,7 +206,7 @@ void XylosView::journuit() {
upd_message();
audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max);
shared_memory.xylos_transmit_done = false;
shared_memory.transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
transmitter_model.enable();
}
@@ -270,7 +270,7 @@ XylosView::XylosView(
receiver_code.set_value(1);
header_code_a.set_value(0);
header_code_b.set_value(0);
options_freq.set_selected_index(6); // 5 ! DEBUG
options_freq.set_selected_index(5);
checkbox_wcsubfamily.set_value(true);
checkbox_wcid.set_value(true);
@@ -352,7 +352,7 @@ XylosView::XylosView(
);
memcpy(ccirmessage, ccirtest, 21);
shared_memory.xylos_transmit_done = false;
shared_memory.transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
transmitter_model.set_tuning_frequency(xylos_freqs[options_freq.selected_index()]);
@@ -401,7 +401,7 @@ XylosView::XylosView(
}
);
shared_memory.xylos_transmit_done = false;
shared_memory.transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
transmitter_model.set_tuning_frequency(xylos_freqs[options_freq.selected_index()]);

View File

@@ -151,7 +151,6 @@ private:
bool txing = false;
const rf::Frequency xylos_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 88000000 };
char ccirmessage[21];
char ccir_received[21];
Text text_title {
{ 8, 8, 11, 16 },