adafruit_seesaw/devices/
rotary_encoder.rs

1use super::SeesawDeviceInit;
2use crate::{
3    modules::{
4        encoder::EncoderModule, gpio::GpioModule, status::StatusModule,
5        HardwareId,
6    },
7    seesaw_device, Driver, SeesawError,
8};
9#[cfg(feature = "module_neopixel")]
10use crate::modules::neopixel::NeopixelModule;
11
12seesaw_device! {
13  name: RotaryEncoder,
14  hardware_id: HardwareId::SAMD09,
15  product_id: 4991,
16  default_addr: 0x36
17}
18
19pub type RotaryEncoderColor = rgb::Grb<u8>;
20
21impl<D: Driver> GpioModule<D> for RotaryEncoder<D> {}
22impl<D: Driver> EncoderModule<D, 1> for RotaryEncoder<D> {
23    const ENCODER_BTN_PINS: [u8; 1] = [24];
24}
25
26#[cfg(feature = "module_neopixel")]
27impl<D: Driver> NeopixelModule<D> for RotaryEncoder<D> {
28    type Color = RotaryEncoderColor;
29
30    const N_LEDS: usize = 1;
31    const PIN: u8 = 6;
32}
33
34impl<D: Driver> SeesawDeviceInit<D> for RotaryEncoder<D> {
35    fn init(mut self) -> Result<Self, SeesawError<D::Error>> {
36        self.reset_and_verify_seesaw()?;
37        self.enable_button(0)?;
38        #[cfg(feature = "module_neopixel")]
39        self.enable_neopixel()?;
40        Ok(self)
41    }
42}