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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub enum Type {
Nspire,
NspireCX,
Future(u32),
}
pub fn hw_type() -> Type {
match unsafe { ndless_sys::hwtype() } {
0 => Type::Nspire,
1 => Type::NspireCX,
future => Type::Future(future),
}
}
pub fn hw_subtype() -> u32 {
unsafe { ndless_sys::nl_hwsubtype() }
}
pub fn is_classic() -> bool {
unsafe { ndless_sys::hwtype() < 1 }
}
pub fn is_cm() -> bool {
hw_subtype() == 1
}
pub fn has_colors() -> bool {
!is_classic()
}
pub fn has_touchpad() -> bool {
unsafe { ndless_sys::_is_touchpad() > 0 }
}
pub fn clear_cache() {
unsafe { ndless_sys::clear_cache() }
}
pub mod screen {
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub enum Screen {
Screen320x240x4,
Screen320x240x8,
Screen320x240x16,
Screen320x240x565,
Screen240x320x565,
Screen320x240x555,
Screen240x320x555,
Unknown,
}
pub fn lcd_type() -> Screen {
match unsafe { ndless_sys::lcd_type() } {
ndless_sys::scr_type_t_SCR_320x240_4 => Screen::Screen320x240x4,
ndless_sys::scr_type_t_SCR_320x240_8 => Screen::Screen320x240x8,
ndless_sys::scr_type_t_SCR_320x240_16 => Screen::Screen320x240x16,
ndless_sys::scr_type_t_SCR_320x240_565 => Screen::Screen320x240x565,
ndless_sys::scr_type_t_SCR_240x320_565 => Screen::Screen240x320x565,
ndless_sys::scr_type_t_SCR_320x240_555 => Screen::Screen320x240x555,
ndless_sys::scr_type_t_SCR_240x320_555 => Screen::Screen240x320x555,
_ => Screen::Unknown,
}
}
}