summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorAgathe Porte <microjoe@microjoe.org>2020-02-08 14:28:16 +0100
committerAgathe Porte <microjoe@microjoe.org>2020-02-08 14:28:16 +0100
commit9b1f700dc54cd1eb6dc73e3260b2c284ec91cca4 (patch)
tree9d407e0c951d04578afc442723563d5cc78c7cb3 /src/lib.rs
parent61a61f3907e802f0be9bc0039a84ebaabba7b372 (diff)
downloadcharlcd-9b1f700dc54cd1eb6dc73e3260b2c284ec91cca4.tar.gz
charlcd-9b1f700dc54cd1eb6dc73e3260b2c284ec91cca4.zip
add width and height support (hack)
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f849712..0e32ee9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,5 @@
mod codes;
+mod of_node;
use std::fs::{File, OpenOptions};
use std::path::Path;
@@ -198,4 +199,30 @@ impl FileScreen {
pub fn default() -> std::io::Result<FileScreen> {
Screen::from_dev_path(&Path::new(DEFAULT_SCREEN_DEV_PATH))
}
+
+ /// Get the width of the screen, in number of characters it can display.
+ ///
+ /// **Important note:** The implementation behind this function is
+ /// currently a hack that will go find the value in the `auxdisplay`
+ /// platform device tree node in
+ /// `/sys/devices/platform/auxdisplay/of_node/*`. This is because the
+ /// `charlcd` driver does not export the screen width nor height to
+ /// userspace (could be using `ioctl` or `read` syscalls).
+ ///
+ pub fn width(&self) -> std::io::Result<u32> {
+ of_node::display_width_chars()
+ }
+
+ /// Get the height of the screen, in number of characters it can display.
+ ///
+ /// **Important note:** The implementation behind this function is
+ /// currently a hack that will go find the value in the `auxdisplay`
+ /// platform device tree node in
+ /// `/sys/devices/platform/auxdisplay/of_node/*`. This is because the
+ /// `charlcd` driver does not export the screen width nor height to
+ /// userspace (could be using `ioctl` or `read` syscalls).
+ ///
+ pub fn height(&self) -> std::io::Result<u32> {
+ of_node::display_height_chars()
+ }
}