kbd_task: Get timestamp after mutex to avoid getting incorrect timestamp

on mutex blocking
replace/3bec061257ad9e14fa034ed6108c9e81691386ab
Federico Amedeo Izzo 2020-12-19 15:45:42 +01:00
rodzic 8d55a3e702
commit ce09f2c208
1 zmienionych plików z 1 dodań i 1 usunięć

Wyświetl plik

@ -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)
{