Skip to content

Commit e88e15a

Browse files
authored
Use new display-interface v0.3 (#117)
Signed-off-by: Daniel Egger <[email protected]>
1 parent 6887568 commit e88e15a

File tree

10 files changed

+30
-28
lines changed

10 files changed

+30
-28
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ targets = [ "thumbv7m-none-eabi", "thumbv7em-none-eabihf" ]
1919

2020
[dependencies]
2121
embedded-hal = "0.2.3"
22-
display-interface = "0.2"
23-
display-interface-i2c = "0.2"
24-
display-interface-spi = "0.2"
22+
display-interface = "0.3"
23+
display-interface-i2c = "0.3"
24+
display-interface-spi = "0.3"
2525

2626
[dependencies.embedded-graphics]
2727
optional = true

examples/rtfm_dvd.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ type Display = ssd1306::mode::graphics::GraphicsMode<
3737
),
3838
>,
3939
gpio::gpiob::PB1<gpio::Output<gpio::PushPull>>,
40-
u8,
4140
>,
4241
>;
4342

src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl Builder {
105105
/// This method consumes the builder and must come last in the method call chain
106106
pub fn connect<I>(self, interface: I) -> DisplayMode<RawMode<I>>
107107
where
108-
I: WriteOnlyDataCommand<u8>,
108+
I: WriteOnlyDataCommand,
109109
{
110110
let properties = DisplayProperties::new(interface, self.display_size, self.rotation);
111111
DisplayMode::<RawMode<I>>::new(properties)
@@ -141,7 +141,7 @@ impl I2CDIBuilder {
141141
/// Finish the builder and return an initialised display interface for further use
142142
///
143143
/// This method consumes the builder and must come last in the method call chain
144-
pub fn init<I: hal::blocking::i2c::Write>(self, i2c: I) -> impl WriteOnlyDataCommand<u8> {
144+
pub fn init<I: hal::blocking::i2c::Write>(self, i2c: I) -> impl WriteOnlyDataCommand {
145145
display_interface_i2c::I2CInterface::new(i2c, self.i2c_addr, 0x40)
146146
}
147147
}

src/command.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Shamefully taken from https://github.com/EdgewaterDevelopment/rust-ssd1306
22

3-
use display_interface::{DisplayError, WriteOnlyDataCommand};
3+
use display_interface::{DataFormat::U8, DisplayError, WriteOnlyDataCommand};
44

55
/// SSD1306 Commands
66
@@ -90,7 +90,7 @@ impl Command {
9090
/// Send command to SSD1306
9191
pub fn send<DI>(self, iface: &mut DI) -> Result<(), DisplayError>
9292
where
93-
DI: WriteOnlyDataCommand<u8>,
93+
DI: WriteOnlyDataCommand,
9494
{
9595
// Transform command into a fixed size array of 7 u8 and the real length for sending
9696
let (data, len) = match self {
@@ -161,7 +161,7 @@ impl Command {
161161
};
162162

163163
// Send command over the interface
164-
iface.send_commands(&data[0..len])
164+
iface.send_commands(U8(&data[0..len]))
165165
}
166166
}
167167

src/mode/displaymode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<MODE> DisplayMode<MODE> {
2020
/// Setup display to run in requested mode
2121
pub fn new<DI>(properties: DisplayProperties<DI>) -> Self
2222
where
23-
DI: WriteOnlyDataCommand<u8>,
23+
DI: WriteOnlyDataCommand,
2424
MODE: DisplayModeTrait<DI>,
2525
{
2626
DisplayMode(MODE::new(properties))
@@ -30,7 +30,7 @@ impl<MODE> DisplayMode<MODE> {
3030
// TODO: Figure out how to stay as generic DisplayMode but act as particular mode
3131
pub fn into<DI, NMODE: DisplayModeTrait<DI>>(self) -> NMODE
3232
where
33-
DI: WriteOnlyDataCommand<u8>,
33+
DI: WriteOnlyDataCommand,
3434
MODE: DisplayModeTrait<DI>,
3535
{
3636
let properties = self.0.release();

src/mode/graphics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use crate::{
6767
/// Graphics mode handler
6868
pub struct GraphicsMode<DI>
6969
where
70-
DI: WriteOnlyDataCommand<u8>,
70+
DI: WriteOnlyDataCommand,
7171
{
7272
properties: DisplayProperties<DI>,
7373
buffer: [u8; 1024],
@@ -79,7 +79,7 @@ where
7979

8080
impl<DI> DisplayModeTrait<DI> for GraphicsMode<DI>
8181
where
82-
DI: WriteOnlyDataCommand<u8>,
82+
DI: WriteOnlyDataCommand,
8383
{
8484
/// Create new GraphicsMode instance
8585
fn new(properties: DisplayProperties<DI>) -> Self {
@@ -101,7 +101,7 @@ where
101101

102102
impl<DI> GraphicsMode<DI>
103103
where
104-
DI: WriteOnlyDataCommand<u8>,
104+
DI: WriteOnlyDataCommand,
105105
{
106106
/// Clear the display buffer. You need to call `disp.flush()` for any effect on the screen
107107
pub fn clear(&mut self) {
@@ -269,7 +269,7 @@ use embedded_graphics::{
269269
#[cfg(feature = "graphics")]
270270
impl<DI> DrawTarget<BinaryColor> for GraphicsMode<DI>
271271
where
272-
DI: WriteOnlyDataCommand<u8>,
272+
DI: WriteOnlyDataCommand,
273273
{
274274
type Error = DisplayError;
275275

src/mode/raw.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ use display_interface::WriteOnlyDataCommand;
1010
/// Raw display mode
1111
pub struct RawMode<DI>
1212
where
13-
DI: WriteOnlyDataCommand<u8>,
13+
DI: WriteOnlyDataCommand,
1414
{
1515
properties: DisplayProperties<DI>,
1616
}
1717

1818
impl<DI> DisplayModeTrait<DI> for RawMode<DI>
1919
where
20-
DI: WriteOnlyDataCommand<u8>,
20+
DI: WriteOnlyDataCommand,
2121
{
2222
/// Create new RawMode instance
2323
fn new(properties: DisplayProperties<DI>) -> Self {
@@ -30,7 +30,7 @@ where
3030
}
3131
}
3232

33-
impl<DI: WriteOnlyDataCommand<u8>> RawMode<DI> {
33+
impl<DI: WriteOnlyDataCommand> RawMode<DI> {
3434
/// Create a new raw display mode
3535
pub fn new(properties: DisplayProperties<DI>) -> Self {
3636
RawMode { properties }

src/mode/terminal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub struct TerminalMode<DI> {
142142

143143
impl<DI> DisplayModeTrait<DI> for TerminalMode<DI>
144144
where
145-
DI: WriteOnlyDataCommand<u8>,
145+
DI: WriteOnlyDataCommand,
146146
{
147147
/// Create new TerminalMode instance
148148
fn new(properties: DisplayProperties<DI>) -> Self {
@@ -160,7 +160,7 @@ where
160160

161161
impl<DI> TerminalMode<DI>
162162
where
163-
DI: WriteOnlyDataCommand<u8>,
163+
DI: WriteOnlyDataCommand,
164164
{
165165
/// Clear the display and reset the cursor to the top left corner
166166
pub fn clear(&mut self) -> Result<(), TerminalModeError> {
@@ -429,7 +429,7 @@ where
429429

430430
impl<DI> fmt::Write for TerminalMode<DI>
431431
where
432-
DI: WriteOnlyDataCommand<u8>,
432+
DI: WriteOnlyDataCommand,
433433
{
434434
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
435435
s.chars().map(move |c| self.print_char(c)).last();

src/properties.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
displayrotation::DisplayRotation,
66
displaysize::DisplaySize,
77
};
8-
use display_interface::{DisplayError, WriteOnlyDataCommand};
8+
use display_interface::{DataFormat::U8, DisplayError, WriteOnlyDataCommand};
99

1010
/// Display properties struct
1111
pub struct DisplayProperties<DI> {
@@ -18,7 +18,7 @@ pub struct DisplayProperties<DI> {
1818

1919
impl<DI> DisplayProperties<DI>
2020
where
21-
DI: WriteOnlyDataCommand<u8>,
21+
DI: WriteOnlyDataCommand,
2222
{
2323
/// Create new DisplayProperties instance
2424
pub fn new(
@@ -136,7 +136,7 @@ where
136136
/// and advance the position accordingly. Cf. `set_draw_area` to modify the area affected by
137137
/// this method in horizontal / vertical mode.
138138
pub fn draw(&mut self, buffer: &[u8]) -> Result<(), DisplayError> {
139-
self.iface.send_data(&buffer)
139+
self.iface.send_data(U8(&buffer))
140140
}
141141

142142
/// Send the data to the display for drawing at the current position in the framebuffer
@@ -167,7 +167,7 @@ where
167167
.skip(starting_page)
168168
.take(num_pages)
169169
.map(|s| &s[page_lower..page_upper])
170-
.try_for_each(|c| self.iface.send_data(&c))
170+
.try_for_each(|c| self.iface.send_data(U8(&c)))
171171
}
172172

173173
/// Get the configured display size

src/test_helpers.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ impl OutputPin for PinStub {
6161
#[derive(Debug, Clone, Copy)]
6262
pub struct StubInterface;
6363

64-
impl WriteOnlyDataCommand<u8> for StubInterface {
65-
fn send_commands(&mut self, _cmd: &[u8]) -> Result<(), DisplayError> {
64+
impl WriteOnlyDataCommand for StubInterface {
65+
fn send_commands(
66+
&mut self,
67+
_cmd: display_interface::DataFormat<'_>,
68+
) -> Result<(), DisplayError> {
6669
Ok(())
6770
}
68-
fn send_data(&mut self, _buf: &[u8]) -> Result<(), DisplayError> {
71+
fn send_data(&mut self, _buf: display_interface::DataFormat<'_>) -> Result<(), DisplayError> {
6972
Ok(())
7073
}
7174
}

0 commit comments

Comments
 (0)