Merge fixing, commit to catch up on recent files

This commit is contained in:
furrtek
2016-02-04 10:27:53 +01:00
parent 44638e504b
commit 6e496e2b26
90 changed files with 2257 additions and 1428 deletions

View File

@@ -148,6 +148,8 @@ CPPSRC = main.cpp \
encoder.cpp \
lcd_ili9341.cpp \
ui.cpp \
ui_alphanum.cpp \
ui_about.cpp \
ui_text.cpp \
ui_widget.cpp \
ui_painter.cpp \
@@ -157,6 +159,9 @@ CPPSRC = main.cpp \
ui_rssi.cpp \
ui_channel.cpp \
ui_audio.cpp \
ui_lcr.cpp \
ui_rds.cpp \
ui_jammer.cpp \
ui_font_fixed_8x16.cpp \
ui_setup.cpp \
ui_debug.cpp \

View File

@@ -19,36 +19,34 @@
* Boston, MA 02110-1301, USA.
*/
#include "irq_ipc.hpp"
#ifndef __FILE_H__
#define __FILE_H__
#include "event.hpp"
#include "ff.h"
#include "ch.h"
#include "hal.h"
#include <cstddef>
#include <string>
#include "lpc43xx_cpp.hpp"
using namespace lpc43xx;
class File {
public:
~File();
void m4txevent_interrupt_enable() {
nvicEnableVector(M4CORE_IRQn, CORTEX_PRIORITY_MASK(LPC43XX_M4TXEVENT_IRQ_PRIORITY));
}
bool open_for_append(const std::string file_path);
bool close();
void m4txevent_interrupt_disable() {
nvicDisableVector(M4CORE_IRQn);
}
bool is_ready();
extern "C" {
bool read(void* const data, const size_t bytes_to_read);
bool write(const void* const data, const size_t bytes_to_write);
CH_IRQ_HANDLER(M4Core_IRQHandler) {
CH_IRQ_PROLOGUE();
bool puts(const std::string string);
chSysLockFromIsr();
events_flag_isr(EVT_MASK_APPLICATION);
chSysUnlockFromIsr();
bool sync();
creg::m4txevent::clear();
private:
const std::string file_path;
FIL f;
};
CH_IRQ_EPILOGUE();
}
}
#endif/*__FILE_H__*/

View File

@@ -106,7 +106,7 @@ void m4_switch(const char * hash) {
// Ask M4 to enter wait loop in RAM
BasebandConfiguration baseband_switch {
.mode = SWITCH,
.mode = 255, // DEBUG
.sampling_rate = 0,
.decimation_factor = 1,
};

View File

@@ -62,7 +62,6 @@
#include "ui_painter.hpp"
#include "ui_navigation.hpp"
#include "irq_ipc.hpp"
#include "irq_lcd_frame.hpp"
#include "irq_controls.hpp"
#include "irq_rtc.hpp"

View File

@@ -75,31 +75,8 @@ uint32_t TransmitterModel::sampling_rate() const {
return baseband_configuration.sampling_rate;
}
void TransmitterModel::set_sampling_rate(uint32_t hz) {
baseband_configuration.sampling_rate = hz;
update_baseband_configuration();
}
mode_type TransmitterModel::modulation() const {
return baseband_configuration.mode;
}
void TransmitterModel::set_modulation(mode_type v) {
baseband_configuration.mode = v;
update_modulation();
}
uint32_t TransmitterModel::baseband_oversampling() const {
// TODO: Rename decimation_factor.
return baseband_configuration.decimation_factor;
}
void TransmitterModel::set_baseband_oversampling(uint32_t v) {
baseband_configuration.decimation_factor = v;
update_baseband_configuration();
}
void TransmitterModel::enable() {
enabled_ = true;
radio::set_direction(rf::Direction::Transmit);
update_tuning_frequency();
update_rf_amp();
@@ -107,23 +84,30 @@ void TransmitterModel::enable() {
update_vga();
update_baseband_bandwidth();
update_baseband_configuration();
radio::streaming_enable();
}
void TransmitterModel::baseband_disable() {
shared_memory.baseband_queue.push_and_wait(
BasebandConfigurationMessage {
.configuration = { },
}
);
}
void TransmitterModel::disable() {
/* TODO: This is a dumb hack to stop baseband from working so hard. */
BasebandConfigurationMessage message {
.configuration = {
.mode = NONE,
.sampling_rate = 0,
.decimation_factor = 1,
}
};
shared_memory.baseband_queue.push(message);
enabled_ = false;
baseband_disable();
// 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;
}
int32_t TransmitterModel::tuning_offset() {
return -(sampling_rate() / 4);
}
@@ -148,8 +132,8 @@ void TransmitterModel::update_vga() {
radio::set_vga_gain(vga_gain_db_);
}
void TransmitterModel::update_modulation() {
update_baseband_configuration();
uint32_t TransmitterModel::modulation() const {
return baseband_configuration.mode;
}
void TransmitterModel::set_baseband_configuration(const BasebandConfiguration config) {
@@ -158,7 +142,12 @@ void TransmitterModel::set_baseband_configuration(const BasebandConfiguration co
}
void TransmitterModel::update_baseband_configuration() {
radio::streaming_disable();
// TODO: Move more low-level radio control stuff to M4. It'll enable tighter
// synchronization for things like wideband (sweeping) spectrum analysis, and
// protocols that need quick RX/TX turn-around.
// Disabling baseband while changing sampling rates seems like a good idea...
baseband_disable();
clock_manager.set_sampling_frequency(sampling_rate() * baseband_oversampling());
update_tuning_frequency();
@@ -166,7 +155,5 @@ void TransmitterModel::update_baseband_configuration() {
BasebandConfigurationMessage message { baseband_configuration };
shared_memory.baseband_queue.push(message);
radio::streaming_enable();
}

View File

@@ -38,7 +38,7 @@ public:
) : clock_manager(clock_manager)
{
}
rf::Frequency tuning_frequency() const;
void set_tuning_frequency(rf::Frequency f);
@@ -55,13 +55,10 @@ public:
void set_vga(int32_t v_db);
uint32_t sampling_rate() const;
void set_sampling_rate(uint32_t hz);
mode_type modulation() const;
void set_modulation(mode_type v);
uint32_t modulation() const;
uint32_t baseband_oversampling() const;
void set_baseband_oversampling(uint32_t v);
void enable();
void disable();
@@ -69,12 +66,14 @@ public:
void set_baseband_configuration(const BasebandConfiguration config);
private:
rf::Frequency frequency_step_ { 25000 };
bool enabled_ { false };
bool rf_amp_ { true };
int32_t lna_gain_db_ { 0 };
uint32_t baseband_bandwidth_ { max2837::filter::bandwidth_minimum };
int32_t vga_gain_db_ { 8 };
BasebandConfiguration baseband_configuration {
.mode = NONE,
.mode = 1,
.sampling_rate = 2280000,
.decimation_factor = 1,
};
@@ -89,6 +88,8 @@ private:
void update_vga();
void update_modulation();
void update_baseband_configuration();
void baseband_disable();
};
#endif/*__TRANSMITTER_MODEL_H__*/

View File

@@ -26,6 +26,7 @@
#include "ymdata.hpp"
#include "portapack.hpp"
#include "event_m0.hpp"
#include "ui_about.hpp"
#include "touch.hpp"
@@ -44,23 +45,21 @@ using namespace portapack;
namespace ui {
void AboutView::on_show() {
auto& message_map = context().message_map();
// Just in case
message_map.unregister_handler(Message::ID::DisplayFrameSync);
EventDispatcher::message_map().unregister_handler(Message::ID::DisplayFrameSync);
// "Vertical blank interrupt"
message_map.register_handler(Message::ID::DisplayFrameSync,
EventDispatcher::message_map().register_handler(Message::ID::DisplayFrameSync,
[this](const Message* const) {
update();
}
);
// Just in case
message_map.unregister_handler(Message::ID::FIFOSignal);
EventDispatcher::message_map().unregister_handler(Message::ID::FIFOSignal);
// Handle baseband asking to fill up FIFO
message_map.register_handler(Message::ID::FIFOSignal,
EventDispatcher::message_map().register_handler(Message::ID::FIFOSignal,
[this](Message* const p) {
FIFODataMessage datamessage;
const auto message = static_cast<const FIFOSignalMessage*>(p);
@@ -349,6 +348,7 @@ void AboutView::update() {
refresh_cnt++;
}
// Slowly increase volume to avoid jumpscare
if (headphone_vol < (70<<2)) {
portapack::audio_codec.set_headphone_volume(volume_t::decibel((headphone_vol/4) - 99) + wolfson::wm8731::headphone_gain_range.max);
headphone_vol++;
@@ -370,14 +370,13 @@ void AboutView::ym_init() {
}
AboutView::AboutView(
NavigationView& nav,
TransmitterModel& transmitter_model
) : transmitter_model(transmitter_model)
NavigationView& nav
)
{
uint8_t p, c;
transmitter_model.set_baseband_configuration({
.mode = PLAY_AUDIO,
.mode = 5,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
@@ -412,8 +411,7 @@ AboutView::AboutView(
ym_init();
button_ok.on_select = [this,&nav](Button&){
auto& message_map = context().message_map();
message_map.unregister_handler(Message::ID::DisplayFrameSync);
EventDispatcher::message_map().unregister_handler(Message::ID::DisplayFrameSync);
if (framebuffer) chHeapFree(framebuffer); // Do NOT forget this
nav.pop();
};

View File

@@ -34,7 +34,7 @@ namespace ui {
class AboutView : public View {
public:
AboutView(NavigationView& nav, TransmitterModel& transmitter_model);
AboutView(NavigationView& nav);
~AboutView();
void on_show() override;
@@ -54,8 +54,6 @@ private:
bool same;
} ymreg_t;
TransmitterModel& transmitter_model;
uint16_t headphone_vol = 5<<2;
ymreg_t ym_regs[14];

View File

@@ -24,19 +24,17 @@
#include "ui_spectrum.hpp"
#include "ui_console.hpp"
#include "event_m0.hpp"
#include "ff.h"
#include "portapack.hpp"
using namespace portapack;
#include "ui_receiver.hpp"
namespace ui {
AFSKRXView::AFSKRXView(
NavigationView& nav,
ReceiverModel& receiver_model
) : receiver_model(receiver_model)
NavigationView& nav
)
{
add_children({ {
&button_done,
@@ -48,7 +46,7 @@ AFSKRXView::AFSKRXView(
};
receiver_model.set_baseband_configuration({
.mode = RX_AFSK,
.mode = 6,
.sampling_rate = 3072000,
.decimation_factor = 4,
});
@@ -60,8 +58,7 @@ AFSKRXView::~AFSKRXView() {
}
void AFSKRXView::on_show() {
auto& message_map = context().message_map();
message_map.register_handler(Message::ID::AFSKData,
EventDispatcher::message_map().register_handler(Message::ID::AFSKData,
[this](Message* const p) {
const auto message = static_cast<const AFSKDataMessage*>(p);
this->on_data_afsk(*message);
@@ -72,8 +69,7 @@ void AFSKRXView::on_show() {
}
void AFSKRXView::on_hide() {
auto& message_map = context().message_map();
message_map.unregister_handler(Message::ID::AFSKData);
EventDispatcher::message_map().unregister_handler(Message::ID::AFSKData);
}
void AFSKRXView::on_data_afsk(const AFSKDataMessage& message) {

View File

@@ -42,7 +42,7 @@ namespace ui {
class AFSKRXView : public View {
public:
AFSKRXView(NavigationView& nav, ReceiverModel& receiver_model);
AFSKRXView(NavigationView& nav);
~AFSKRXView();
void focus() override;
@@ -51,8 +51,6 @@ public:
void on_hide() override;
private:
ReceiverModel& receiver_model;
std::unique_ptr<Widget> widget_content;
Button button_done {

View File

@@ -66,9 +66,8 @@ void AFSKSetupView::updfreq(rf::Frequency f) {
}
AFSKSetupView::AFSKSetupView(
NavigationView& nav,
TransmitterModel& transmitter_model
) : transmitter_model(transmitter_model)
NavigationView& nav
)
{
uint8_t rpt;

View File

@@ -36,15 +36,13 @@ namespace ui {
class AFSKSetupView : public View {
public:
AFSKSetupView(NavigationView& nav, TransmitterModel& transmitter_model);
AFSKSetupView(NavigationView& nav);
void updfreq(rf::Frequency f);
void focus() override;
void paint(Painter& painter) override;
private:
TransmitterModel& transmitter_model;
Text text_title {
{ 40, 32, 160, 16 },
"AFSK modulator setup"

View File

@@ -110,7 +110,7 @@ void AlphanumView::set_uppercase() {
size_t n = 0;
for(auto& button : buttons) {
add_child(&button);
//add_child(&button);
const std::string label {
key_caps[n]
};
@@ -125,7 +125,7 @@ void AlphanumView::set_lowercase() {
size_t n = 0;
for(auto& button : buttons) {
add_child(&button);
//add_child(&button);
const std::string label {
key_caps[n]
};

View File

@@ -245,20 +245,6 @@ void RegistersView::focus() {
button_done.focus();
}
void DebugLCRView::paint(Painter& painter) {
const Point offset = {
static_cast<Coord>(32),
static_cast<Coord>(32)
};
const auto text = to_string_hex(fr, 2);
painter.draw_string(
screen_pos() + offset,
style(),
text
);
}
char hexify(char in) {
if (in > 9) in += 7;
return in + 0x30;
@@ -301,26 +287,26 @@ void DebugLCRView::focus() {
DebugMenuView::DebugMenuView(NavigationView& nav) {
add_items<8>({ {
{ "Memory", [&nav](){ nav.push<DebugMemoryView>(); } },
{ "Radio State", [&nav](){ nav.push<NotImplementedView>(); } },
{ "SD Card", [&nav](){ nav.push<NotImplementedView>(); } },
{ "RFFC5072", [&nav](){ nav.push<RegistersView>(
{ "Memory", ui::Color::white(), [&nav](){ nav.push<DebugMemoryView>(); } },
{ "Radio State", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
{ "SD Card", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
{ "RFFC5072", ui::Color::white(), [&nav](){ nav.push<RegistersView>(
"RFFC5072", RegistersWidgetConfig { 31, 2, 4, 4 },
[](const size_t register_number) { return radio::first_if.read(register_number); }
); } },
{ "MAX2837", [&nav](){ nav.push<RegistersView>(
{ "MAX2837", ui::Color::white(), [&nav](){ nav.push<RegistersView>(
"MAX2837", RegistersWidgetConfig { 32, 2, 3, 4 },
[](const size_t register_number) { return radio::second_if.read(register_number); }
); } },
{ "Si5351C", [&nav](){ nav.push<RegistersView>(
{ "Si5351C", ui::Color::white(), [&nav](){ nav.push<RegistersView>(
"Si5351C", RegistersWidgetConfig { 96, 2, 2, 8 },
[](const size_t register_number) { return portapack::clock_generator.read_register(register_number); }
); } },
{ "WM8731", [&nav](){ nav.push<RegistersView>(
{ "WM8731", ui::Color::white(), [&nav](){ nav.push<RegistersView>(
"WM8731", RegistersWidgetConfig { wolfson::wm8731::reg_count, 1, 3, 4 },
[](const size_t register_number) { return portapack::audio_codec.read(register_number); }
); } },
{ "Temperature", [&nav](){ nav.push<TemperatureView>(); } },
{ "Temperature", ui::Color::white(), [&nav](){ nav.push<TemperatureView>(); } },
} });
on_left = [&nav](){ nav.pop(); };
}

View File

@@ -246,8 +246,6 @@ public:
void focus() override;
void paint(Painter& painter) override;
private:
Text text_lcr1 {
{ 16, 32, 208, 8 },

View File

@@ -29,6 +29,8 @@
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
#include "string_format.hpp"
#include "event_m0.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
@@ -37,7 +39,7 @@
#include <cstring>
#include <stdio.h>
using namespace hackrf::one;
using namespace portapack;
namespace ui {
@@ -146,9 +148,8 @@ void JammerView::updfreq(uint8_t id, rf::Frequency f) {
}
JammerView::JammerView(
NavigationView& nav,
TransmitterModel& transmitter_model
) : transmitter_model(transmitter_model)
NavigationView& nav
)
{
static constexpr Style style_val {
@@ -169,7 +170,11 @@ JammerView::JammerView(
.foreground = Color::grey(),
};
transmitter_model.set_modulation(TX_JAMMER);
transmitter_model.set_baseband_configuration({
.mode = 3,
.sampling_rate = 1536000, // ?
.decimation_factor = 1,
});
add_children({ {
&text_type,
@@ -232,11 +237,9 @@ JammerView::JammerView(
button_transmit.on_select = [this,&transmitter_model](Button&) {
uint8_t i = 0;
rf::Frequency t, range_lower;
auto& message_map = context().message_map();
EventDispatcher::message_map().unregister_handler(Message::ID::Retune);
message_map.unregister_handler(Message::ID::Retune);
message_map.register_handler(Message::ID::Retune,
EventDispatcher::message_map().register_handler(Message::ID::Retune,
[this,&transmitter_model](Message* const p) {
const auto message = static_cast<const RetuneMessage*>(p);
if (message->freq > 0) {

View File

@@ -36,7 +36,7 @@ namespace ui {
class JammerView : public View {
public:
JammerView(NavigationView& nav, TransmitterModel& transmitter_model);
JammerView(NavigationView& nav);
~JammerView();
void updfreq(uint8_t id, rf::Frequency f);
@@ -117,7 +117,6 @@ private:
bool jamming = false;
rf::Frequency f;
TransmitterModel& transmitter_model;
Text text_type {
{ 1 * 8, 1 * 16, 40, 16 },

View File

@@ -31,8 +31,11 @@
#include "ff.h"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "event_m0.hpp"
#include "radio.hpp"
#include "string_format.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
#include "portapack_persistent_memory.hpp"
@@ -40,7 +43,7 @@
#include <cstring>
#include <stdio.h>
using namespace hackrf::one;
using namespace portapack;
namespace ui {
@@ -176,9 +179,8 @@ void LCRView::paint(Painter& painter) {
}
LCRView::LCRView(
NavigationView& nav,
TransmitterModel& transmitter_model
) : transmitter_model(transmitter_model)
NavigationView& nav
)
{
char finalstr[24] = {0};
@@ -188,7 +190,12 @@ LCRView::LCRView(
.foreground = Color::black(),
};
transmitter_model.set_modulation(TX_LCR);
transmitter_model.set_baseband_configuration({
.mode = 1,
.sampling_rate = 1536000, // Is this right ?
.decimation_factor = 1,
});
transmitter_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
memset(litteral, 0, 5*8);
memset(rgsb, 0, 5);
@@ -277,8 +284,6 @@ LCRView::LCRView(
};
button_transmit.on_select = [this,&transmitter_model](Button&){
auto& message_map = context().message_map();
make_frame();
shared_memory.afsk_samples_per_bit = 228000/portapack::persistent_memory::afsk_bitrate();
@@ -293,7 +298,7 @@ LCRView::LCRView(
shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = (portapack::persistent_memory::afsk_config() >> 8) & 0xFF;
message_map.register_handler(Message::ID::TXDone,
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this,&transmitter_model](Message* const p) {
char str[8];
const auto message = static_cast<const TXDoneMessage*>(p);
@@ -319,7 +324,7 @@ LCRView::LCRView(
};
button_txsetup.on_select = [&nav, &transmitter_model](Button&){
nav.push(new AFSKSetupView { nav, transmitter_model });
nav.push(new AFSKSetupView { nav });
};
button_exit.on_select = [&nav](Button&){

View File

@@ -36,7 +36,7 @@ namespace ui {
class LCRView : public View {
public:
LCRView(NavigationView& nav, TransmitterModel& transmitter_model);
LCRView(NavigationView& nav);
~LCRView();
void make_frame();
@@ -63,7 +63,6 @@ private:
char lcrframe[256];
char lcrframe_f[256];
rf::Frequency f;
TransmitterModel& transmitter_model;
Text text_status {
{ 168, 196, 64, 16 },

View File

@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* This file is part of PortaPack.
*
@@ -24,10 +25,12 @@
#include "ch.h"
#include "ff.h"
#include "event_m0.hpp"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "portapack_shared_memory.hpp"
#include "hackrf_hal.hpp"
#include "string_format.hpp"
#include <cstring>
#include <stdio.h>
@@ -45,18 +48,17 @@ void LoadModuleView::paint(Painter& painter) {
}
void LoadModuleView::on_hide() {
auto& message_map = context().message_map();
message_map.unregister_handler(Message::ID::ReadyForSwitch);
EventDispatcher::message_map().unregister_handler(Message::ID::ReadyForSwitch);
EventDispatcher::message_map().unregister_handler(Message::ID::ModuleID);
}
void LoadModuleView::on_show() {
// Ask for MD5 signature and compare
ModuleIDMessage message;
auto& message_map = context().message_map();
//message_map.unregister_handler(Message::ID::ModuleID);
message_map.unregister_handler(Message::ID::ModuleID);
message_map.register_handler(Message::ID::ModuleID,
EventDispatcher::message_map().register_handler(Message::ID::ModuleID,
[this](Message* const p) {
uint8_t c;
const auto message = static_cast<const ModuleIDMessage*>(p);
@@ -78,13 +80,66 @@ void LoadModuleView::on_show() {
shared_memory.baseband_queue.push(message);
}
int LoadModuleView::load_image() {
const char magic[6] = {'P', 'P', 'M', ' ', 0x02, 0x00};
UINT bw;
uint8_t i;
uint32_t cnt;
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
if (f_opendir(&rootdir, "/") == FR_OK) {
for (;;) {
res = f_readdir(&rootdir, &modinfo);
if (res != FR_OK || modinfo.fname[0] == 0) break; // Reached last file, abort
// Only care about files with .bin extension
if ((!(modinfo.fattrib & AM_DIR)) && (modinfo.fname[9] == 'B') && (modinfo.fname[10] == 'I') && (modinfo.fname[11] == 'N')) {
res = f_open(&modfile, modinfo.fname, FA_OPEN_EXISTING | FA_READ);
if (res != FR_OK) return 0;
// Magic bytes and version check
f_read(&modfile, &md5sum, 6, &bw);
for (i = 0; i < 6; i++)
if (md5sum[i] != magic[i]) break;
if (i == 6) {
f_lseek(&modfile, 26);
f_read(&modfile, &md5sum, 16, &bw);
for (i = 0; i < 16; i++)
if (md5sum[i] != _hash[i]) break;
// f_read can't read more than 512 bytes at a time ?
if (i == 16) {
f_lseek(&modfile, 512);
for (cnt = 0; cnt < 64; cnt++) {
if (f_read(&modfile, reinterpret_cast<void*>(portapack::memory::map::m4_code.base() + (cnt * 512)), 512, &bw)) return 0;
}
f_close(&modfile);
f_closedir(&rootdir);
LPC_RGU->RESET_CTRL[0] = (1 << 13);
return 1;
}
}
f_close(&modfile);
}
}
f_closedir(&rootdir);
}
return 0;
}
void LoadModuleView::loadmodule() {
auto& message_map = context().message_map();
message_map.register_handler(Message::ID::ReadyForSwitch,
//message_map.unregister_handler(Message::ID::ReadyForSwitch);
EventDispatcher::message_map().register_handler(Message::ID::ReadyForSwitch,
[this](Message* const p) {
(void)p;
if (m4_load_image()) {
text_info.set("Module loaded :)");
if (load_image()) {
text_info.set(to_string_hex(*((unsigned int*)0x10080000),8));
//text_infob.set(to_string_hex(*((unsigned int*)0x10080004),8));
text_infob.set("Module loaded :)");
_mod_loaded = true;
} else {
text_info.set("Module not found :(");
@@ -104,6 +159,7 @@ LoadModuleView::LoadModuleView(
{
add_children({ {
&text_info,
&text_infob,
&button_ok
} });

View File

@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* This file is part of PortaPack.
*
@@ -31,7 +32,7 @@ namespace ui {
class LoadModuleView : public View {
public:
LoadModuleView(NavigationView& nav, const char * hash, View* new_view);
LoadModuleView(NavigationView& nav, const char * hash, View * new_view);
void loadmodule();
void on_show() override;
@@ -40,12 +41,17 @@ public:
void paint(Painter& painter) override;
private:
int load_image(void);
const char * _hash;
bool _mod_loaded = false;
Text text_info {
{ 8, 64, 224, 16 },
"Searching module..."
"-"
};
Text text_infob {
{ 8, 64+16, 224, 16 },
"-"
};
Button button_ok {

View File

@@ -108,6 +108,10 @@ View* NavigationView::push_view(std::unique_ptr<View> new_view) {
return p;
}
void NavigationView::push(View* v) {
push_view(std::unique_ptr<View>(v));
}
void NavigationView::pop() {
// Can't pop last item from stack.
if( view_stack.size() > 1 ) {
@@ -149,9 +153,9 @@ void NavigationView::focus() {
TranspondersMenuView::TranspondersMenuView(NavigationView& nav) {
add_items<3>({ {
{ "AIS: Boats", [&nav](){ nav.push<AISAppView>(); } },
{ "ERT: Utility Meters", [&nav](){ nav.push<ERTAppView>(); } },
{ "TPMS: Cars", [&nav](){ nav.push<TPMSAppView>(); } },
{ "AIS: Boats", ui::Color::white(), [&nav](){ nav.push<AISAppView>(); } },
{ "ERT: Utility Meters", ui::Color::white(), [&nav](){ nav.push<ERTAppView>(); } },
{ "TPMS: Cars", ui::Color::white(), [&nav](){ nav.push<TPMSAppView>(); } },
} });
}
@@ -159,8 +163,8 @@ TranspondersMenuView::TranspondersMenuView(NavigationView& nav) {
ReceiverMenuView::ReceiverMenuView(NavigationView& nav) {
add_items<2>({ {
{ "Audio", [&nav](){ nav.push<ReceiverView>(); } },
{ "Transponders", [&nav](){ nav.push<TranspondersMenuView>(); } },
{ "Audio", ui::Color::white(), [&nav](){ nav.push<ReceiverView>(); } },
{ "Transponders", ui::Color::white(), [&nav](){ nav.push<TranspondersMenuView>(); } },
} });
}
@@ -168,24 +172,24 @@ ReceiverMenuView::ReceiverMenuView(NavigationView& nav) {
SystemMenuView::SystemMenuView(NavigationView& nav) {
add_items<10>({ {
{ "Play dead", ui::Color::red(), [&nav](){ nav.push(new PlayDeadView { nav, false }); } },
{ "Receiver", ui::Color::cyan(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new ReceiverMenuView { nav, receiver_model }}); } },
{ "Play dead", ui::Color::red(), [&nav](){ nav.push<PlayDeadView>(false); } },
{ "Receiver", ui::Color::cyan(), [&nav](){ nav.push<LoadModuleView>(md5_baseband, new ReceiverMenuView(nav)); } },
//{ "Nordic/BTLE RX", ui::Color::cyan(), [&nav](){ nav.push(new NotImplementedView { nav }); } },
{ "Jammer", ui::Color::white(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new JammerView { nav, transmitter_model }}); } },
{ "Jammer", ui::Color::white(), [&nav](){ nav.push<LoadModuleView>(md5_baseband, new JammerView(nav)); } },
//{ "Audio file TX", ui::Color::white(), [&nav](){ nav.push(new NotImplementedView { nav }); } },
//{ "Encoder TX", ui::Color::green(), [&nav](){ nav.push(new NotImplementedView { nav }); } },
//{ "Whistle", ui::Color::purple(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new WhistleView { nav, transmitter_model }}); } },
//{ "SIGFOX RX", ui::Color::orange(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new SIGFRXView { nav, receiver_model }}); } },
{ "RDS TX", ui::Color::yellow(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new RDSView { nav, transmitter_model }}); } },
{ "Xylos TX", ui::Color::orange(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new XylosView { nav, transmitter_model }}); } },
{ "RDS TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, new RDSView(nav)); } },
{ "Xylos TX", ui::Color::orange(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, new XylosView(nav)); } },
//{ "Xylos RX", ui::Color::green(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new XylosRXView { nav, receiver_model }}); } },
//{ "AFSK RX", ui::Color::cyan(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new AFSKRXView { nav, receiver_model }}); } },
{ "TEDI/LCR TX", ui::Color::yellow(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new LCRView { nav, transmitter_model }}); } },
{ "TEDI/LCR TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, new LCRView(nav)); } },
//{ "Numbers station", ui::Color::purple(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new NumbersStationView { nav, transmitter_model }}); } },
{ "Setup", ui::Color::white(), [&nav](){ nav.push(new SetupMenuView { nav }); } },
{ "About", ui::Color::white(), [&nav](){ nav.push(new AboutView { nav, transmitter_model }); } },
{ "Debug", ui::Color::white(), [&nav](){ nav.push(new DebugMenuView { nav }); } },
{ "HackRF", ui::Color::white(), [&nav](){ nav.push(new HackRFFirmwareView { nav }); } },
{ "Setup", ui::Color::white(), [&nav](){ nav.push<SetupMenuView>(); } },
{ "About", ui::Color::white(), [&nav](){ nav.push<AboutView>(); } },
{ "Debug", ui::Color::white(), [&nav](){ nav.push<DebugMenuView>(); } },
{ "HackRF", ui::Color::white(), [&nav](){ nav.push<HackRFFirmwareView>(); } },
} });
}
@@ -266,6 +270,41 @@ HackRFFirmwareView::HackRFFirmwareView(NavigationView& nav) {
} });
}
/* PlayDeadView **********************************************************/
void PlayDeadView::focus() {
button_done.focus();
}
PlayDeadView::PlayDeadView(NavigationView& nav, bool booting) {
_booting = booting;
persistent_memory::set_playing_dead(0x59);
add_children({ {
&text_playdead1,
&text_playdead2,
&button_done,
} });
button_done.on_dir = [this,&nav](Button&, KeyEvent key){
sequence = (sequence<<3) | static_cast<std::underlying_type<KeyEvent>::type>(key);
};
button_done.on_select = [this,&nav](Button&){
if (sequence == persistent_memory::playdead_sequence()) {
persistent_memory::set_playing_dead(0);
if (_booting) {
nav.pop();
nav.push<SystemMenuView>();
} else {
nav.pop();
}
} else {
sequence = 0;
}
};
}
void HackRFFirmwareView::focus() {
button_no.focus();
}

View File

@@ -82,6 +82,8 @@ public:
T* push(Args&&... args) {
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
}
void push(View* v);
void pop();
@@ -120,6 +122,29 @@ private:
};
};
class PlayDeadView : public View {
public:
PlayDeadView(NavigationView& nav, bool booting);
void focus() override;
private:
bool _booting;
uint32_t sequence = 0;
Text text_playdead1 {
{ 6 * 8, 7 * 16, 14 * 8, 16 },
"Firmware error"
};
Text text_playdead2 {
{ 6 * 8, 9 * 16, 16 * 8, 16 },
"0x1400_0000 : 2C"
};
Button button_done {
{ 240, 0, 1, 1 },
""
};
};
class ReceiverMenuView : public MenuView {
public:
ReceiverMenuView(NavigationView& nav);

View File

@@ -34,7 +34,7 @@
#include <cstring>
using namespace hackrf::one;
using namespace portapack;
namespace ui {
@@ -134,9 +134,8 @@ void RDSView::paint(Painter& painter) {
}
RDSView::RDSView(
NavigationView& nav,
TransmitterModel& transmitter_model
) : transmitter_model(transmitter_model)
NavigationView& nav
)
{
transmitter_model.set_tuning_frequency(93000000);
strcpy(psname, "TEST1234");

View File

@@ -86,7 +86,7 @@ private:
*/
class RDSView : public View {
public:
RDSView(NavigationView& nav, TransmitterModel& transmitter_model);
RDSView(NavigationView& nav);
~RDSView();
void focus() override;
@@ -94,7 +94,6 @@ public:
private:
char psname[9];
TransmitterModel& transmitter_model;
Text text_title {
{ 76, 16, 88, 16 },

View File

@@ -20,13 +20,16 @@
*/
#include "ui_setup.hpp"
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
#include "ui_font_fixed_8x16.hpp"
#include "lpc43xx_cpp.hpp"
using namespace lpc43xx;
#include "portapack.hpp"
using portapack::receiver_model;
using namespace portapack;
namespace ui {
@@ -167,12 +170,6 @@ void AntennaBiasSetupView::focus() {
button_done.focus();
}
void AboutView::focus() {
button_ok.focus();
}
void SetTouchCalibView::focus() {
button_ok.focus();
}
@@ -433,13 +430,13 @@ void ModInfoView::focus() {
SetupMenuView::SetupMenuView(NavigationView& nav) {
add_items<7>({ {
{ "SD card modules", ui::Color::white(), [&nav](){ nav.push(new ModInfoView { nav }); } },
{ "Date/Time", ui::Color::white(), [&nav](){ nav.push(new SetDateTimeView { nav }); } },
{ "SD card modules", ui::Color::white(), [&nav](){ nav.push<ModInfoView>(); } },
{ "Date/Time", ui::Color::white(), [&nav](){ nav.push<SetDateTimeView>(); } },
{ "Frequency correction", ui::Color::white(), [&nav](){ nav.push<SetFrequencyCorrectionView>(); } },
{ "Antenna Bias Voltage", [&nav](){ nav.push<AntennaBiasSetupView>(); } },
{ "Touch screen", ui::Color::white(), [&nav](){ nav.push(new SetTouchCalibView { nav }); } },
{ "Play dead", ui::Color::red(), [&nav](){ nav.push(new SetPlayDeadView { nav }); } },
{ "UI", ui::Color::white(), [&nav](){ nav.push(new SetUIView { nav }); } },
{ "Antenna Bias Voltage", ui::Color::white(), [&nav](){ nav.push<AntennaBiasSetupView>(); } },
{ "Touch screen", ui::Color::white(), [&nav](){ nav.push<SetTouchCalibView>(); } },
{ "Play dead", ui::Color::red(), [&nav](){ nav.push<SetPlayDeadView>(); } },
{ "UI", ui::Color::white(), [&nav](){ nav.push<SetUIView>(); } },
} });
on_left = [&nav](){ nav.pop(); };
}

View File

@@ -25,6 +25,7 @@
#include "ui_widget.hpp"
#include "ui_menu.hpp"
#include "ui_navigation.hpp"
#include "ff.h"
#include <cstdint>
@@ -252,6 +253,132 @@ private:
};
};
class SetUIView : public View {
public:
SetUIView(NavigationView& nav);
void focus() override;
private:
Checkbox checkbox_showsplash {
{ 3 * 8, 2 * 16},
"Show splash"
};
Checkbox checkbox_bloff {
{ 3 * 8, 4 * 16},
"Backlight off after:"
};
OptionsField options_bloff {
{ 10 * 8, 5 * 16 + 4 },
10,
{
{ "5 seconds ", 0 },
{ "15 seconds", 1 },
{ "1 minute ", 2 },
{ "5 minutes ", 3 },
{ "10 minutes", 4 }
}
};
Button button_ok {
{ 4 * 8, 272, 64, 24 },
"Ok"
};
};
class SetPlayDeadView : public View {
public:
SetPlayDeadView(NavigationView& nav);
void focus() override;
private:
bool entermode = false;
uint32_t sequence = 0;
uint8_t keycount, key_code;
char sequence_txt[11];
Text text_sequence {
{ 64, 32, 14 * 8, 16 },
"Enter sequence",
};
Button button_enter {
{ 16, 192, 96, 24 },
"Enter"
};
Button button_cancel {
{ 128, 192, 96, 24 },
"Cancel"
};
};
class ModInfoView : public View {
public:
ModInfoView(NavigationView& nav);
void focus() override;
void on_show() override;
private:
void update_infos(uint8_t modn);
typedef struct moduleinfo_t{
char filename[9];
uint16_t version;
uint32_t size;
char md5[16];
char name[16];
char description[214];
} moduleinfo_t;
moduleinfo_t module_list[8]; // 8 max for now
Text text_modcount {
{ 2 * 8, 1 * 16, 18 * 8, 16 },
"Searching..."
};
OptionsField option_modules {
{ 2 * 8, 2 * 16 },
24,
{ { "-", 0 }
}
};
Text text_name {
{ 2 * 8, 4 * 16, 5 * 8, 16 },
"Name:"
};
Text text_namestr {
{ 8 * 8, 4 * 16, 16 * 8, 16 },
"..."
};
Text text_size {
{ 2 * 8, 5 * 16, 5 * 8, 16 },
"Size:"
};
Text text_sizestr {
{ 8 * 8, 5 * 16, 16 * 8, 16 },
"..."
};
Text text_md5 {
{ 2 * 8, 6 * 16, 4 * 8, 16 },
"MD5:"
};
Text text_md5_a {
{ 7 * 8, 6 * 16, 16 * 8, 16 },
"..."
};
Text text_md5_b {
{ 7 * 8, 7 * 16, 16 * 8, 16 },
"..."
};
Button button_ok {
{ 4 * 8, 272, 64, 24 },
"Ok"
};
};
class SetupMenuView : public MenuView {
public:
SetupMenuView(NavigationView& nav);

View File

@@ -25,11 +25,13 @@
#include "ch.h"
#include "evtimer.h"
#include "event_m0.hpp"
#include "ff.h"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
//#include "fox_bmp.hpp"
#include "string_format.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
@@ -38,7 +40,7 @@
#include <cstring>
#include <stdio.h>
using namespace hackrf::one;
using namespace portapack;
namespace ui {
@@ -98,20 +100,23 @@ void SIGFRXView::on_channel_spectrum(const ChannelSpectrum& spectrum) {
}
void SIGFRXView::on_show() {
context().message_map().register_handler(Message::ID::ChannelSpectrum,
/*EventDispatcher::message_map().register_handler(Message::ID::ChannelSpectrum,
[this](const Message* const p) {
this->on_channel_spectrum(reinterpret_cast<const ChannelSpectrumMessage*>(p)->spectrum);
}
);
);*/
}
void SIGFRXView::on_hide() {
//EventDispatcher::message_map().unregister_handler(Message::ID::ChannelSpectrum);
}
SIGFRXView::SIGFRXView(
NavigationView& nav,
ReceiverModel& receiver_model
) : receiver_model(receiver_model)
NavigationView& nav
)
{
receiver_model.set_baseband_configuration({
.mode = RX_SIGFOX,
.mode = 255, // DEBUG
.sampling_rate = 3072000,
.decimation_factor = 4,
});

View File

@@ -36,17 +36,16 @@ namespace ui {
class SIGFRXView : public View {
public:
SIGFRXView(NavigationView& nav, ReceiverModel& receiver_model);
SIGFRXView(NavigationView& nav);
~SIGFRXView();
void on_channel_spectrum(const ChannelSpectrum& spectrum);
void on_show() override;
void on_hide() override;
void focus() override;
void paint(Painter& painter) override;
private:
ReceiverModel& receiver_model;
private:
uint8_t last_channel;
uint8_t detect_counter = 0;

View File

@@ -25,6 +25,7 @@
#include "ch.h"
#include "hackrf_hal.hpp"
#include "event_m0.hpp"
#include "ui_alphanum.hpp"
#include "ff.h"
#include "hackrf_gpio.hpp"
@@ -38,7 +39,7 @@
#include <cstring>
#include <stdio.h>
using namespace hackrf::one;
using namespace portapack;
namespace ui {
@@ -91,9 +92,8 @@ void XylosRXView::on_show() {
}
XylosRXView::XylosRXView(
NavigationView& nav,
ReceiverModel& receiver_model
) : receiver_model(receiver_model)
NavigationView& nav
)
{
char ccirdebug[21] = { 0,0,0,0,1,8,1,10,10,10,11,1,1,2,0,11,0,0,0,0,0xFF };
@@ -211,9 +211,8 @@ void XylosView::journuit() {
}
XylosView::XylosView(
NavigationView& nav,
TransmitterModel& transmitter_model
) : transmitter_model(transmitter_model)
NavigationView& nav
)
{
static constexpr Style style_val {
.font = font::fixed_8x16,
@@ -228,13 +227,11 @@ XylosView::XylosView(
};
transmitter_model.set_baseband_configuration({
.mode = TX_XYLOS,
.mode = 4,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
transmitter_model.set_modulation(TX_XYLOS); // Useless ?
add_children({ {
&text_title,
&button_txtest,
@@ -323,11 +320,9 @@ XylosView::XylosView(
button_txtest.on_select = [this,&transmitter_model](Button&) {
const uint8_t ccirtest[21] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,13,12,11,0xFF };
if (txing == false) {
auto& message_map = context().message_map();
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
message_map.unregister_handler(Message::ID::TXDone);
message_map.register_handler(Message::ID::TXDone,
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this,&transmitter_model](Message* const p) {
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n == 25) {
@@ -359,11 +354,9 @@ XylosView::XylosView(
if (txing == false) {
upd_message();
auto& message_map = context().message_map();
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
message_map.unregister_handler(Message::ID::TXDone);
message_map.register_handler(Message::ID::TXDone,
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this,&transmitter_model](Message* const p) {
uint8_t c;
char progress[21];

View File

@@ -45,7 +45,7 @@ void do_something();
class XylosRXView : public View {
public:
XylosRXView(NavigationView& nav, ReceiverModel& receiver_model);
XylosRXView(NavigationView& nav);
~XylosRXView();
void talk();
@@ -91,8 +91,6 @@ private:
"trailer.wav"
};
char ccir_received[21];
ReceiverModel& receiver_model;
Text text_title {
{ 1 * 8, 1 * 16, 11, 16 },
@@ -142,7 +140,7 @@ private:
class XylosView : public View {
public:
XylosView(NavigationView& nav, TransmitterModel& transmitter_model);
XylosView(NavigationView& nav);
~XylosView();
void journuit();
@@ -184,8 +182,6 @@ private:
};
char ccirmessage[21];
char ccir_received[21];
TransmitterModel& transmitter_model;
Text text_title {
{ 1 * 8, 1 * 16, 11, 16 },