From 9b1f700dc54cd1eb6dc73e3260b2c284ec91cca4 Mon Sep 17 00:00:00 2001 From: Agathe Porte Date: Sat, 8 Feb 2020 14:28:16 +0100 Subject: add width and height support (hack) --- src/of_node.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/of_node.rs (limited to 'src/of_node.rs') diff --git a/src/of_node.rs b/src/of_node.rs new file mode 100644 index 0000000..5dff2a0 --- /dev/null +++ b/src/of_node.rs @@ -0,0 +1,24 @@ +// This module is a hack to read additional information in the DT nodes in the +// kernel to retrieve data that is currently not exposed in the charlcd.c +// driver. + +use std::fs::File; +use std::io::Result; + +use byteorder::{BigEndian, ReadBytesExt}; + +fn read_u32_node(node_name: &str) -> Result { + let mut f = File::open(format!( + "/sys/devices/platform/auxdisplay/of_node/{}", + node_name + ))?; + Ok(f.read_u32::()?) +} + +pub fn display_height_chars() -> Result { + read_u32_node("display-height-chars") +} + +pub fn display_width_chars() -> Result { + read_u32_node("display-width-chars") +} -- cgit v1.2.3