Skip to content

Commit 67d1fd0

Browse files
iriieldruin
authored andcommitted
Update to embedded-hal-1.0.0
1 parent 8d00c5e commit 67d1fd0

File tree

10 files changed

+79
-40
lines changed

10 files changed

+79
-40
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ SSD1306 monochrome OLED display.
77

88
## [Unreleased] - ReleaseDate
99

10+
- Changed dependencies for embbedded-hal-1.0.0
11+
1012
### Added
1113

1214
- [#203](https://github.com/jamwaffles/ssd1306/pull/203) Added `Ssd1306::release(self)` to release the contained i2c interface.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ repository = "https://github.com/rust-embedded-community/ssd1306"
1111
version = "0.8.4"
1212
edition = "2018"
1313
exclude = [ "build.rs", "build.sh", "memory.x", "doc", "*.jpg", "*.png", "*.bmp" ]
14-
rust-version = "1.61"
14+
rust-version = "1.75.0"
1515

1616
[package.metadata.docs.rs]
1717
targets = [ "thumbv7m-none-eabi", "thumbv7em-none-eabihf" ]
1818

1919
[dependencies]
20-
embedded-hal = "0.2.5"
21-
display-interface = "0.4.1"
22-
display-interface-i2c = "0.4.0"
23-
display-interface-spi = "0.4.1"
20+
embedded-hal = "1.0.0"
21+
display-interface = "0.5.0"
22+
display-interface-i2c = "0.5.0"
23+
display-interface-spi = "0.5.0"
2424
embedded-graphics-core = { version = "0.4.0", optional = true }
2525

2626
[dev-dependencies]

examples/graphics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn main() -> ! {
7272
clocks,
7373
);
7474

75-
let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
75+
let interface = display_interface_spi::SPIInterface::new(spi, dc);
7676
let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate0)
7777
.into_buffered_graphics_mode();
7878

examples/pixelsquare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn main() -> ! {
6868
clocks,
6969
);
7070

71-
let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
71+
let interface = display_interface_spi::SPIInterface::new(spi, dc);
7272
let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate0)
7373
.into_buffered_graphics_mode();
7474

examples/rtic_brightness.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#[rtic::app(device = stm32f1xx_hal::pac, peripherals = true, dispatchers = [EXTI0])]
1010
mod app {
11-
use display_interface_spi::SPIInterfaceNoCS;
11+
use display_interface_spi::SPIInterface;
1212
use embedded_graphics::{
1313
geometry::Point,
1414
image::Image,
@@ -28,7 +28,7 @@ mod app {
2828
use tinybmp::Bmp;
2929

3030
type Display = Ssd1306<
31-
SPIInterfaceNoCS<
31+
SPIInterface<
3232
spi::Spi<
3333
SPI1,
3434
spi::Spi1NoRemap,
@@ -100,7 +100,7 @@ mod app {
100100
clocks,
101101
);
102102

103-
let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
103+
let interface = display_interface_spi::SPIInterface::new(spi, dc);
104104
let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate180)
105105
.into_buffered_graphics_mode();
106106

examples/rtic_dvd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#[rtic::app(device = stm32f1xx_hal::pac, peripherals = true, dispatchers = [EXTI0])]
1111
mod app {
12-
use display_interface_spi::SPIInterfaceNoCS;
12+
use display_interface_spi::SPIInterface;
1313
use embedded_graphics::{
1414
geometry::Point,
1515
image::Image,
@@ -29,7 +29,7 @@ mod app {
2929
use tinybmp::Bmp;
3030

3131
type Display = Ssd1306<
32-
SPIInterfaceNoCS<
32+
SPIInterface<
3333
spi::Spi<
3434
SPI1,
3535
spi::Spi1NoRemap,
@@ -100,7 +100,7 @@ mod app {
100100
clocks,
101101
);
102102

103-
let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
103+
let interface = display_interface_spi::SPIInterface::new(spi, dc);
104104
let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate180)
105105
.into_buffered_graphics_mode();
106106

src/i2c_interface.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ impl I2CDisplayInterface {
1212
// pub fn with_i2c<I>(i2c: I) -> I2CInterface<I> // alternative, but breaking change
1313
pub fn new<I>(i2c: I) -> I2CInterface<I>
1414
where
15-
I: embedded_hal::blocking::i2c::Write,
15+
I: embedded_hal::i2c::I2c,
1616
{
1717
Self::new_custom_address(i2c, 0x3C)
1818
}
1919

2020
/// Create a new I2C interface with the alternate address 0x3D as specified in the datasheet.
2121
pub fn new_alternate_address<I>(i2c: I) -> I2CInterface<I>
2222
where
23-
I: embedded_hal::blocking::i2c::Write,
23+
I: embedded_hal::i2c::I2c,
2424
{
2525
Self::new_custom_address(i2c, 0x3D)
2626
}
2727

2828
/// Create a new I2C interface with a custom address.
2929
pub fn new_custom_address<I>(i2c: I, address: u8) -> I2CInterface<I>
3030
where
31-
I: embedded_hal::blocking::i2c::Write,
31+
I: embedded_hal::i2c::I2c,
3232
{
3333
I2CInterface::new(i2c, address, 0x40)
3434
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ use crate::mode::BasicMode;
126126
use brightness::Brightness;
127127
use command::{AddrMode, Command, VcomhLevel};
128128
use display_interface::{DataFormat::U8, DisplayError, WriteOnlyDataCommand};
129-
use embedded_hal::{blocking::delay::DelayMs, digital::v2::OutputPin};
129+
use embedded_hal::{delay::DelayNs, digital::OutputPin};
130130
use error::Error;
131131
use mode::{BufferedGraphicsMode, TerminalMode};
132132
use rotation::DisplayRotation;
@@ -430,12 +430,12 @@ impl<DI, SIZE, MODE> Ssd1306<DI, SIZE, MODE> {
430430
) -> Result<(), Error<Infallible, RST::Error>>
431431
where
432432
RST: OutputPin,
433-
DELAY: DelayMs<u8>,
433+
DELAY: DelayNs,
434434
{
435435
fn inner_reset<RST, DELAY>(rst: &mut RST, delay: &mut DELAY) -> Result<(), RST::Error>
436436
where
437437
RST: OutputPin,
438-
DELAY: DelayMs<u8>,
438+
DELAY: DelayNs,
439439
{
440440
rst.set_high()?;
441441
delay.delay_ms(1);

src/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
pub use display_interface::WriteOnlyDataCommand;
44
pub use display_interface_i2c::I2CInterface;
5-
pub use display_interface_spi::{SPIInterface, SPIInterfaceNoCS};
5+
pub use display_interface_spi::SPIInterface;
66

77
pub use super::{
88
brightness::Brightness,

src/test_helpers.rs

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,76 @@
22
33
use display_interface::{DisplayError, WriteOnlyDataCommand};
44
use embedded_hal::{
5-
blocking::{
6-
i2c,
7-
spi::{self, Transfer},
8-
},
9-
digital::v2::OutputPin,
5+
digital::{ErrorType, OutputPin},
6+
i2c,
7+
spi::{self, SpiBus},
108
};
119

10+
#[derive(PartialEq, Eq, Clone, Debug, Copy)]
11+
pub struct Error {}
12+
13+
impl embedded_hal::digital::Error for Error {
14+
fn kind(&self) -> embedded_hal::digital::ErrorKind {
15+
embedded_hal::digital::ErrorKind::Other
16+
}
17+
}
18+
19+
impl i2c::Error for Error {
20+
fn kind(&self) -> i2c::ErrorKind {
21+
i2c::ErrorKind::Other
22+
}
23+
}
24+
25+
impl spi::Error for Error {
26+
fn kind(&self) -> spi::ErrorKind {
27+
spi::ErrorKind::Other
28+
}
29+
}
30+
1231
#[allow(dead_code)]
1332
#[derive(Debug, Clone, Copy)]
1433
pub struct SpiStub;
1534

16-
impl spi::Write<u8> for SpiStub {
17-
type Error = ();
35+
impl spi::ErrorType for SpiStub {
36+
type Error = Error;
37+
}
1838

19-
fn write(&mut self, _buf: &[u8]) -> Result<(), ()> {
39+
impl SpiBus<u8> for SpiStub {
40+
fn read(&mut self, _words: &mut [u8]) -> Result<(), Self::Error> {
41+
todo!()
42+
}
43+
44+
fn write(&mut self, _words: &[u8]) -> Result<(), Self::Error> {
45+
Ok(())
46+
}
47+
48+
fn transfer(&mut self, _read: &mut [u8], _write: &[u8]) -> Result<(), Self::Error> {
2049
Ok(())
2150
}
22-
}
2351

24-
impl Transfer<u8> for SpiStub {
25-
type Error = ();
52+
fn transfer_in_place(&mut self, _words: &mut [u8]) -> Result<(), Self::Error> {
53+
todo!()
54+
}
2655

27-
fn transfer<'a>(&mut self, buf: &'a mut [u8]) -> Result<&'a [u8], ()> {
28-
Ok(buf)
56+
fn flush(&mut self) -> Result<(), Self::Error> {
57+
todo!()
2958
}
3059
}
3160

3261
#[allow(dead_code)]
3362
#[derive(Debug, Clone, Copy)]
3463
pub struct I2cStub;
3564

36-
impl i2c::Write for I2cStub {
37-
type Error = ();
65+
impl i2c::ErrorType for I2cStub {
66+
type Error = Error;
67+
}
3868

39-
fn write(&mut self, _addr: u8, _buf: &[u8]) -> Result<(), ()> {
69+
impl i2c::I2c for I2cStub {
70+
fn transaction(
71+
&mut self,
72+
_address: u8,
73+
_operations: &mut [i2c::Operation<'_>],
74+
) -> Result<(), Self::Error> {
4075
Ok(())
4176
}
4277
}
@@ -45,14 +80,16 @@ impl i2c::Write for I2cStub {
4580
#[derive(Debug, Clone, Copy)]
4681
pub struct PinStub;
4782

48-
impl OutputPin for PinStub {
49-
type Error = ();
83+
impl ErrorType for PinStub {
84+
type Error = Error;
85+
}
5086

51-
fn set_high(&mut self) -> Result<(), ()> {
87+
impl OutputPin for PinStub {
88+
fn set_low(&mut self) -> Result<(), Self::Error> {
5289
Ok(())
5390
}
5491

55-
fn set_low(&mut self) -> Result<(), ()> {
92+
fn set_high(&mut self) -> Result<(), Self::Error> {
5693
Ok(())
5794
}
5895
}

0 commit comments

Comments
 (0)