Skip to content

Commit cafc5a1

Browse files
authored
Remove a generic param, signify no comm error during reset (#179)
* Remove a generic param, signify no comm error during reset * Add changelog entry
1 parent 2dd9911 commit cafc5a1

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
### Changed
1414

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

1718
## [0.7.1] - 2022-08-15
1819

src/lib.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ pub mod size;
119119
#[doc(hidden)]
120120
pub mod test_helpers;
121121

122+
use core::convert::Infallible;
123+
122124
pub use crate::i2c_interface::I2CDisplayInterface;
123125
use crate::mode::BasicMode;
124126
use brightness::Brightness;
@@ -412,43 +414,43 @@ where
412414
// SPI-only reset
413415
impl<SPI, DC, SIZE, MODE> Ssd1306<SPIInterfaceNoCS<SPI, DC>, SIZE, MODE> {
414416
/// Reset the display.
415-
pub fn reset<RST, DELAY, PinE>(
417+
pub fn reset<RST, DELAY>(
416418
&mut self,
417419
rst: &mut RST,
418420
delay: &mut DELAY,
419-
) -> Result<(), Error<(), PinE>>
421+
) -> Result<(), Error<Infallible, RST::Error>>
420422
where
421-
RST: OutputPin<Error = PinE>,
423+
RST: OutputPin,
422424
DELAY: DelayMs<u8>,
423425
{
424-
inner_reset(rst, delay)
426+
inner_reset(rst, delay).map_err(Error::Pin)
425427
}
426428
}
427429

428430
// SPI-only reset
429431
impl<SPI, DC, CS, SIZE, MODE> Ssd1306<SPIInterface<SPI, DC, CS>, SIZE, MODE> {
430432
/// Reset the display.
431-
pub fn reset<RST, DELAY, PinE>(
433+
pub fn reset<RST, DELAY>(
432434
&mut self,
433435
rst: &mut RST,
434436
delay: &mut DELAY,
435-
) -> Result<(), Error<(), PinE>>
437+
) -> Result<(), Error<Infallible, RST::Error>>
436438
where
437-
RST: OutputPin<Error = PinE>,
439+
RST: OutputPin,
438440
DELAY: DelayMs<u8>,
439441
{
440-
inner_reset(rst, delay)
442+
inner_reset(rst, delay).map_err(Error::Pin)
441443
}
442444
}
443445

444-
fn inner_reset<RST, DELAY, PinE>(rst: &mut RST, delay: &mut DELAY) -> Result<(), Error<(), PinE>>
446+
fn inner_reset<RST, DELAY>(rst: &mut RST, delay: &mut DELAY) -> Result<(), RST::Error>
445447
where
446-
RST: OutputPin<Error = PinE>,
448+
RST: OutputPin,
447449
DELAY: DelayMs<u8>,
448450
{
449-
rst.set_high().map_err(Error::Pin)?;
451+
rst.set_high()?;
450452
delay.delay_ms(1);
451-
rst.set_low().map_err(Error::Pin)?;
453+
rst.set_low()?;
452454
delay.delay_ms(10);
453-
rst.set_high().map_err(Error::Pin)
455+
rst.set_high()
454456
}

0 commit comments

Comments
 (0)