firmware for my Touchscreen E-Paper Input Module for Framework Laptop 16
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

tp370pgh01: cache PSR fw16-epd-main: properly reset touch controller

+18 -2
+10 -2
fw16-epd-main/src/main.rs
··· 17 17 use embedded_graphics::prelude::*; 18 18 use embedded_graphics::primitives::{Line, PrimitiveStyle, PrimitiveStyleBuilder}; 19 19 use embedded_graphics::text::Text; 20 - use embedded_hal::digital::PinState; 20 + use embedded_hal::digital::{OutputPin, PinState}; 21 21 use embedded_hal::i2c::I2c; 22 22 use embedded_hal_bus::i2c::RefCellDevice; 23 23 use mcp9808::MCP9808; ··· 47 47 static GLOBAL_TOUCH_INT_PIN: Mutex<RefCell<Option<EpdTouchInt>>> = Mutex::new(RefCell::new(None)); 48 48 static GLOBAL_I2C: Mutex<RefCell<Option<I2C<I2C0, (I2CSda, I2CScl)>>>> = Mutex::new(RefCell::new(None)); 49 49 50 - static IMAGE_BUFFER: Mutex<RefCell<[u8; tp370pgh01::IMAGE_BYTES]>> = Mutex::new(RefCell::new([0; tp370pgh01::IMAGE_BYTES])); 50 + static IMAGE_BUFFER: Mutex<RefCell<[u8; IMAGE_BYTES]>> = Mutex::new(RefCell::new([0; tp370pgh01::IMAGE_BYTES])); 51 51 static DO_REFRESH: AtomicBool = AtomicBool::new(false); 52 52 static FAST_REFRESH: AtomicBool = AtomicBool::new(false); 53 53 static TEMP: AtomicU8 = AtomicU8::new(20); ··· 98 98 99 99 100 100 let _power = pins.epd_pwr_sw.into_push_pull_output_in_state(PinState::Low); 101 + 102 + let mut touch_reset = pins.epd_touch_rst.into_push_pull_output_in_state(PinState::High); 103 + cortex_m::asm::delay(120000); 104 + touch_reset.set_low().unwrap(); 105 + cortex_m::asm::delay(120000); 106 + touch_reset.set_high().unwrap(); 107 + cortex_m::asm::delay(1200000); 108 + 101 109 102 110 let cs: EpdCs = pins.spi3_epd_cs.reconfigure(); 103 111 let dc: EpdDc = pins.epd_dc.reconfigure();
+8
tp370pgh01/src/lib.rs
··· 63 63 busy: Busy, 64 64 reset: Reset, 65 65 delay: Delay, 66 + psr: Option<[u8; 2]>, 66 67 } 67 68 68 69 impl<Cs, Sda, Sck, Dc, Busy, Reset, Delay, SpiDelay, Error> ··· 108 109 busy, 109 110 reset, 110 111 delay, 112 + psr: None, 111 113 } 112 114 } 113 115 ··· 138 140 } 139 141 140 142 fn get_psr(&mut self) -> Result<[u8; 2], Tp370pgh01Error<Error>> { 143 + if let Some(psr) = self.psr { 144 + return Ok(psr); 145 + } 146 + 141 147 debug!("tp370pgh01: reading PSR"); 142 148 self.spi.write_register(&[0xa2])?; 143 149 let mut buf = [0u8; 2]; ··· 172 178 173 179 self.spi.read(&mut buf)?; 174 180 debug!("tp370pgh01: found PSR: {} {}", buf[0], buf[1]); 181 + 182 + self.psr.replace(buf); 175 183 176 184 Ok(buf) 177 185 }