Frequency manager empty file bugfix

This commit is contained in:
furrtek 2017-01-30 01:09:00 +00:00
parent c8e71bcdee
commit 0642d633c3
15 changed files with 133 additions and 54 deletions

View File

@ -155,9 +155,11 @@ void set_adsb() {
send_message(&message); send_message(&message);
} }
void set_jammer(const bool run) { void set_jammer(const bool run, const uint32_t type, const uint32_t speed) {
const JammerConfigureMessage message { const JammerConfigureMessage message {
run run,
type,
speed
}; };
send_message(&message); send_message(&message);
} }

View File

@ -65,7 +65,7 @@ void set_ook_data(const uint32_t stream_length, const uint32_t samples_per_bit,
const uint32_t pause_symbols); const uint32_t pause_symbols);
void set_pocsag(const pocsag::BitRate bitrate); void set_pocsag(const pocsag::BitRate bitrate);
void set_adsb(); void set_adsb();
void set_jammer(const bool run); void set_jammer(const bool run, const uint32_t type, const uint32_t speed);
void set_rds_data(const uint16_t message_length); void set_rds_data(const uint16_t message_length);
//void set_dtmf_data(const uint32_t bw, const uint32_t tone_length, const uint32_t pause_length); //void set_dtmf_data(const uint32_t bw, const uint32_t tone_length, const uint32_t pause_length);

View File

@ -29,6 +29,30 @@ namespace ui {
// Use firmware/tools/make_bitmap.py ! // Use firmware/tools/make_bitmap.py !
static constexpr uint8_t bitmap_previous_data[] = {
0x00, 0x00,
0x00, 0x00,
0xE0, 0x03,
0x10, 0x03,
0x88, 0x01,
0xC4, 0x00,
0xE2, 0x3F,
0x01, 0x20,
0x01, 0x20,
0xE3, 0x3F,
0xC6, 0x3F,
0x8C, 0x00,
0x18, 0x01,
0xF0, 0x03,
0xE0, 0x03,
0x00, 0x00,
};
static constexpr Bitmap bitmap_previous {
{ 16, 16 }, bitmap_previous_data
};
static constexpr uint8_t bitmap_icon_adsb_data[] = { static constexpr uint8_t bitmap_icon_adsb_data[] = {
0x80, 0x01, 0x80, 0x01,
0xC0, 0x03, 0xC0, 0x03,

View File

@ -35,9 +35,8 @@ bool load_freqman_file(std::vector<freqman_entry> &frequencies) {
while (freqs_file.open("freqman.txt").is_valid()) { while (freqs_file.open("freqman.txt").is_valid()) {
auto result = freqs_file.create("freqman.txt"); auto result = freqs_file.create("freqman.txt");
if (result.is_valid()) { if (result.is_valid())
return false; return false;
}
} }
freqs_file.read(file_buffer, 2048); freqs_file.read(file_buffer, 2048);

View File

@ -31,6 +31,12 @@
using namespace ui; using namespace ui;
enum freqman_error {
NO_ERROR = 0,
ERROR_ACCESS,
ERROR_EMPTY
};
struct freqman_entry { struct freqman_entry {
rf::Frequency value; rf::Frequency value;
std::string frequency_str; std::string frequency_str;

View File

@ -36,16 +36,17 @@ void FrequencySaveView::on_save_name(NavigationView& nav) {
frequencies.push_back({ value_, "", desc_buffer }); frequencies.push_back({ value_, "", desc_buffer });
nav.pop(); nav.pop();
} }
void FrequencySaveView::on_save_timestamp(NavigationView& nav) { void FrequencySaveView::on_save_timestamp(NavigationView& nav) {
frequencies.push_back({ value_, "", str_timestamp }); frequencies.push_back({ value_, "", str_timestamp });
nav.pop(); nav.pop();
} }
void FrequencySaveView::focus() { void FrequencySaveView::focus() {
button_save_timestamp.focus(); if (error == ERROR_ACCESS)
nav_.display_modal("Error", "File acces error", ABORT, nullptr);
if (error) else
nav_.display_modal("Error", "File acces error !", ABORT, nullptr); button_save_timestamp.focus();
} }
void FrequencySaveView::on_tick_second() { void FrequencySaveView::on_tick_second() {
@ -69,7 +70,10 @@ FrequencySaveView::FrequencySaveView(
File freqs_file; File freqs_file;
if (!load_freqman_file(frequencies)) { if (!load_freqman_file(frequencies)) {
if (!create_freqman_file(freqs_file)) error = true; if (!create_freqman_file(freqs_file)) {
error = ERROR_ACCESS;
return;
}
} }
signal_token_tick_second = rtc_time::signal_tick_second += [this]() { signal_token_tick_second = rtc_time::signal_tick_second += [this]() {
@ -119,17 +123,27 @@ void FrequencyLoadView::on_frequency_select() {
} }
void FrequencyLoadView::focus() { void FrequencyLoadView::focus() {
menu_view.focus(); if (error == ERROR_ACCESS)
nav_.display_modal("Error", "File acces error", ABORT, nullptr);
if (error) else if (error == ERROR_EMPTY)
nav_.display_modal("Error", "File acces error !", ABORT, nullptr); nav_.display_modal("Error", "Frequency DB empty", ABORT, nullptr);
else
menu_view.focus();
} }
FrequencyLoadView::FrequencyLoadView( FrequencyLoadView::FrequencyLoadView(
NavigationView& nav NavigationView& nav
) : nav_ (nav) ) : nav_ (nav)
{ {
error = !load_freqman_file(frequencies); if (!load_freqman_file(frequencies)) {
error = ERROR_ACCESS;
return;
}
if (frequencies.size() == 0) {
error = ERROR_EMPTY;
return;
}
add_children({ add_children({
&menu_view, &menu_view,
@ -181,10 +195,12 @@ void FreqManView::setup_list() {
} }
void FreqManView::focus() { void FreqManView::focus() {
menu_view.focus(); if (error == ERROR_ACCESS)
nav_.display_modal("Error", "File acces error", ABORT, nullptr);
if (error) else if (error == ERROR_EMPTY)
nav_.display_modal("Error", "File acces error !", ABORT, nullptr); nav_.display_modal("Error", "Frequency DB empty", ABORT, nullptr);
else
menu_view.focus();
} }
FreqManView::~FreqManView() { FreqManView::~FreqManView() {
@ -195,7 +211,15 @@ FreqManView::FreqManView(
NavigationView& nav NavigationView& nav
) : nav_ (nav) ) : nav_ (nav)
{ {
error = !load_freqman_file(frequencies); if (!load_freqman_file(frequencies)) {
error = ERROR_ACCESS;
return;
}
if (frequencies.size() == 0) {
error = ERROR_EMPTY;
return;
}
add_children({ add_children({
&menu_view, &menu_view,
@ -231,7 +255,6 @@ FreqManView::FreqManView(
button_exit.on_select = [this, &nav](Button&) { button_exit.on_select = [this, &nav](Button&) {
nav.pop(); nav.pop();
}; };
} }
} }

View File

@ -43,19 +43,19 @@ public:
private: private:
NavigationView& nav_; NavigationView& nav_;
bool error = false; freqman_error error { NO_ERROR };
char desc_buffer[32] = { 0 }; char desc_buffer[32] = { 0 };
rtc::RTC datetime; rtc::RTC datetime { };
rf::Frequency value_; rf::Frequency value_ { };
std::string str_timestamp { }; std::string str_timestamp { };
void on_save_name(NavigationView& nav); void on_save_name(NavigationView& nav);
void on_save_timestamp(NavigationView& nav); void on_save_timestamp(NavigationView& nav);
void on_tick_second(); void on_tick_second();
std::vector<freqman_entry> frequencies; std::vector<freqman_entry> frequencies { };
SignalToken signal_token_tick_second; SignalToken signal_token_tick_second { };
BigFrequency big_display { BigFrequency big_display {
{ 4, 2 * 16, 28 * 8, 32 }, { 4, 2 * 16, 28 * 8, 32 },
@ -87,7 +87,7 @@ private:
class FrequencyLoadView : public View { class FrequencyLoadView : public View {
public: public:
std::function<void(rf::Frequency)> on_changed; std::function<void(rf::Frequency)> on_changed { };
FrequencyLoadView(NavigationView& nav); FrequencyLoadView(NavigationView& nav);
@ -97,14 +97,14 @@ public:
private: private:
NavigationView& nav_; NavigationView& nav_;
bool error = false; freqman_error error { NO_ERROR };
void on_frequency_select(); void on_frequency_select();
void setup_list(); void setup_list();
std::vector<freqman_entry> frequencies; std::vector<freqman_entry> frequencies { };
MenuView menu_view; MenuView menu_view { };
Button button_cancel { Button button_cancel {
{ 72, 264, 96, 32 }, { 72, 264, 96, 32 },
@ -123,7 +123,8 @@ public:
private: private:
NavigationView& nav_; NavigationView& nav_;
bool error = false;
freqman_error error { NO_ERROR };
void on_frequency_select(); void on_frequency_select();
void on_edit_freq(rf::Frequency f); void on_edit_freq(rf::Frequency f);
@ -131,7 +132,7 @@ private:
void on_delete(); void on_delete();
void setup_list(); void setup_list();
std::vector<freqman_entry> frequencies; std::vector<freqman_entry> frequencies { };
MenuView menu_view { true }; MenuView menu_view { true };

View File

@ -230,7 +230,7 @@ JammerView::JammerView(NavigationView& nav) {
button_transmit.set_text("START"); button_transmit.set_text("START");
transmitter_model.disable(); transmitter_model.disable();
radio::disable(); radio::disable();
baseband::set_jammer(false); baseband::set_jammer(false, 0, 0);
jamming = false; jamming = false;
} else { } else {
@ -297,7 +297,7 @@ JammerView::JammerView(NavigationView& nav) {
transmitter_model.set_tx_gain(47); transmitter_model.set_tx_gain(47);
transmitter_model.enable(); transmitter_model.enable();
baseband::set_jammer(true); baseband::set_jammer(true, options_type.selected_index(), options_speed.selected_index());
} else { } else {
nav.display_modal("Error", "Jamming bandwidth too large."); nav.display_modal("Error", "Jamming bandwidth too large.");
} }

View File

@ -68,7 +68,14 @@ namespace ui {
/* SystemStatusView ******************************************************/ /* SystemStatusView ******************************************************/
SystemStatusView::SystemStatusView() { SystemStatusView::SystemStatusView() {
static constexpr Style style_systemstatus {
.font = font::fixed_8x16,
.background = Color::dark_grey(),
.foreground = Color::white(),
};
add_children({ add_children({
&backdrop,
&button_back, &button_back,
&title, &title,
&button_stealth, &button_stealth,
@ -78,6 +85,8 @@ SystemStatusView::SystemStatusView() {
&sd_card_status_view, &sd_card_status_view,
}); });
title.set_style(&style_systemstatus);
if (!portapack::persistent_memory::ui_config_textentry()) if (!portapack::persistent_memory::ui_config_textentry())
button_textentry.set_bitmap(&bitmap_keyboard); button_textentry.set_bitmap(&bitmap_keyboard);
else else
@ -86,7 +95,7 @@ SystemStatusView::SystemStatusView() {
if (portapack::persistent_memory::stealth_mode()) if (portapack::persistent_memory::stealth_mode())
button_stealth.set_foreground(ui::Color::green()); button_stealth.set_foreground(ui::Color::green());
button_back.on_select = [this](Button&){ button_back.on_select = [this](ImageButton&){
if (this->on_back) if (this->on_back)
this->on_back(); this->on_back();
}; };
@ -110,7 +119,7 @@ SystemStatusView::SystemStatusView() {
} }
void SystemStatusView::set_back_enabled(bool new_value) { void SystemStatusView::set_back_enabled(bool new_value) {
//button_back.set_text(new_value ? back_text_enabled : back_text_disabled); button_back.set_foreground(new_value ? Color::white() : Color::dark_grey());
button_back.set_focusable(new_value); button_back.set_focusable(new_value);
} }

View File

@ -64,12 +64,17 @@ public:
private: private:
static constexpr auto default_title = "PortaPack|Havoc"; static constexpr auto default_title = "PortaPack|Havoc";
//static constexpr auto back_text_enabled = " < ";
//static constexpr auto back_text_disabled = " * ";
Button button_back { Rectangle backdrop {
{ 0 * 8, 0 * 16, 240, 16 },
Color::dark_grey()
};
ImageButton button_back {
{ 0 * 8, 0 * 16, 16, 16 }, { 0 * 8, 0 * 16, 16, 16 },
"", //back_text_disabled, &bitmap_previous,
Color::white(),
Color::dark_grey()
}; };
Text title { Text title {
@ -81,28 +86,28 @@ private:
{ 152, 0, 2 * 8, 1 * 16 }, { 152, 0, 2 * 8, 1 * 16 },
&bitmap_stealth, &bitmap_stealth,
Color::light_grey(), Color::light_grey(),
Color::black() Color::dark_grey()
}; };
ImageButton button_textentry { ImageButton button_textentry {
{ 170, 0, 2 * 8, 1 * 16 }, { 170, 0, 2 * 8, 1 * 16 },
&bitmap_unistroke, &bitmap_unistroke,
Color::white(), Color::white(),
Color::black() Color::dark_grey()
}; };
ImageButton button_camera { ImageButton button_camera {
{ 188, 0, 2 * 8, 1 * 16 }, { 188, 0, 2 * 8, 1 * 16 },
&bitmap_camera, &bitmap_camera,
Color::white(), Color::white(),
Color::black() Color::dark_grey()
}; };
ImageButton button_sleep { ImageButton button_sleep {
{ 206, 0, 2 * 8, 1 * 16 }, { 206, 0, 2 * 8, 1 * 16 },
&bitmap_sleep, &bitmap_sleep,
Color::white(), Color::white(),
Color::black() Color::dark_grey()
}; };
SDCardStatusView sd_card_status_view { SDCardStatusView sd_card_status_view {

View File

@ -83,7 +83,7 @@ const Color color_sd_card(const sd_card::Status status) {
SDCardStatusView::SDCardStatusView( SDCardStatusView::SDCardStatusView(
const Rect parent_rect const Rect parent_rect
) : Image { parent_rect, &bitmap_sd_card_unknown, detail::color_sd_card_unknown, Color::black() } ) : Image { parent_rect, &bitmap_sd_card_unknown, detail::color_sd_card_unknown, Color::dark_grey() }
{ {
} }

View File

@ -63,25 +63,25 @@ void JammerProcessor::execute(const buffer_c8_t& buffer) {
// Phase noise // Phase noise
if (r >= 10) { if (r >= 10) {
aphase += ((aphase>>4) ^ 0x4573) << 14; aphase += ((aphase >> 4) ^ 0x4573) << 20;
r = 0; r = 0;
} else { } else {
r++; r++;
} }
aphase += 8830; aphase += 8830;
sample = sine_table_i8[(aphase & 0x03FC0000) >> 18]; sample = sine_table_i8[(aphase & 0xFF000000) >> 24];
// FM // FM
delta = sample * jammer_bw; delta = sample * jammer_bw;
phase += delta; phase += delta;
sphase = phase + (64 << 18); sphase = phase + (64 << 24);
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]); re = (sine_table_i8[(sphase & 0xFF000000) >> 24]);
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]); im = (sine_table_i8[(phase & 0xFF000000) >> 24]);
buffer.p[i] = {(int8_t)re, (int8_t)im}; buffer.p[i] = {re, im};
} }
}; };
@ -91,6 +91,8 @@ void JammerProcessor::on_message(const Message* const msg) {
if (message.id == Message::ID::JammerConfigure) { if (message.id == Message::ID::JammerConfigure) {
if (message.run) { if (message.run) {
jammer_channels = (JammerChannel*)shared_memory.bb_data.data; jammer_channels = (JammerChannel*)shared_memory.bb_data.data;
noise_type = message.type;
noise_speed = message.speed;
jammer_duration = 0; jammer_duration = 0;
current_range = 0; current_range = 0;

View File

@ -40,6 +40,8 @@ private:
JammerChannel * jammer_channels { }; JammerChannel * jammer_channels { };
uint32_t noise_type { 0 };
uint32_t noise_speed { 0 };
uint32_t jammer_duration { 0 }; uint32_t jammer_duration { 0 };
int8_t r { 0 }, ir { 0 }; int8_t r { 0 }, ir { 0 };
uint32_t current_range { 0 }; uint32_t current_range { 0 };
@ -47,7 +49,7 @@ private:
uint32_t sample_count { 0 }; uint32_t sample_count { 0 };
uint32_t aphase { 0 }, phase { 0 }, delta { 0 }, sphase { 0 }; uint32_t aphase { 0 }, phase { 0 }, delta { 0 }, sphase { 0 };
int32_t sample { 0 }, jammer_bw { 0 }; int32_t sample { 0 }, jammer_bw { 0 };
int8_t re, im; int8_t re { 0 }, im { 0 };
RetuneMessage message { }; RetuneMessage message { };
}; };

View File

@ -706,13 +706,19 @@ public:
class JammerConfigureMessage : public Message { class JammerConfigureMessage : public Message {
public: public:
constexpr JammerConfigureMessage( constexpr JammerConfigureMessage(
const bool run const bool run,
const uint32_t type,
const uint32_t speed
) : Message { ID::JammerConfigure }, ) : Message { ID::JammerConfigure },
run(run) run(run),
type(type),
speed(speed)
{ {
} }
const bool run; const bool run;
const uint32_t type;
const uint32_t speed;
}; };
class DTMFTXConfigMessage : public Message { class DTMFTXConfigMessage : public Message {

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B