Added missing files, ENUMed modulation modes

This commit is contained in:
furrtek
2016-01-05 11:47:46 +01:00
parent 9b8b8cc83f
commit 3477a2691a
34 changed files with 583 additions and 98 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ void m4_switch(const char * hash) {
// Ask M4 to enter loop in RAM
BasebandConfiguration baseband_switch {
.mode = 0xFF,
.mode = SWITCH,
.sampling_rate = 0,
.decimation_factor = 1,
};
+3 -1
View File
@@ -19,6 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
//TODO: Enum modulation modes (baseband)
//TODO: More gfx, cute icons :)
//TODO: check jammer bandwidths
//TODO: GSM channel detector
//TODO: wait_for_switch() in baseband-tx !
@@ -27,7 +29,7 @@
//TODO: Reset baseband if module not found (instead of lockup in RAM loop)
//TODO: Module name/filename in modules.hpp to indicate requirement in case it's not found ui_loadmodule
//TODO: LCD backlight PWM
//TODO: BUG: Crash after TX stop
//TODO: BUG: Crash after TX stop (unregister message !)
//TODO: Check bw setting in LCR TX
//TODO: BUG: Crash after PSN entry in RDS TX
//TODO: Dynamically load baseband code depending on mode (disable M4 & interrupts, load, reset)
-2
View File
@@ -1,2 +0,0 @@
const char md5_baseband[16] = {0xce,0x87,0x2b,0x2c,0x9e,0x74,0xe8,0x1c,0x1c,0xe9,0xfc,0xc2,0x40,0xc3,0x32,0xd5,};
const char md5_baseband_tx[16] = {0x1b,0xef,0x34,0x50,0x45,0xd7,0xae,0x7c,0xb5,0x4f,0x0c,0x5a,0x80,0xa0,0xbc,0x05,};
+1 -1
View File
@@ -130,7 +130,7 @@ void ReceiverModel::disable() {
/* TODO: This is a dumb hack to stop baseband from working so hard. */
BasebandConfigurationMessage message {
.configuration = {
.mode = -1,
.mode = NONE,
.sampling_rate = 0,
.decimation_factor = 1,
}
+1 -1
View File
@@ -81,7 +81,7 @@ private:
uint32_t baseband_bandwidth_ { max2837::filter::bandwidth_minimum };
int32_t vga_gain_db_ { 32 };
BasebandConfiguration baseband_configuration {
.mode = 1, /* TODO: Enum! */
.mode = NONE,
.sampling_rate = 3072000,
.decimation_factor = 4,
};
+9 -3
View File
@@ -80,11 +80,11 @@ void TransmitterModel::set_sampling_rate(uint32_t hz) {
update_baseband_configuration();
}
uint32_t TransmitterModel::modulation() const {
mode_type TransmitterModel::modulation() const {
return baseband_configuration.mode;
}
void TransmitterModel::set_modulation(int32_t v) {
void TransmitterModel::set_modulation(mode_type v) {
baseband_configuration.mode = v;
update_modulation();
}
@@ -114,7 +114,7 @@ void TransmitterModel::disable() {
/* TODO: This is a dumb hack to stop baseband from working so hard. */
BasebandConfigurationMessage message {
.configuration = {
.mode = -1,
.mode = NONE,
.sampling_rate = 0,
.decimation_factor = 1,
}
@@ -152,6 +152,11 @@ void TransmitterModel::update_modulation() {
update_baseband_configuration();
}
void TransmitterModel::set_baseband_configuration(const BasebandConfiguration config) {
baseband_configuration = config;
update_baseband_configuration();
}
void TransmitterModel::update_baseband_configuration() {
radio::streaming_disable();
@@ -164,3 +169,4 @@ void TransmitterModel::update_baseband_configuration() {
radio::streaming_enable();
}
+5 -3
View File
@@ -57,14 +57,16 @@ public:
uint32_t sampling_rate() const;
void set_sampling_rate(uint32_t hz);
uint32_t modulation() const;
void set_modulation(int32_t v);
mode_type modulation() const;
void set_modulation(mode_type v);
uint32_t baseband_oversampling() const;
void set_baseband_oversampling(uint32_t v);
void enable();
void disable();
void set_baseband_configuration(const BasebandConfiguration config);
private:
bool rf_amp_ { true };
@@ -72,7 +74,7 @@ private:
uint32_t baseband_bandwidth_ { max2837::filter::bandwidth_minimum };
int32_t vga_gain_db_ { 8 };
BasebandConfiguration baseband_configuration {
.mode = 16,
.mode = NONE,
.sampling_rate = 2280000,
.decimation_factor = 1,
};
+1 -1
View File
@@ -48,7 +48,7 @@ AFSKRXView::AFSKRXView(
};
receiver_model.set_baseband_configuration({
.mode = 6,
.mode = RX_AFSK,
.sampling_rate = 3072000,
.decimation_factor = 4,
});
+1 -1
View File
@@ -46,7 +46,7 @@ void AFSKSetupView::focus() {
}
void AFSKSetupView::paint(Painter& painter) {
(void)painter;
}
void AFSKSetupView::updfreq(rf::Frequency f) {
+2 -2
View File
@@ -50,7 +50,7 @@ JammerView::~JammerView() {
}
void JammerView::paint(Painter& painter) {
(void)painter;
}
void JammerView::updfreq(uint8_t id, rf::Frequency f) {
@@ -169,7 +169,7 @@ JammerView::JammerView(
.foreground = Color::grey(),
};
transmitter_model.set_modulation(18);
transmitter_model.set_modulation(TX_JAMMER);
add_children({ {
&text_type,
+2 -4
View File
@@ -187,7 +187,7 @@ LCRView::LCRView(
.foreground = Color::black(),
};
transmitter_model.set_modulation(16);
transmitter_model.set_modulation(TX_LCR);
transmitter_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
memset(litteral, 0, 5*8);
memset(rgsb, 0, 5);
@@ -275,9 +275,7 @@ LCRView::LCRView(
nav.push(new DebugLCRView { nav, lcrstring, checksum });
};
button_transmit.on_select = [this,&transmitter_model](Button&){
uint16_t c;
button_transmit.on_select = [this,&transmitter_model](Button&){
auto& message_map = context().message_map();
make_frame();
+3 -2
View File
@@ -41,7 +41,7 @@ void LoadModuleView::focus() {
}
void LoadModuleView::paint(Painter& painter) {
(void)painter;
}
void LoadModuleView::on_hide() {
@@ -53,7 +53,8 @@ void LoadModuleView::on_show() {
auto& message_map = context().message_map();
message_map.register_handler(Message::ID::ReadyForSwitch,
[this](Message* const p) {
const auto message = static_cast<const ReadyForSwitchMessage*>(p);
(void)p;
// const auto message = static_cast<const ReadyForSwitchMessage*>(p);
if (m4_load_image()) {
text_info.set("Module loaded :)");
_mod_loaded = true;
+1
View File
@@ -195,6 +195,7 @@ BMPView::BMPView(NavigationView& nav) {
}
void BMPView::paint(Painter& painter) {
(void)painter;
portapack::display.drawBMP({(240-185)/2, 0}, splash_bmp);
}
+2 -2
View File
@@ -456,7 +456,7 @@ ReceiverView::ReceiverView(
options_modulation.set_by_value(receiver_model.modulation());
options_modulation.on_change = [this](size_t n, OptionsField::value_t v) {
(void)n;
this->on_modulation_changed(v);
this->on_modulation_changed((mode_type)v);
};
/*
options_baseband_oversampling.set_by_value(receiver_model.baseband_oversampling());
@@ -625,7 +625,7 @@ void ReceiverView::on_vga_changed(int32_t v_db) {
receiver_model.set_vga(v_db);
}
void ReceiverView::on_modulation_changed(int32_t modulation) {
void ReceiverView::on_modulation_changed(mode_type modulation) {
/* TODO: This is TERRIBLE!!! */
switch(modulation) {
case 3:
+7 -8
View File
@@ -411,13 +411,12 @@ private:
{ 19 * 8, 1 * 16 },
4,
{
// TODO: Put ordinals in here...
{ " AM ", 0 },
{ "NFM ", 1 },
{ "WFM ", 2 },
{ "AIS ", 3 },
{ "TPMS", 5 },
{ "SPEC", 4 },
{ " AM ", RX_NBAM_AUDIO },
{ "NFM ", RX_NBFM_AUDIO },
{ "WFM ", RX_WBFM_AUDIO },
{ "AIS ", RX_AIS },
{ "TPMS", RX_TPMS },
{ "SPEC", RX_WBSPECTRUM },
}
};
/*
@@ -464,7 +463,7 @@ private:
void on_rf_amp_changed(bool v);
void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db);
void on_modulation_changed(int32_t modulation);
void on_modulation_changed(mode_type modulation);
void on_show_options_frequency();
void on_show_options_rf_gain();
void on_frequency_step_changed(rf::Frequency f);
+144
View File
@@ -0,0 +1,144 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
*
* 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_sigfrx.hpp"
#include "ui_receiver.hpp"
#include "ch.h"
#include "evtimer.h"
#include "ff.h"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
//#include "fox_bmp.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
#include "portapack_persistent_memory.hpp"
#include <cstring>
#include <stdio.h>
using namespace hackrf::one;
namespace ui {
void SIGFRXView::focus() {
button_exit.focus();
}
SIGFRXView::~SIGFRXView() {
receiver_model.disable();
}
void SIGFRXView::paint(Painter& painter) {
uint8_t i, xp;
//portapack::display.drawBMP({0, 302-160}, fox_bmp);
portapack::display.fill_rectangle({0,16,240,160-16}, ui::Color::white());
for (i = 0; i < 6; i++) {
xp = sigfrx_marks[i*3];
painter.draw_string({ (ui::Coord)sigfrx_marks[(i*3)+1], 144-20 }, style_white, to_string_dec_uint(sigfrx_marks[(i*3)+2]) );
portapack::display.draw_line({xp, 144-4}, {xp, 144}, ui::Color::black());
}
}
void SIGFRXView::on_channel_spectrum(const ChannelSpectrum& spectrum) {
portapack::display.fill_rectangle({0, 144, 240, 4},ui::Color::white());
uint8_t xmax = 0, imax = 0;
size_t i;
for (i=0; i<120; i++) {
if (spectrum.db[i] > xmax) {
xmax = spectrum.db[i];
imax = i;
}
}
for (i=136; i<256; i++) {
if (spectrum.db[i-16] > xmax) {
xmax = spectrum.db[i-16];
imax = i-16;
}
}
if ((imax >= last_channel-2) && (imax <= last_channel+2)) {
if (detect_counter >= 5) {
// Latched !
} else {
detect_counter++;
}
} else {
if (detect_counter >= 5) text_channel.set("... ");
detect_counter = 0;
}
last_channel = imax;
portapack::display.fill_rectangle({(ui::Coord)(imax-2), 144, 4, 4}, ui::Color::red());
}
void SIGFRXView::on_show() {
context().message_map().register_handler(Message::ID::ChannelSpectrum,
[this](const Message* const p) {
this->on_channel_spectrum(reinterpret_cast<const ChannelSpectrumMessage*>(p)->spectrum);
}
);
}
SIGFRXView::SIGFRXView(
NavigationView& nav,
ReceiverModel& receiver_model
) : receiver_model(receiver_model)
{
receiver_model.set_baseband_configuration({
.mode = RX_SIGFOX,
.sampling_rate = 3072000,
.decimation_factor = 4,
});
receiver_model.set_baseband_bandwidth(1750000);
receiver_model.set_tuning_frequency(868110000);
receiver_model.set_lna(0);
receiver_model.set_vga(0);
add_children({ {
&text_type,
&text_channel,
&text_data,
&button_exit
} });
text_type.set_style(&style_white);
text_channel.set_style(&style_white);
text_data.set_style(&style_white);
button_exit.on_select = [&nav](Button&){
nav.pop();
};
receiver_model.enable();
}
} /* namespace ui */
+87
View File
@@ -0,0 +1,87 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
*
* 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 "receiver_model.hpp"
namespace ui {
class SIGFRXView : public View {
public:
SIGFRXView(NavigationView& nav, ReceiverModel& receiver_model);
~SIGFRXView();
void on_channel_spectrum(const ChannelSpectrum& spectrum);
void on_show() override;
void focus() override;
void paint(Painter& painter) override;
private:
ReceiverModel& receiver_model;
uint8_t last_channel;
uint8_t detect_counter = 0;
const Style style_white {
.font = font::fixed_8x16,
.background = Color::white(),
.foreground = Color::black()
};
const uint16_t sigfrx_marks[18] = {
10, 8, 0,
60, 52, 90,
119, 95, 180,
121, 122, 220,
179, 171, 310,
230, 214, 400 };
Text text_type {
{ 1 * 8, 1 * 16, 28 * 8, 16 },
"SIGFOX interceptor. Yap !"
};
Text text_channel {
{ 1 * 8, 3 * 16, 28 * 8, 16 },
"PL: "
};
Text text_data {
{ 1 * 8, 4 * 16, 28 * 8, 16 },
"??: "
};
Button button_exit {
{ 22 * 8, 160 - 32, 56, 32 },
"Exit"
};
};
} /* namespace ui */
+2 -2
View File
@@ -50,7 +50,7 @@ WhistleView::~WhistleView() {
}
void WhistleView::paint(Painter& painter) {
(void)painter;
}
void WhistleView::whistle_th(void *arg) {
@@ -72,7 +72,7 @@ WhistleView::WhistleView(
msg_t mbox_buffer[3];
chMBInit(&mbox, mbox_buffer, 3);
transmitter_model.set_modulation(17);
transmitter_model.set_modulation(TX_TONE);
transmitter_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
add_children({ {
+59 -7
View File
@@ -49,7 +49,7 @@ XylosView::~XylosView() {
}
void XylosView::paint(Painter& painter) {
(void)painter;
}
void XylosView::upd_message() {
@@ -96,7 +96,37 @@ void XylosView::upd_message() {
ccirmessage[20] = 0;
// Display as text
text_debug.set(ccirmessage);
// ASCII to baseband frequency LUT index
for (c=0; c<20; c++) {
if (ccirmessage[c] > '9')
ccirmessage[c] -= 0x37;
else
ccirmessage[c] -= 0x30;
}
}
void XylosView::journuit() {
uint8_t sr;
chThdSleepMilliseconds(1000);
// Invert relay states
sr = options_ra.selected_index();
if (sr > 0) options_ra.set_selected_index(sr ^ 3);
sr = options_rb.selected_index();
if (sr > 0) options_rb.set_selected_index(sr ^ 3);
sr = options_rc.selected_index();
if (sr > 0) options_rc.set_selected_index(sr ^ 3);
upd_message();
portapack::audio_codec.set_headphone_volume(volume_t::decibel(90 - 99) + wolfson::wm8731::headphone_gain_range.max);
shared_memory.xylos_transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
transmitter_model.enable();
}
XylosView::XylosView(
@@ -116,7 +146,13 @@ XylosView::XylosView(
.foreground = Color::black(),
};
transmitter_model.set_modulation(19);
transmitter_model.set_baseband_configuration({
.mode = TX_XYLOS,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
transmitter_model.set_modulation(TX_XYLOS); // Useless ?
add_children({ {
&text_title,
@@ -141,6 +177,7 @@ XylosView::XylosView(
&text_progress,
&text_debug,
&button_transmit,
&checkbox_cligno,
&button_exit
} });
@@ -170,9 +207,17 @@ XylosView::XylosView(
XylosView::upd_message();
};
checkbox_wcsubfamily.on_select = [this](Checkbox&) {
if (checkbox_wcsubfamily.value() == true)
subfamily_code.hidden(true);
else
subfamily_code.hidden(false);
XylosView::upd_message();
};
checkbox_wcid.on_select = [this](Checkbox&) {
if (checkbox_wcid.value() == true)
receiver_code.hidden(true);
else
receiver_code.hidden(false);
XylosView::upd_message();
};
options_ra.on_change = [this](size_t n, OptionsField::value_t v) {
@@ -207,14 +252,19 @@ XylosView::XylosView(
char progress[21];
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n == 25) {
portapack::audio_codec.set_headphone_volume(volume_t::decibel(0 - 99) + wolfson::wm8731::headphone_gain_range.max);
transmitter_model.disable();
for (c=0;c<20;c++)
progress[c] = ' ';
progress[20] = 0;
text_progress.set(progress);
txing = false;
button_transmit.set_style(&style_val);
button_transmit.set_text("START");
if (checkbox_cligno.value() == false) {
txing = false;
button_transmit.set_style(&style_val);
button_transmit.set_text("START");
} else {
journuit();
}
} else {
for (c=0;c<message->n;c++)
progress[c] = ' ';
@@ -227,9 +277,11 @@ XylosView::XylosView(
shared_memory.xylos_transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
transmitter_model.set_tuning_frequency(xylos_freqs[options_freq.selected_index()]);
transmitter_model.set_tuning_frequency(87700000); //xylos_freqs[options_freq.selected_index()]);
portapack::audio_codec.set_headphone_volume(volume_t::decibel(90 - 99) + wolfson::wm8731::headphone_gain_range.max);
txing = true;
button_transmit.set_style(&style_cancel);
button_transmit.set_text("Wait");
+10 -3
View File
@@ -38,6 +38,7 @@ class XylosView : public View {
public:
XylosView(NavigationView& nav, TransmitterModel& transmitter_model);
~XylosView();
void journuit();
void upd_message();
void focus() override;
@@ -45,7 +46,7 @@ public:
private:
bool txing = false;
const rf::Frequency xylos_freqs[6] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000 };
const rf::Frequency xylos_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 87000000 };
char ccirmessage[21];
TransmitterModel& transmitter_model;
@@ -117,14 +118,15 @@ private:
};
OptionsField options_freq {
{ 16 * 8, 9 * 16 },
6,
7,
{
{ "31.3250", 0 },
{ "31.3875", 1 },
{ "31.4375", 2 },
{ "31.4750", 3 },
{ "31.6875", 4 },
{ "31.9750", 5 }
{ "31.9750", 5 },
{ "TEST 87", 6 }
}
};
@@ -182,6 +184,11 @@ private:
"START"
};
Checkbox checkbox_cligno {
{ 96, 16 * 16 + 4},
"J/N"
};
Button button_exit {
{ 21 * 8, 16 * 16, 64, 32 },
"Exit"