Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@ version = "0.3.0"
edition = "2018"

[package.metadata.docs.rs]
targets = [ "thumbv7m-none-eabi" ]
targets = ["thumbv7m-none-eabi"]
all-features = true

[badges]
circle-ci = { repository = "jamwaffles/ssd1331", branch = "master" }

[dependencies]
embedded-hal = "0.2.3"
embedded-hal = "0.2.6"
embedded-graphics-core = { version = "0.3.2", optional = true }
embassy-traits = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy", optional = true }

[dev-dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.6.11"
panic-semihosting = "0.5.3"
embedded-graphics = "0.7.1"
tinybmp = "0.3.1"
stm32f1xx-hal = { version = "0.7.0", features = [ "rt", "stm32f103" ] }
stm32f1xx-hal = { version = "0.7.0", features = ["rt", "stm32f103"] }

[features]
default = ["graphics"]
graphics = ["embedded-graphics-core"]
async = ["embassy-traits"]

[profile.dev]
codegen-units = 1
Expand Down
3 changes: 3 additions & 0 deletions examples/bmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
#![feature(unchecked_math)]
#![allow(incomplete_features)]

use cortex_m_rt::{entry, exception, ExceptionFrame};
use embedded_graphics::{geometry::Point, image::Image, pixelcolor::Rgb565, prelude::*};
Expand Down
19 changes: 19 additions & 0 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,25 @@ where
Ok(())
}

/// Send the full framebuffer to the display
///
/// This resets the draw area the full size of the display
#[cfg(feature = "async")]
pub async fn flush_async(&mut self) -> Result<(), Error<CommE, PinE>> {
use embassy_traits::spi::Write as SpiTrait;

// Ensure the display buffer is at the origin of the display before we send the full frame
// to prevent accidental offsets
self.set_draw_area((0, 0), (DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1))?;

// 1 = data, 0 = command
self.dc.set_high().map_err(Error::Pin)?;

self.spi.write(&self.buffer).map_err(Error::Comm)?;

Ok(())
}

/// Set the top left and bottom right corners of a bounding box to draw to
pub fn set_draw_area(
&mut self,
Expand Down