mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-09-22 05:54:37 -04:00
Frequency manager empty file bugfix
This commit is contained in:
parent
c8e71bcdee
commit
0642d633c3
15 changed files with 133 additions and 54 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() }
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue