diff --git a/Cargo.toml b/Cargo.toml index 30a0d1804..46d59865d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,8 @@ sdio-host = { version = "0.6.0", optional = true } embedded-dma = "0.2.0" bare-metal = { version = "1" } void = { default-features = false, version = "1.0.2" } -display-interface = { version = "0.4.1", optional = true } +display-interface = { version = "0.5.0", optional = true } +display-interface-04 = { package = "display-interface", version = "0.4.1", optional = true } fugit = "0.3.7" fugit-timer = "0.1.3" # rtic1 @@ -83,8 +84,9 @@ panic-semihosting = "0.6.0" cortex-m-semihosting = "0.5.0" heapless = "0.8" panic-halt = "0.2.0" -ssd1306 = "0.7.1" -embedded-graphics = "0.7.1" +ssd1306 = "0.8.4" +embedded-graphics = "0.8.1" +embedded-graphics-07 = { package = "embedded-graphics", version = "0.7.1" } usb-device = "0.3.1" usbd-serial = "0.2.0" micromath = "2" @@ -96,7 +98,8 @@ ist7920 = "0.1.1" smart-leds = "0.3.0" ws2812-spi = { version = "0.4.0", features = [] } hd44780-driver = "0.4.0" -display-interface = "0.4" +display-interface = "0.5" +display-interface-04 = { package = "display-interface", version = "0.4.1" } ft6x06 = "0.1.2" ushell = "0.3.5" @@ -288,7 +291,7 @@ usb_fs = ["dep:synopsys-usb-otg", "synopsys-usb-otg/fs"] usb_hs = ["dep:synopsys-usb-otg", "synopsys-usb-otg/hs"] ## LCD support via FMC/FSMC peripheral. See [display-interface](https://crates.io/crates/display-interface) -fsmc_lcd = ["dep:display-interface"] +fsmc_lcd = ["dep:display-interface", "dep:display-interface-04"] ## SDIO peripheral support. See [sdio-host](https://crates.io/crates/sdio-host) sdio-host = ["dep:sdio-host"] diff --git a/examples/analog-stopwatch-with-spi-ssd1306.rs b/examples/analog-stopwatch-with-spi-ssd1306.rs index 5e7ec9033..eac2596b8 100644 --- a/examples/analog-stopwatch-with-spi-ssd1306.rs +++ b/examples/analog-stopwatch-with-spi-ssd1306.rs @@ -147,7 +147,7 @@ fn main() -> ! { let mut format_buf = String::<10>::new(); format_elapsed(&mut format_buf, elapsed); - disp.clear(); + disp.clear_buffer(); let state = free(|cs| STATE.borrow(cs).get()); let state_msg = match state { diff --git a/examples/display-touch.rs b/examples/display-touch.rs index 5cbfaa8d5..04f6af1dc 100644 --- a/examples/display-touch.rs +++ b/examples/display-touch.rs @@ -25,7 +25,7 @@ use stm32f4xx_hal::{ rcc::Rcc, }; -use embedded_graphics::{ +use embedded_graphics_07::{ pixelcolor::Rgb565, prelude::*, primitives::{Circle, PrimitiveStyle}, diff --git a/examples/f413disco-lcd-ferris.rs b/examples/f413disco-lcd-ferris.rs index 8138e7bb1..ea4d38072 100644 --- a/examples/f413disco-lcd-ferris.rs +++ b/examples/f413disco-lcd-ferris.rs @@ -22,14 +22,14 @@ use crate::hal::{ prelude::*, }; -use embedded_graphics::geometry::Size; -use embedded_graphics::image::*; -use embedded_graphics::pixelcolor::Rgb565; -use embedded_graphics::prelude::*; -use embedded_graphics::primitives::*; +use embedded_graphics_07::geometry::Size; +use embedded_graphics_07::image::*; +use embedded_graphics_07::pixelcolor::Rgb565; +use embedded_graphics_07::prelude::*; +use embedded_graphics_07::primitives::*; use st7789::*; -pub use display_interface::{DisplayError, WriteOnlyDataCommand}; +pub use display_interface_04::{DisplayError, WriteOnlyDataCommand}; /// Define the lovely ferris crab sprite const FERRIS: [u8; 11008] = [ diff --git a/examples/rng-display.rs b/examples/rng-display.rs index 0829455a9..943ddf572 100644 --- a/examples/rng-display.rs +++ b/examples/rng-display.rs @@ -87,7 +87,7 @@ fn main() -> ! { let mut format_buf = String::<20>::new(); loop { //display clear - disp.clear(); + disp.clear_buffer(); //this will continuously report an error if RNG_CLK < HCLK/16 let rand_val = rand_source.next_u32(); diff --git a/examples/rtic-usart-shell-ssd1306.rs b/examples/rtic-usart-shell-ssd1306.rs index 825c70fb5..3c5d5c967 100644 --- a/examples/rtic-usart-shell-ssd1306.rs +++ b/examples/rtic-usart-shell-ssd1306.rs @@ -190,7 +190,7 @@ mod usart_shell { } else { write!(ledstr, "LED is OFF").unwrap(); } - ldisp.clear(); + ldisp.clear_buffer(); Text::with_baseline(fpsstr.as_str(), Point::zero(), text_style, Baseline::Top) .draw(ldisp) .unwrap(); diff --git a/examples/st7789-lcd.rs b/examples/st7789-lcd.rs index 4c3380f22..964c5bb29 100644 --- a/examples/st7789-lcd.rs +++ b/examples/st7789-lcd.rs @@ -25,10 +25,10 @@ use core::slice::Iter; use cortex_m_rt::entry; use panic_semihosting as _; -use embedded_graphics::pixelcolor::Rgb565; -use embedded_graphics::prelude::*; +use embedded_graphics_07::pixelcolor::Rgb565; +use embedded_graphics_07::prelude::*; -use embedded_graphics::primitives::{Circle, PrimitiveStyle}; +use embedded_graphics_07::primitives::{Circle, PrimitiveStyle}; use st7789::ST7789; use stm32f4xx_hal::fsmc_lcd::{DataPins16, FsmcLcd, LcdPins, Timing}; use stm32f4xx_hal::pac::{CorePeripherals, Peripherals}; diff --git a/examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs b/examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs index 620a7d421..ebef349f3 100644 --- a/examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs +++ b/examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs @@ -38,7 +38,7 @@ use core::ops::DerefMut; use core::sync::atomic::{AtomicBool, Ordering}; use cortex_m::interrupt::{free, CriticalSection, Mutex}; use cortex_m_rt::entry; -use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; +use display_interface_04::{DataFormat, DisplayError, WriteOnlyDataCommand}; use embedded_graphics::{ mono_font::{ ascii::{FONT_6X12, FONT_9X15}, @@ -226,7 +226,7 @@ fn main() -> ! { let mut format_buf = String::<10>::new(); format_elapsed(&mut format_buf, elapsed); - disp.clear(); + disp.clear_buffer(); let state = free(|cs| STATE.borrow(cs).get()); let state_msg = match state { diff --git a/examples/stopwatch-with-ssd1306-and-interrupts.rs b/examples/stopwatch-with-ssd1306-and-interrupts.rs index fd5659fa2..0777959c0 100644 --- a/examples/stopwatch-with-ssd1306-and-interrupts.rs +++ b/examples/stopwatch-with-ssd1306-and-interrupts.rs @@ -109,7 +109,7 @@ fn main() -> ! { let mut format_buf = String::<10>::new(); format_elapsed(&mut format_buf, elapsed); - disp.clear(); + disp.clear_buffer(); let state = free(|cs| STATE.borrow(cs).get()); let state_msg = match state { diff --git a/src/fsmc_lcd/display_interface_impl.rs b/src/fsmc_lcd/display_interface_impl.rs index e9d131438..4ee26b2c1 100644 --- a/src/fsmc_lcd/display_interface_impl.rs +++ b/src/fsmc_lcd/display_interface_impl.rs @@ -1,76 +1,89 @@ -use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; - use super::{Lcd, SubBank}; -impl WriteOnlyDataCommand for Lcd -where - S: SubBank, -{ - fn send_commands(&mut self, cmd: DataFormat<'_>) -> Result<(), DisplayError> { - match cmd { - DataFormat::U8(slice) => { - for value in slice { - self.write_command(u16::from(*value)); - } - } - DataFormat::U16(slice) => { - for value in slice { - self.write_command(*value); - } - } - DataFormat::U16BE(slice) | DataFormat::U16LE(slice) => { - // As long as the data bus is 16 bits wide, the byte order doesn't matter. - for value in slice { - self.write_command(*value); +macro_rules! impl_display_interface { + ($display_interface:ident) => { + impl $display_interface::WriteOnlyDataCommand for Lcd + where + S: SubBank, + { + fn send_commands( + &mut self, + cmd: $display_interface::DataFormat<'_>, + ) -> Result<(), $display_interface::DisplayError> { + use $display_interface::DataFormat; + match cmd { + DataFormat::U8(slice) => { + for value in slice { + self.write_command(u16::from(*value)); + } + } + DataFormat::U16(slice) => { + for value in slice { + self.write_command(*value); + } + } + DataFormat::U16BE(slice) | DataFormat::U16LE(slice) => { + // As long as the data bus is 16 bits wide, the byte order doesn't matter. + for value in slice { + self.write_command(*value); + } + } + DataFormat::U8Iter(iter) => { + for value in iter { + self.write_command(u16::from(value)); + } + } + DataFormat::U16BEIter(iter) | DataFormat::U16LEIter(iter) => { + // As long as the data bus is 16 bits wide, the byte order doesn't matter. + for value in iter { + self.write_command(value); + } + } + _ => return Err($display_interface::DisplayError::DataFormatNotImplemented), } + Ok(()) } - DataFormat::U8Iter(iter) => { - for value in iter { - self.write_command(u16::from(value)); - } - } - DataFormat::U16BEIter(iter) | DataFormat::U16LEIter(iter) => { - // As long as the data bus is 16 bits wide, the byte order doesn't matter. - for value in iter { - self.write_command(value); - } - } - _ => return Err(DisplayError::DataFormatNotImplemented), - } - Ok(()) - } - fn send_data(&mut self, buf: DataFormat<'_>) -> Result<(), DisplayError> { - match buf { - DataFormat::U8(slice) => { - for value in slice { - self.write_data(u16::from(*value)); + fn send_data( + &mut self, + buf: $display_interface::DataFormat<'_>, + ) -> Result<(), $display_interface::DisplayError> { + use $display_interface::DataFormat; + match buf { + DataFormat::U8(slice) => { + for value in slice { + self.write_data(u16::from(*value)); + } + } + DataFormat::U16(slice) => { + for value in slice { + self.write_data(*value); + } + } + DataFormat::U16BE(slice) | DataFormat::U16LE(slice) => { + // As long as the data bus is 16 bits wide, the byte order doesn't matter. + for value in slice { + self.write_data(*value); + } + } + DataFormat::U8Iter(iter) => { + for value in iter { + self.write_data(u16::from(value)); + } + } + DataFormat::U16BEIter(iter) | DataFormat::U16LEIter(iter) => { + // As long as the data bus is 16 bits wide, the byte order doesn't matter. + for value in iter { + self.write_data(value); + } + } + _ => return Err($display_interface::DisplayError::DataFormatNotImplemented), } + Ok(()) } - DataFormat::U16(slice) => { - for value in slice { - self.write_data(*value); - } - } - DataFormat::U16BE(slice) | DataFormat::U16LE(slice) => { - // As long as the data bus is 16 bits wide, the byte order doesn't matter. - for value in slice { - self.write_data(*value); - } - } - DataFormat::U8Iter(iter) => { - for value in iter { - self.write_data(u16::from(value)); - } - } - DataFormat::U16BEIter(iter) | DataFormat::U16LEIter(iter) => { - // As long as the data bus is 16 bits wide, the byte order doesn't matter. - for value in iter { - self.write_data(value); - } - } - _ => return Err(DisplayError::DataFormatNotImplemented), } - Ok(()) - } + }; } + +impl_display_interface!(display_interface); +impl_display_interface!(display_interface_04);