From a498332a7cac2f2db1eae735ad6197f7f7727ab5 Mon Sep 17 00:00:00 2001 From: Levi Pearson Date: Wed, 15 Apr 2020 21:21:30 -0600 Subject: [PATCH] Update to released EG versions and fix some bugs --- Cargo.toml | 4 ++-- src/main.rs | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c250ece..4df1e21 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ cortex-m-rt = "0.6.12" panic-halt = "0.2.0" embedded-hal = "0.2.3" nb = "0.1.2" -ssd1306 = "0.3.0-alpha.4" +ssd1306 = "0.3.1" switch-hal = "0.3.2" [dependencies.arrayvec] @@ -20,7 +20,7 @@ version = "0.5.1" default-features = false [dependencies.embedded-graphics] -version = "0.6.0-alpha.3" +version = "0.6.1" [dependencies.stm32f1] version = "0.10.0" diff --git a/src/main.rs b/src/main.rs index c2db462..2e8a66b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -152,9 +152,11 @@ fn main() -> ! { let mut cx = 20; let mut cy = 20; + let t = Text::new("Hello Rust!", Point::new(20, 16)) .into_styled(TextStyle::new(Font6x8, BinaryColor::On)); + // Very brief delay before the loop, just to show how delay.delay_us(10_u8); @@ -186,13 +188,13 @@ fn main() -> ! { .into_styled(TextStyle::new(Font6x8, BinaryColor::On)); display.clear(); - c.draw(&mut display); - t.draw(&mut display); - count.draw(&mut display); + c.draw(&mut display).unwrap(); + t.draw(&mut display).unwrap(); + count.draw(&mut display).unwrap(); display.flush().unwrap(); // Control the horizontal position with the knob - cx = counter.min(0).max(DISPLAY_W); + cx = counter.max(C_RADIUS/2).min(DISPLAY_W-C_RADIUS/2); // Wrap the ball back to the top when it falls off the bottom cy += 1; if cy > (DISPLAY_H + C_RADIUS) { cy = -C_RADIUS }; @@ -211,8 +213,8 @@ fn init_encoder_pins( clk.trigger_on_edge(exti, Edge::RISING_FALLING); clk.enable_interrupt(exti); - CLK_PIN.borrow(cs).replace(Some(clk)).unwrap(); - DT_PIN.borrow(cs).replace(Some(dt)).unwrap(); + CLK_PIN.borrow(cs).replace(Some(clk)); + DT_PIN.borrow(cs).replace(Some(dt)); }); }