Added SD card wiper tool

Frequency manager now creates FREQMAN.TXT if not found
Moved graphics files
This commit is contained in:
furrtek 2017-01-10 18:40:33 +00:00
parent a0469d709d
commit 3ec725c172
46 changed files with 157 additions and 51 deletions

View File

@ -174,7 +174,7 @@ set(CPPSRC
ui_record_view.cpp
ui_rssi.cpp
ui_sd_card_status_view.cpp
ui_sd_card_debug.cpp
# ui_sd_card_debug.cpp
ui_setup.cpp
ui_soundboard.cpp
ui_spectrum.cpp

View File

@ -4811,33 +4811,6 @@ ui_rssi.cpp.s:
cd /home/furrtek/portapack-hackrf && $(MAKE) -f firmware/application/CMakeFiles/application.elf.dir/build.make firmware/application/CMakeFiles/application.elf.dir/ui_rssi.cpp.s
.PHONY : ui_rssi.cpp.s
ui_sd_card_debug.obj: ui_sd_card_debug.cpp.obj
.PHONY : ui_sd_card_debug.obj
# target to build an object file
ui_sd_card_debug.cpp.obj:
cd /home/furrtek/portapack-hackrf && $(MAKE) -f firmware/application/CMakeFiles/application.elf.dir/build.make firmware/application/CMakeFiles/application.elf.dir/ui_sd_card_debug.cpp.obj
.PHONY : ui_sd_card_debug.cpp.obj
ui_sd_card_debug.i: ui_sd_card_debug.cpp.i
.PHONY : ui_sd_card_debug.i
# target to preprocess a source file
ui_sd_card_debug.cpp.i:
cd /home/furrtek/portapack-hackrf && $(MAKE) -f firmware/application/CMakeFiles/application.elf.dir/build.make firmware/application/CMakeFiles/application.elf.dir/ui_sd_card_debug.cpp.i
.PHONY : ui_sd_card_debug.cpp.i
ui_sd_card_debug.s: ui_sd_card_debug.cpp.s
.PHONY : ui_sd_card_debug.s
# target to generate assembly for a file
ui_sd_card_debug.cpp.s:
cd /home/furrtek/portapack-hackrf && $(MAKE) -f firmware/application/CMakeFiles/application.elf.dir/build.make firmware/application/CMakeFiles/application.elf.dir/ui_sd_card_debug.cpp.s
.PHONY : ui_sd_card_debug.cpp.s
ui_sd_card_status_view.obj: ui_sd_card_status_view.cpp.obj
.PHONY : ui_sd_card_status_view.obj
@ -5610,9 +5583,6 @@ help:
@echo "... ui_rssi.obj"
@echo "... ui_rssi.i"
@echo "... ui_rssi.s"
@echo "... ui_sd_card_debug.obj"
@echo "... ui_sd_card_debug.i"
@echo "... ui_sd_card_debug.s"
@echo "... ui_sd_card_status_view.obj"
@echo "... ui_sd_card_status_view.i"
@echo "... ui_sd_card_status_view.s"

View File

@ -74,8 +74,7 @@ bool save_freqman_file(std::vector<freqman_entry> &frequencies) {
size_t n;
std::string item_string;
auto result = freqs_file.create("freqman.txt");
if (result.is_valid()) return false;
if (!create_freqman_file(freqs_file)) return false;
for (n = 0; n < frequencies.size(); n++) {
item_string = "f=" + to_string_dec_uint(frequencies[n].value);
@ -89,6 +88,13 @@ bool save_freqman_file(std::vector<freqman_entry> &frequencies) {
return true;
}
bool create_freqman_file(File &freqs_file) {
auto result = freqs_file.create("freqman.txt");
if (result.is_valid()) return false;
return true;
}
std::string freqman_item_string(freqman_entry &entry) {
std::string item_string, frequency_str, description;
char temp_buffer[32];

View File

@ -39,6 +39,7 @@ struct freqman_entry {
bool load_freqman_file(std::vector<freqman_entry> &frequencies);
bool save_freqman_file(std::vector<freqman_entry> &frequencies);
bool create_freqman_file(File &freqs_file);
std::string freqman_item_string(freqman_entry &frequencies);
#endif/*__FREQMAN_H__*/

View File

@ -26,7 +26,7 @@
//TEST: Imperial in whipcalc
//TEST: Numbers
//TEST: Jammer
//TEST: Frequency manager + save/load
//TODO: Frequency manager auto-remove duplicates
//TODO: "TX box" view or composite widget with frequency and bw settings, simple and advanced setup TX buttons...
//TODO: Morse coder for foxhunts
@ -57,7 +57,6 @@
//TODO: CTCSS detector
//TODO: DMR detector
//TODO: SD card wiper
//TODO: GSM channel detector
//TODO: SIGFOX RX/TX
//TODO: Bodet :)

View File

@ -27,14 +27,14 @@
namespace sd_card {
FATFS fs;
namespace {
bool card_present = false;
Status status_ { Status::NotPresent };
FATFS fs;
FRESULT mount() {
return f_mount(&fs, "", 0);
}

View File

@ -24,9 +24,12 @@
#include <cstdint>
#include "ff.h"
#include "signal.hpp"
namespace sd_card {
extern FATFS fs;
enum class Status : int32_t {
IOError = -3,

View File

@ -28,7 +28,7 @@
#include "audio.hpp"
#include "ui_sd_card_debug.hpp"
// #include "ui_sd_card_debug.hpp"
namespace ui {
@ -271,10 +271,10 @@ DebugPeripheralsMenuView::DebugPeripheralsMenuView(NavigationView& nav) {
/* DebugMenuView *********************************************************/
DebugMenuView::DebugMenuView(NavigationView& nav) {
add_items<5>({ {
add_items<4>({ {
{ "Memory", ui::Color::white(), nullptr, [&nav](){ nav.push<DebugMemoryView>(); } },
{ "Radio State", ui::Color::white(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } },
{ "SD Card", ui::Color::white(), nullptr, [&nav](){ nav.push<SDCardDebugView>(); } },
//{ "SD Card", ui::Color::white(), nullptr, [&nav](){ nav.push<SDCardDebugView>(); } },
{ "Peripherals", ui::Color::white(), nullptr, [&nav](){ nav.push<DebugPeripheralsMenuView>(); } },
{ "Temperature", ui::Color::white(), nullptr, [&nav](){ nav.push<TemperatureView>(); } },
} });

View File

@ -65,7 +65,11 @@ FrequencySaveView::FrequencySaveView(
) : nav_ (nav),
value_ (value)
{
error = !load_freqman_file(frequencies);
File freqs_file;
if (!load_freqman_file(frequencies)) {
if (!create_freqman_file(freqs_file)) error = true;
}
signal_token_tick_second = time::signal_tick_second += [this]() {
this->on_tick_second();

View File

@ -317,10 +317,11 @@ TransmitterAudioMenuView::TransmitterAudioMenuView(NavigationView& nav) {
/* UtilitiesView *****************************************************************/
UtilitiesView::UtilitiesView(NavigationView& nav) {
add_items<3>({ {
{ "Frequency manager", ui::Color::red(), nullptr, [&nav](){ nav.push<FreqManView>(); } },
{ "Whip antenna length", ui::Color::green(), nullptr, [&nav](){ nav.push<WhipCalcView>(); } },
add_items<4>({ {
{ "Frequency manager", ui::Color::green(), nullptr, [&nav](){ nav.push<FreqManView>(); } },
{ "Whip antenna length", ui::Color::yellow(),nullptr, [&nav](){ nav.push<WhipCalcView>(); } },
{ "Notepad", ui::Color::grey(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } },
{ "Wipe SD card", ui::Color::red(), nullptr, [&nav](){ nav.push<WipeSDView>(); } },
} });
on_left = [&nav](){ nav.pop(); };
}
@ -348,7 +349,7 @@ SystemMenuView::SystemMenuView(NavigationView& nav) {
{ "Utilities", ui::Color::purple(),nullptr, [&nav](){ nav.push<UtilitiesView>(); } },
//{ "Analyze", ui::Color::white(), [&nav](){ nav.push<NotImplementedView>(); } },
{ "Setup", ui::Color::white(), nullptr, [&nav](){ nav.push<SetupMenuView>(); } },
//{ "Debug", ui::Color::white(), [&nav](){ nav.push<DebugMenuView>(); } },
//{ "Debug", ui::Color::white(), nullptr, [&nav](){ nav.push<DebugMenuView>(); } },
{ "HackRF mode", ui::Color::white(), &bitmap_icon_hackrf, [this, &nav](){ hackrf_mode(nav); } },
{ "About", ui::Color::white(), nullptr, [&nav](){ nav.push<AboutView>(); } }
} });
@ -433,6 +434,45 @@ void BMPView::paint(Painter&) {
portapack::display.drawBMP({(240 - 185) / 2, 0}, splash_bmp, false);
}
/* WipeSDView ************************************************************/
WipeSDView::WipeSDView(NavigationView& nav) : nav_ (nav) {
add_children({ {
&text_info,
&progress,
&dummy
} });
}
WipeSDView::~WipeSDView() {
if (thread) chThdTerminate(thread);
}
Thread* WipeSDView::thread { nullptr };
void WipeSDView::focus() {
BlockDeviceInfo block_device_info;
dummy.focus();
if (!confirmed) {
nav_.push<ModalMessageView>("Warning !", "Wipe first 32MB of SD card ?", YESCANCEL, [this](bool choice) {
if (choice)
confirmed = true;
}
);
} else {
if (sdcGetInfo(&SDCD1, &block_device_info) == CH_SUCCESS) {
blocks = 32; // Only erase first 32MB (block_device_info.blk_size * uint64_t(block_device_info.blk_num)) / (1024 * 1024);
progress.set_max(blocks);
thread = chThdCreateFromHeap(NULL, 2048, NORMALPRIO + 10, WipeSDView::static_fn, this);
} else {
nav_.pop(); // Just silently abort for now
}
}
}
/* PlayDeadView **********************************************************/
void PlayDeadView::focus() {
@ -450,6 +490,8 @@ void PlayDeadView::paint(Painter& painter) {
}
PlayDeadView::PlayDeadView(NavigationView& nav) {
rtc::RTC datetime;
portapack::persistent_memory::set_playing_dead(0x5920C1DF); // Enable
add_children({ {
@ -459,6 +501,10 @@ PlayDeadView::PlayDeadView(NavigationView& nav) {
&button_seq_entry,
} });
// Seed from RTC
rtcGetTime(&RTCD1, &datetime);
text_playdead2.set("0x" + to_string_hex(lfsr_iterate(datetime.second()), 6) + "00");
text_playdead3.hidden(true);
button_seq_entry.on_dir = [this](Button&, KeyEvent key){
@ -532,7 +578,21 @@ ModalMessageView::ModalMessageView(
if (on_choice_) on_choice_(false);
nav.pop();
};
} else {
} else if (type == YESCANCEL) {
add_children({ {
&button_yes,
&button_no
} });
button_yes.on_select = [this, &nav](Button&){
if (on_choice_) on_choice_(true);
nav.pop();
};
button_no.on_select = [this, &nav](Button&){
//if (on_choice_) on_choice_(false);
nav.pop_modal();
};
} else { // ABORT
add_child(&button_ok);
button_ok.on_select = [this, &nav](Button&){
@ -554,7 +614,7 @@ void ModalMessageView::paint(Painter&) {
}
void ModalMessageView::focus() {
if (type_ == YESNO) {
if ((type_ == YESNO) || (type_ == YESCANCEL)) {
button_yes.focus();
} else {
button_ok.focus();

View File

@ -34,15 +34,22 @@
#include "ui_sd_card_status_view.hpp"
#include "bitmap.hpp"
#include "ff.h"
#include "diskio.h"
#include "lfsr_random.hpp"
#include "sd_card.hpp"
#include <vector>
#include <utility>
using namespace sd_card;
namespace ui {
enum modal_t {
INFO = 0,
YESNO,
YESCANCEL,
ABORT
};
@ -167,6 +174,62 @@ private:
};
};
class WipeSDView : public View {
public:
WipeSDView(NavigationView& nav);
~WipeSDView();
void focus() override;
std::string title() const override { return "SD card wipe"; };
private:
NavigationView& nav_;
bool confirmed = false;
uint32_t blocks;
static Thread* thread;
static msg_t static_fn(void* arg) {
auto obj = static_cast<WipeSDView*>(arg);
obj->run();
return 0;
}
void run() {
uint32_t n, b;
lfsr_word_t v = 1;
const auto buffer = std::make_unique<std::array<uint8_t, 16384>>();
for (b = 0; b < blocks; b++) {
progress.set_value(b);
lfsr_fill(v,
reinterpret_cast<lfsr_word_t*>(buffer->data()),
sizeof(*buffer.get()) / sizeof(lfsr_word_t));
// 1MB
for (n = 0; n < 64; n++) {
if (disk_write(sd_card::fs.drv, buffer->data(), n + (b * 64), 16384 / 512) != RES_OK) nav_.pop();
}
}
nav_.pop();
}
Text text_info {
{ 10 * 8, 16 * 8, 10 * 8, 16 },
"Working..."
};
ProgressBar progress {
{ 2 * 8, 19 * 8, 26 * 8, 24 }
};
Button dummy {
{ 240, 0, 0, 0 },
""
};
};
class PlayDeadView : public View {
public:
PlayDeadView(NavigationView& nav);
@ -179,11 +242,11 @@ private:
Text text_playdead1 {
{ 6 * 8, 7 * 16, 14 * 8, 16 },
"Firmware error"
"\x46irmwa" "re " "er\x72o\x72"
};
Text text_playdead2 {
{ 6 * 8, 9 * 16, 16 * 8, 16 },
"0x1400_0000 : 2C"
""
};
Text text_playdead3 {
{ 6 * 8, 12 * 16, 16 * 8, 16 },

View File

@ -53,6 +53,7 @@ void NuoptixView::transmit(bool setup) {
uint8_t mod, tone_code;
uint8_t c;
uint8_t dtmf_message[6];
rtc::RTC datetime;
if (!tx_mode) {
transmitter_model.disable();

View File

@ -90,7 +90,6 @@ private:
void transmit(bool setup);
uint32_t timecode;
rtc::RTC datetime;
FrequencyField field_frequency {
{ 1 * 8, 4 },

View File

@ -459,7 +459,7 @@ void ProgressBar::set_value(const uint32_t value) {
}
void ProgressBar::paint(Painter& painter) {
uint16_t v_sized;
uint32_t v_sized;
const auto rect = screen_rect();
const auto s = style();

View File

Before

Width:  |  Height:  |  Size: 133 B

After

Width:  |  Height:  |  Size: 133 B

View File

Before

Width:  |  Height:  |  Size: 134 B

After

Width:  |  Height:  |  Size: 134 B

View File

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

View File

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 127 B

View File

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 145 B

View File

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 138 B

View File

Before

Width:  |  Height:  |  Size: 143 B

After

Width:  |  Height:  |  Size: 143 B

View File

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

View File

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

View File

Before

Width:  |  Height:  |  Size: 133 B

After

Width:  |  Height:  |  Size: 133 B

View File

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

View File

Before

Width:  |  Height:  |  Size: 114 B

After

Width:  |  Height:  |  Size: 114 B

View File

Before

Width:  |  Height:  |  Size: 135 B

After

Width:  |  Height:  |  Size: 135 B

View File

Before

Width:  |  Height:  |  Size: 117 B

After

Width:  |  Height:  |  Size: 117 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 129 B

After

Width:  |  Height:  |  Size: 129 B

View File

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 127 B

View File

Before

Width:  |  Height:  |  Size: 132 B

After

Width:  |  Height:  |  Size: 132 B

View File

Before

Width:  |  Height:  |  Size: 131 B

After

Width:  |  Height:  |  Size: 131 B

View File

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

View File

Before

Width:  |  Height:  |  Size: 112 B

After

Width:  |  Height:  |  Size: 112 B

View File

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 109 B

View File

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

View File

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

View File

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 522 B

View File

Before

Width:  |  Height:  |  Size: 478 B

After

Width:  |  Height:  |  Size: 478 B

View File

Before

Width:  |  Height:  |  Size: 510 B

After

Width:  |  Height:  |  Size: 510 B

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 830 B

After

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.