Skip to content

Commit 13d1cbd

Browse files
committed
fixup! keyboard: Implement reading of arrow keys
1 parent f1faa5b commit 13d1cbd

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

keyboard/src/main.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,30 @@ fn main() -> ! {
395395
let up = scanner.measure_key(1, 13);
396396
let down = scanner.measure_key(1, 8);
397397
let right = scanner.measure_key(2, 15);
398+
398399
let mut text: String<64> = String::new();
399400
write!(
400401
&mut text,
401-
"L:{}.{:0>4}V, R:{}.{:0>4}V, U:{}.{:0>4}V, D:{}.{:0>4}V\r\n",
402+
"L:{}.{:0>3}V, R:{}.{:0>3}V, U:{}.{:0>3}V, D:{}.{:0>3}V\r\n",
402403
left.0, left.1, right.0, right.1, up.0, up.1, down.0, down.1
403404
)
404405
.unwrap();
405406
let _ = serial.write(text.as_bytes());
406407

408+
let left_p = left.0 < 2 || (left.0 == 2 && left.1 < 290);
409+
let right_p = right.0 < 2 || (right.0 == 2 && right.1 < 290);
410+
let up_p = up.0 < 2 || (up.0 == 2 && up.1 < 290);
411+
let down_p = down.0 < 2 || (up.0 == 2 && down.1 < 290);
412+
413+
let mut text: String<64> = String::new();
414+
write!(
415+
&mut text,
416+
"L:{:5}, R:{:5}, U:{:5}, D:{:5}\r\n",
417+
left_p, right_p, up_p, down_p
418+
)
419+
.unwrap();
420+
let _ = serial.write(text.as_bytes());
421+
407422
animation_timer = timer.get_counter().ticks();
408423
}
409424

0 commit comments

Comments
 (0)