Show a black/white matrix Send everything in a single command
(serialdev: &str, matrix: &[[u8; 34]; 9])
| 779 | /// Show a black/white matrix |
| 780 | /// Send everything in a single command |
| 781 | fn render_matrix(serialdev: &str, matrix: &[[u8; 34]; 9]) { |
| 782 | // One bit for each LED, on or off |
| 783 | // 39 = ceil(34 * 9 / 8) |
| 784 | let mut vals: [u8; 39] = [0x00; 39]; |
| 785 | |
| 786 | for x in 0..9 { |
| 787 | for y in 0..34 { |
| 788 | let i = x + 9 * y; |
| 789 | if matrix[x][y] == 0xFF { |
| 790 | vals[i / 8] |= 1 << (i % 8); |
| 791 | } |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | simple_cmd(serialdev, Command::DisplayBwImage, &vals); |
| 796 | } |
| 797 | |
| 798 | /// Render the current time and display. |
| 799 | /// Loops forever, updating every second |