(bytes: &[u8; DRAW_BYTES])
| 26 | >; |
| 27 | |
| 28 | pub fn draw(bytes: &[u8; DRAW_BYTES]) -> Grid { |
| 29 | let mut grid = Grid::default(); |
| 30 | |
| 31 | for y in 0..HEIGHT { |
| 32 | for x in 0..WIDTH { |
| 33 | let index = x + WIDTH * y; |
| 34 | let byte = index / 8; |
| 35 | let bit = index % 8; |
| 36 | let val = if bytes[byte] & (1 << bit) > 0 { |
| 37 | 0xFF |
| 38 | } else { |
| 39 | 0x00 |
| 40 | }; |
| 41 | grid.0[8 - x][y] = val; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | grid |
| 46 | } |
| 47 | |
| 48 | pub fn draw_grey_col(grid: &mut Grid, col: u8, levels: &[u8; HEIGHT]) { |
| 49 | // TODO: I don't think I need the [..HEIGHT] slicing |