summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/alpine_cdc.c5
-rw-r--r--apps/plugins/battery_bench.c28
2 files changed, 25 insertions, 8 deletions
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c
index 134bb3dee6..65108680c6 100644
--- a/apps/plugins/alpine_cdc.c
+++ b/apps/plugins/alpine_cdc.c
@@ -1122,8 +1122,10 @@ void thread(void)
1122} 1122}
1123 1123
1124/* callback to end the TSR plugin, called before a new one gets loaded */ 1124/* callback to end the TSR plugin, called before a new one gets loaded */
1125void exit_tsr(void) 1125bool exit_tsr(bool reenter)
1126{ 1126{
1127 if (reenter)
1128 return false; /* dont let it start again */
1127 gTread.exiting = true; /* tell the thread to end */ 1129 gTread.exiting = true; /* tell the thread to end */
1128 while (!gTread.ended) /* wait until it did */ 1130 while (!gTread.ended) /* wait until it did */
1129 rb->yield(); 1131 rb->yield();
@@ -1133,6 +1135,7 @@ void exit_tsr(void)
1133 timer_set_mode(TM_OFF); /* timer interrupt off */ 1135 timer_set_mode(TM_OFF); /* timer interrupt off */
1134 1136
1135 sound_normal(); /* restore sound settings */ 1137 sound_normal(); /* restore sound settings */
1138 return true;
1136} 1139}
1137 1140
1138/****************** main ******************/ 1141/****************** main ******************/
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 75d5cbcabd..85d35b003e 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -92,7 +92,7 @@ PLUGIN_HEADER
92/****************************** Plugin Entry Point ****************************/ 92/****************************** Plugin Entry Point ****************************/
93static struct plugin_api* rb; 93static struct plugin_api* rb;
94int main(void); 94int main(void);
95void exit_tsr(void); 95bool exit_tsr(bool);
96void thread(void); 96void thread(void);
97 97
98 98
@@ -119,13 +119,27 @@ struct batt_info
119 119
120struct event_queue thread_q; 120struct event_queue thread_q;
121 121
122void exit_tsr(void) 122bool exit_tsr(bool reenter)
123{ 123{
124 rb->queue_post(&thread_q, EV_EXIT, NULL); 124 bool exit = true;
125 while (!s_thread.ended) 125 (void)reenter;
126 rb->yield(); 126 rb->lcd_clear_display();
127 /* remove the thread's queue from the broadcast list */ 127 rb->lcd_puts_scroll(0, 0, "Batt.Bench is currently running.");
128 rb->queue_delete(&thread_q); 128 rb->lcd_puts_scroll(0, 1, "Press OFF to cancel the test");
129 rb->lcd_puts_scroll(0, 2, "Anything else will resume");
130 rb->lcd_update();
131 if (rb->button_get(true) != BATTERY_OFF)
132 exit = false;
133 if (exit)
134 {
135 rb->queue_post(&thread_q, EV_EXIT, NULL);
136 while (!s_thread.ended)
137 rb->yield();
138 /* remove the thread's queue from the broadcast list */
139 rb->queue_delete(&thread_q);
140 return true;
141 }
142 else return false;
129} 143}
130 144
131#define BIT_CHARGER 0x1000 145#define BIT_CHARGER 0x1000