Sync with Sharebrained's fw, only Xylos TX works for now

This commit is contained in:
furrtek
2016-07-27 03:03:40 +02:00
parent fdfa7c9776
commit 739956b42b
150 changed files with 17236 additions and 7875 deletions
+15
View File
@@ -141,6 +141,7 @@ set(CPPSRC
${COMMON}/ui_widget.cpp
${COMMON}/ui_painter.cpp
${COMMON}/ui_focus.cpp
${COMMON}/msgpack.cpp
ui_navigation.cpp
ui_menu.cpp
ui_rssi.cpp
@@ -155,9 +156,23 @@ set(CPPSRC
ui_console.cpp
ui_receiver.cpp
ui_record_view.cpp
ui_textentry.cpp
ui_alphanum.cpp
ui_spectrum.cpp
ui_about.cpp
ui_jammer.cpp
ui_handwrite.cpp
ui_afsksetup.cpp
ui_closecall.cpp
ui_soundboard.cpp
ui_rds.cpp
ui_lcr.cpp
ui_xylos.cpp
ui_freqman.cpp
# ui_loadmodule.cpp
recent_entries.cpp
receiver_model.cpp
transmitter_model.cpp
spectrum_color_lut.cpp
analog_audio_app.cpp
${COMMON}/ais_baseband.cpp
Executable → Regular
+4661 -349
View File
File diff suppressed because it is too large Load Diff
+7 -9
View File
@@ -78,6 +78,13 @@ void WFMConfig::apply() const {
audio::set_rate(audio::Rate::Hz_48000);
}
void set_xylos_data(const char ccir_message[]) {
const XylosConfigureMessage message {
ccir_message
};
send_message(&message);
}
static bool baseband_image_running = false;
void run_image(const portapack::spi_flash::image_tag_t image_tag) {
@@ -108,15 +115,6 @@ void shutdown() {
baseband_image_running = false;
}
void spectrum_streaming_start(size_t decimation_factor) {
shared_memory.baseband_queue.push_and_wait(
SpectrumStreamingConfigMessage {
SpectrumStreamingConfigMessage::Mode::Running,
decimation_factor
}
);
}
void spectrum_streaming_start() {
SpectrumStreamingConfigMessage message {
SpectrumStreamingConfigMessage::Mode::Running
+2 -1
View File
@@ -52,10 +52,11 @@ struct WFMConfig {
void apply() const;
};
void set_xylos_data(const char ccir_message[]);
void run_image(const portapack::spi_flash::image_tag_t image_tag);
void shutdown();
void spectrum_streaming_start(size_t decimation_factor);
void spectrum_streaming_start();
void spectrum_streaming_stop();
-55
View File
@@ -28,12 +28,9 @@ using namespace lpc43xx;
#include "message.hpp"
#include "baseband_api.hpp"
#include "portapack_shared_memory.hpp"
#include <cstring>
char * modhash;
/* TODO: OK, this is cool, but how do I put the M4 to sleep so I can switch to
* a different image? Other than asking the old image to sleep while the M0
* makes changes?
@@ -74,55 +71,3 @@ void m0_halt() {
port_wait_for_interrupt();
}
}
int m4_load_image(void) {
uint32_t mod_size;
UINT bw;
uint8_t i;
char md5sum[16];
FILINFO modinfo;
FIL modfile;
DIR rootdir;
FRESULT res;
// Scan SD card root directory for files with the right md5 fingerprint at the right location
f_opendir(&rootdir, "/");
for (;;) {
res = f_readdir(&rootdir, &modinfo);
if (res != FR_OK || modinfo.fname[0] == 0) break;
if (!(modinfo.fattrib & AM_DIR)) {
f_open(&modfile, modinfo.fname, FA_OPEN_EXISTING | FA_READ);
f_lseek(&modfile, 26);
f_read(&modfile, &md5sum, 16, &bw);
for (i = 0; i < 16; i++) {
if (md5sum[i] != modhash[i]) break;
}
if (i == 16) {
f_lseek(&modfile, 6);
f_read(&modfile, &mod_size, 4, &bw);
f_lseek(&modfile, 256);
f_read(&modfile, reinterpret_cast<void*>(portapack::memory::map::m4_code.base()), mod_size, &bw);
LPC_RGU->RESET_CTRL[0] = (1 << 13);
f_close(&modfile);
return 1;
}
f_close(&modfile);
}
}
return 0;
}
void m4_switch(const char * hash) {
modhash = const_cast<char*>(hash);
// Ask M4 to enter loop in RAM
BasebandConfiguration baseband_switch {
.mode = 0xFF,
.sampling_rate = 0,
.decimation_factor = 1,
};
BasebandConfigurationMessage message { baseband_switch };
shared_memory.baseband_queue.push(message);
}
-4
View File
@@ -24,15 +24,11 @@
#include <cstddef>
#include "ff.h"
#include "memory_map.hpp"
#include "spi_image.hpp"
#include "ui_navigation.hpp"
void m4_init(const portapack::spi_flash::image_tag_t image_tag, const portapack::memory::region_t to);
void m4_request_shutdown();
void m4_switch(const char * hash);
int m4_load_image(void);
void m0_halt();
+1
View File
@@ -22,6 +22,7 @@
#include "event_m0.hpp"
#include "portapack.hpp"
#include "portapack_persistent_memory.hpp"
#include "sd_card.hpp"
#include "time.hpp"
+1 -1
View File
@@ -106,7 +106,7 @@ void set_direction(const rf::Direction new_direction) {
/* TODO: Refactor all the various "Direction" enumerations into one. */
/* TODO: Only make changes if direction changes, but beware of clock enabling. */
direction = new_direction;
second_if.set_mode((direction == rf::Direction::Transmit) ? max2837::Mode::Transmit : max2837::Mode::Receive);
rf_path.set_direction(direction);
+6 -15
View File
@@ -78,6 +78,11 @@ uint32_t TransmitterModel::sampling_rate() const {
return baseband_configuration.sampling_rate;
}
uint32_t TransmitterModel::baseband_oversampling() const {
// TODO: Rename decimation_factor.
return baseband_configuration.decimation_factor;
}
void TransmitterModel::enable() {
enabled_ = true;
radio::set_direction(rf::Direction::Transmit);
@@ -91,20 +96,14 @@ void TransmitterModel::enable() {
void TransmitterModel::disable() {
enabled_ = false;
baseband::stop();
// TODO: Responsibility for enabling/disabling the radio is muddy.
// Some happens in ReceiverModel, some inside radio namespace.
radio::disable();
}
uint32_t TransmitterModel::baseband_oversampling() const {
// TODO: Rename decimation_factor.
return baseband_configuration.decimation_factor;
}
void TransmitterModel::update_tuning_frequency() {
radio::set_tuning_frequency(tuning_frequency());
radio::set_tuning_frequency(persistent_memory::tuned_frequency());
}
void TransmitterModel::update_rf_amp() {
@@ -123,10 +122,6 @@ void TransmitterModel::update_vga() {
radio::set_vga_gain(vga_gain_db_);
}
uint32_t TransmitterModel::modulation() const {
return baseband_configuration.mode;
}
void TransmitterModel::set_baseband_configuration(const BasebandConfiguration config) {
baseband_configuration = config;
update_baseband_configuration();
@@ -138,11 +133,7 @@ void TransmitterModel::update_baseband_configuration() {
// protocols that need quick RX/TX turn-around.
// Disabling baseband while changing sampling rates seems like a good idea...
baseband::stop();
radio::set_baseband_rate(sampling_rate() * baseband_oversampling());
update_tuning_frequency();
radio::set_baseband_decimation_by(baseband_oversampling());
baseband::start(baseband_configuration);
}
+1 -1
View File
@@ -25,7 +25,7 @@
#include <cstdint>
#include <cstddef>
#include "clock_manager.hpp"
#include "receiver_model.hpp"
#include "message.hpp"
#include "rf_path.hpp"
#include "max2837.hpp"
+12 -47
View File
@@ -25,9 +25,11 @@
#include "demofont.hpp"
#include "ymdata.hpp"
#include "cpld_update.hpp"
#include "portapack.hpp"
#include "audio.hpp"
#include "event_m0.hpp"
#include "baseband_api.hpp"
#include "ui_about.hpp"
#include "touch.hpp"
@@ -46,42 +48,8 @@ using namespace portapack;
namespace ui {
void AboutView::on_show() {
// Just in case
EventDispatcher::message_map().unregister_handler(Message::ID::DisplayFrameSync);
// "Vertical blank interrupt"
EventDispatcher::message_map().register_handler(Message::ID::DisplayFrameSync,
[this](const Message* const) {
update();
}
);
// Just in case
EventDispatcher::message_map().unregister_handler(Message::ID::FIFOSignal);
// Handle baseband asking to fill up FIFO
EventDispatcher::message_map().register_handler(Message::ID::FIFOSignal,
[this](Message* const p) {
FIFODataMessage datamessage;
const auto message = static_cast<const FIFOSignalMessage*>(p);
if (message->signaltype == 1) {
//debug_cnt++;
//if (debug_cnt == 250) for(;;) {}
render_audio();
datamessage.data = ym_buffer;
shared_memory.baseband_queue.push(datamessage);
}
}
);
transmitter_model.set_tuning_frequency(92200000); // 92.2MHz, change !
transmitter_model.set_baseband_configuration({
.mode = 0,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
transmitter_model.set_rf_amp(true);
transmitter_model.enable();
about_radio_config.tuning_frequency = 92200000; // 92.2MHz, change !
radio::enable(about_radio_config);
//audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max);
}
@@ -384,22 +352,20 @@ AboutView::AboutView(
{
uint8_t p, c;
/*
transmitter_model.set_baseband_configuration({
.mode = 0,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
*/
add_children({ {
&text_title,
&text_firmware,
&text_cpld_hackrf,
&text_cpld_portapack,
&text_cpld_hackrf_status,
&button_ok,
} });
if( cpld_hackrf_verify_eeprom() ) {
text_cpld_hackrf_status.set(" OK");
} else {
text_cpld_hackrf_status.set("BAD");
}
// Politely ask for about 26kB
framebuffer = (ui::Color *)chHeapAlloc(0x0, 180 * 72 * sizeof(ui::Color));
@@ -422,14 +388,13 @@ AboutView::AboutView(
ym_init();
button_ok.on_select = [this,&nav](Button&){
EventDispatcher::message_map().unregister_handler(Message::ID::DisplayFrameSync);
if (framebuffer) chHeapFree(framebuffer); // Do NOT forget this
nav.pop();
};
}
AboutView::~AboutView() {
transmitter_model.disable();
radio::disable();
}
void AboutView::focus() {
+41 -7
View File
@@ -48,6 +48,17 @@ private:
void draw_demoglyph(ui::Point p, char ch, ui::Color * pal);
uint16_t debug_cnt = 0;
radio::Configuration about_radio_config = {
0,
1536000, // ?
2500000, // ?
rf::Direction::Transmit,
true,
0,
0,
1,
};
typedef struct ymreg_t {
uint8_t value;
uint8_t cnt;
@@ -127,24 +138,47 @@ private:
};
Text text_firmware {
{ 0, 224, 240, 16 },
"Git Commit hash " GIT_REVISION,
{ 0, 128, 240, 16 },
"Git Commit Hash " GIT_REVISION,
};
Text text_cpld_hackrf {
{ 0, 240, 240, 16 },
"HackRF CPLD CRC 0x????????",
{ 0, 144, 11*8, 16 },
"HackRF CPLD",
};
Text text_cpld_portapack {
{ 0, 256, 240, 16 },
"PortaPack CPLD CRC 0x????????",
Text text_cpld_hackrf_status {
{ 240 - 3*8, 144, 3*8, 16 },
"???"
};
Button button_ok {
{ 72, 272, 96, 24 },
"OK"
};
MessageHandlerRegistration message_handler_update {
Message::ID::DisplayFrameSync,
[this](const Message* const) {
this->update();
}
};
MessageHandlerRegistration message_handler_fifo_signal {
Message::ID::FIFOSignal,
[this](const Message* const p) {
FIFODataMessage datamessage;
const auto message = static_cast<const FIFOSignalMessage*>(p);
if (message->signaltype == 1) {
//debug_cnt++;
//if (debug_cnt == 250) for(;;) {}
this->render_audio();
datamessage.data = ym_buffer;
EventDispatcher::send_message(datamessage);
}
}
};
};
} /* namespace ui */
+1 -2
View File
@@ -54,7 +54,6 @@ void AFSKSetupView::updfreq(rf::Frequency f) {
char finalstr[9] = {0};
portapack::persistent_memory::set_tuned_frequency(f);
transmitter_model.set_tuning_frequency(f);
auto mhz = to_string_dec_int(f / 1000000, 3);
auto hz100 = to_string_dec_int((f / 100) % 10000, 4, '0');
@@ -106,7 +105,7 @@ AFSKSetupView::AFSKSetupView(
field_repeat.set_value(rpt);
button_setfreq.on_select = [this,&nav](Button&){
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.tuning_frequency());
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::tuned_frequency());
new_view->on_changed = [this](rf::Frequency f) {
updfreq(f);
};
-1
View File
@@ -30,7 +30,6 @@
#include "rf_path.hpp"
#include "max2837.hpp"
#include "volume.hpp"
#include "transmitter_model.hpp"
namespace ui {
+4 -24
View File
@@ -159,7 +159,7 @@ void CloseCallView::on_channel_spectrum(const ChannelSpectrum& spectrum) {
uint8_t threshold;
size_t i, m;
baseband::spectrum_streaming_stop;
baseband::spectrum_streaming_stop();
// Spectrum line (for debug)
std::array<Color, 240> pixel_row;
@@ -228,35 +228,15 @@ void CloseCallView::on_channel_spectrum(const ChannelSpectrum& spectrum) {
do_detection();
}
baseband::spectrum_streaming_start(1);
baseband::spectrum_streaming_start();
}
void CloseCallView::on_show() {
EventDispatcher::message_map().register_handler(Message::ID::ChannelSpectrumConfig,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const ChannelSpectrumConfigMessage*>(p);
this->fifo = message.fifo;
}
);
EventDispatcher::message_map().register_handler(Message::ID::DisplayFrameSync,
[this](const Message* const) {
if( this->fifo ) {
ChannelSpectrum channel_spectrum;
while( fifo->out(channel_spectrum) ) {
this->on_channel_spectrum(channel_spectrum);
}
}
}
);
baseband::spectrum_streaming_start(1);
baseband::spectrum_streaming_start();
}
void CloseCallView::on_hide() {
baseband::spectrum_streaming_stop();
EventDispatcher::message_map().unregister_handler(Message::ID::DisplayFrameSync);
EventDispatcher::message_map().unregister_handler(Message::ID::ChannelSpectrumConfig);
}
void CloseCallView::on_range_changed() {
@@ -455,7 +435,7 @@ CloseCallView::CloseCallView(
.decimation_factor = 1,
});
receiver_model.set_baseband_bandwidth(CC_SLICE_WIDTH);
receiver_model.enable();
//receiver_model.enable();
}
} /* namespace ui */
+19
View File
@@ -166,6 +166,25 @@ private:
{ 92, 264, 56, 32 },
"Exit"
};
MessageHandlerRegistration message_handler_spectrum_config {
Message::ID::ChannelSpectrumConfig,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const ChannelSpectrumConfigMessage*>(p);
this->fifo = message.fifo;
}
};
MessageHandlerRegistration message_handler_frame_sync {
Message::ID::DisplayFrameSync,
[this](const Message* const) {
if( this->fifo ) {
ChannelSpectrum channel_spectrum;
while( fifo->out(channel_spectrum) ) {
this->on_channel_spectrum(channel_spectrum);
}
}
}
};
};
} /* namespace ui */
-11
View File
@@ -376,20 +376,9 @@ void HandWriteView::sample_pen() {
}
void HandWriteView::on_show() {
// Use screen refresh rate as sampling frequency
EventDispatcher::message_map().unregister_handler(Message::ID::DisplayFrameSync);
EventDispatcher::message_map().register_handler(Message::ID::DisplayFrameSync,
[this](const Message* const) {
sample_pen();
}
);
clear_zone(Color::black(), false);
}
void HandWriteView::on_hide() {
EventDispatcher::message_map().unregister_handler(Message::ID::DisplayFrameSync);
}
char * HandWriteView::value() {
return txtinput;
}
+7 -1
View File
@@ -41,7 +41,6 @@ public:
void paint(Painter& painter) override;
void on_show() override;
void on_hide() override;
bool on_touch(const TouchEvent event) override;
char * value();
@@ -89,6 +88,13 @@ private:
void on_button(Button& button);
void update_text();
MessageHandlerRegistration message_handler_sample {
Message::ID::DisplayFrameSync,
[this](const Message* const) {
this->sample_pen();
}
};
};
} /* namespace ui */
+23 -30
View File
@@ -24,7 +24,7 @@
#include "ch.h"
#include "evtimer.h"
#include "baseband_api.hpp"
#include "ff.h"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
@@ -48,11 +48,8 @@ void JammerView::focus() {
}
JammerView::~JammerView() {
transmitter_model.disable();
}
void JammerView::paint(Painter& painter) {
(void)painter;
radio::disable();
baseband::shutdown();
}
void JammerView::updfreq(uint8_t id, rf::Frequency f) {
@@ -147,10 +144,14 @@ void JammerView::updfreq(uint8_t id, rf::Frequency f) {
}
}
JammerView::JammerView(
NavigationView& nav
)
{
void JammerView::on_retune(const int64_t freq) {
if (freq > 0) {
radio::set_tuning_frequency(freq);
}
}
JammerView::JammerView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_jammer);
static constexpr Style style_val {
.font = font::fixed_8x16,
@@ -170,12 +171,6 @@ JammerView::JammerView(
.foreground = Color::grey(),
};
transmitter_model.set_baseband_configuration({
.mode = 6,
.sampling_rate = 1536000, // ?
.decimation_factor = 1,
});
add_children({ {
&text_type,
&options_modulation,
@@ -237,16 +232,6 @@ JammerView::JammerView(
button_transmit.on_select = [this](Button&) {
uint8_t i = 0;
rf::Frequency t, range_lower;
EventDispatcher::message_map().unregister_handler(Message::ID::Retune);
EventDispatcher::message_map().register_handler(Message::ID::Retune,
[this](Message* const p) {
const auto message = static_cast<const RetuneMessage*>(p);
if (message->freq > 0) {
transmitter_model.set_tuning_frequency(message->freq);
}
}
);
for (i = 0; i < 16; i++) {
shared_memory.jammer_ranges[i].active = false;
@@ -327,18 +312,16 @@ JammerView::JammerView(
}
// }
transmitter_model.set_tuning_frequency(shared_memory.jammer_ranges[0].center);
if (jamming == true) {
jamming = false;
button_transmit.set_style(&style_val);
button_transmit.set_text("START");
transmitter_model.disable();
radio::disable();
} else {
jamming = true;
button_transmit.set_style(&style_cancel);
button_transmit.set_text("STOP");
transmitter_model.enable();
radio::disable();
}
};
@@ -346,6 +329,16 @@ JammerView::JammerView(
nav.pop();
};
radio::enable({
shared_memory.jammer_ranges[0].center,
1536000, // ?
2500000, // ?
rf::Direction::Transmit,
true,
static_cast<int8_t>(receiver_model.lna()),
static_cast<int8_t>(receiver_model.vga()),
1,
});
}
} /* namespace ui */
+12 -2
View File
@@ -30,7 +30,6 @@
#include "rf_path.hpp"
#include "max2837.hpp"
#include "volume.hpp"
#include "transmitter_model.hpp"
namespace ui {
@@ -41,9 +40,12 @@ public:
void updfreq(uint8_t id, rf::Frequency f);
void focus() override;
void paint(Painter& painter) override;
std::string title() const override { return "Jammer"; };
private:
void on_retune(const int64_t freq);
rf::Frequency range1_min;
rf::Frequency range1_max;
rf::Frequency range2_min;
@@ -253,6 +255,14 @@ private:
{ 21 * 8, 16 * 16, 64, 32 },
"Exit"
};
MessageHandlerRegistration message_handler_retune {
Message::ID::Retune,
[this](Message* const p) {
const auto message = static_cast<const RetuneMessage*>(p);
this->on_retune(message->freq);
}
};
};
} /* namespace ui */
+69 -80
View File
@@ -28,6 +28,7 @@
#include "ch.h"
#include "ff.h"
#include "baseband_api.hpp"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "event_m0.hpp"
@@ -51,7 +52,7 @@ void LCRView::focus() {
}
LCRView::~LCRView() {
transmitter_model.disable();
radio::disable();
}
void LCRView::make_frame() {
@@ -216,6 +217,69 @@ void LCRView::paint(Painter& painter) {
text_recap.set(finalstr);
}
void LCRView::on_txdone(int n) {
char str[16];
if (abort_scan) {
text_status.set(" ");
strcpy(str, "Abort @");
strcat(str, rgsb);
text_status.set(str);
progress.set_value(0);
radio::disable();
txing = false;
scanning = false;
abort_scan = false;
button_scan.set_style(&style_val);
button_scan.set_text("SCAN");
return;
}
if (n > 0) {
if (scanning) {
scan_progress += 0.555f;
progress.set_value(scan_progress);
} else {
text_status.set(" ");
strcpy(str, to_string_dec_int(6 - n).c_str());
strcat(str, "/5");
text_status.set(str);
progress.set_value((6 - n) * 20);
}
} else {
if (scanning && (scan_index < 36)) {
radio::disable();
// Next address
strcpy(rgsb, RGSB_list[scan_index]);
make_frame();
memset(shared_memory.radio_data, 0, 256);
memcpy(shared_memory.radio_data, lcrframe_f, 256);
shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = 5;
text_status.set(" ");
strcpy(str, to_string_dec_int(scan_index).c_str());
strcat(str, "/36");
text_status.set(str);
scan_progress += 0.694f;
progress.set_value(scan_progress);
scan_index++;
radio::disable();
} else {
text_status.set("Ready ");
progress.set_value(0);
radio::disable();
txing = false;
scanning = false;
button_scan.set_style(&style_val);
button_scan.set_text("SCAN");
}
}
}
void LCRView::start_tx() {
char str[16];
@@ -226,7 +290,7 @@ void LCRView::start_tx() {
make_frame();
transmitter_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
lcr_radio_config.tuning_frequency = portapack::persistent_memory::tuned_frequency();
shared_memory.afsk_samples_per_bit = 228000 / portapack::persistent_memory::afsk_bitrate();
shared_memory.afsk_phase_inc_mark = portapack::persistent_memory::afsk_mark_freq() * (0x40000 * 256) / 2280;
@@ -244,74 +308,6 @@ void LCRView::start_tx() {
shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = 5; //(portapack::persistent_memory::afsk_config() >> 8) & 0xFF;
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this](Message* const p) {
char str[16];
if (abort_scan) {
text_status.set(" ");
strcpy(str, "Abort @");
strcat(str, rgsb);
text_status.set(str);
progress.set_value(0);
transmitter_model.disable();
txing = false;
scanning = false;
abort_scan = false;
button_scan.set_style(&style_val);
button_scan.set_text("SCAN");
return;
}
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n > 0) {
if (scanning) {
scan_progress += 0.555f;
progress.set_value(scan_progress);
} else {
text_status.set(" ");
strcpy(str, to_string_dec_int(6 - message->n).c_str());
strcat(str, "/5");
text_status.set(str);
progress.set_value((6 - message->n) * 20);
}
} else {
if (scanning && (scan_index < 36)) {
transmitter_model.disable();
// Next address
strcpy(rgsb, RGSB_list[scan_index]);
make_frame();
memset(shared_memory.radio_data, 0, 256);
memcpy(shared_memory.radio_data, lcrframe_f, 256);
shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = 5;
text_status.set(" ");
strcpy(str, to_string_dec_int(scan_index).c_str());
strcat(str, "/36");
text_status.set(str);
scan_progress += 0.694f;
progress.set_value(scan_progress);
scan_index++;
transmitter_model.enable();
} else {
text_status.set("Ready ");
progress.set_value(0);
transmitter_model.disable();
txing = false;
scanning = false;
button_scan.set_style(&style_val);
button_scan.set_text("SCAN");
}
}
}
);
if (scanning) {
text_status.set(" ");
@@ -327,18 +323,11 @@ void LCRView::start_tx() {
}
txing = true;
transmitter_model.enable();
radio::enable(lcr_radio_config);
}
LCRView::LCRView(
NavigationView& nav
)
{
transmitter_model.set_baseband_configuration({
.mode = 3,
.sampling_rate = 2280000,
.decimation_factor = 1,
});
LCRView::LCRView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_lcr);
memset(litteral, 0, 5 * 8);
memset(rgsb, 0, 5);
+25 -5
View File
@@ -73,6 +73,18 @@ private:
void make_frame();
void start_tx();
void on_txdone(int n);
radio::Configuration lcr_radio_config = {
0,
2280000, // ?
2500000, // ?
rf::Direction::Transmit,
true,
0,
0,
1,
};
// 2: 94 ?
// 9: 85 ?
@@ -113,12 +125,12 @@ private:
};
OptionsField options_ec {
{ 20 * 8, 1 * 16 },
4,
{ 19 * 8, 6 },
7,
{
{ "Auto", 0 },
{ "Jour", 1 },
{ "Nuit", 2 }
{ "EC:Auto", 0 },
{ "EC:Jour", 1 },
{ "EC:Nuit", 2 }
}
};
@@ -206,6 +218,14 @@ private:
{ 160, 270, 64, 32 },
"CLEAR"
};
MessageHandlerRegistration message_handler_tx_done {
Message::ID::TXDone,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXDoneMessage*>(p);
this->on_txdone(message.n);
}
};
};
} /* namespace ui */
+1 -8
View File
@@ -54,11 +54,6 @@ void LoadModuleView::focus() {
button_ok.focus();
}
void LoadModuleView::on_hide() {
EventDispatcher::message_map().unregister_handler(Message::ID::ReadyForSwitch);
EventDispatcher::message_map().unregister_handler(Message::ID::ModuleID);
}
void LoadModuleView::on_show() {
char md5_signature[16];
uint8_t c;
@@ -129,9 +124,7 @@ int LoadModuleView::load_image() {
}
void LoadModuleView::loadmodule() {
//message_map.unregister_handler(Message::ID::ReadyForSwitch);
m4_switch(_hash);
//baseband::shutdown();
/*EventDispatcher::message_map().register_handler(Message::ID::ReadyForSwitch,
[this](Message* const p) {
-1
View File
@@ -49,7 +49,6 @@ public:
void loadmodule();
void on_show() override;
void on_hide() override;
void focus() override;
private:
+17 -7
View File
@@ -20,7 +20,7 @@
*/
#include "ui_navigation.hpp"
#include "ui_loadmodule.hpp"
//#include "ui_loadmodule.hpp"
#include "modules.h"
@@ -38,6 +38,16 @@
#include "ui_closecall.hpp" // DEBUG
#include "ui_freqman.hpp" // DEBUG
#include "ui_setup.hpp"
#include "ui_debug.hpp"
#include "ui_rds.hpp"
#include "ui_xylos.hpp"
#include "ui_epar.hpp"
#include "ui_lcr.hpp"
#include "analog_audio_app.hpp"
#include "ui_audiotx.hpp"
#include "ui_jammer.hpp"
#include "analog_audio_app.hpp"
#include "ais_app.hpp"
#include "ert_app.hpp"
@@ -230,16 +240,16 @@ ReceiverMenuView::ReceiverMenuView(NavigationView& nav) {
SystemMenuView::SystemMenuView(NavigationView& nav) {
add_items<12>({ {
{ "Play dead", ui::Color::red(), [&nav](){ nav.push<PlayDeadView>(false); } },
{ "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); } },
{ "Pokemon GO Away TX", ui::Color::blue(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, Jammer); } },
{ "Receiver RX", ui::Color::cyan(), [&nav](){ nav.push<ReceiverMenuView>(); } },
{ "Close Call RX", ui::Color::cyan(), [&nav](){ nav.push<CloseCallView>(); } },
{ "Pokemon GO Away TX", ui::Color::blue(), [&nav](){ nav.push<JammerView>(); } },
//{ "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); } },
{ "Frequency manager", ui::Color::white(), [&nav](){ nav.push<FreqManView>(); } },
//{ "EPAR TX", ui::Color::green(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, EPAR); } },
{ "Xylos TX", ui::Color::green(), [&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); } },
{ "Xylos TX", ui::Color::green(), [&nav](){ nav.push<XylosView>(); } },
{ "TEDI/LCR TX", ui::Color::orange(), [&nav](){ nav.push<LCRView>(); } },
{ "RDS TX", ui::Color::yellow(), [&nav](){ nav.push<RDSView>(); } },
//{ "Capture", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
//{ "Analyze", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
{ "Setup", ui::Color::white(), [&nav](){ nav.push<SetupMenuView>(); } },
+13 -18
View File
@@ -27,6 +27,7 @@
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
#include "baseband_api.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
@@ -42,7 +43,8 @@ void RDSView::focus() {
}
RDSView::~RDSView() {
transmitter_model.disable();
radio::disable();
baseband::shutdown();
}
std::string to_string_bin(const uint32_t n, const uint8_t l) {
@@ -213,15 +215,8 @@ void RDSView::paint(Painter& painter) {
text_radiotextb.set(&RadioText[16]);
}
RDSView::RDSView(
NavigationView& nav
)
{
transmitter_model.set_baseband_configuration({
.mode = 5,
.sampling_rate = 2280000,
.decimation_factor = 1,
});
RDSView::RDSView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_rds);
strcpy(PSN, "TEST1234");
strcpy(RadioText, "Radiotext test !");
@@ -242,10 +237,10 @@ RDSView::RDSView(
&button_exit
} });
field_frequency.set_value(transmitter_model.tuning_frequency());
rds_radio_config.tuning_frequency = tuning_frequency;
field_frequency.set_step(100000);
field_frequency.on_edit = [this, &nav]() {
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.tuning_frequency());
auto new_view = nav.push<FrequencyKeypadView>(tuning_frequency);
new_view->on_changed = [this](rf::Frequency f) {
this->field_frequency.set_value(f);
};
@@ -260,16 +255,16 @@ RDSView::RDSView(
};
button_txpsn.on_select = [this](Button&){
if (txing) {
transmitter_model.disable();
radio::disable();
button_txpsn.set_text("PSN");
button_txradiotext.set_text("Radiotext");
txing = false;
} else {
gen_PSN(PSN);
transmitter_model.set_tuning_frequency(field_frequency.value());
rds_radio_config.tuning_frequency = tuning_frequency;
button_txpsn.set_text("STOP");
txing = true;
transmitter_model.enable();
radio::disable();
}
};
@@ -278,16 +273,16 @@ RDSView::RDSView(
};
button_txradiotext.on_select = [this](Button&){
if (txing) {
transmitter_model.disable();
radio::disable();
button_txpsn.set_text("PSN");
button_txradiotext.set_text("Radiotext");
txing = false;
} else {
gen_RadioText(RadioText);
transmitter_model.set_tuning_frequency(field_frequency.value());
rds_radio_config.tuning_frequency = tuning_frequency;
button_txradiotext.set_text("STOP");
txing = true;
transmitter_model.enable();
radio::enable(rds_radio_config);
}
};
+12
View File
@@ -54,6 +54,7 @@ private:
char PSN[9];
char RadioText[25];
bool txing = false;
int64_t tuning_frequency = 92200000; // TODO: CHANGE !
uint8_t b2b(const bool in);
@@ -64,6 +65,17 @@ private:
const bool MS, const bool DI, const uint8_t C, const char * chars);
void make_2A_group(uint32_t group[], const uint16_t PI_code, const bool TP, const uint8_t PTY, const bool AB,
const bool segment, const char * chars);
radio::Configuration rds_radio_config = {
0,
2280000, // ?
2500000, // ?
rf::Direction::Transmit,
true,
0,
0,
1,
};
FrequencyField field_frequency {
{ 1 * 8, 1 * 16 },
+5 -24
View File
@@ -27,8 +27,11 @@ using namespace lpc43xx;
#include "portapack.hpp"
using portapack::receiver_model;
using namespace portapack;
#include "cpld_update.hpp"
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
#include "ui_font_fixed_8x16.hpp"
namespace ui {
@@ -169,28 +172,6 @@ void AntennaBiasSetupView::focus() {
button_done.focus();
}
AboutView::AboutView(NavigationView& nav) {
add_children({ {
&text_title,
&text_firmware,
&text_cpld_hackrf,
&text_cpld_hackrf_status,
&button_ok,
} });
button_ok.on_select = [&nav](Button&){ nav.pop(); };
if( cpld_hackrf_verify_eeprom() ) {
text_cpld_hackrf_status.set(" OK");
} else {
text_cpld_hackrf_status.set("BAD");
}
}
void AboutView::focus() {
button_ok.focus();
}
void SetTouchCalibView::focus() {
button_ok.focus();
}
@@ -464,7 +445,7 @@ SetupMenuView::SetupMenuView(NavigationView& nav) {
{ "Date/Time", ui::Color::white(), [&nav](){ nav.push<SetDateTimeView>(); } },
{ "Frequency correction", ui::Color::white(), [&nav](){ nav.push<SetFrequencyCorrectionView>(); } },
{ "Antenna Bias Voltage", ui::Color::white(), [&nav](){ nav.push<AntennaBiasSetupView>(); } },
{ "Touch screen", ui::Color::white(), [&nav](){ nav.push<SetTouchCalibView>(); } },
{ "Touch screen", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
{ "Play dead", ui::Color::red(), [&nav](){ nav.push<SetPlayDeadView>(); } }
} });
on_left = [&nav](){ nav.pop(); };
+1 -33
View File
@@ -25,6 +25,7 @@
#include "ui_widget.hpp"
#include "ui_menu.hpp"
#include "ui_navigation.hpp"
#include "ff.h"
#include <cstdint>
@@ -246,39 +247,6 @@ private:
};
};
class AboutView : public View {
public:
AboutView(NavigationView& nav);
void focus() override;
private:
Text text_title {
{ 100, 96, 40, 16 },
"About",
};
Text text_firmware {
{ 0, 128, 240, 16 },
"Git Commit Hash " GIT_REVISION,
};
Text text_cpld_hackrf {
{ 0, 144, 11*8, 16 },
"HackRF CPLD",
};
Text text_cpld_hackrf_status {
{ 240 - 3*8, 144, 3*8, 16 },
"???"
};
Button button_ok {
{ 72, 192, 96, 24 },
"OK"
};
};
class SetUIView : public View {
public:
SetUIView(NavigationView& nav);
+99 -110
View File
@@ -32,6 +32,7 @@
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
#include "baseband_api.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
@@ -117,11 +118,8 @@ void XylosView::focus() {
}
XylosView::~XylosView() {
transmitter_model.disable();
}
void XylosView::paint(Painter& painter) {
(void)painter;
receiver_model.disable();
baseband::shutdown();
}
void XylosView::upd_message() {
@@ -187,23 +185,98 @@ void XylosView::upd_message() {
void XylosView::start_tx() {
upd_message();
audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max);
shared_memory.transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
transmitter_model.enable();
}
XylosView::XylosView(
NavigationView& nav
)
{
int c;
//audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max);
transmitter_model.set_baseband_configuration({
.mode = 2,
.sampling_rate = 1536000,
.mode = 0,
.sampling_rate = 1536000U,
.decimation_factor = 1,
});
transmitter_model.set_rf_amp(true);
transmitter_model.set_baseband_bandwidth(1750000);
transmitter_model.enable();
baseband::set_xylos_data(ccirmessage);
}
void XylosView::on_txdone(const int n) {
int c, sr;
if (testing == true) {
if (n == 25) {
transmitter_model.disable();
if (sequence_idx != 9) {
chThdSleepMilliseconds(15000);
memcpy(ccirmessage, &xylos_sequence[sequence_idx][0], 21);
// ASCII to frequency LUT index
for (c=0; c<20; c++) {
if (ccirmessage[c] > '9')
ccirmessage[c] -= 0x37;
else
ccirmessage[c] -= 0x30;
}
ccirmessage[20] = 0xFF;
//memcpy(shared_memory.xylosdata, ccirmessage, 21); TODO !!!
sequence_idx++;
txing = true;
transmitter_model.enable();
} else {
button_txtest.set_style(&style());
button_txtest.set_text("TEST");
testing = false;
}
}
} else {
if (n == 25) {
audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max);
transmitter_model.disable();
progress.set_value(0);
if (inc_cnt) {
chThdSleepMilliseconds(1000);
header_code_b.set_value(header_code_b.value() + 1);
upd_message();
start_tx();
inc_cnt--;
} else {
header_code_b.set_value(header_init);
if (checkbox_cligno.value() == false) {
txing = false;
button_transmit.set_style(&style_val);
button_transmit.set_text("START");
} else {
if (checkbox_hinc.value())
inc_cnt = 3;
else
inc_cnt = 0;
chThdSleepMilliseconds(tempo_cligno.value() * 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);
sr = options_rd.selected_index();
if (sr > 0) options_rd.set_selected_index(sr ^ 3);
upd_message();
start_tx();
}
}
} else {
progress.set_value((n + 1) * 5);
}
}
}
XylosView::XylosView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_xylos);
add_children({ {
&checkbox_hinc,
@@ -366,38 +439,6 @@ XylosView::XylosView(
if (txing == false) {
sequence_idx = 0;
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this](Message* const p) {
int c;
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n == 25) {
transmitter_model.disable();
if (sequence_idx != 9) {
chThdSleepMilliseconds(15000);
memcpy(ccirmessage, &xylos_sequence[sequence_idx][0], 21);
// ASCII to frequency LUT index
for (c=0; c<20; c++) {
if (ccirmessage[c] > '9')
ccirmessage[c] -= 0x37;
else
ccirmessage[c] -= 0x30;
}
ccirmessage[20] = 0xFF;
shared_memory.transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
sequence_idx++;
txing = true;
transmitter_model.enable();
} else {
button_txtest.set_style(&style());
button_txtest.set_text("TEST");
}
}
}
);
memcpy(ccirmessage, &xylos_sequence[sequence_idx][0], 21);
// ASCII to frequency LUT index
@@ -408,14 +449,14 @@ XylosView::XylosView(
ccirmessage[c] -= 0x30;
}
ccirmessage[20] = 0xFF;
shared_memory.transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
//memcpy(shared_memory.xylosdata, ccirmessage, 21); TODO !!!
sequence_idx++;
transmitter_model.set_tuning_frequency(xylos_freqs[options_freq.selected_index()]);
txing = true;
testing = true;
button_txtest.set_style(&style_cancel);
button_txtest.set_text("Wait");
transmitter_model.enable();
@@ -433,70 +474,18 @@ XylosView::XylosView(
inc_cnt = 0;
header_init = header_code_b.value();
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this](Message* const p) {
uint8_t sr;
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n == 25) {
audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max);
transmitter_model.disable();
progress.set_value(0);
if (inc_cnt) {
chThdSleepMilliseconds(1000);
header_code_b.set_value(header_code_b.value() + 1);
upd_message();
start_tx();
inc_cnt--;
} else {
header_code_b.set_value(header_init);
if (checkbox_cligno.value() == false) {
txing = false;
button_transmit.set_style(&style_val);
button_transmit.set_text("START");
} else {
if (checkbox_hinc.value())
inc_cnt = 3;
else
inc_cnt = 0;
chThdSleepMilliseconds(tempo_cligno.value() * 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);
sr = options_rd.selected_index();
if (sr > 0) options_rd.set_selected_index(sr ^ 3);
upd_message();
start_tx();
}
}
} else {
progress.set_value((message->n + 1) * 5);
}
}
);
shared_memory.transmit_done = false;
memcpy(shared_memory.xylosdata, ccirmessage, 21);
//shared_memory.transmit_done = false;
//memcpy(shared_memory.xylosdata, ccirmessage, 21);
transmitter_model.set_tuning_frequency(xylos_freqs[options_freq.selected_index()]);
audio::headphone::set_volume(volume_t::decibel(90 - 99) + audio::headphone::volume_range().max);
txing = true;
testing = false;
button_transmit.set_style(&style_cancel);
button_transmit.set_text("Wait");
transmitter_model.enable();
start_tx();
}
};
}
+10 -1
View File
@@ -148,12 +148,12 @@ public:
std::string title() const override { return "Xylos transmit"; };
void focus() override;
void paint(Painter& painter) override;
private:
int inc_cnt;
int header_init;
bool txing = false;
bool testing = false;
const rf::Frequency xylos_freqs[7] = { 31325000, 31387500, 31437500, 31475000, 31687500, 31975000, 88000000 };
char ccirmessage[21];
@@ -173,6 +173,7 @@ private:
void start_tx();
void upd_message();
void on_txdone(const int n);
const Style style_val {
.font = font::fixed_8x16,
@@ -363,6 +364,14 @@ private:
{ 20 * 8, 16 * 16, 64, 32 },
"TEST"
};
MessageHandlerRegistration message_handler_tx_done {
Message::ID::TXDone,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const TXDoneMessage*>(p);
this->on_txdone(message.n);
}
};
};
} /* namespace ui */