diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2020-06-28 16:42:21 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2020-06-28 16:42:21 +0200 |
commit | 5d1cff57f9f5acd740a8b5f8c941beefdcc00176 (patch) | |
tree | bdfd0e394d6333aead7d3a0295ba3457bd68275d /sw/deps/hd44780-driver/examples/raspberrypi/src | |
parent | 93220f99a52dc93f9a2d5b11074f60156ef70210 (diff) | |
download | picardy-5d1cff57f9f5acd740a8b5f8c941beefdcc00176.tar.gz picardy-5d1cff57f9f5acd740a8b5f8c941beefdcc00176.tar.bz2 picardy-5d1cff57f9f5acd740a8b5f8c941beefdcc00176.zip |
sw: configure si5351
Diffstat (limited to 'sw/deps/hd44780-driver/examples/raspberrypi/src')
-rw-r--r-- | sw/deps/hd44780-driver/examples/raspberrypi/src/main.rs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/sw/deps/hd44780-driver/examples/raspberrypi/src/main.rs b/sw/deps/hd44780-driver/examples/raspberrypi/src/main.rs new file mode 100644 index 0000000..2fefcbe --- /dev/null +++ b/sw/deps/hd44780-driver/examples/raspberrypi/src/main.rs @@ -0,0 +1,75 @@ +extern crate linux_embedded_hal; +extern crate hd44780_driver; + +use linux_embedded_hal::{Delay, Pin}; +use linux_embedded_hal::sysfs_gpio::Direction; + +use hd44780_driver::{HD44780, DisplayMode, Cursor, CursorBlink, Display}; + +fn main() { + + let rs = Pin::new(26); + let en = Pin::new(22); + + let db0 = Pin::new(19); + let db1 = Pin::new(13); + let db2 = Pin::new(6); + let db3 = Pin::new(5); + let db4 = Pin::new(21); + let db5 = Pin::new(20); + let db6 = Pin::new(16); + let db7 = Pin::new(12); + + rs.export().unwrap(); + en.export().unwrap(); + + db0.export().unwrap(); + db1.export().unwrap(); + db2.export().unwrap(); + db3.export().unwrap(); + db4.export().unwrap(); + db5.export().unwrap(); + db6.export().unwrap(); + db7.export().unwrap(); + + rs.set_direction(Direction::Low).unwrap(); + en.set_direction(Direction::Low).unwrap(); + + db0.set_direction(Direction::Low).unwrap(); + db1.set_direction(Direction::Low).unwrap(); + db2.set_direction(Direction::Low).unwrap(); + db3.set_direction(Direction::Low).unwrap(); + db4.set_direction(Direction::Low).unwrap(); + db5.set_direction(Direction::Low).unwrap(); + db6.set_direction(Direction::Low).unwrap(); + db7.set_direction(Direction::Low).unwrap(); + + let mut lcd = HD44780::new_8bit( + rs, + en, + db0, + db1, + db2, + db3, + db4, + db5, + db6, + db7, + Delay, + ); + + lcd.reset(); + + lcd.clear(); + + lcd.set_display_mode( + DisplayMode { + display: Display::On, + cursor_visibility: Cursor::Visible, + cursor_blink: CursorBlink::On, + } + ); + + lcd.write_str("Hello, world!"); + +} |