Skip to content

Commit

Permalink
Remove a generic param, signify no comm error during reset (#179)
Browse files Browse the repository at this point in the history
* Remove a generic param, signify no comm error during reset

* Add changelog entry
  • Loading branch information
bugadani authored May 2, 2023
1 parent 2dd9911 commit cafc5a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
### Changed

- **(breaking)** [#175](https://github.com/jamwaffles/ssd1306/pull/175) Increased MSRV to 1.57.0
- **(breaking)** [#179](https://github.com/jamwaffles/ssd1306/pull/179) Changed `Ssd1306::reset` signature.

## [0.7.1] - 2022-08-15

Expand Down
28 changes: 15 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ pub mod size;
#[doc(hidden)]
pub mod test_helpers;

use core::convert::Infallible;

pub use crate::i2c_interface::I2CDisplayInterface;
use crate::mode::BasicMode;
use brightness::Brightness;
Expand Down Expand Up @@ -412,43 +414,43 @@ where
// SPI-only reset
impl<SPI, DC, SIZE, MODE> Ssd1306<SPIInterfaceNoCS<SPI, DC>, SIZE, MODE> {
/// Reset the display.
pub fn reset<RST, DELAY, PinE>(
pub fn reset<RST, DELAY>(
&mut self,
rst: &mut RST,
delay: &mut DELAY,
) -> Result<(), Error<(), PinE>>
) -> Result<(), Error<Infallible, RST::Error>>
where
RST: OutputPin<Error = PinE>,
RST: OutputPin,
DELAY: DelayMs<u8>,
{
inner_reset(rst, delay)
inner_reset(rst, delay).map_err(Error::Pin)
}
}

// SPI-only reset
impl<SPI, DC, CS, SIZE, MODE> Ssd1306<SPIInterface<SPI, DC, CS>, SIZE, MODE> {
/// Reset the display.
pub fn reset<RST, DELAY, PinE>(
pub fn reset<RST, DELAY>(
&mut self,
rst: &mut RST,
delay: &mut DELAY,
) -> Result<(), Error<(), PinE>>
) -> Result<(), Error<Infallible, RST::Error>>
where
RST: OutputPin<Error = PinE>,
RST: OutputPin,
DELAY: DelayMs<u8>,
{
inner_reset(rst, delay)
inner_reset(rst, delay).map_err(Error::Pin)
}
}

fn inner_reset<RST, DELAY, PinE>(rst: &mut RST, delay: &mut DELAY) -> Result<(), Error<(), PinE>>
fn inner_reset<RST, DELAY>(rst: &mut RST, delay: &mut DELAY) -> Result<(), RST::Error>
where
RST: OutputPin<Error = PinE>,
RST: OutputPin,
DELAY: DelayMs<u8>,
{
rst.set_high().map_err(Error::Pin)?;
rst.set_high()?;
delay.delay_ms(1);
rst.set_low().map_err(Error::Pin)?;
rst.set_low()?;
delay.delay_ms(10);
rst.set_high().map_err(Error::Pin)
rst.set_high()
}

0 comments on commit cafc5a1

Please sign in to comment.