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
61
62
63
64
use enum_map::{enum_map, Enum, EnumMap};
pub type SymbolIndex = u8;
#[derive(Debug, Enum)]
pub enum Symbol {
Antenna,
Battery,
BoxDrawningLightUp,
VeclocityVector,
Alpha,
Square,
LineTop,
LineUpper1,
LineUpper2,
LineCenter,
LineLower1,
LineLower2,
LineBottom,
LineLeft,
LineLeft1,
LineVerticalCenter,
LineRight1,
LineRight,
ZeroWithTraillingDot,
}
pub fn to_number_with_dot(byte: u8, zero_with_trailling_dot: SymbolIndex) -> u8 {
if b'0' <= byte && byte <= b'9' {
if zero_with_trailling_dot > b'0' {
byte + (zero_with_trailling_dot - b'0')
} else {
byte - (b'0' - zero_with_trailling_dot)
}
} else {
zero_with_trailling_dot
}
}
pub type SymbolTable = EnumMap<Symbol, SymbolIndex>;
pub fn default_symbol_table() -> SymbolTable {
enum_map! {
Symbol::Antenna => 1,
Symbol::Battery => 2,
Symbol::BoxDrawningLightUp => 3,
Symbol::VeclocityVector => 4,
Symbol::Alpha => 5,
Symbol::Square => 6,
Symbol::LineTop => 128,
Symbol::LineUpper1 => 129,
Symbol::LineUpper2 => 130,
Symbol::LineCenter => 131,
Symbol::LineLower1 => 132,
Symbol::LineLower2 => 133,
Symbol::LineBottom => 134,
Symbol::LineLeft => 135,
Symbol::LineLeft1 => 136,
Symbol::LineVerticalCenter => 137,
Symbol::LineRight1 => 138,
Symbol::LineRight => 139,
Symbol::ZeroWithTraillingDot => 144,
}
}