Module formatters

Source
Available on crate feature formatters only.
Expand description

Format numbers into byte arrays.

Functions for converting numbers (i8s, i16s, i32s or f32s) into arrays of bytes that can be sent to a TM1637 display.

There are versions of these functions that are meant for 4-digit displays and for 6-digit displays. The 6-digit versions take into account that the order of the bytes does not drectly correlate with the order of the physical digits.

All numbers are aligned to the right.

§Example

tm.write_bytes_raw(0, i16_to_4digits(1234));

This module is only available when the formatters feature of this library is activated.

Functions§

celsius_to_4digits
Formats a i8 clamped between -9 and 99, appending the degrees symbol (°) and an uppercase C, for a 4-digit display.
clock_to_4digits
Formats two u8s between 0 and 99, with an optional colon between them.
degrees_to_4digits
Formats a i16 clamped between -99 and 999, appending the degrees symbol (°), for a 4-digit display.
f32_to_6digits
Formats a f32 with the given amount of decimal digits, for a 6-digit display.
i16_to_4digits
Formats a i16 clamped between -999 and 9999, for a 4-digit display.
i16_to_upsidedown_4digits
Formats a i16 clamped between -999 and 9999, for an upside-down 4-digit display.
i32_to_6digits
Formats a i32 clamped between -99999 and 999999, for a 6-digit display.