mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-13 01:59:29 +00:00
Fix sd_over_usb serial command (#3015)
This commit is contained in:
@@ -105,26 +105,23 @@ static void cmd_sd_over_usb(BaseSequentialStream* chp, int argc, char* argv[]) {
|
|||||||
(void)chp;
|
(void)chp;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
auto evtd = getEventDispatcherInstance();
|
||||||
ui::Painter painter;
|
if (!evtd) return;
|
||||||
painter.fill_rectangle(
|
auto top_widget = evtd->getTopWidget();
|
||||||
{0, 0, portapack::display.width(), portapack::display.height()},
|
if (!top_widget) return;
|
||||||
Theme::getInstance()->fg_yellow->background);
|
auto nav = static_cast<ui::SystemView*>(top_widget)->get_navigation_view();
|
||||||
|
if (!nav) return;
|
||||||
painter.draw_bitmap(
|
nav->home(false);
|
||||||
{portapack::display.width() / 2 - 8, portapack::display.height() / 2 - 8},
|
std::string appwithpath = "/" + apps_dir.string() + "/";
|
||||||
ui::bitmap_icon_hackrf,
|
appwithpath += "sdusb.ppma";
|
||||||
Theme::getInstance()->fg_yellow->foreground,
|
bool ret = ui::ExternalItemsMenuLoader::run_external_app(*nav, path_from_string8((char*)appwithpath.c_str()));
|
||||||
Theme::getInstance()->fg_yellow->background);
|
if (ret) {
|
||||||
|
chprintf(chp, "ok\r\n");
|
||||||
sdcDisconnect(&SDCD1);
|
} else {
|
||||||
sdcStop(&SDCD1);
|
chprintf(chp, "Failed to start SD over USB\r\n");
|
||||||
|
}
|
||||||
m4_request_shutdown();
|
evtd->wait_finish_frame();
|
||||||
chThdSleepMilliseconds(50);
|
evtd->emulateKeyboard('\n');
|
||||||
portapack::shutdown(true);
|
|
||||||
m4_init(portapack::spi_flash::image_tag_usb_sd, portapack::memory::map::m4_code, false);
|
|
||||||
m0_halt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool strEndsWith(const std::u16string& str, const std::u16string& suffix) {
|
bool strEndsWith(const std::u16string& str, const std::u16string& suffix) {
|
||||||
|
|||||||
Reference in New Issue
Block a user