1#[allow(unused_imports)]
2use crate::{Error, IS31FL3743};
3#[allow(unused_imports)]
4use core::convert::TryFrom;
5#[allow(unused_imports)]
6use embedded_hal::blocking::delay::DelayMs;
7use embedded_hal::blocking::i2c::Read;
8#[allow(unused_imports)]
9use embedded_hal::blocking::i2c::Write;
10
11pub struct UnknownDevice<I2C> {
12 pub device: IS31FL3743<I2C>,
13}
14
15impl<I2C, I2cError> UnknownDevice<I2C>
16where
17 I2C: Write<Error = I2cError>,
18 I2C: Read<Error = I2cError>,
19{
20 pub fn unwrap(self) -> I2C {
21 self.device.i2c
22 }
23
24 pub fn set_scaling(&mut self, scale: u8) -> Result<(), I2cError> {
25 self.device.set_scaling(scale)
26 }
27
28 pub fn configure(i2c: I2C) -> UnknownDevice<I2C> {
29 UnknownDevice {
30 device: IS31FL3743 {
31 i2c,
32 address: 0b0100000,
33 width: 18 * 11,
35 height: 1,
37 calc_pixel: |_x: u8, _y: u8| -> u8 {
38 unimplemented!("No Matrix support yet")
40 },
41 },
42 }
43 }
44
45 pub fn setup<DEL: DelayMs<u8>>(&mut self, delay: &mut DEL) -> Result<(), Error<I2cError>> {
46 self.device.setup(delay)
47 }
48}