tm1637_embedded_hal::mappings

Function from_ascii_byte

source
pub const fn from_ascii_byte(byte: u8) -> u8
Available on crate feature mappings only.
Expand description

Converts an ASCII byte to a 7-segment display byte.

Unknown characters are converted to 0 (all segments off).

§Note

Rust strings are UTF-8 encoded, so what you see as a single character may be multiple bytes.

§Example

Display Err text on a 4-digit display:

let err = "Err".as_bytes().iter().copied().map(from_ascii_byte);
tm.write_segments_raw_iter(0, err).ok();