From b85c491f76e2d5e903fd2a1ad64c98f3d815f53a Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Tue, 16 Sep 2025 13:58:57 -1000 Subject: [PATCH 1/2] Report key presses in more detail --- ui-app/src/lib.rs | 15 ++++++++++----- ui-app/tests/integration.rs | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ui-app/src/lib.rs b/ui-app/src/lib.rs index 7711a94..2fb09fc 100644 --- a/ui-app/src/lib.rs +++ b/ui-app/src/lib.rs @@ -1,6 +1,7 @@ #![no_std] -use bitmap_font::{TextStyle, tamzen::FONT_14x26}; +use bitmap_font::{tamzen::FONT_14x26, TextStyle}; +use core::fmt::Write; use defmt::Format; use embedded_graphics::{ draw_target::DrawTarget, @@ -277,12 +278,16 @@ impl App { } }, - Event::KeyDown(_key, _value) => { - out.log("key down"); + Event::KeyDown(key, value) => { + let mut msg: heapless::String<64> = Default::default(); + write!(&mut msg, "key down: {:?} {:?}", key, value).unwrap(); + out.log(&msg); } - Event::KeyUp(_key) => { - out.log("key up"); + Event::KeyUp(key) => { + let mut msg: heapless::String<64> = Default::default(); + write!(&mut msg, "key up: {:?}", key).unwrap(); + out.log(&msg); } Event::FromNet(from_net) => match from_net { diff --git a/ui-app/tests/integration.rs b/ui-app/tests/integration.rs index aa2b5d4..2d2ea32 100644 --- a/ui-app/tests/integration.rs +++ b/ui-app/tests/integration.rs @@ -146,10 +146,10 @@ fn key_logging() { assert_eq!(outputs.last_message, ""); app.handle(Event::KeyDown(Key::A, KeyValue::Char('a')), &mut outputs); - assert_eq!(outputs.last_message, "key down"); + assert_eq!(outputs.last_message, "key down: A Char('a')"); app.handle(Event::KeyUp(Key::A), &mut outputs); - assert_eq!(outputs.last_message, "key up"); + assert_eq!(outputs.last_message, "key up: A"); } #[test] From f1f6c0f7bd1500c955e1a8e04f912a31c967d2a7 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Tue, 16 Sep 2025 14:02:20 -1000 Subject: [PATCH 2/2] cargo fmt --- ui-app/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-app/src/lib.rs b/ui-app/src/lib.rs index 2fb09fc..858b3a8 100644 --- a/ui-app/src/lib.rs +++ b/ui-app/src/lib.rs @@ -1,6 +1,6 @@ #![no_std] -use bitmap_font::{tamzen::FONT_14x26, TextStyle}; +use bitmap_font::{TextStyle, tamzen::FONT_14x26}; use core::fmt::Write; use defmt::Format; use embedded_graphics::{