Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement FrameBufferBackend for slices #23

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
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
16 changes: 16 additions & 0 deletions src/backends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ impl<C: PixelColor, const N: usize> FrameBufferBackend for [C; N] {
}
}

/// Warning, this can panic, if the assumed size of the framebuffer (widht * height) is larger than the slice.
impl<C: PixelColor> FrameBufferBackend for &mut [C] {
type Color = C;
fn set(&mut self, index: usize, color: C) {
self[index] = color
}

fn get(&self, index: usize) -> C {
self[index]
}

fn nr_elements(&self) -> usize {
self.len()
}
}

/// Backends implementing this Trait can be used for DMA.
///
/// # Safety
Expand Down
Loading