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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use tiny_led_matrix::{Frame, Matrix, RowPlan};
use crate::display::display_port::pin_constants::{MATRIX_COLS, MATRIX_ROWS};
pub struct MicrobitMatrix ();
const MICROBIT_LED_LAYOUT: [[Option<(usize, usize)>; 3]; 9] = [
[Some((0, 0)), Some((4, 2)), Some((2, 4))],
[Some((2, 0)), Some((0, 2)), Some((4, 4))],
[Some((4, 0)), Some((2, 2)), Some((0, 4))],
[Some((4, 3)), Some((1, 0)), Some((0, 1))],
[Some((3, 3)), Some((3, 0)), Some((1, 1))],
[Some((2, 3)), Some((3, 4)), Some((2, 1))],
[Some((1, 3)), Some((1, 4)), Some((3, 1))],
[Some((0, 3)), None, Some((4, 1))],
[Some((1, 2)), None, Some((3, 2))],
];
impl Matrix for MicrobitMatrix {
const MATRIX_COLS: usize = MATRIX_COLS;
const MATRIX_ROWS: usize = MATRIX_ROWS;
const IMAGE_COLS: usize = 5;
const IMAGE_ROWS: usize = 5;
fn image_coordinates(col: usize, row: usize) -> Option<(usize, usize)> {
MICROBIT_LED_LAYOUT[col][row]
}
}
#[derive(Copy, Clone, Debug)]
pub struct MicrobitFrame (
[RowPlan; MicrobitFrame::ROWS]
);
impl MicrobitFrame {
pub const fn const_default() -> MicrobitFrame {
MicrobitFrame([RowPlan::default(); MicrobitFrame::ROWS])
}
}
impl Default for MicrobitFrame {
fn default() -> MicrobitFrame {
MicrobitFrame::const_default()
}
}
impl Frame for MicrobitFrame {
type Mtx = MicrobitMatrix;
fn row_plan(&self, row: usize) -> &RowPlan {
&self.0[row]
}
fn row_plan_mut(&mut self, row: usize) -> &mut RowPlan {
&mut self.0[row]
}
}