diff options
author | Romain Porte <microjoe@microjoe.org> | 2020-01-11 12:34:49 +0100 |
---|---|---|
committer | Romain Porte <microjoe@microjoe.org> | 2020-02-08 12:26:23 +0100 |
commit | 7be6f770263b4a3bbaab32ab4aa7d88ca43089fa (patch) | |
tree | 05e915d5303b5744cb107c0904ce2ff3aa79d7b4 /examples/all_methods.rs | |
download | charlcd-7be6f770263b4a3bbaab32ab4aa7d88ca43089fa.tar.gz charlcd-7be6f770263b4a3bbaab32ab4aa7d88ca43089fa.zip |
initial version
Diffstat (limited to 'examples/all_methods.rs')
-rw-r--r-- | examples/all_methods.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/examples/all_methods.rs b/examples/all_methods.rs new file mode 100644 index 0000000..2052469 --- /dev/null +++ b/examples/all_methods.rs @@ -0,0 +1,49 @@ +use std::io::Write; + +use std::{thread, time}; + +use charlcd::Screen; + +macro_rules! test_method { + ($screen: ident, $method:ident) => { + $screen.clear()?; + $screen.flush()?; + $screen.write(stringify!($method).as_bytes())?; + $screen.write(b"..")?; + $screen.flush()?; + + thread::sleep(time::Duration::from_secs(2)); + + $screen.$method()?; + $screen.write(b"ok")?; + $screen.flush()?; + + thread::sleep(time::Duration::from_secs(2)); + }; +} + +fn main() -> std::io::Result<()> { + let mut screen = Screen::default()?; + + test_method!(screen, reinit); + test_method!(screen, display_off); + test_method!(screen, display_on); + test_method!(screen, backlight_on); + test_method!(screen, backlight_off); + test_method!(screen, cursor_off); + test_method!(screen, cursor_on); + test_method!(screen, blink_on); + test_method!(screen, blink_off); + test_method!(screen, shift_cursor_left); + test_method!(screen, shift_cursor_right); + test_method!(screen, shift_display_left); + test_method!(screen, kill_eol); + test_method!(screen, shift_display_right); + test_method!(screen, one_line); + test_method!(screen, two_lines); + + // reinit everything back after the test + test_method!(screen, reinit); + + Ok(()) +} |