From ae1dc0adf8cd803e23dfe7d9f9fc457ed296e376 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Tue, 27 May 2025 04:53:56 +0200 Subject: [PATCH] talk: Keep UI responsive when spelling out long strings Commit 3b1230b ensured that strings exceeding QUEUE_SIZE were spelled out completely, but also resulted in the UI becoming unresponsive. We now check for any button presses, and truncate the spelled-out string in that case. Change-Id: Ibbd4f630cb5b88c9c133fdaf3a591e1a38f61e82 --- apps/talk.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/talk.c b/apps/talk.c index 38e9cb264c..f2df5bfd45 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -752,6 +752,7 @@ static void do_enqueue(bool enqueue) static int _talk_spell(const char* spell, size_t len, bool enqueue) { char c; /* currently processed char */ + int button = BUTTON_NONE; if (talk_is_disabled()) return -1; @@ -780,8 +781,15 @@ static int _talk_spell(const char* spell, size_t len, bool enqueue) else if (c == PATH_SEPCH) talk_id(VOICE_CHAR_SLASH, true); - while (QUEUE_LEVEL == QUEUE_SIZE - 1) /* queue full - busy loop */ - yield(); + + if (QUEUE_LEVEL == QUEUE_SIZE - 1) + button = button_get(false); /* prevent UI unresponsiveness */ + + if (button == BUTTON_NONE || IS_SYSEVENT(button)) + while (QUEUE_LEVEL == QUEUE_SIZE - 1) /* queue full - busy loop */ + yield(); + else + return 0; /* truncate spelled-out string */ } return 0; }