Skip to content

Commit b628103

Browse files
committed
Don't require display interface for reset
1 parent 8903cb7 commit b628103

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

src/lib.rs

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ use crate::mode::BasicMode;
126126
use brightness::Brightness;
127127
use command::{AddrMode, Command, VcomhLevel};
128128
use display_interface::{DataFormat::U8, DisplayError, WriteOnlyDataCommand};
129-
use display_interface_spi::{SPIInterface, SPIInterfaceNoCS};
130129
use embedded_hal::{blocking::delay::DelayMs, digital::v2::OutputPin};
131130
use error::Error;
132131
use mode::{BufferedGraphicsMode, TerminalMode};
@@ -412,7 +411,7 @@ where
412411
}
413412

414413
// SPI-only reset
415-
impl<SPI, DC, SIZE, MODE> Ssd1306<SPIInterfaceNoCS<SPI, DC>, SIZE, MODE> {
414+
impl<DI, SIZE, MODE> Ssd1306<DI, SIZE, MODE> {
416415
/// Reset the display.
417416
pub fn reset<RST, DELAY>(
418417
&mut self,
@@ -423,34 +422,18 @@ impl<SPI, DC, SIZE, MODE> Ssd1306<SPIInterfaceNoCS<SPI, DC>, SIZE, MODE> {
423422
RST: OutputPin,
424423
DELAY: DelayMs<u8>,
425424
{
426-
inner_reset(rst, delay).map_err(Error::Pin)
427-
}
428-
}
425+
fn inner_reset<RST, DELAY>(rst: &mut RST, delay: &mut DELAY) -> Result<(), RST::Error>
426+
where
427+
RST: OutputPin,
428+
DELAY: DelayMs<u8>,
429+
{
430+
rst.set_high()?;
431+
delay.delay_ms(1);
432+
rst.set_low()?;
433+
delay.delay_ms(10);
434+
rst.set_high()
435+
}
429436

430-
// SPI-only reset
431-
impl<SPI, DC, CS, SIZE, MODE> Ssd1306<SPIInterface<SPI, DC, CS>, SIZE, MODE> {
432-
/// Reset the display.
433-
pub fn reset<RST, DELAY>(
434-
&mut self,
435-
rst: &mut RST,
436-
delay: &mut DELAY,
437-
) -> Result<(), Error<Infallible, RST::Error>>
438-
where
439-
RST: OutputPin,
440-
DELAY: DelayMs<u8>,
441-
{
442437
inner_reset(rst, delay).map_err(Error::Pin)
443438
}
444439
}
445-
446-
fn inner_reset<RST, DELAY>(rst: &mut RST, delay: &mut DELAY) -> Result<(), RST::Error>
447-
where
448-
RST: OutputPin,
449-
DELAY: DelayMs<u8>,
450-
{
451-
rst.set_high()?;
452-
delay.delay_ms(1);
453-
rst.set_low()?;
454-
delay.delay_ms(10);
455-
rst.set_high()
456-
}

0 commit comments

Comments
 (0)