From d835ad91a35afd4aa01a07a6907b846d5a32323d Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 12 Mar 2016 20:08:08 +0200 Subject: Resend the keyboard state every ms In case there's some errors on the link, and the packet gets lost --- serial_link/system/system.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'serial_link/system/system.c') diff --git a/serial_link/system/system.c b/serial_link/system/system.c index 9e4ee5d95e..efd0991e9c 100644 --- a/serial_link/system/system.c +++ b/serial_link/system/system.c @@ -140,13 +140,6 @@ void init_serial_link(void) { void matrix_set_remote(matrix_row_t* rows, uint8_t index); void serial_link_update(void) { - systime_t current_time = chVTGetSystemTimeX(); - if (current_time - last_update > 1000) { - *begin_write_serial_link_connected() = true; - end_write_serial_link_connected(); - last_update = current_time; - } - if (read_serial_link_connected()) { serial_link_connected = true; } @@ -157,13 +150,19 @@ void serial_link_update(void) { matrix.rows[i] = matrix_get_row(i); changed |= matrix.rows[i] != last_matrix.rows[i]; } - if (changed) { + + systime_t current_time = chVTGetSystemTimeX(); + systime_t delta = current_time - last_update; + if (changed || delta > US2ST(1000)) { + last_update = current_time; last_matrix = matrix; matrix_object_t* m = begin_write_keyboard_matrix(); for(uint8_t i=0;irows[i] = matrix.rows[i]; } end_write_keyboard_matrix(); + *begin_write_serial_link_connected() = true; + end_write_serial_link_connected(); } matrix_object_t* m = read_keyboard_matrix(0); -- cgit v1.2.3