adafruit_seesaw/devices/
neorotary4.rs

1use super::SeesawDeviceInit;
2use crate::{
3    modules::{encoder::EncoderModule, status::StatusModule, HardwareId},
4    prelude::GpioModule,
5    seesaw_device, Driver, SeesawError,
6};
7#[cfg(feature = "module_neopixel")]
8use crate::modules::neopixel::NeopixelModule;
9
10seesaw_device! {
11    /// Anecdotally, I've had a lot of issues with the quad rotary encoder.
12    ///
13    /// Specifically, calls to set/reset the encoders' position seem to have no
14    /// effect on the firmware's internal position counters.
15    name: NeoRotary4,
16    hardware_id: HardwareId::ATTINY817,
17    product_id: 5752,
18    default_addr: 0x49
19}
20
21pub type NeoRotary4Color = rgb::Grb<u8>;
22
23impl<D: Driver> GpioModule<D> for NeoRotary4<D> {}
24impl<D: Driver> EncoderModule<D, 4> for NeoRotary4<D> {
25    const ENCODER_BTN_PINS: [u8; 4] = [12, 14, 17, 9];
26}
27#[cfg(feature = "module_neopixel")]
28impl<D: Driver> NeopixelModule<D> for NeoRotary4<D> {
29    type Color = NeoRotary4Color;
30
31    const N_LEDS: usize = 4;
32    const PIN: u8 = 18;
33}
34
35impl<D: Driver> SeesawDeviceInit<D> for NeoRotary4<D> {
36    fn init(mut self) -> Result<Self, SeesawError<D::Error>> {
37        self.reset_and_verify_seesaw()?;
38        self.enable_button(0)?;
39        self.enable_button(1)?;
40        self.enable_button(2)?;
41        self.enable_button(3)?;
42        #[cfg(feature = "module_neopixel")]
43        self.enable_neopixel()?;
44        Ok(self)
45    }
46}