MCPcopy Index your code
hub / github.com/FrameworkComputer/inputmodule-rs / render_matrix

Function render_matrix

inputmodule-control/src/inputmodule.rs:781–796  ·  view source on GitHub ↗

Show a black/white matrix Send everything in a single command

(serialdev: &str, matrix: &[[u8; 34]; 9])

Source from the content-addressed store, hash-verified

779/// Show a black/white matrix
780/// Send everything in a single command
781fn 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

Callers 1

eq_cmdFunction · 0.70

Calls 1

simple_cmdFunction · 0.85

Tested by

no test coverage detected