Initializes the LCD.
(&mut self)
| 288 | |
| 289 | /// Initializes the LCD. |
| 290 | fn lcd_init(&mut self) -> io::Result<()> { |
| 291 | let mut pins = self.pins.lock().unwrap(); |
| 292 | |
| 293 | // I'm not sure what this does. This does not have an effect on Linux but |
| 294 | // setting this to high on NetBSD causes the LCD to remain lit up. |
| 295 | pins.write(OUTPUT_PIN_CS, false)?; |
| 296 | |
| 297 | pins.write(OUTPUT_PIN_BL, true)?; |
| 298 | |
| 299 | Self::lcd_reset(&mut *pins)?; |
| 300 | Self::lcd_init_reg(&mut *pins, &mut self.spi_bus)?; |
| 301 | |
| 302 | Self::lcd_set_gram_scan_way(&mut *pins, &mut self.spi_bus)?; |
| 303 | std::thread::sleep(Duration::from_millis(200)); |
| 304 | |
| 305 | Self::lcd_write_reg(&mut *pins, &mut self.spi_bus, &[0x11])?; |
| 306 | std::thread::sleep(Duration::from_millis(200)); |
| 307 | |
| 308 | // Turn display on. |
| 309 | Self::lcd_write_reg(&mut *pins, &mut self.spi_bus, &[0x29])?; |
| 310 | |
| 311 | Ok(()) |
| 312 | } |
| 313 | |
| 314 | /// Configures the LCD so that the next write, which carries pixel data, affects the specified |
| 315 | /// region. |