summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAgathe Porte <microjoe@microjoe.org>2020-01-11 12:34:49 +0100
committerAgathe Porte <microjoe@microjoe.org>2020-02-08 12:26:23 +0100
commit61a61f3907e802f0be9bc0039a84ebaabba7b372 (patch)
tree02fdc99a4a88858ed522727efb1f3a508fc081a1 /examples
downloadcharlcd-61a61f3907e802f0be9bc0039a84ebaabba7b372.tar.gz
charlcd-61a61f3907e802f0be9bc0039a84ebaabba7b372.zip
initial version
Diffstat (limited to 'examples')
-rw-r--r--examples/all_methods.rs49
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(())
+}