From a2e5d9563f9dec84907f4f2060af6dfad895c4ba Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Mon, 20 Mar 2023 22:15:33 -0400 Subject: [Feature] resume TSR plugins after interruption WIP save tsr plugin path for later resume tsr plugin when user stops the interrupting plugin expand return of tsr_exit function to allow continue, suspend, terminate tsr plugins check parameter at start to determine if the plugin is being resumed Change-Id: I6fc70de664c7771e7dbc9a1af7a831e7b50b1d15 --- apps/plugins/test_usb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'apps/plugins/test_usb.c') diff --git a/apps/plugins/test_usb.c b/apps/plugins/test_usb.c index 6bb77c40be..28ef8f7e5f 100644 --- a/apps/plugins/test_usb.c +++ b/apps/plugins/test_usb.c @@ -85,7 +85,7 @@ static void kill_tsr(void) rb->queue_delete(&queue); } -static bool exit_tsr(bool reenter) +static int exit_tsr(bool reenter) { MENUITEM_STRINGLIST(menu, "USB test menu", NULL, "Status", "Stop plugin", "Back"); @@ -100,9 +100,9 @@ static bool exit_tsr(bool reenter) case 1: rb->splashf(HZ, "Stopping USB test thread"); kill_tsr(); - return true; + return (reenter ? PLUGIN_TSR_TERMINATE : PLUGIN_TSR_SUSPEND); case 2: - return false; + return PLUGIN_TSR_CONTINUE; } } } @@ -119,14 +119,15 @@ static void run_tsr(void) enum plugin_status plugin_start(const void* parameter) { - (void)parameter; + bool resume = (parameter == rb->plugin_tsr); + MENUITEM_STRINGLIST(menu, "USB test menu", NULL, "Start", "Quit"); - switch(rb->do_menu(&menu, NULL, NULL, false)) { + switch(!resume ? rb->do_menu(&menu, NULL, NULL, false) : 0) { case 0: run_tsr(); - rb->splashf(HZ, "Thread started"); + rb->splashf(HZ, "USB test thread started"); return PLUGIN_OK; case 1: return PLUGIN_OK; -- cgit v1.2.3