mod contiguous_pixels;
mod draw_item;
mod orientation;
mod tga;
pub mod tiling;
use core::{convert::Infallible, future::Future};
use embedded_graphics::{pixelcolor::Rgb565, prelude::DrawTarget, primitives::Rectangle};
use crate::pixel_target::PixelTarget;
pub(crate) use contiguous_pixels::ContiguousPixels;
pub use draw_item::{DrawItem, Image565View};
pub use orientation::Orientation;
pub use tga::{Image565Fixed, Image888Fixed, MaskFixed, MaskedDrawable, mask_byte_count};
pub use crate::__cyd_tga as tga;
#[cfg_attr(
feature = "doc-images",
doc = ::embed_doc_image::embed_image!(
"cyd_frame_preview",
"docs/assets/cyd_frame_preview.png"
)
)]
#[cfg_attr(
feature = "host",
doc = r#"
```rust
use device_envoy_core::cyd::{CydDisplay, display::CydFrame};
use embedded_graphics::{
pixelcolor::{Rgb565, RgbColor},
prelude::{Point, Size},
primitives::Rectangle,
};
async fn draw<D: CydDisplay>(display: &mut D) -> Result<(), D::Error> {
let mut frame = display.frame_mut(Rectangle::new(Point::new(10, 10), Size::new(100, 40)));
frame.fill(Rgb565::BLUE).write_text("CYD").flush().await
}
# use device_envoy_core::memory::{CydMemory, assert_framebuffer_matches_expected_png};
# use embedded_graphics::{mono_font::ascii::FONT_9X15_BOLD, pixelcolor::Rgb888};
# let mut cyd_memory = CydMemory::new(
# Size::new(320, 240),
# Rgb888::BLACK,
# Rgb888::WHITE,
# &FONT_9X15_BOLD,
# );
# let mut display = cyd_memory.display();
# futures_executor::block_on(draw(&mut display))?;
# let golden_result = assert_framebuffer_matches_expected_png(
# &cyd_memory,
# env!("CARGO_MANIFEST_DIR"),
# "cyd_frame_preview.png",
# );
# assert!(golden_result.is_ok(), "{golden_result:?}");
# Ok::<(), device_envoy_core::memory::Error>(())
```
"#
)]
#[cfg_attr(
all(feature = "host", feature = "doc-images"),
doc = "\n![A blue frame containing white CYD text on an in-memory display.][cyd_frame_preview]\n"
)]
pub trait CydFrame: DrawTarget<Color = Rgb565, Error = Infallible> + PixelTarget {
type Error;
fn rectangle(&self) -> Rectangle;
fn fill(&mut self, color: Rgb565) -> &mut Self;
fn clear(&mut self) -> &mut Self;
fn write_text(&mut self, text: &str) -> &mut Self;
fn copy_from_565(&mut self, src: &[u16]) -> crate::Result<()>;
fn flush(&mut self) -> impl Future<Output = Result<(), <Self as CydFrame>::Error>>;
}