1#![no_std]
2#![allow(non_upper_case_globals)]
3#![allow(non_camel_case_types)]
4#![allow(non_snake_case)]
5
6#[cfg(not(all(target_arch = "arm", target_os = "none")))]
7include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
8
9#[cfg(all(target_arch = "arm", target_os = "none"))]
10include!("./thumbv7em_bindings.rs");
11
12#[repr(transparent)]
13#[derive(Debug, PartialEq, Eq, Hash, Default)]
14pub struct LCDColor(u64);
15
16impl LCDColor {
17 pub fn as_solid_color(&self) -> Option<LCDSolidColor> {
19 match self.0 {
20 0 => Some(LCDSolidColor::Black),
21 1 => Some(LCDSolidColor::White),
22 2 => Some(LCDSolidColor::Clear),
23 3 => Some(LCDSolidColor::XOR),
24 _ => None,
25 }
26 }
27
28 pub unsafe fn as_pattern(&self) -> Option<LCDPattern> {
35 match self.0 {
36 x if x <= 3 => None,
37 _ => Some(unsafe { *(self.0 as *const LCDPattern) }),
38 }
39 }
40}
41
42impl From<LCDSolidColor> for LCDColor {
43 fn from(value: LCDSolidColor) -> Self {
44 LCDColor(value as _)
45 }
46}
47
48impl From<&LCDPattern> for LCDColor {
49 fn from(value: &LCDPattern) -> Self {
50 LCDColor(value as *const LCDPattern as _)
51 }
52}