kbd_task: Get timestamp after mutex to avoid getting incorrect timestamp

on mutex blocking
This commit is contained in:
Federico Amedeo Izzo 2020-12-19 15:45:42 +01:00
parent 8d55a3e702
commit ce09f2c208
1 changed files with 1 additions and 1 deletions

View File

@ -170,11 +170,11 @@ static void kbd_task(void *arg)
// Reset flags and get current time
long_press = false;
send_event = false;
now = OSTimeGet(&os_err);
// Lock display mutex and read keyboard status
OSMutexPend(&display_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err);
keys = kbd_getKeys();
OSMutexPost(&display_mutex, OS_OPT_POST_NONE, &os_err);
now = OSTimeGet(&os_err);
// The key status has changed
if(keys != prev_keys)
{