Compare commits

..

1 commit

Author SHA1 Message Date
69d2c65076
refactor: lcd modern but still boom 2025-05-13 17:41:38 +02:00

View file

@ -1,8 +1,7 @@
#![no_main] #![no_main]
#![no_std] #![no_std]
use defmt::{debug, error, info, println, trace, warn}; use defmt::info;
use hal::pwm::Pin;
use panic_probe as _; use panic_probe as _;
use defmt_rtt as _; // global logger use defmt_rtt as _; // global logger
@ -12,7 +11,6 @@ use core::fmt::Write;
use cortex_m_rt::entry; use cortex_m_rt::entry;
use hal::{pac, prelude::*, rcc::Config}; use hal::{pac, prelude::*, rcc::Config};
use hd44780_driver::HD44780; use hd44780_driver::HD44780;
use heapless::Vec;
#[defmt::panic_handler] #[defmt::panic_handler]
fn panic() -> ! { fn panic() -> ! {
@ -30,10 +28,6 @@ fn main() -> ! {
let gpiob = dp.GPIOB.split(&mut rcc); let gpiob = dp.GPIOB.split(&mut rcc);
let gpioc = dp.GPIOC.split(&mut rcc); let gpioc = dp.GPIOC.split(&mut rcc);
// contrast over A0 analog port
// analog output seems to not be supported somehow?
let mut vO = gpioa.pa0.into_push_pull_output();
// literal D4-D7 ports etc as written on the nucleo board, mapped to the D4-D7 ports of the LCD // literal D4-D7 ports etc as written on the nucleo board, mapped to the D4-D7 ports of the LCD
// controller // controller
let d4 = gpiob.pb5.into_push_pull_output(); let d4 = gpiob.pb5.into_push_pull_output();
@ -41,10 +35,10 @@ fn main() -> ! {
let d6 = gpiob.pb10.into_push_pull_output(); let d6 = gpiob.pb10.into_push_pull_output();
let d7 = gpioa.pa8.into_push_pull_output(); let d7 = gpioa.pa8.into_push_pull_output();
// clock enable on D8 // clock enable on D9
let en = gpioa.pa9.into_push_pull_output(); let en = gpioc.pc7.into_push_pull_output();
// register select on D9, the lib wants that but I'd just put it on ground otherwise // register select on D8, the lib wants that but I'd just put it on ground otherwise
let rs = gpioc.pc7.into_push_pull_output(); let rs = gpioa.pa9.into_push_pull_output();
// See https://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller#Interface // See https://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller#Interface
// for the pins of the LCD // for the pins of the LCD
@ -69,7 +63,6 @@ fn main() -> ! {
let mut i = 0; let mut i = 0;
loop { loop {
vO.set_low().expect("set contrast low boom?");
led.set_high().unwrap(); led.set_high().unwrap();
info!("Writing to LCD..."); info!("Writing to LCD...");
lcd.write_str("Hello world!\nGoing on", &mut delay) lcd.write_str("Hello world!\nGoing on", &mut delay)