mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-12 01:29:29 +00:00
proper fix for flasher (#3223)
This commit is contained in:
@@ -134,12 +134,6 @@ bool FlashUtilityView::endsWith(const std::u16string& str, const std::u16string&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlashUtilityView::wait_till_loaded() {
|
|
||||||
while (!isLoaded) {
|
|
||||||
chThdSleepMilliseconds(50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::string_type path, ui::Painter& painter) {
|
std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::string_type path, ui::Painter& painter) {
|
||||||
//
|
//
|
||||||
painter.fill_rectangle(
|
painter.fill_rectangle(
|
||||||
@@ -157,6 +151,7 @@ std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::strin
|
|||||||
|
|
||||||
bool FlashUtilityView::flash_firmware(std::filesystem::path::string_type path) {
|
bool FlashUtilityView::flash_firmware(std::filesystem::path::string_type path) {
|
||||||
ui::Painter painter;
|
ui::Painter painter;
|
||||||
|
menu_view.hidden(true);
|
||||||
if (endsWith(path, u".tar")) {
|
if (endsWith(path, u".tar")) {
|
||||||
// extract, then update
|
// extract, then update
|
||||||
path = extract_tar(u'/' + path, painter).native();
|
path = extract_tar(u'/' + path, painter).native();
|
||||||
@@ -166,6 +161,7 @@ bool FlashUtilityView::flash_firmware(std::filesystem::path::string_type path) {
|
|||||||
painter.fill_rectangle({0, 50, portapack::display.width(), 90}, Theme::getInstance()->bg_darkest->background);
|
painter.fill_rectangle({0, 50, portapack::display.width(), 90}, Theme::getInstance()->bg_darkest->background);
|
||||||
painter.draw_string({0, 60}, *Theme::getInstance()->fg_red, "BAD FIRMWARE FILE OR W/R ERR");
|
painter.draw_string({0, 60}, *Theme::getInstance()->fg_red, "BAD FIRMWARE FILE OR W/R ERR");
|
||||||
chThdSleepMilliseconds(5000);
|
chThdSleepMilliseconds(5000);
|
||||||
|
menu_view.hidden(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
painter.fill_rectangle(
|
painter.fill_rectangle(
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ class FlashUtilityView : public View {
|
|||||||
|
|
||||||
std::string title() const override { return "Flash Utility"; };
|
std::string title() const override { return "Flash Utility"; };
|
||||||
bool flash_firmware(std::filesystem::path::string_type path);
|
bool flash_firmware(std::filesystem::path::string_type path);
|
||||||
void wait_till_loaded();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NavigationView& nav_;
|
NavigationView& nav_;
|
||||||
@@ -68,14 +67,6 @@ class FlashUtilityView : public View {
|
|||||||
void firmware_selected(std::filesystem::path::string_type path);
|
void firmware_selected(std::filesystem::path::string_type path);
|
||||||
|
|
||||||
bool endsWith(const std::u16string& str, const std::u16string& suffix);
|
bool endsWith(const std::u16string& str, const std::u16string& suffix);
|
||||||
bool isLoaded = false;
|
|
||||||
uint8_t refreshcnt = 0;
|
|
||||||
MessageHandlerRegistration message_handler_frame_sync{
|
|
||||||
Message::ID::DisplayFrameSync,
|
|
||||||
[this](const Message* const) {
|
|
||||||
refreshcnt++;
|
|
||||||
if (refreshcnt > 5) isLoaded = true;
|
|
||||||
}};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
|||||||
@@ -157,8 +157,7 @@ static void cmd_flash(BaseSequentialStream* chp, int argc, char* argv[]) {
|
|||||||
// call nav with flash
|
// call nav with flash
|
||||||
auto open_view = nav->push<ui::FlashUtilityView>();
|
auto open_view = nav->push<ui::FlashUtilityView>();
|
||||||
chprintf(chp, "Flashing started\r\n");
|
chprintf(chp, "Flashing started\r\n");
|
||||||
chThdSleepMilliseconds(150); // to give display some time to paint the screen
|
chThdSleepMilliseconds(150); // to give display some time to paint the screen
|
||||||
open_view->wait_till_loaded(); // also wait for first frame sync
|
|
||||||
if (!open_view->flash_firmware(path.native())) {
|
if (!open_view->flash_firmware(path.native())) {
|
||||||
chprintf(chp, "error\r\n");
|
chprintf(chp, "error\r\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user