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);
}
void set_jammer(const bool run) {
void set_jammer(const bool run, const uint32_t type, const uint32_t speed) {
const JammerConfigureMessage message {
run
run,
type,
speed
};
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);
void set_pocsag(const pocsag::BitRate bitrate);
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_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 !
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[] = {
0x80, 0x01,
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()) {
auto result = freqs_file.create("freqman.txt");
if (result.is_valid()) {
if (result.is_valid())
return false;
}
}
freqs_file.read(file_buffer, 2048);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -64,12 +64,17 @@ public:
private:
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 },
"", //back_text_disabled,
&bitmap_previous,
Color::white(),
Color::dark_grey()
};
Text title {
@ -81,28 +86,28 @@ private:
{ 152, 0, 2 * 8, 1 * 16 },
&bitmap_stealth,
Color::light_grey(),
Color::black()
Color::dark_grey()
};
ImageButton button_textentry {
{ 170, 0, 2 * 8, 1 * 16 },
&bitmap_unistroke,
Color::white(),
Color::black()
Color::dark_grey()
};
ImageButton button_camera {
{ 188, 0, 2 * 8, 1 * 16 },
&bitmap_camera,
Color::white(),
Color::black()
Color::dark_grey()
};
ImageButton button_sleep {
{ 206, 0, 2 * 8, 1 * 16 },
&bitmap_sleep,
Color::white(),
Color::black()
Color::dark_grey()
};
SDCardStatusView sd_card_status_view {

View File

@ -83,7 +83,7 @@ const Color color_sd_card(const sd_card::Status status) {
SDCardStatusView::SDCardStatusView(
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
if (r >= 10) {
aphase += ((aphase>>4) ^ 0x4573) << 14;
aphase += ((aphase >> 4) ^ 0x4573) << 20;
r = 0;
} else {
r++;
}
aphase += 8830;
sample = sine_table_i8[(aphase & 0x03FC0000) >> 18];
sample = sine_table_i8[(aphase & 0xFF000000) >> 24];
// FM
delta = sample * jammer_bw;
phase += delta;
sphase = phase + (64 << 18);
sphase = phase + (64 << 24);
re = (sine_table_i8[(sphase & 0x03FC0000) >> 18]);
im = (sine_table_i8[(phase & 0x03FC0000) >> 18]);
re = (sine_table_i8[(sphase & 0xFF000000) >> 24]);
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.run) {
jammer_channels = (JammerChannel*)shared_memory.bb_data.data;
noise_type = message.type;
noise_speed = message.speed;
jammer_duration = 0;
current_range = 0;

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B