From 700bfcb4fd5f65068d6c98e6cfe182bd6aade7c8 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sun, 13 Oct 2024 21:51:34 -0400 Subject: [PATCH] feat: "optimize" scan (increase i2c speed) --- src/bin/piano_firmware.rs | 2 +- src/matrix.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/piano_firmware.rs b/src/bin/piano_firmware.rs index 2055aa0..605d350 100644 --- a/src/bin/piano_firmware.rs +++ b/src/bin/piano_firmware.rs @@ -465,7 +465,7 @@ async fn main(_spawner: Spawner) { let scl = p.PIN_17; let mut i2c_config = i2c::Config::default(); - let freq = 400_000; + let freq = 1_000_000; i2c_config.frequency = freq; let i2c = i2c::I2c::new_blocking(p.I2C0, scl, sda, i2c_config); diff --git a/src/matrix.rs b/src/matrix.rs index 8142d00..4226dd9 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -62,7 +62,7 @@ impl KeyMatrix { // scan frequency // this might(?) panic if the scan takes longer than the tick - let mut ticker = Ticker::every(Duration::from_millis(8)); + let mut ticker = Ticker::every(Duration::from_micros(3600)); let chan = midi::MidiChannel::new(0); const MAX_NOTES: usize = 128; @@ -80,7 +80,7 @@ impl KeyMatrix { loop { let profile: bool = counter == 0; counter += 1; - counter %= 50; + counter %= 500; let prof_start = Instant::now(); let mut prof_time_last_col = prof_start; let mut prof_dur_col = Duration::from_ticks(0);