Compare commits

..

34 Commits

Author SHA1 Message Date
gullradriel ce23c7d882 Merge pull request #841 from gullradriel/looking-glass-update
fixing width too tiny for calculation. It has to be a multiple of 240
2023-03-20 16:45:33 +01:00
GullCode 7eba8fd49b fixing width too tiny for calculation. It has to be a multiple of 240 2023-03-20 16:43:31 +01:00
gullradriel bfdf7660b6 Merge pull request #838 from bernd-herzog/error_handling
improved runtime error details in guru meditation
2023-03-19 08:40:25 +01:00
Bernd Herzog b83f43793c improved runtime error handling 2023-03-18 23:19:23 +01:00
Bernd Herzog ed1c2e1c03 Merge remote-tracking branch 'origin/next' into error_handling 2023-03-18 19:35:22 +01:00
Bernd Herzog caba16a549 Merge remote-tracking branch 'origin/next' into error_handling 2023-03-18 16:39:56 +01:00
gullradriel 5318542021 Merge pull request #836 from gullradriel/looking-glass-update
Looking glass update
2023-03-16 17:41:22 +01:00
GullCode 93f966bdcd Fixing 20MHz boudaries 2023-03-16 12:09:13 +01:00
GullCode 7b5f138dfb Fixing max<min case 2023-03-16 12:03:00 +01:00
GullCode 149cd755ca Restoring min step of 1, forcing 20Mhz minimum wide view 2023-03-16 11:56:24 +01:00
GullCode 63d0201b71 Fixing set freq and min step value 2023-03-16 11:32:26 +01:00
GullCode cf19408784 Merge branch 'next' of github.com:gullradriel/portapack-mayhem into looking-glass-update 2023-03-16 10:40:11 +01:00
gullradriel f882de5eff Merge pull request #835 from gullradriel/recon-update
Recon update
2023-03-16 10:36:24 +01:00
GullCode 49bda24079 added steps config and thus possibility to adjust config / see under 240 MHz 2023-03-16 10:33:36 +01:00
GullCode a1705dd9d4 reoganised things a little, added nb_columns management in ui 2023-03-14 22:23:16 +01:00
GullCode 155543e5d5 Added nb_columns, changed drawing due to column system 2023-03-14 22:22:49 +01:00
gullradriel 62b9fa2b6a Merge pull request #834 from gullradriel/recon-update
Recon minor update, RSSI widget get 'on touch'
2023-03-14 00:28:22 +01:00
GullCode f5427d7fdc UI adjustements 2023-03-14 00:26:25 +01:00
GullCode b8c1e8c4a6 Added on_touch on RSSI widget 2023-03-14 00:26:12 +01:00
gullradriel 7a0d02cb83 Merge pull request #833 from gullradriel/recon-update
Recon minor update
2023-03-13 23:29:37 +01:00
gullradriel c23f03c074 Merge branch 'eried:next' into recon-update 2023-03-13 23:27:44 +01:00
GullCode cfdd12d8a6 aligned OPT to the right 2023-03-13 23:27:04 +01:00
gullradriel d1ab93f644 Merge pull request #832 from gullradriel/recon-update
Recon update
2023-03-13 23:18:26 +01:00
GullCode f7df4f3575 Use rssi focusable, added shortcut to level app, glass app, cut buttons a bit better in the ui, better pause/resume/skiplock/unlock button 2023-03-13 23:14:06 +01:00
GullCode ad4cfe5a44 adding header guard 2023-03-13 23:12:46 +01:00
GullCode 8db44d1a92 fixed a text size, used new rssi focusable property so you can launch the level app by touching or selecting and clicking the rssi bars 2023-03-13 22:56:47 +01:00
GullCode 37cfcb0d5c added focusable ability to rssi field 2023-03-13 22:55:48 +01:00
gullradriel 6a61b9528e Merge pull request #831 from gullradriel/level-app-updates
Level app updates
2023-03-13 15:59:24 +01:00
gullradriel ab58f368b5 Merge branch 'eried:next' into level-app-updates 2023-03-13 15:56:41 +01:00
gullradriel 023ee2a6f5 Merge pull request #830 from bernd-herzog/error_handling
added runtime error details to guru meditation
2023-03-13 15:50:27 +01:00
Bernd Herzog b6011a777b added runtime error details to guru meditation 2023-03-13 15:04:00 +01:00
GullCode 37494500b2 Added display of rssi get delta, swapped audio and steps button for convenience 2023-03-13 14:04:23 +01:00
GullCode f42812c6b4 Added rssi get_delta, better rssi min graph view 2023-03-13 14:03:37 +01:00
GullCode a7acb37a56 added 0.1 and 1Khz steps 2023-03-13 14:02:29 +01:00
18 changed files with 881 additions and 402 deletions
+1 -1
View File
@@ -125,7 +125,7 @@ set(CPPSRC
${COMMON}/cpld_max5.cpp
${COMMON}/cpld_update.cpp
${COMMON}/cpld_xilinx.cpp
${COMMON}/debug.cpp
debug.cpp
${COMMON}/ert_packet.cpp
${COMMON}/event.cpp
${COMMON}/gcc.cpp
+10 -2
View File
@@ -62,6 +62,7 @@ namespace ui {
&field_bw,
&field_mode,
&step_mode,
&rssi_resolution,
&button_frequency,
&text_ctcss,
&freq_stats_rssi,
@@ -143,6 +144,13 @@ namespace ui {
}
};
rssi_resolution.on_change = [this](size_t, OptionsField::value_t v) {
if( v != -1 )
{
rssi_graph.set_nb_columns( v );
}
};
audio_mode.on_change = [this](size_t, OptionsField::value_t v) {
if( v == 0 )
{
@@ -215,7 +223,7 @@ namespace ui {
last_min_rssi = rssi.get_min();
last_avg_rssi = rssi.get_avg();
last_max_rssi = rssi.get_max();
freq_stats_rssi.set( "RSSI: "+to_string_dec_int( rssi.get_min() )+"/"+to_string_dec_int( rssi.get_avg() )+"/"+to_string_dec_int( rssi.get_max() )+" db" );
freq_stats_rssi.set( "RSSI: "+to_string_dec_int( rssi.get_min() )+"/"+to_string_dec_int( rssi.get_avg() )+"/"+to_string_dec_int( rssi.get_max() )+",dt: "+to_string_dec_int( rssi.get_delta() ) );
}
} /* on_statistic_updates */
@@ -290,7 +298,7 @@ namespace ui {
{
last_idx = min_idx ;
if (min_diff < 40)
text_ctcss.set(tone_keys[min_idx].first);
text_ctcss.set("T: "+tone_keys[min_idx].first);
else
text_ctcss.set(" ");
}
+24 -13
View File
@@ -47,10 +47,8 @@ namespace ui {
~LevelView();
void focus() override;
void big_display_freq( int64_t f );
void on_audio_spectrum(const AudioSpectrum* spectrum);
void big_display_freq( int64_t f );
const Style style_grey { // level
.font = font::fixed_8x16,
@@ -143,18 +141,18 @@ namespace ui {
};
OptionsField step_mode {
{ 21 * 8, 1 * 16 },
{ 16 * 8, 2 * 16 + 4 },
12,
{
}
};
RSSIGraph rssi_graph { // 240x320 =>
{ 0 , 5 * 16 + 4 , 240 - 5 * 8 , 320 - 5 * 16 - 4 },
{ 0 , 5 * 16 + 4 , 240 - 5 * 8 , 216 },
};
RSSI rssi { // 240x320 =>
{ 240 - 5 * 8 , 5 * 16 + 4 , 5 * 8 , 320 - 5 * 16 - 4 },
RSSI rssi { // 240x320 =>
{ 240 - 5 * 8 , 5 * 16 + 4 , 5 * 8 , 216 },
};
@@ -164,7 +162,7 @@ namespace ui {
};
OptionsField audio_mode {
{ 16 * 8, 2 * 16 + 4 },
{ 21 * 8, 1 * 16 },
9,
{
{"audio off", 0},
@@ -176,21 +174,22 @@ namespace ui {
Text text_ctcss {
{ 20 * 8, 3 * 16 + 4 , 14 * 8, 1 * 8 },
{ 22 * 8, 3 * 16 + 4 , 14 * 8, 1 * 8 },
""
};
// RSSI: XX/XX/XXX,dt: XX
Text freq_stats_rssi {
{ 0 * 8 , 3 * 16 + 4 , 20 * 8, 16 },
{ 0 * 8 , 3 * 16 + 4 , 22 * 8, 16 },
};
Text freq_stats_db {
{ 0 * 8 , 4 * 16 + 4 , 15 * 8, 16 },
};
OptionsField peak_mode {
{ 44 + 10 * 8, 4 * 16 + 4 },
{ 40 + 10 * 8, 4 * 16 + 4 },
10,
{
{"peak:none", 0},
@@ -202,6 +201,18 @@ namespace ui {
{"peak:10s",10000},
}
};
OptionsField rssi_resolution {
{ 44 + 20 * 8, 4 * 16 + 4},
4,
{
{"16x", 16},
{"32x", 32},
{"64x", 64},
{"128x", 128},
{"240x", 240},
}
};
void handle_coded_squelch(const uint32_t value);
void on_headphone_volume_changed(int32_t v);
@@ -184,6 +184,7 @@ namespace ui
&field_lna,
&field_vga,
&text_range,
&steps_config,
&filter_config,
&field_rf_amp,
&range_presets,
@@ -194,21 +195,71 @@ namespace ui
load_Presets(); // Load available presets from TXT files (or default)
field_frequency_min.set_value(presets_db[0].min); // Defaults to first preset
field_frequency_min.set_step( steps );
field_frequency_min.on_change = [this](int32_t v)
{
if (v >= field_frequency_max.value())
field_frequency_max.set_value(v + 240);
int32_t steps_ = steps ;
if( steps_ < 24 )
steps_ = 24 ;
if( v > 7200 - steps_ )
{
v = 7200 - steps_ ;
field_frequency_min.set_value( v );
}
if (v >= (field_frequency_max.value() - steps_ ) )
field_frequency_max.set_value( v + steps_ );
this->on_range_changed();
};
field_frequency_min.on_select = [this, &nav](NumberField& field) {
auto new_view = nav_.push<FrequencyKeypadView>(field_frequency_min.value()*1000000);
new_view->on_changed = [this, &field](rf::Frequency f) {
int32_t freq = f / 1000000 ;
int32_t steps_ = steps ;
if( steps_ < 24 )
steps_ = 24 ;
if( freq > (7200 - steps_ ) )
freq= 7200 - steps_ ;
field_frequency_min.set_value( freq );
if( field_frequency_max.value() < ( freq + steps_ ) )
field_frequency_max.set_value( freq + steps_ );
this->on_range_changed();
};
};
field_frequency_max.set_value(presets_db[0].max); // Defaults to first preset
field_frequency_max.set_step( steps );
field_frequency_max.on_change = [this](int32_t v)
{
if (v <= field_frequency_min.value())
field_frequency_min.set_value(v - 240);
{
int32_t steps_ = steps ;
if( steps_ < 24 )
steps_ = 24 ;
if( v < steps_ )
{
v = steps_ ;
field_frequency_max.set_value( v );
}
if (v < (field_frequency_min.value() + steps_) )
field_frequency_min.set_value(v - steps_);
this->on_range_changed();
};
field_frequency_max.on_select = [this, &nav](NumberField& field) {
auto new_view = nav_.push<FrequencyKeypadView>(field_frequency_max.value()*1000000);
new_view->on_changed = [this, &field](rf::Frequency f) {
int32_t steps_ = steps ;
if( steps_ < 24 )
steps_ = 24 ;
int32_t freq = f / 1000000 ;
if( freq < 24 )
freq = 24 ;
field_frequency_max.set_value( freq );
if( field_frequency_min.value() > ( freq - steps) )
field_frequency_min.set_value( freq - steps );
this->on_range_changed();
};
};
field_lna.set_value(receiver_model.lna());
field_lna.on_change = [this](int32_t v)
{
@@ -221,11 +272,13 @@ namespace ui
this->on_vga_changed(v_db);
};
filter_config.set_selected_index(0);
filter_config.on_change = [this](size_t n, OptionsField::value_t v)
steps_config.set_selected_index(3); //default of 250 Mhz steps
steps_config.on_change = [this](size_t n, OptionsField::value_t v)
{
(void)n;
min_color_power = v;
field_frequency_min.set_step( v );
field_frequency_max.set_step( v );
steps = v ;
};
range_presets.on_change = [this](size_t n, OptionsField::value_t v)
+184 -169
View File
@@ -1,187 +1,202 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2020 euquiq
*
* 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.
*/
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2020 euquiq
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "ui.hpp"
#include "portapack.hpp"
#include "baseband_api.hpp"
#include "receiver_model.hpp"
#include "ui_widget.hpp"
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "string_format.hpp"
#include "analog_audio_app.hpp"
#include "spectrum_color_lut.hpp"
#ifndef _UI_GLASS
#define _UI_GLASS
namespace ui
{
#define LOOKING_GLASS_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz
#define MHZ_DIV 1000000
#define X2_MHZ_DIV 2000000
#include "ui.hpp"
#include "portapack.hpp"
#include "baseband_api.hpp"
#include "receiver_model.hpp"
#include "ui_widget.hpp"
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "string_format.hpp"
#include "analog_audio_app.hpp"
#include "spectrum_color_lut.hpp"
class GlassView : public View
{
public:
GlassView(NavigationView &nav);
namespace ui
{
#define LOOKING_GLASS_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz
#define MHZ_DIV 1000000
#define X2_MHZ_DIV 2000000
GlassView( const GlassView &);
GlassView& operator=(const GlassView &nav);
class GlassView : public View
{
public:
GlassView(NavigationView &nav);
~GlassView();
std::string title() const override { return "Looking Glass"; };
GlassView( const GlassView &);
GlassView& operator=(const GlassView &nav);
void on_show() override;
void on_hide() override;
void focus() override;
~GlassView();
std::string title() const override { return "Looking Glass"; };
private:
NavigationView& nav_;
void on_show() override;
void on_hide() override;
void focus() override;
struct preset_entry
{
rf::Frequency min{};
rf::Frequency max{};
std::string label{};
};
private:
NavigationView& nav_;
std::vector<preset_entry> presets_db{};
void on_channel_spectrum(const ChannelSpectrum& spectrum);
void do_timers();
void on_range_changed();
void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db);
void add_spectrum_pixel(Color color);
void PlotMarker(rf::Frequency pos);
void load_Presets();
void txtline_process(std::string& line);
void populate_Presets();
void presets_Default();
rf::Frequency f_min { 0 }, f_max { 0 };
rf::Frequency search_span { 0 };
rf::Frequency f_center { 0 };
rf::Frequency f_center_ini { 0 };
rf::Frequency marker_pixel_step { 0 };
rf::Frequency each_bin_size { LOOKING_GLASS_SLICE_WIDTH / 240 };
rf::Frequency bins_Hz_size { 0 };
uint8_t min_color_power { 0 };
uint32_t pixel_index { 0 };
std::array<Color, 240> spectrum_row = { 0 };
ChannelSpectrumFIFO* fifo { nullptr };
uint8_t max_power = 0;
Labels labels{
{{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()},
{{0, 1 * 16}, " RANGE: FILTER: AMP:", Color::light_grey()},
{{0, 2 * 16}, "PRESET:", Color::light_grey()},
{{0, 3 * 16}, "MARKER: MHz +/- MHz", Color::light_grey()},
{{0, 4 * 16}, "RESOLUTION: (fft trigger)", Color::light_grey()}
};
NumberField field_frequency_min {
{ 4 * 8, 0 * 16 },
4,
{ 0, 6960 },
240,
' '
};
NumberField field_frequency_max {
{ 13 * 8, 0 * 16 },
4,
{ 240, 7200 },
240,
' '
};
LNAGainField field_lna {
{ 21 * 8, 0 * 16 }
};
VGAGainField field_vga {
{ 27 * 8, 0 * 16 }
};
Text text_range{
{7 * 8, 1 * 16, 4 * 8, 16},
""};
OptionsField filter_config{
{19 * 8, 1 * 16},
4,
struct preset_entry
{
{"OFF ", 0},
{"MID ", 118}, //85 +25 (110) + a bit more to kill all blue
{"HIGH", 202}, //168 + 25 (193)
}};
rf::Frequency min{};
rf::Frequency max{};
std::string label{};
};
RFAmpField field_rf_amp{
{29 * 8, 1 * 16}};
std::vector<preset_entry> presets_db{};
OptionsField range_presets{
{7 * 8, 2 * 16},
20,
{
{" NONE (WIFI 2.4GHz)", 0},
}};
void on_channel_spectrum(const ChannelSpectrum& spectrum);
void do_timers();
void on_range_changed();
void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db);
void add_spectrum_pixel(Color color);
void PlotMarker(rf::Frequency pos);
void load_Presets();
void txtline_process(std::string& line);
void populate_Presets();
void presets_Default();
NumberField field_marker{
{7 * 8, 3 * 16},
4,
{0, 7200},
25,
' '};
rf::Frequency f_min { 0 }, f_max { 0 };
rf::Frequency search_span { 0 };
rf::Frequency f_center { 0 };
rf::Frequency f_center_ini { 0 };
rf::Frequency marker_pixel_step { 0 };
rf::Frequency each_bin_size { LOOKING_GLASS_SLICE_WIDTH / 240 };
rf::Frequency bins_Hz_size { 0 };
uint8_t min_color_power { 0 };
uint32_t pixel_index { 0 };
std::array<Color, 240> spectrum_row = { 0 };
ChannelSpectrumFIFO* fifo { nullptr };
uint8_t max_power = 0;
int32_t steps = 250 ; // default of 250 Mhz steps
Text text_marker_pm{
{20 * 8, 3 * 16, 2 * 8, 16},
""};
Labels labels{
{{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()},
{{0, 1 * 16}, " RANGE: FILTER: AMP:", Color::light_grey()},
{{0, 2 * 16}, "PRESET:", Color::light_grey()},
{{0, 3 * 16}, "MARKER: MHz +/- MHz", Color::light_grey()},
{{0, 4 * 16}, "RESOLUTION: STEPS:", Color::light_grey()}
};
NumberField field_trigger{
{11 * 8, 4 * 16},
3,
{2, 128},
2,
' '};
NumberField field_frequency_min {
{ 4 * 8, 0 * 16 },
4,
{ 0, 7199 },
1, // number of steps by encoder delta
' '
};
NumberField field_frequency_max {
{ 13 * 8, 0 * 16 },
4,
{ 1, 7200 },
1, // number of steps by encoder delta
' '
};
LNAGainField field_lna {
{ 21 * 8, 0 * 16 }
};
VGAGainField field_vga {
{ 27 * 8, 0 * 16 }
};
Text text_range{
{7 * 8, 1 * 16, 4 * 8, 16},
""};
OptionsField steps_config{
{ 22 * 8, 4 * 16},
4,
{
{"1", 1},
{"50", 50},
{"100", 100},
{"250", 250},
{"500", 500},
{"1000", 1000},
}};
OptionsField filter_config{
{19 * 8, 1 * 16},
4,
{
{"OFF ", 0},
{"MID ", 118}, //85 +25 (110) + a bit more to kill all blue
{"HIGH", 202}, //168 + 25 (193)
}};
RFAmpField field_rf_amp{
{29 * 8, 1 * 16}};
OptionsField range_presets{
{7 * 8, 2 * 16},
20,
{
{" NONE (WIFI 2.4GHz)", 0},
}};
NumberField field_marker{
{7 * 8, 3 * 16},
4,
{0, 7200},
25,
' '};
Text text_marker_pm{
{20 * 8, 3 * 16, 2 * 8, 16},
""};
NumberField field_trigger{
{11 * 8, 4 * 16},
3,
{2, 128},
2,
' '};
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);
}
}
}
};
};
}
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);
}
}
}
};
};
}
#endif
+24 -3
View File
@@ -524,15 +524,21 @@ namespace ui {
if(frequency_list[index].description.size() > 0) desc_cycle.set( frequency_list[index].description ); //Show new description
}
big_display.set_style(&style_white);
if( !userpause )
button_pause.set_text("<PAUSE>");
else
button_pause.set_text("<RESUME>");
}
else if( freq_lock == 1 && recon_lock_nb_match != 1 )
{
//STARTING LOCK FREQ
big_display.set_style(&style_yellow);
button_pause.set_text("<SKPLCK>");
}
else if( index < 1000 && freq_lock >= recon_thread -> get_lock_nb_match() )
{
big_display.set_style( &style_green);
button_pause.set_text("<UNLOCK>");
//FREQ IS STRONG: GREEN and recon will pause when on_statistics_update()
if( (!scanner_mode) && autosave && last_freq != freq ) {
@@ -660,6 +666,7 @@ namespace ui {
&field_lock_wait,
&button_recon_setup,
&button_scanner_mode,
&button_looking_glass,
&file_name,
&rssi,
&text_cycle,
@@ -875,6 +882,20 @@ namespace ui {
nav_.push<AnalogAudioView>();
};
button_looking_glass.on_select = [this](Button&) {
recon_thread->stop();
nav_.pop();
nav_.push<GlassView>();
};
rssi.set_focusable(true);
rssi.on_select = [this](RSSI&) {
recon_thread->stop();
nav_.pop();
nav_.push<LevelView>();
};
button_mic_app.on_select = [this](Button&) {
recon_thread->stop();
nav_.pop();
@@ -1091,7 +1112,7 @@ namespace ui {
show_max(); /* display step information */
text_cycle.set( "MANUAL SEARCH" );
button_scanner_mode.set_style( &style_white );
button_scanner_mode.set_text( "M-SEARCH" );
button_scanner_mode.set_text( "MSEARCH" );
file_name.set_style( &style_white );
file_name.set( "USE: MANUAL RANGE" );
@@ -1653,7 +1674,7 @@ namespace ui {
void ReconView::user_pause() {
timer = 0 ; // Will trigger a recon_resume() on_statistics_update, also advancing to next freq.
button_pause.set_text("<RESUME>"); //PAUSED, show resume
//button_pause.set_text("<RESUME>"); //PAUSED, show resume
userpause=true;
continuous_lock=false;
recon_pause();
@@ -1661,7 +1682,7 @@ namespace ui {
void ReconView::user_resume() {
timer = 0 ; // Will trigger a recon_resume() on_statistics_update, also advancing to next freq.
button_pause.set_text("<PAUSE>"); //Show button for pause
//button_pause.set_text("<PAUSE>"); //Show button for pause
userpause=false; // Resume recon
continuous_lock=false;
recon_resume();
+15 -9
View File
@@ -31,6 +31,8 @@
#include "analog_audio_app.hpp"
#include "audio.hpp"
#include "ui_mictx.hpp"
#include "ui_level.hpp"
#include "ui_looking_glass_app.hpp"
#include "portapack_persistent_memory.hpp"
#include "baseband_api.hpp"
#include "string_format.hpp"
@@ -264,7 +266,7 @@ namespace ui {
};
RSSI rssi {
{ 0 * 16, 2 * 16, 15 * 16, 8 },
{ 0 * 16, 2 * 16, 240 - 4 * 8 , 16 },
};
Text text_cycle {
@@ -276,7 +278,7 @@ namespace ui {
};
Text desc_cycle {
{0, 4 * 16, 240, 16 },
{0, 4 * 16, 240 , 16 },
};
/* BigFrequency big_display { //Show frequency in glamour
@@ -285,32 +287,36 @@ namespace ui {
}; */
Text big_display { //Show frequency in text mode
{ 0, 5 * 16 , 28 * 8, 16 },
{ 0, 5 * 16 , 21 * 8, 16 },
};
Text freq_stats { //Show frequency stats in text mode
{ 0, 6 * 16 , 28 * 8, 16 },
{ 0, 6 * 16 , 21 * 8, 16 },
};
Text text_timer { //Show frequency stats in text mode
{ 0, 7 * 16 , 28 * 8, 16 },
{ 0, 7 * 16 , 21 * 8, 16 },
};
Button button_recon_setup {
{ 25 * 8 , 2 * 16 + 8 , 4 * 8, 28 },
{ 240 - 4 * 8 , 2 * 16 , 4 * 8, 28 },
"OPT"
};
Button button_looking_glass {
{ 240 - 5 * 8 , 6 * 16 - 4 , 5 * 8, 28 },
"GLASS"
};
Button button_scanner_mode {
{ 21 * 8 , 8 * 16 , 9 * 8, 28 },
{ 240 - 8 * 8 , 8 * 16 , 8 * 8, 28 },
"RECON"
};
Text file_name { //Show file used
{ 0 , 8 * 16 + 4 , 20 * 8, 16 },
{ 0 , 8 * 16 + 6 , 21 * 8, 16 },
};
ButtonWithEncoder button_manual_start {
{ 0 * 8, 11 * 16, 11 * 8, 28 },
""
+203
View File
@@ -0,0 +1,203 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Bernd Herzog
*
* 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 "debug.hpp"
#include <ch.h>
#include <hal.h>
#include <string>
#include "ui_painter.hpp"
#include "portapack.hpp"
#include "ui_font_fixed_8x16.hpp"
#include "string_format.hpp"
void runtime_error(LED);
std::string number_to_hex_string(uint32_t);
void draw_line(int32_t, const char *, regarm_t);
static bool error_shown = false;
void draw_guru_meditation_header(uint8_t source, const char *hint) {
ui::Painter painter;
ui::Style style_default {
.font = ui::font::fixed_8x16,
.background = ui::Color::black(),
.foreground = ui::Color::white()
};
painter.fill_rectangle(
{ 0, 0, portapack::display.width(), portapack::display.height() },
ui::Color::red()
);
constexpr int border = 8;
painter.fill_rectangle(
{ border, border, portapack::display.width() - (border * 2), portapack::display.height() - (border * 2) },
ui::Color::black()
);
// NOTE: in situations like a hard fault it seems not possible to write strings longer than 16 characters.
painter.draw_string({ 48, 24 }, style_default, "M? Guru");
painter.draw_string({ 48 + 8*8, 24 }, style_default, "Meditation");
if (source == CORTEX_M0)
painter.draw_string({ 48 + 8, 24 }, style_default, "0");
if (source == CORTEX_M4)
painter.draw_string({ 48 + 8, 24 }, style_default, "4");
painter.draw_string({ 15, 55 }, style_default, "Hint: ");
painter.draw_string({ 15 + 8*8, 55 }, style_default, hint);
}
void draw_guru_meditation(uint8_t source, const char *hint) {
if(error_shown == false){
error_shown = true;
draw_guru_meditation_header(source, hint);
}
if (source == CORTEX_M0)
runtime_error(hackrf::one::led_rx);
if (source == CORTEX_M4)
runtime_error(hackrf::one::led_tx);
}
void draw_guru_meditation(uint8_t source, const char *hint, struct extctx *ctxp, uint32_t cfsr = 0) {
if(error_shown == false)
{
error_shown = true;
draw_guru_meditation_header(source, hint);
if (ctxp != nullptr) {
int i = 0;
draw_line(80 + i++ * 20, "r0:", ctxp->r0);
draw_line(80 + i++ * 20, "r1:", ctxp->r1);
draw_line(80 + i++ * 20, "r2:", ctxp->r2);
draw_line(80 + i++ * 20, "r3:", ctxp->r3);
draw_line(80 + i++ * 20, "r12:", ctxp->r12);
// NOTE: run for M0
// # arm-none-eabi-gdb --batch --eval-command="x/8i 0x<link_register_value_here>" firmware/application/application.elf
// or for M4
// # arm-none-eabi-gdb --batch --eval-command="x/8i 0x<link_register_value_here>" firmware/baseband/<image_name_here>.elf
// to see whats causing the fault.
draw_line(80 + i++ * 20, "lr:", ctxp->lr_thd);
draw_line(80 + i++ * 20, "pc:", ctxp->pc);
// see SCB_CFSR_* in libopencm3/cm3/scb.h for details
if (cfsr != 0)
draw_line(80 + i++ * 20, "cfsr:", (void *)cfsr);
}
}
if (source == CORTEX_M0)
runtime_error(hackrf::one::led_rx);
if (source == CORTEX_M4)
runtime_error(hackrf::one::led_tx);
}
void draw_line(int32_t y_offset, const char *label, regarm_t value){
ui::Painter painter;
ui::Style style_default {
.font = ui::font::fixed_8x16,
.background = ui::Color::black(),
.foreground = ui::Color::white()
};
painter.draw_string({ 15, y_offset }, style_default, label);
painter.draw_string({ 15 + 8*8, y_offset }, style_default, to_string_hex((uint32_t)value, 8));
}
void runtime_error(LED led) {
led.off();
while(true) {
volatile size_t n = 1000000U;
while(n--);
led.toggle();
}
}
extern "C" {
#if CH_DBG_ENABLED
void port_halt(void) {
port_disable();
if (dbg_panic_msg == nullptr)
dbg_panic_msg = "system halted";
draw_guru_meditation(CORTEX_M0, dbg_panic_msg);
}
#endif
CH_IRQ_HANDLER(MemManageVector) {
#if CH_DBG_ENABLED
chDbgPanic("MemManage");
#else
chSysHalt();
#endif
}
CH_IRQ_HANDLER(BusFaultVector) {
#if CH_DBG_ENABLED
chDbgPanic("BusFault");
#else
chSysHalt();
#endif
}
CH_IRQ_HANDLER(UsageFaultVector) {
#if CH_DBG_ENABLED
chDbgPanic("UsageFault");
#else
chSysHalt();
#endif
}
CH_IRQ_HANDLER(HardFaultVector) {
#if CH_DBG_ENABLED
CH_IRQ_PROLOGUE();
struct extctx *ctxp;
port_lock_from_isr();
if ((uint32_t)_saved_lr & 0x04)
ctxp = (struct extctx *)__get_PSP();
else
ctxp = (struct extctx *)__get_MSP();
port_disable();
auto stack_space_left = get_free_stack_space();
if (stack_space_left < 16)
draw_guru_meditation(CORTEX_M0, "Stack Overflow", ctxp);
draw_guru_meditation(CORTEX_M0, "Hard Fault", ctxp);
CH_IRQ_EPILOGUE();
#else
chSysHalt();
#endif
}
} /* extern "C" */
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Bernd Herzog
*
* This file is part of PortaPack.
*
@@ -22,4 +23,21 @@
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include "hackrf_gpio.hpp"
extern void draw_guru_meditation(uint8_t, const char *);
extern void draw_guru_meditation(uint8_t, const char *, struct extctx *, uint32_t);
extern uint32_t __process_stack_base__;
extern uint32_t __process_stack_end__;
#define CRT0_STACKS_FILL_PATTERN 0x55555555
inline uint32_t get_free_stack_space(){
uint32_t *p;
for (p = &__process_stack_base__; *p == CRT0_STACKS_FILL_PATTERN && p < &__process_stack_end__; p++);
auto stack_space_left = p - &__process_stack_base__;
return stack_space_left;
}
#endif/*__DEBUG_H__*/
+9 -31
View File
@@ -23,6 +23,7 @@
#include "portapack.hpp"
#include "portapack_persistent_memory.hpp"
#include "debug.hpp"
#include "sd_card.hpp"
#include "rtc_time.hpp"
@@ -141,37 +142,14 @@ eventmask_t EventDispatcher::wait() {
void EventDispatcher::dispatch(const eventmask_t events) {
if( shared_memory.m4_panic_msg[0] != 0 ) {
halt = true;
}
if( halt ) {
if( shared_memory.m4_panic_msg[0] != 0 ) {
painter.fill_rectangle(
{ 0, 0, portapack::display.width(), portapack::display.height() },
ui::Color::red()
);
constexpr int border = 8;
painter.fill_rectangle(
{ border, border, portapack::display.width() - (border * 2), portapack::display.height() - (border * 2) },
ui::Color::black()
);
painter.draw_string({ 48, 24 }, top_widget->style(), "M4 Guru Meditation");
shared_memory.m4_panic_msg[sizeof(shared_memory.m4_panic_msg) - 1] = 0;
const std::string message = shared_memory.m4_panic_msg;
const int x_offset = (portapack::display.width() - (message.size() * 8)) / 2;
constexpr int y_offset = (portapack::display.height() - 16) / 2;
painter.draw_string(
{ x_offset, y_offset },
top_widget->style(),
message
);
shared_memory.m4_panic_msg[0] = 0;
}
return;
if (shared_memory.bb_data.data[0] == 0)
draw_guru_meditation(CORTEX_M4, shared_memory.m4_panic_msg);
else
draw_guru_meditation(
CORTEX_M4,
shared_memory.m4_panic_msg,
(struct extctx *)&shared_memory.bb_data.data[8],
*(uint32_t *)&shared_memory.bb_data.data[4]);
}
if( events & EVT_MASK_APPLICATION ) {
-1
View File
@@ -98,7 +98,6 @@ private:
static bool is_running;
bool sd_card_present = false;
static bool display_sleep;
bool halt = false;
bool in_key_event = false;
eventmask_t wait();
+4
View File
@@ -51,6 +51,8 @@ options_t freqman_entry_bandwidths[ 4 ] = {
};
options_t freqman_entry_steps = {
{ "0.1KHz " , 100 },
{ "1KHz " , 1000 },
{ "5KHz (SA AM)" , 5000 },
{ "6.25KHz(NFM)" , 6250 },
{ "8.33KHz(AIR)" , 8330 },
@@ -68,6 +70,8 @@ options_t freqman_entry_steps = {
};
options_t freqman_entry_steps_short = {
{ "0.1KHz" , 100 },
{ "1KHz" , 1000 },
{ "5KHz" , 5000 },
{ "6.25KHz" , 6250 },
{ "8.33KHz" , 8330 },
+132 -47
View File
@@ -32,14 +32,23 @@
namespace ui {
RSSI::RSSI(
Rect parent_rect,
bool instant_exec
) : Widget { parent_rect },
instant_exec_ { instant_exec }
{
}
void RSSI::paint(Painter& painter) {
const auto r = screen_rect();
constexpr int rssi_sample_range = 256;
constexpr float rssi_voltage_min = 0.4;
//constexpr float rssi_voltage_min = 0.4;
constexpr float rssi_voltage_max = 2.2;
constexpr float adc_voltage_max = 3.3;
constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max;
//constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max;
constexpr int raw_min = 0 ;
constexpr int raw_max = rssi_sample_range * rssi_voltage_max / adc_voltage_max;
constexpr int raw_delta = raw_max - raw_min;
@@ -48,12 +57,12 @@ namespace ui {
{
// horizontal left to right level meters
const range_t<int> x_avg_range { 0, r.width() - 1 };
const auto x_avg = x_avg_range.clip((avg_ - raw_min) * r.width() / raw_delta);
const int16_t x_avg = x_avg_range.clip((avg_ - raw_min) * r.width() / raw_delta);
const range_t<int> x_min_range { 0, x_avg };
const auto x_min = x_min_range.clip((min_ - raw_min) * r.width() / raw_delta);
const int16_t x_min = x_min_range.clip((min_ - raw_min) * r.width() / raw_delta);
const range_t<int> x_max_range { x_avg + 1, r.width() - 1 };
const auto x_max = x_max_range.clip((max_ - raw_min) * r.width() / raw_delta);
const auto peak = x_max_range.clip((peak_ - raw_min) * r.width() / raw_delta);
const int16_t x_max = x_max_range.clip((max_ - raw_min) * r.width() / raw_delta);
const int16_t peak = x_max_range.clip((peak_ - raw_min) * r.width() / raw_delta);
// x_min
const Rect r0 { r.left(), r.top(), x_min, r.height() };
@@ -104,13 +113,13 @@ namespace ui {
{
// vertical bottom to top level meters
const range_t<int> y_avg_range { 0, r.height() - 1 };
const auto y_avg = y_avg_range.clip((avg_ - raw_min) * r.height() / raw_delta);
const int16_t y_avg = y_avg_range.clip((avg_ - raw_min) * r.height() / raw_delta);
const range_t<int> y_min_range { 0, y_avg };
const auto y_min = y_min_range.clip((min_ - raw_min) * r.height() / raw_delta);
const int16_t y_min = y_min_range.clip((min_ - raw_min) * r.height() / raw_delta);
const range_t<int> y_max_range { y_avg + 1, r.height() - 1 };
const auto y_max = y_max_range.clip((max_ - raw_min) * r.height() / raw_delta);
const int16_t y_max = y_max_range.clip((max_ - raw_min) * r.height() / raw_delta);
const range_t<int> peak_range { 0, r.height() - 1 };
const auto peak = peak_range.clip((peak_ - raw_min) * r.height() / raw_delta);
const int16_t peak = peak_range.clip((peak_ - raw_min) * r.height() / raw_delta);
// y_min
const Rect r0 { r.left(), r.bottom() - y_min, r.width() , y_min };
@@ -161,23 +170,37 @@ namespace ui {
if (pitch_rssi_enabled) {
baseband::set_pitch_rssi((avg_ - raw_min) * 2000 / raw_delta, true);
}
if( has_focus() || highlighted() )
{
const Rect r6 { r.left(), r.top(), r.width(), r.height() };
painter.draw_rectangle(
r6,
Color::white()
);
}
}
int32_t RSSI::get_min()
int16_t RSSI::get_min()
{
return min_ ;
}
int32_t RSSI::get_avg()
int16_t RSSI::get_avg()
{
return avg_ ;
}
int32_t RSSI::get_max()
int16_t RSSI::get_max()
{
return max_ ;
}
int16_t RSSI::get_delta()
{
return max_ - min_ ;
}
void RSSI::set_pitch_rssi(bool enabled) {
pitch_rssi_enabled = enabled;
if (!enabled) baseband::set_pitch_rssi(0, false);
@@ -218,27 +241,32 @@ namespace ui {
void RSSIGraph::paint(Painter& painter) {
const auto r = screen_rect();
int16_t size = r.width() / nb_columns ;
int16_t top_y_val = 0 ;
int16_t width_y = 0 ;
if( size < 1 )
size = 1 ;
int xpos = r.right() ;
for ( int n = 2 ; (unsigned)n <= graph_list.size(); n++) {
auto& entry = graph_list[graph_list.size()-n];
auto& prev_entry = graph_list[graph_list.size()-(n-1)];
// black
const Point p0{ r.right() - n , r.top() };
painter.draw_vline(
p0,
r.height(),
Color::black());
const Rect r0{ xpos - size , r.top() , size , r.height() };
painter.fill_rectangle(
r0,
Color::black());
// y_max
int32_t top_y_val = max( entry.rssi_max , prev_entry.rssi_max );
int32_t width_y = abs( entry.rssi_max - prev_entry.rssi_max );
top_y_val = max( entry.rssi_max , prev_entry.rssi_max );
width_y = abs( entry.rssi_max - prev_entry.rssi_max );
if( width_y == 0 )
width_y = 1 ;
const Point p1{ r.right() - n , r.bottom() - top_y_val };
painter.draw_vline(
p1,
width_y,
const Rect r1{ xpos - size , r.bottom() - top_y_val , size , width_y };
painter.fill_rectangle(
r1,
Color::red());
// y_avg
@@ -246,10 +274,9 @@ namespace ui {
width_y = abs( entry.rssi_avg - prev_entry.rssi_avg );
if( width_y == 0 )
width_y = 1 ;
const Point p2{ r.right() - n , r.bottom() - top_y_val };
painter.draw_vline(
p2,
width_y,
const Rect r2{ xpos - size , r.bottom() - top_y_val , size , width_y };
painter.fill_rectangle(
r2,
Color::white());
// y_min
@@ -257,10 +284,9 @@ namespace ui {
width_y = abs( entry.rssi_min - prev_entry.rssi_min );
if( width_y == 0 )
width_y = 1 ;
const Point p3{ r.right() - n , r.bottom() - top_y_val };
painter.draw_vline(
p3,
width_y,
const Rect r3{ xpos - size , r.bottom() - top_y_val , size , width_y };
painter.fill_rectangle(
r3,
Color::blue());
// hack to display db
@@ -268,44 +294,103 @@ namespace ui {
width_y = abs( entry.db - prev_entry.db );
if( width_y == 0 )
width_y = 1 ;
const Point p4{ r.right() - n , r.bottom() - top_y_val };
painter.draw_vline(
p4,
width_y,
const Rect r4{ xpos - size , r.bottom() - top_y_val , size , width_y };
painter.fill_rectangle(
r4,
Color::green());
xpos = xpos - size ;
}
if( xpos > r.left() )
{
const Rect r5{ r.left() , r.top() , xpos - r.left() , r.height() };
painter.fill_rectangle(
r5,
Color::black());
}
}
void RSSIGraph::add_values(int32_t rssi_min, int32_t rssi_avg, int32_t rssi_max, int32_t db )
void RSSIGraph::add_values(int16_t rssi_min, int16_t rssi_avg, int16_t rssi_max, int16_t db )
{
const auto r = screen_rect();
constexpr int rssi_sample_range = 256;
constexpr float rssi_voltage_min = 0.4;
//constexpr float rssi_voltage_min = 0.4;
constexpr float rssi_voltage_max = 2.2;
constexpr float adc_voltage_max = 3.3;
constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max;
//constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max;
constexpr int raw_min = 0 ;
constexpr int raw_max = rssi_sample_range * rssi_voltage_max / adc_voltage_max;
constexpr int raw_delta = raw_max - raw_min;
// vertical bottom to top level meters
const range_t<int> y_avg_range { 0, r.height() - 1 };
const auto y_avg = y_avg_range.clip((rssi_avg - raw_min) * r.height() / raw_delta);
const int16_t y_avg = y_avg_range.clip((rssi_avg - raw_min) * r.height() / raw_delta);
const range_t<int> y_min_range { 0, y_avg };
const auto y_min = y_min_range.clip((rssi_min - raw_min) * r.height() / raw_delta);
const int16_t y_min = y_min_range.clip((rssi_min - raw_min) * r.height() / raw_delta);
const range_t<int> y_max_range { y_avg + 1, r.height() - 1 };
const auto y_max = y_max_range.clip((rssi_max - raw_min) * r.height() / raw_delta);
const range_t<int> db_range { -100 , 20 };
auto db_ = db_range.clip( db );
db_ = db_ - 20 ;
db_ = db_ * r.height() / 120 ;
const int16_t y_max = y_max_range.clip((rssi_max - raw_min) * r.height() / raw_delta);
const range_t<int> db_range { -80 , 10 };
int16_t db_ = db_range.clip( db );
db_ = db_ - 10 ;
db_ = db_ * r.height() / 90 ;
db_ = r.height() + db_ ;
graph_list . push_back( { y_min, y_avg, y_max , db_ } );
if( graph_list.size() > (unsigned)r.width() )
while( graph_list.size() > nb_columns )
{
graph_list.erase( graph_list.begin() );
}
set_dirty();
}
void RSSIGraph::set_nb_columns( int16_t nb )
{
nb_columns = nb ;
}
void RSSI::on_focus() {
if( on_highlight )
on_highlight(*this);
}
bool RSSI::on_key(const KeyEvent key) {
if( key == KeyEvent::Select ) {
if( on_select ) {
on_select(*this);
return true;
}
} else {
if( on_dir ) {
return on_dir(*this, key);
}
}
return false;
}
bool RSSI::on_touch(const TouchEvent event) {
switch(event.type) {
case TouchEvent::Type::Start:
set_highlighted(true);
set_dirty();
if( on_touch_press) {
on_touch_press(*this);
}
if( on_select && instant_exec_ ) {
on_select(*this);
}
return true;
case TouchEvent::Type::End:
set_highlighted(false);
set_dirty();
if( on_touch_release) {
on_touch_release(*this);
}
if( on_select && !instant_exec_ ) {
on_select(*this);
}
return true;
default:
return false;
}
}
} /* namespace ui */
+83 -69
View File
@@ -25,87 +25,101 @@
#include "ui.hpp"
#include "ui_widget.hpp"
#include "ui_painter.hpp"
#include "event_m0.hpp"
#include "message.hpp"
#include <cstdint>
namespace ui {
class RSSI : public Widget {
public:
RSSI(
const Rect parent_rect
) : Widget { parent_rect },
min_ { 0 },
avg_ { 0 },
max_ { 0 }
{
}
class RSSI : public Widget {
public:
std::function<void(RSSI&)> on_select { };
std::function<void(RSSI&)> on_touch_release { }; // Executed when releasing touch, after on_select.
std::function<void(RSSI&)> on_touch_press { }; // Executed when touching, before on_select.
std::function<bool(RSSI&, KeyEvent)> on_dir { };
std::function<void(RSSI&)> on_highlight { };
void paint(Painter& painter) override;
int32_t get_min();
int32_t get_avg();
int32_t get_max();
void set_vertical_rssi(bool enabled);
void set_peak(bool enabled, size_t duration);
private:
int32_t min_;
int32_t avg_;
int32_t max_;
int32_t peak_ = 0 ;
size_t peak_duration_ = 0 ;
bool pitch_rssi_enabled = false;
bool vertical_rssi_enabled = false; // scale [vertically/from bottom to top]
// instead of [horizontally/from left to right]
bool peak_enabled = false;
size_t peak_duration = 1000; // peak duration in msec before being reset to actual max_rssi
RSSI(Rect parent_rect, bool instant_exec); // instant_exec: Execute on_select when you touching instead of releasing
RSSI(
Rect parent_rect
) : RSSI { parent_rect, false }
{
}
MessageHandlerRegistration message_handler_stats {
Message::ID::RSSIStatistics,
[this](const Message* const p) {
this->on_statistics_update(static_cast<const RSSIStatisticsMessage*>(p)->statistics);
}
};
MessageHandlerRegistration message_handler_pitch_rssi {
Message::ID::PitchRSSIConfigure,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const PitchRSSIConfigureMessage*>(p);
this->set_pitch_rssi(message.enabled);
}
};
RSSI(
) : RSSI { { }, { } }
{
}
void on_statistics_update(const RSSIStatistics& statistics);
void set_pitch_rssi(bool enabled);
};
int16_t get_min();
int16_t get_avg();
int16_t get_max();
int16_t get_delta();
void set_vertical_rssi(bool enabled);
void set_peak(bool enabled, size_t duration);
struct RSSIGraph_entry {
int32_t rssi_min { 0 };
int32_t rssi_avg { 0 };
int32_t rssi_max { 0 };
int32_t db { 0 };
};
void paint(Painter& painter) override;
void on_focus() override;
bool on_key(const KeyEvent key) override;
bool on_touch(const TouchEvent event) override;
using RSSIGraphList = std::vector<RSSIGraph_entry>;
private:
int16_t min_ = 0;
int16_t avg_ = 0;
int16_t max_ = 0;
int16_t peak_ = 0 ;
size_t peak_duration_ = 0 ;
bool instant_exec_ { false };
class RSSIGraph : public Widget {
public:
RSSIGraph(
const Rect parent_rect
) : Widget { parent_rect }
{
}
void paint(Painter& painter) override;
void add_values(int32_t rssi_min, int32_t rssi_avg, int32_t rssi_max, int32_t db );
private:
RSSIGraphList graph_list { } ;
};
bool pitch_rssi_enabled = false;
bool vertical_rssi_enabled = false; // scale [vertically/from bottom to top]
// instead of [horizontally/from left to right]
bool peak_enabled = false;
size_t peak_duration = 1000; // peak duration in msec before being reset to actual max_rssi
MessageHandlerRegistration message_handler_stats {
Message::ID::RSSIStatistics,
[this](const Message* const p) {
this->on_statistics_update(static_cast<const RSSIStatisticsMessage*>(p)->statistics);
}
};
MessageHandlerRegistration message_handler_pitch_rssi {
Message::ID::PitchRSSIConfigure,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const PitchRSSIConfigureMessage*>(p);
this->set_pitch_rssi(message.enabled);
}
};
void on_statistics_update(const RSSIStatistics& statistics);
void set_pitch_rssi(bool enabled);
};
struct RSSIGraph_entry {
int16_t rssi_min { 0 };
int16_t rssi_avg { 0 };
int16_t rssi_max { 0 };
int16_t db { 0 };
};
using RSSIGraphList = std::vector<RSSIGraph_entry>;
class RSSIGraph : public Widget {
public:
RSSIGraph(
const Rect parent_rect
) : Widget { parent_rect }
{
}
void paint(Painter& painter) override;
void add_values(int16_t rssi_min, int16_t rssi_avg, int16_t rssi_max, int16_t db );
void set_nb_columns( int16_t nb );
private:
uint16_t nb_columns = 16 ;
RSSIGraphList graph_list { } ;
};
}
+1 -1
View File
@@ -139,7 +139,7 @@ set(CPPSRC
audio_stats_collector.cpp
${COMMON}/utility.cpp
${COMMON}/chibios_cpp.cpp
${COMMON}/debug.cpp
debug.cpp
${COMMON}/gcc.cpp
tone_gen.cpp
)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Bernd Herzog
*
* This file is part of PortaPack.
*
@@ -26,60 +27,41 @@
#include "portapack_shared_memory.hpp"
#if defined(LPC43XX_M0)
static void debug_indicate_error_init() {
// TODO: Get knowledge of LED GPIO port/bit from shared place.
LPC_GPIO->CLR[2] = (1 << 2);
}
void write_m4_panic_msg(const char *panic_message, struct extctx *ctxp) {
if (ctxp == nullptr) {
shared_memory.bb_data.data[0] = 0;
}
else {
shared_memory.bb_data.data[0] = 1;
*((uint32_t *)&shared_memory.bb_data.data[4]) = SCB->CFSR;
memcpy(&shared_memory.bb_data.data[8], ctxp, sizeof(struct extctx));
}
static void debug_indicate_error_update() {
// Flash RX (yellow) LED to indicate baseband error.
// TODO: Get knowledge of LED GPIO port/bit from shared place.
LPC_GPIO->NOT[2] = (1 << 2);
}
#endif
#if defined(LPC43XX_M4)
static void debug_indicate_error_init() {
// TODO: Get knowledge of LED GPIO port/bit from shared place.
LPC_GPIO->CLR[2] = (1 << 8);
}
static void debug_indicate_error_update() {
// Flash TX (red) LED to indicate baseband error.
// TODO: Get knowledge of LED GPIO port/bit from shared place.
LPC_GPIO->NOT[2] = (1 << 8);
}
#endif
static void runtime_error() {
debug_indicate_error_init();
while(true) {
volatile size_t n = 1000000U;
while(n--);
debug_indicate_error_update();
for(size_t i=0; i<sizeof(shared_memory.m4_panic_msg); i++) {
if( *panic_message == 0 ) {
shared_memory.m4_panic_msg[i] = 0;
} else {
shared_memory.m4_panic_msg[i] = *(panic_message++);
}
}
}
extern "C" {
#if CH_DBG_ENABLED
void port_halt(void) {
// Copy debug panic message to M0 region.
const auto* p = dbg_panic_msg;
for(size_t i=0; i<sizeof(shared_memory.m4_panic_msg); i++) {
if( *p == 0 ) {
shared_memory.m4_panic_msg[i] = 0;
} else {
shared_memory.m4_panic_msg[i] = *(p++);
}
}
port_disable();
runtime_error();
}
#if defined(LPC43XX_M4)
if (dbg_panic_msg == nullptr)
dbg_panic_msg = "system halted";
write_m4_panic_msg(dbg_panic_msg, nullptr);
while (true) {
HALT_IF_DEBUGGING();
}
}
#endif
CH_IRQ_HANDLER(MemManageVector) {
#if CH_DBG_ENABLED
chDbgPanic("MemManage");
@@ -103,6 +85,36 @@ CH_IRQ_HANDLER(UsageFaultVector) {
chSysHalt();
#endif
}
CH_IRQ_HANDLER(HardFaultVector) {
#if CH_DBG_ENABLED
regarm_t _saved_lr;
asm volatile ("mov %0, lr" : "=r" (_saved_lr) : : "memory");
struct extctx *ctxp;
port_lock_from_isr();
if ((uint32_t)_saved_lr & 0x04)
ctxp = (struct extctx *)__get_PSP();
else
ctxp = (struct extctx *)__get_MSP();
volatile uint32_t stack_space_left = get_free_stack_space();
if (stack_space_left < 16)
write_m4_panic_msg("Stack Overflow", ctxp);
else write_m4_panic_msg("Hard Fault", ctxp);
port_disable();
while (true) {
HALT_IF_DEBUGGING();
}
#else
chSysHalt();
#endif
}
}
+46
View File
@@ -0,0 +1,46 @@
/*
* 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.
*/
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include <ch.h>
extern uint32_t __process_stack_base__;
extern uint32_t __process_stack_end__;
#define CRT0_STACKS_FILL_PATTERN 0x55555555
inline uint32_t get_free_stack_space(){
uint32_t *p;
for (p = &__process_stack_base__; *p == CRT0_STACKS_FILL_PATTERN && p < &__process_stack_end__; p++);
auto stack_space_left = p - &__process_stack_base__;
return stack_space_left;
}
#define HALT_IF_DEBUGGING() \
do { \
if ((*(volatile uint32_t *)0xE000EDF0) & (1 << 0)) { \
__asm__ __volatile__("bkpt 1"); \
} \
} while (0)
#endif/*__DEBUG_H__*/
+8 -2
View File
@@ -26,11 +26,17 @@
#include <ch.h>
void* operator new(size_t size) {
return chHeapAlloc(0x0, size);
void *p = chHeapAlloc(0x0, size);
if (p == nullptr)
chDbgPanic("Out of Memory");
return p;
}
void* operator new[](size_t size) {
return chHeapAlloc(0x0, size);
void *p = chHeapAlloc(0x0, size);
if (p == nullptr)
chDbgPanic("Out of Memory");
return p;
}
void operator delete(void* p) noexcept {