Layout
Convert a 5x5 array into a 3x9 array to match the display's circuitry.
# #![allow(unused_variables)] #fn main() { const LED_LAYOUT: [[(usize, usize); 5]; 5] = [ [(0, 0), (1, 3), (0, 1), (1, 4), (0, 2)], [(2, 3), (2, 4), (2, 5), (2, 6), (2, 7)], [(1, 1), (0, 8), (1, 2), (2, 8), (1, 0)], [(0, 7), (0, 6), (0, 5), (0, 4), (0, 3)], [(2, 2), (1, 6), (2, 0), (1, 5), (2, 1)], ]; /// Convert 5x5 display image to 3x9 matrix image pub fn display2matrix(led_display: [[u8; 5]; 5]) -> [[u8; 9]; 3] { // Create 3x9 array let mut led_matrix: [[u8; 9]; 3] = [[0; 9]; 3]; // Iterate through zip of input array and layout array for (led_display_row, layout_row) in led_display.iter().zip(LED_LAYOUT.iter()) { // Continue iterating through rows for (led_display_val, layout_loc) in led_display_row.iter().zip(layout_row) { // Assign dereferenced val to array led_matrix[layout_loc.0][layout_loc.1] = *led_display_val; } } return led_matrix; } #}