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
This commit is contained in:
Christian Soffke 2025-05-27 04:53:56 +02:00 committed by Solomon Peachy
parent c51ca1eeb5
commit ae1dc0adf8

View file

@ -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;
}