1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
mod pendolino;
use crate::graphics::image::BitImage;
pub const PRINTABLE_START: usize = 32;
pub const PRINTABLE_COUNT: usize = 95;
const UNKNOWN: BitImage = BitImage::new(&[
[1, 1, 1, 1, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 1, 1, 1, 1],
]);
pub fn character(index: u8) -> &'static BitImage {
let index = index as usize;
if index < PRINTABLE_START || index >= PRINTABLE_START + PRINTABLE_COUNT {
return &UNKNOWN;
}
&self::pendolino::PENDOLINO3[index - PRINTABLE_START]
}
const fn font_entry(data: [u8; 5]) -> BitImage {
const fn row_bits(byte: u8) -> [u8; 5] {[
((byte & 1<<4) != 0) as u8,
((byte & 1<<3) != 0) as u8,
((byte & 1<<2) != 0) as u8,
((byte & 1<<1) != 0) as u8,
((byte & 1<<0) != 0) as u8,
]};
BitImage::new(&[
row_bits(data[0]),
row_bits(data[1]),
row_bits(data[2]),
row_bits(data[3]),
row_bits(data[4]),
])
}