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
use super::*;
pub struct UnicodeDisplay {}
impl UnicodeDisplay {
pub fn new() -> UnicodeDisplay {
UnicodeDisplay {}
}
}
impl Display for UnicodeDisplay {
fn show(&mut self, buffer: &[Column]) -> Result<(), Error> {
print!("{}", termion::clear::All);
let col = &buffer[0];
println!("{}╔", termion::cursor::Goto(1, 1));
for y in 0..LED_ROWS {
println!("{}║", termion::cursor::Goto(1, y as u16 + 2));
}
println!("{}╚", termion::cursor::Goto(1, LED_ROWS as u16 + 2));
for x in 0..LED_COLUMNS {
println!("{}═", termion::cursor::Goto(x as u16 + 2, 1));
if let Some(ref col) = buffer.get(x) {
for y in 0..LED_ROWS {
let c = col[y];
let v = if c == 0 { '░' } else { '▓' };
println!("{}{}", termion::cursor::Goto(x as u16 + 2, y as u16 + 2), v);
}
} else {
for y in 0..LED_ROWS {
let v = '░';
println!("{}{}", termion::cursor::Goto(x as u16 + 2, y as u16 + 2), v);
}
}
println!(
"{}═",
termion::cursor::Goto(x as u16 + 2, LED_ROWS as u16 + 2)
);
}
println!("{}╗", termion::cursor::Goto(LED_COLUMNS as u16 + 1, 1));
for y in 0..LED_ROWS {
println!(
"{}║",
termion::cursor::Goto(LED_COLUMNS as u16 + 1, y as u16 + 2)
);
}
println!(
"{}╝",
termion::cursor::Goto(LED_COLUMNS as u16 + 1, col.len() as u16 + 2)
);
Ok(())
}
}