Skip to content

Commit

Permalink
Debug rotary encoder ticks
Browse files Browse the repository at this point in the history
  • Loading branch information
goodhoko committed Dec 11, 2023
1 parent 8554094 commit 64b0e28
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ license = "MIT"
edition = "2018"

[dependencies]
arrayvec = { version = "0.5.2", default-features = false }
stm32f4xx-hal = { version = "0.9", features = ["rt", "stm32f411", "usb_fs"] }
embedded-hal = "0.2"
cortex-m = "0.7"
Expand Down
4 changes: 4 additions & 0 deletions src/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ impl<PINS> Counter<PINS> {
None
}
}

pub fn current_count(&self) -> u16 {
self.qei.count()
}
}
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use crate::{
rgb_led::{LedStrip, Pulser},
serial::{Command, Report, SerialProtocol},
};
use arrayvec::ArrayString;
use core::fmt::Write;
use cortex_m_rt::entry;
use embedded_hal::digital::v2::OutputPin;
use hal::{
Expand Down Expand Up @@ -184,6 +186,10 @@ fn main() -> ! {
_ => {},
}

let mut buf = ArrayString::<[u8; 256]>::new();
write!(&mut buf, "count: {}", counter.current_count()).expect("can write count");
protocol.debug(buf.as_str());

if let Some(diff) = counter.poll() {
if !encoder_button.is_pressed() {
protocol.report(Report::DialValue { diff }).unwrap();
Expand Down

0 comments on commit 64b0e28

Please sign in to comment.