Skip to content

Commit

Permalink
bump display-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Jan 14, 2024
1 parent e5f5370 commit 0eeb670
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 88 deletions.
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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"

Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion examples/analog-stopwatch-with-spi-ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/display-touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use stm32f4xx_hal::{
rcc::Rcc,
};

use embedded_graphics::{
use embedded_graphics_07::{
pixelcolor::Rgb565,
prelude::*,
primitives::{Circle, PrimitiveStyle},
Expand Down
12 changes: 6 additions & 6 deletions examples/f413disco-lcd-ferris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Expand Down
2 changes: 1 addition & 1 deletion examples/rng-display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/rtic-usart-shell-ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions examples/st7789-lcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/stopwatch-with-ssd1306-and-interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
147 changes: 80 additions & 67 deletions src/fsmc_lcd/display_interface_impl.rs
Original file line number Diff line number Diff line change
@@ -1,76 +1,89 @@
use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand};

use super::{Lcd, SubBank};

impl<S> WriteOnlyDataCommand for Lcd<S>
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<S> $display_interface::WriteOnlyDataCommand for Lcd<S>
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);

0 comments on commit 0eeb670

Please sign in to comment.