Fixed module loading (again), only audio tx works for now

This commit is contained in:
furrtek
2016-04-28 14:59:14 +02:00
parent 2fcfdba9ea
commit d55a420dfd
64 changed files with 1400 additions and 879 deletions
+6 -6
View File
@@ -22,7 +22,7 @@
PATH_BOOTSTRAP=bootstrap
PATH_APPLICATION=application
PATH_BASEBAND=baseband
# PATH_BASEBAND_TX=baseband-tx
PATH_BASEBAND_TX=baseband-tx
TARGET=portapack-h1-firmware
@@ -30,7 +30,7 @@ TARGET_BOOTSTRAP=$(PATH_BOOTSTRAP)/bootstrap
TARGET_HACKRF_FIRMWARE=hackrf_one_usb_ram
TARGET_APPLICATION=$(PATH_APPLICATION)/build/application
TARGET_BASEBAND=$(PATH_BASEBAND)/build/baseband
# TARGET_BASEBAND_TX=$(PATH_BASEBAND_TX)/build/baseband-tx
TARGET_BASEBAND_TX=$(PATH_BASEBAND_TX)/build/baseband-tx
MAKE_SPI_IMAGE=tools/make_spi_image.py
MAKE_MODULES_FILE=tools/make_baseband_file.py
@@ -59,13 +59,13 @@ program: $(TARGET).bin modules
sleep 1s
hackrf_spiflash -w $(TARGET).bin
modules: $(TARGET_BASEBAND).bin # $(TARGET_BASEBAND_TX).bin
modules: $(TARGET_BASEBAND).bin $(TARGET_BASEBAND_TX).bin
$(MAKE_MODULES_FILE) $(MODULES)
cp $(PATH_BASEBAND).bin ../sdcard/$(PATH_BASEBAND).bin
# cp $(PATH_BASEBAND_TX).bin ../sdcard/$(PATH_BASEBAND_TX).bin
cp $(PATH_BASEBAND_TX).bin ../sdcard/$(PATH_BASEBAND_TX).bin
$(TARGET).bin: modules $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND).bin $(TARGET_APPLICATION).bin
$(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND).bin $(TARGET_APPLICATION).bin $(TARGET).bin
$(TARGET).bin: modules $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND)_inc.bin $(TARGET_APPLICATION).bin
$(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND)_inc.bin $(TARGET_APPLICATION).bin $(TARGET).bin
$(TARGET_BOOTSTRAP).bin: $(TARGET_BOOTSTRAP).elf
$(CP) -O binary $(TARGET_BOOTSTRAP).elf $(TARGET_BOOTSTRAP).bin
+1
View File
@@ -161,6 +161,7 @@ CPPSRC = main.cpp \
ui_rssi.cpp \
ui_channel.cpp \
ui_audio.cpp \
ui_audiotx.cpp \
ui_lcr.cpp \
ui_rds.cpp \
ui_jammer.cpp \
+53
View File
@@ -28,6 +28,7 @@ using namespace lpc43xx;
#include "message.hpp"
#include "baseband_api.hpp"
#include "portapack_shared_memory.hpp"
#include <cstring>
@@ -63,3 +64,55 @@ 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);
}
+28 -5
View File
@@ -22,7 +22,7 @@
#include "event_m0.hpp"
#include "portapack.hpp"
#include "portapack_shared_memory.hpp"
#include "portapack_persistent_memory.hpp"
#include "sd_card.hpp"
@@ -99,6 +99,7 @@ void EventDispatcher::set_display_sleep(const bool sleep) {
portapack::io.lcd_backlight(false);
portapack::display.sleep();
} else {
portapack::bl_tick_counter = 0;
portapack::display.wake();
portapack::io.lcd_backlight(true);
}
@@ -121,16 +122,16 @@ void EventDispatcher::dispatch(const eventmask_t events) {
if( events & EVT_MASK_SWITCHES ) {
handle_switches();
}
if( events & EVT_MASK_ENCODER ) {
handle_encoder();
}
if( !display_sleep ) {
if( events & EVT_MASK_LCD_FRAME_SYNC ) {
handle_lcd_frame_sync();
}
if( events & EVT_MASK_ENCODER ) {
handle_encoder();
}
if( events & EVT_MASK_TOUCH ) {
handle_touch();
}
@@ -144,9 +145,19 @@ void EventDispatcher::handle_application_queue() {
}
void EventDispatcher::handle_rtc_tick() {
uint16_t bloff;
sd_card::poll_inserted();
portapack::temperature_logger.second_tick();
bloff = portapack::persistent_memory::ui_config_bloff();
if (bloff) {
if (portapack::bl_tick_counter == bloff)
set_display_sleep(true);
else
portapack::bl_tick_counter++;
}
}
ui::Widget* EventDispatcher::touch_widget(ui::Widget* const w, ui::TouchEvent event) {
@@ -156,6 +167,7 @@ ui::Widget* EventDispatcher::touch_widget(ui::Widget* const w, ui::TouchEvent ev
for(const auto child : w->children()) {
const auto touched_widget = touch_widget(child, event);
if( touched_widget ) {
portapack::bl_tick_counter = 0;
return touched_widget;
}
}
@@ -164,6 +176,7 @@ ui::Widget* EventDispatcher::touch_widget(ui::Widget* const w, ui::TouchEvent ev
if( r.contains(event.point) ) {
if( w->on_touch(event) ) {
// This widget responded. Return it up the call stack.
portapack::bl_tick_counter = 0;
return w;
}
}
@@ -200,6 +213,8 @@ void EventDispatcher::handle_lcd_frame_sync() {
void EventDispatcher::handle_switches() {
const auto switches_state = get_switches_state();
portapack::bl_tick_counter = 0;
if( display_sleep ) {
// Swallow event, wake up display.
if( switches_state.any() ) {
@@ -220,6 +235,14 @@ void EventDispatcher::handle_switches() {
}
void EventDispatcher::handle_encoder() {
portapack::bl_tick_counter = 0;
if( display_sleep ) {
// Swallow event, wake up display.
set_display_sleep(false);
return;
}
const uint32_t encoder_now = get_encoder_position();
const int32_t delta = static_cast<int32_t>(encoder_now - encoder_last);
encoder_last = encoder_now;
+9 -16
View File
@@ -21,11 +21,14 @@
#include "transmitter_model.hpp"
#include "portapack_shared_memory.hpp"
#include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp"
#include "portapack.hpp"
using namespace portapack;
#include "radio.hpp"
#include "audio.hpp"
rf::Frequency TransmitterModel::tuning_frequency() const {
return persistent_memory::tuned_frequency();
}
@@ -86,17 +89,9 @@ void TransmitterModel::enable() {
update_baseband_configuration();
}
void TransmitterModel::baseband_disable() {
shared_memory.baseband_queue.push_and_wait(
BasebandConfigurationMessage {
.configuration = { },
}
);
}
void TransmitterModel::disable() {
enabled_ = false;
baseband_disable();
baseband::stop();
// TODO: Responsibility for enabling/disabling the radio is muddy.
// Some happens in ReceiverModel, some inside radio namespace.
@@ -147,13 +142,11 @@ 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_disable();
baseband::stop();
clock_manager.set_sampling_frequency(sampling_rate() * baseband_oversampling());
radio::set_baseband_rate(sampling_rate() * baseband_oversampling());
update_tuning_frequency();
radio::set_baseband_decimation_by(baseband_oversampling());
BasebandConfigurationMessage message { baseband_configuration };
shared_memory.baseband_queue.push(message);
baseband::start(baseband_configuration);
}
+2 -11
View File
@@ -33,11 +33,6 @@
class TransmitterModel {
public:
constexpr TransmitterModel(
)
{
}
rf::Frequency tuning_frequency() const;
void set_tuning_frequency(rf::Frequency f);
@@ -65,18 +60,16 @@ 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 = 1,
.sampling_rate = 2280000,
.mode = 0, /* TODO: Enum! */
.sampling_rate = 3072000,
.decimation_factor = 1,
};
int32_t tuning_offset();
void update_tuning_frequency();
@@ -86,8 +79,6 @@ private:
void update_vga();
void update_modulation();
void update_baseband_configuration();
void baseband_disable();
};
#endif/*__TRANSMITTER_MODEL_H__*/
+14 -4
View File
@@ -65,17 +65,25 @@ void AboutView::on_show() {
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 !
audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max);
transmitter_model.set_baseband_configuration({
.mode = 0,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
transmitter_model.set_rf_amp(true);
transmitter_model.enable();
//audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max);
}
void AboutView::render_video() {
@@ -376,11 +384,13 @@ AboutView::AboutView(
{
uint8_t p, c;
/*
transmitter_model.set_baseband_configuration({
.mode = 5,
.mode = 0,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
*/
add_children({ {
&text_title,
+1
View File
@@ -46,6 +46,7 @@ private:
void render_video();
void render_audio();
void draw_demoglyph(ui::Point p, char ch, ui::Color * pal);
uint16_t debug_cnt = 0;
typedef struct ymreg_t {
uint8_t value;
+1 -2
View File
@@ -104,11 +104,10 @@ AFSKSetupView::AFSKSetupView(
field_repeat.set_value(rpt);
button_setfreq.on_select = [this,&nav](Button&){
auto new_view = new FrequencyKeypadView { nav, transmitter_model.tuning_frequency() };
auto new_view = nav.push<FrequencyKeypadView>(transmitter_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
updfreq(f);
};
nav.push(new_view);
};
if (portapack::persistent_memory::afsk_bitrate() == 1200) {
+95
View File
@@ -0,0 +1,95 @@
/*
* 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_audiotx.hpp"
#include "ch.h"
#include "ui_alphanum.hpp"
#include "ff.h"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
#include "hackrf_hal.hpp"
#include "portapack_shared_memory.hpp"
#include <cstring>
using namespace portapack;
namespace ui {
void AudioTXView::focus() {
button_transmit.focus();
}
void AudioTXView::on_tuning_frequency_changed(rf::Frequency f) {
transmitter_model.set_tuning_frequency(f);
}
AudioTXView::AudioTXView(
NavigationView& nav
)
{
transmitter_model.set_tuning_frequency(92200000);
add_children({ {
&text_title,
&field_frequency,
&button_transmit,
&button_exit
} });
field_frequency.set_value(transmitter_model.tuning_frequency());
field_frequency.set_step(receiver_model.frequency_step());
field_frequency.on_change = [this](rf::Frequency f) {
this->on_tuning_frequency_changed(f);
};
field_frequency.on_edit = [this, &nav]() {
// TODO: Provide separate modal method/scheme?
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.tuning_frequency());
new_view->on_changed = [this](rf::Frequency f) {
this->on_tuning_frequency_changed(f);
this->field_frequency.set_value(f);
};
};
button_transmit.on_select = [](Button&){
transmitter_model.set_baseband_configuration({
.mode = 1,
.sampling_rate = 1536000,
.decimation_factor = 1,
});
transmitter_model.set_rf_amp(true);
transmitter_model.enable();
};
button_exit.on_select = [&nav](Button&){
nav.pop();
};
}
AudioTXView::~AudioTXView() {
transmitter_model.disable();
}
}
@@ -19,39 +19,51 @@
* Boston, MA 02110-1301, USA.
*/
#include "dsp_iir.hpp"
#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 "ui_receiver.hpp"
#include "transmitter_model.hpp"
#include <hal.h>
void IIRBiquadFilter::configure(const iir_biquad_config_t& new_config) {
config = new_config;
}
void IIRBiquadFilter::execute(const buffer_f32_t& buffer_in, const buffer_f32_t& buffer_out) {
const auto a_ = config.a;
const auto b_ = config.b;
namespace ui {
auto x_ = x;
auto y_ = y;
class AudioTXView : public View {
public:
AudioTXView(NavigationView& nav);
~AudioTXView();
// TODO: Assert that buffer_out.count == buffer_in.count.
for(size_t i=0; i<buffer_out.count; i++) {
x_[0] = x_[1];
x_[1] = x_[2];
x_[2] = buffer_in.p[i];
y_[0] = y_[1];
y_[1] = y_[2];
y_[2] = b_[0] * x_[2] + b_[1] * x_[1] + b_[2] * x_[0]
- a_[1] * y_[1] - a_[2] * y_[0];
void focus() override;
buffer_out.p[i] = y_[2];
}
private:
void on_tuning_frequency_changed(rf::Frequency f);
FrequencyField field_frequency {
{ 5 * 8, 3 * 16 },
};
Text text_title {
{ 76, 64, 88, 16 },
"Audio TX"
};
Button button_transmit {
{ 72, 130, 96, 32 },
"Transmit"
};
Button button_exit {
{ 72, 270, 96, 32 },
"Exit"
};
};
x = x_;
y = y_;
}
void IIRBiquadFilter::execute_in_place(const buffer_f32_t& buffer) {
execute(buffer, buffer);
}
} /* namespace ui */
+47 -9
View File
@@ -248,19 +248,19 @@ void RegistersView::focus() {
DebugPeripheralsMenuView::DebugPeripheralsMenuView(NavigationView& nav) {
add_items<4>({ {
{ "RFFC5072", [&nav](){ nav.push<RegistersView>(
{ "RFFC5072", ui::Color::white(), [&nav](){ nav.push<RegistersView>(
"RFFC5072", RegistersWidgetConfig { 31, 2, 4, 4 },
[](const size_t register_number) { return radio::debug::first_if::register_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::debug::second_if::register_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 { audio::debug::reg_count(), 1, 3, 4 },
[](const size_t register_number) { return audio::debug::reg_read(register_number); }
); } },
@@ -272,13 +272,51 @@ DebugPeripheralsMenuView::DebugPeripheralsMenuView(NavigationView& nav) {
DebugMenuView::DebugMenuView(NavigationView& nav) {
add_items<5>({ {
{ "Memory", [&nav](){ nav.push<DebugMemoryView>(); } },
{ "Radio State", [&nav](){ nav.push<NotImplementedView>(); } },
{ "SD Card", [&nav](){ nav.push<SDCardDebugView>(); } },
{ "Peripherals", [&nav](){ nav.push<DebugPeripheralsMenuView>(); } },
{ "Temperature", [&nav](){ nav.push<TemperatureView>(); } },
{ "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<SDCardDebugView>(); } },
{ "Peripherals", ui::Color::white(), [&nav](){ nav.push<DebugPeripheralsMenuView>(); } },
{ "Temperature", ui::Color::white(), [&nav](){ nav.push<TemperatureView>(); } },
} });
on_left = [&nav](){ nav.pop(); };
}
char hexify(char in) {
if (in > 9) in += 7;
return in + 0x30;
}
DebugLCRView::DebugLCRView(NavigationView& nav, char * lcrstring, uint8_t checksum) {
char cstr[15] = "Checksum: 0x ";
add_children({ {
&text_lcr1,
&text_lcr2,
&text_lcr3,
&text_lcr4,
&text_lcr5,
&text_checksum,
&button_done
} });
std::string b = std::string(lcrstring);
text_lcr1.set(b.substr(8+(0*26),26));
if (strlen(lcrstring) > 34) text_lcr2.set(b.substr(8+(1*26),26));
if (strlen(lcrstring) > 34+26) text_lcr3.set(b.substr(8+(2*26),26));
if (strlen(lcrstring) > 34+26+26) text_lcr4.set(b.substr(8+(3*26),26));
if (strlen(lcrstring) > 34+26+26+26) text_lcr5.set(b.substr(8+(4*26),26));
cstr[12] = hexify(checksum >> 4);
cstr[13] = hexify(checksum & 15);
text_checksum.set(cstr);
button_done.on_select = [&nav](Button&){ nav.pop(); };
}
void DebugLCRView::focus() {
button_done.focus();
}
} /* namespace ui */
+8 -14
View File
@@ -245,42 +245,36 @@ LCRView::LCRView(
button_transmit_scan.set_style(&style_val);
button_setrgsb.on_select = [this,&nav](Button&){
auto an_view = new AlphanumView { nav, rgsb, 4 };
auto an_view = nav.push<AlphanumView>(rgsb, 4);
an_view->on_changed = [this](char *rgsb) {
button_setrgsb.set_text(rgsb);
};
nav.push(an_view);
};
button_setam_a.on_select = [this,&nav](Button&){
auto an_view = new AlphanumView { nav, litteral[0], 7 };
auto an_view = nav.push<AlphanumView>(litteral[0], 7);
an_view->on_changed = [this](char *) {};
nav.push(an_view);
};
button_setam_b.on_select = [this,&nav](Button&){
auto an_view = new AlphanumView { nav, litteral[1], 7 };
auto an_view = nav.push<AlphanumView>(litteral[1], 7);
an_view->on_changed = [this](char *) {};
nav.push(an_view);
};
button_setam_c.on_select = [this,&nav](Button&){
auto an_view = new AlphanumView { nav, litteral[2], 7 };
auto an_view = nav.push<AlphanumView>(litteral[2], 7);
an_view->on_changed = [this](char *) {};
nav.push(an_view);
};
button_setam_d.on_select = [this,&nav](Button&){
auto an_view = new AlphanumView { nav, litteral[3], 7 };
auto an_view = nav.push<AlphanumView>(litteral[3], 7);
an_view->on_changed = [this](char *) {};
nav.push(an_view);
};
button_setam_e.on_select = [this,&nav](Button&){
auto an_view = new AlphanumView { nav, litteral[4], 7 };
auto an_view = nav.push<AlphanumView>(litteral[4], 7);
an_view->on_changed = [this](char *) {};
nav.push(an_view);
};
button_lcrdebug.on_select = [this,&nav](Button&){
make_frame();
nav.push(new DebugLCRView { nav, lcrstring, checksum });
nav.push<DebugLCRView>(lcrstring, checksum);
};
button_transmit.on_select = [this,&transmitter_model](Button&){
@@ -324,7 +318,7 @@ LCRView::LCRView(
};
button_txsetup.on_select = [&nav](Button&){
nav.push(new AFSKSetupView { nav });
nav.push<AFSKSetupView>();
};
button_exit.on_select = [&nav](Button&){
+18 -6
View File
@@ -32,6 +32,12 @@
#include "hackrf_hal.hpp"
#include "string_format.hpp"
#include "ui_rds.hpp"
#include "ui_xylos.hpp"
#include "ui_lcr.hpp"
#include "ui_audiotx.hpp"
#include "ui_debug.hpp"
#include <cstring>
#include <stdio.h>
@@ -60,6 +66,8 @@ void LoadModuleView::on_show() {
for (c=0; c<16; c++) {
if (md5_signature[c] != _hash[c]) break;
}
//text_info.set(to_string_hex(*((unsigned int*)0x10087FF0), 8));
if (c == 16) {
text_info.set("Module already loaded :)");
_mod_loaded = true;
@@ -128,8 +136,6 @@ void LoadModuleView::loadmodule() {
[this](Message* const p) {
(void)p;*/
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 {
@@ -144,7 +150,7 @@ void LoadModuleView::loadmodule() {
LoadModuleView::LoadModuleView(
NavigationView& nav,
const char * hash,
View* new_view
uint8_t ViewID
)
{
add_children({ {
@@ -155,9 +161,15 @@ LoadModuleView::LoadModuleView(
_hash = hash;
button_ok.on_select = [this,&nav,new_view](Button&){
//nav.pop();
if (_mod_loaded == true) nav.push(new_view);
button_ok.on_select = [this, &nav, ViewID](Button&){
if (_mod_loaded == true) {
if (ViewID == 0) nav.push<RDSView>();
if (ViewID == 1) nav.push<XylosView>();
if (ViewID == 2) nav.push<LCRView>();
if (ViewID == 3) nav.push<AudioTXView>();
} else {
nav.pop();
}
};
}
+1 -1
View File
@@ -32,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, uint8_t ViewID);
void loadmodule();
void on_show() override;
+11 -1
View File
@@ -52,10 +52,20 @@ void MenuItemView::paint(Painter& painter) {
r,
paint_style.background
);
ui::Color final_item_color = item.color;
if (final_item_color.v == paint_style.background.v) final_item_color = paint_style.foreground;
Style text_style {
.font = paint_style.font,
.background = paint_style.background,
.foreground = final_item_color
};
painter.draw_string(
{ r.pos.x + 8, r.pos.y + (r.size.h - font_height) / 2 },
paint_style,
text_style,
item.text
);
}
+1
View File
@@ -34,6 +34,7 @@ namespace ui {
struct MenuItem {
std::string text;
ui::Color color;
std::function<void(void)> on_select;
// TODO: Prevent default-constructed MenuItems.
+23 -24
View File
@@ -20,6 +20,9 @@
*/
#include "ui_navigation.hpp"
#include "ui_loadmodule.hpp"
#include "modules.h"
#include "portapack.hpp"
#include "event_m0.hpp"
@@ -156,9 +159,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>(); } },
} });
on_left = [&nav](){ nav.pop(); };
}
@@ -167,8 +170,8 @@ TranspondersMenuView::TranspondersMenuView(NavigationView& nav) {
ReceiverMenuView::ReceiverMenuView(NavigationView& nav) {
add_items<2>({ {
{ "Audio", [&nav](){ nav.push<AnalogAudioView>(); } },
{ "Transponders", [&nav](){ nav.push<TranspondersMenuView>(); } },
{ "Audio", ui::Color::white(), [&nav](){ nav.push<AnalogAudioView>(); } },
{ "Transponders", ui::Color::white(), [&nav](){ nav.push<TranspondersMenuView>(); } },
} });
on_left = [&nav](){ nav.pop(); };
}
@@ -176,36 +179,32 @@ ReceiverMenuView::ReceiverMenuView(NavigationView& nav) {
/* SystemMenuView ********************************************************/
SystemMenuView::SystemMenuView(NavigationView& nav) {
add_items<7>({ {
{ "Receiver", [&nav](){ nav.push<ReceiverMenuView>(); } },
{ "Capture", [&nav](){ nav.push<NotImplementedView>(); } },
{ "Analyze", [&nav](){ nav.push<NotImplementedView>(); } },
{ "Setup", [&nav](){ nav.push<SetupMenuView>(); } },
{ "About", [&nav](){ nav.push<AboutView>(); } },
{ "Debug", [&nav](){ nav.push<DebugMenuView>(); } },
{ "HackRF", [&nav](){ nav.push<HackRFFirmwareView>(); } },
add_items<10>({ {
{ "Play dead", ui::Color::red(), [&nav](){ nav.push<PlayDeadView>(false); } },
{ "Receiver", ui::Color::cyan(), [&nav](){ nav.push<ReceiverMenuView>(); } },
{ "RDS TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, 0); } },
{ "Xylos TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, 1); } },
{ "TEDI/LCR TX", ui::Color::yellow(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, 2); } },
{ "Audio TX", ui::Color::orange(), [&nav](){ nav.push<LoadModuleView>(md5_baseband_tx, 3); } },
//{ "Capture", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
//{ "Analyze", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
{ "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>(); } },
} });
/* add_items<10>({ {
{ "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<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<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<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<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>(); } },
} });*/
*/
}
/* SystemView ************************************************************/
+1 -1
View File
@@ -93,7 +93,7 @@ public:
void set_title(const std::string new_value);
private:
static constexpr auto default_title = "PortaPack";
static constexpr auto default_title = "PortaPack|Havoc";
static constexpr auto back_text_enabled = " < ";
static constexpr auto back_text_disabled = " * ";
+1 -2
View File
@@ -148,8 +148,7 @@ RDSView::RDSView(
} });
button_setpsn.on_select = [this,&nav](Button&){
auto an_view = new AlphanumView { nav, psname, 8 };
nav.push(an_view);
nav.push<AlphanumView>(psname, 8);
};
button_transmit.on_select = [&transmitter_model](Button&){

Some files were not shown because too many files have changed in this diff Show More