OLED driver with shared SPI bus integrated
This commit was merged in pull request #35.
This commit is contained in:
@@ -1 +1,34 @@
|
||||
// Secondary OLED module
|
||||
use ch1115::{Ch1115, Size128x64};
|
||||
use display_interface_spi::SPIInterface;
|
||||
use embedded_hal::digital::OutputPin as EhOutputPin;
|
||||
use embedded_hal_bus::spi::AtomicDevice;
|
||||
use embedded_hal_bus::util::AtomicCell;
|
||||
use esp_hal::delay::Delay;
|
||||
use esp_hal::gpio::{Level, Output, OutputConfig, OutputPin};
|
||||
|
||||
pub type SecondaryOledDisplay<'a, BUS, RST, DC> =
|
||||
Ch1115<SPIInterface<AtomicDevice<'a, BUS, Output<'a>, Delay>, DC>, RST, Size128x64>;
|
||||
|
||||
pub fn init_secondary_oled_on_bus<'a, BUS, CS, RES, DC>(
|
||||
spi_bus: &'a AtomicCell<BUS>,
|
||||
cs: CS,
|
||||
res: RES,
|
||||
dc: DC,
|
||||
delay: &mut Delay,
|
||||
) -> SecondaryOledDisplay<'a, BUS, RES, DC>
|
||||
where
|
||||
BUS: embedded_hal::spi::SpiBus,
|
||||
CS: OutputPin + 'static,
|
||||
RES: EhOutputPin,
|
||||
DC: EhOutputPin,
|
||||
{
|
||||
let cs_pin = Output::new(cs, Level::High, OutputConfig::default());
|
||||
let spi_dev = AtomicDevice::new(spi_bus, cs_pin, *delay).unwrap();
|
||||
let interface = SPIInterface::new(spi_dev, dc);
|
||||
|
||||
let mut display = Ch1115::new(interface, res, Size128x64);
|
||||
|
||||
display.init(&mut Delay::new()).unwrap();
|
||||
|
||||
display
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user