adafruit_seesaw/devices/
neotrellis.rs1use super::SeesawDeviceInit;
2#[cfg(feature = "module_neopixel")]
3use crate::modules::neopixel::NeopixelModule;
4use crate::{
5    modules::{keypad::KeypadModule, status::StatusModule, HardwareId},
6    seesaw_device, Driver, SeesawError,
7};
8
9seesaw_device! {
10    name: NeoTrellis,
11    hardware_id: HardwareId::SAMD09,
12    product_id: 3954,
13    default_addr: 0x2E
14}
15
16pub type NeoTrellisColor = rgb::Grb<u8>;
17
18impl<D: Driver> KeypadModule<D> for NeoTrellis<D> {
19    const NUM_COLS: u8 = 4;
20    const NUM_ROWS: u8 = 4;
21}
22
23#[cfg(feature = "module_neopixel")]
24impl<D: Driver> NeopixelModule<D> for NeoTrellis<D> {
25    type Color = NeoTrellisColor;
26
27    const N_LEDS: usize = 16;
28    const PIN: u8 = 3;
29}
30
31impl<D: Driver> SeesawDeviceInit<D> for NeoTrellis<D> {
32    fn init(mut self) -> Result<Self, SeesawError<D::Error>> {
33        self.reset_and_verify_seesaw()?;
34        #[cfg(feature = "module_neopixel")]
35        self.enable_neopixel()?;
36        Ok(self)
37    }
38}
39
40impl<D: Driver> NeoTrellis<D> {
41    #[cfg(feature = "module_neopixel")]
42    pub fn set_xy_neopixel_color(
43        &mut self,
44        x: u8,
45        y: u8,
46        color: NeoTrellisColor,
47    ) -> Result<(), SeesawError<D::Error>>
48    where
49        [(); 2 + Self::C_SIZE]: Sized,
50    {
51        self.set_nth_neopixel_color((y * Self::NUM_COLS + x).into(), color)
52    }
53}