From 569015f44bdf294b91b0d1546c54d49e98cb461f Mon Sep 17 00:00:00 2001
From: Stephen D <webmaster@scd31.com>
Date: Sat, 23 Mar 2024 10:44:55 -0300
Subject: [PATCH] it works!

---
 src/keyboard.rs |  2 --
 src/main.rs     | 21 ++++++++++++---------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/keyboard.rs b/src/keyboard.rs
index 2a11aef..3da7f1a 100644
--- a/src/keyboard.rs
+++ b/src/keyboard.rs
@@ -176,8 +176,6 @@ impl<
                             is_shift_pressed(state),
                         );
                         rprint!("{}", keycode);
-                    } else {
-                        rprint!("\n({}, {})", x, y);
                     }
                 }
             }
diff --git a/src/main.rs b/src/main.rs
index a4a5ae2..e4cc6ba 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -28,7 +28,7 @@ mod app {
         text::{Baseline, Text},
         Drawable,
     };
-    use embedded_hal::PwmPin;
+    use embedded_hal::{digital::v2::OutputPin, PwmPin};
     use fugit::RateExtU32;
     use hal::{
         gpio::{
@@ -36,12 +36,12 @@ mod app {
                 Gpio0, Gpio1, Gpio12, Gpio13, Gpio14, Gpio15, Gpio16, Gpio18, Gpio2, Gpio23,
                 Gpio24, Gpio3, Gpio4, Gpio6, Gpio7, Gpio8,
             },
-            FunctionI2C, FunctionSio, FunctionSpi, Pin, PullDown, PullNone, PullUp, SioInput,
-            SioOutput,
+            FunctionI2C, FunctionSio, FunctionSpi, Pin, PinState, PullDown, PullNone, PullUp,
+            SioInput, SioOutput,
         },
         pac::{I2C1, SPI1},
         pwm::{self, Channel, FreeRunning, Pwm4, Pwm5, Slice},
-        spi,
+        reset, spi,
         timer::{monotonic::Monotonic, Timer},
         Clock, I2C,
     };
@@ -49,7 +49,6 @@ mod app {
     use mipidsi::{models::ST7789, Builder};
     use rp2040_hal::{self as hal, timer::Alarm0};
     use rtic_monotonics::rp2040::*;
-    use rtt_target::rprintln;
 
     const XTAL_FREQ_HZ: u32 = 12_000_000u32;
 
@@ -171,6 +170,8 @@ mod app {
 
         // let mut vibrator = pins.gpio9.into_push_pull_output();
 
+        let mut delay = Delay::new(ctx.core.SYST, clocks.system_clock.freq().to_Hz());
+
         // Display backlight
         let mut pwm = pwm_slices.pwm5;
         pwm.set_ph_correct();
@@ -180,7 +181,9 @@ mod app {
         display_bl.set_inverted();
 
         let tp_reset = pins.gpio3.into_push_pull_output();
-        let disp_reset = pins.gpio4.into_push_pull_output();
+        let mut disp_reset = pins.gpio4.into_push_pull_output_in_state(PinState::Low);
+        delay.delay_us(10);
+        disp_reset.set_high().unwrap();
 
         // Touchpad
         let sda_pin: Pin<_, FunctionI2C, PullUp> = pins.gpio18.reconfigure();
@@ -226,16 +229,15 @@ mod app {
         let spi = spi.init(
             &mut pac.RESETS,
             clocks.peripheral_clock.freq(),
-            8.MHz(),
+            60.MHz(),
             embedded_hal::spi::MODE_0,
         );
 
         let spi_cs = SPIInterface::new(spi, display_dc, display_cs);
 
-        let mut delay = Delay::new(ctx.core.SYST, clocks.system_clock.freq().to_Hz());
         let display = Builder::st7789(spi_cs)
             .with_display_size(320, 240)
-            .init(&mut delay, Some(disp_reset))
+            .init(&mut delay, None)
             .unwrap();
 
         display_update::spawn().unwrap();
@@ -310,6 +312,7 @@ mod app {
         *r %= 255;
         *g %= 255;
         *b %= 255;
+
         display.clear(Rgb565::new(*r, *g, *b)).unwrap();
 
         // Draw a smiley face with white eyes and a red mouth
-- 
GitLab