portapack-mayhem/firmware/application/ui_sd_wipe.cpp
furrtek fc8279aa30 POCSAG TX text and bitrate can be changed
Modal view message can be multiline now
2017-02-07 19:54:18 +00:00

65 lines
1.8 KiB
C++

/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* 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_sd_wipe.hpp"
namespace ui {
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\n(filesystem included) ?", 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
}
}
}
} /* namespace ui */