#[repr(C)]pub struct DmaFrameBuffer<const ROWS: usize, const COLS: usize, const NROWS: usize, const BITS: u8, const FRAME_COUNT: usize> { /* private fields */ }
Expand description
DMA-compatible framebuffer for HUB75 LED panels.
This is a framebuffer implementation that:
- Manages multiple frames for Binary Code Modulation (BCM)
- Provides DMA-compatible memory layout
- Implements the embedded-graphics
DrawTarget
trait
§Type Parameters
ROWS
: Total number of rows in the panelCOLS
: Number of columns in the panelNROWS
: Number of rows per scan (typically half of ROWS)BITS
: Color depth (1-8 bits)FRAME_COUNT
: Number of frames used for Binary Code Modulation
§Helper Functions
Use these functions to compute the correct values:
esp_hub75::compute_frame_count(BITS)
: Computes the required number of framesesp_hub75::compute_rows(ROWS)
: Computes the number of rows per scan
§Memory Layout
The buffer is aligned to ensure efficient DMA transfers and contains:
- A 64-bit alignment field
- An array of frames, each containing the full panel data
Implementations§
Source§impl<const ROWS: usize, const COLS: usize, const NROWS: usize, const BITS: u8, const FRAME_COUNT: usize> DmaFrameBuffer<ROWS, COLS, NROWS, BITS, FRAME_COUNT>
impl<const ROWS: usize, const COLS: usize, const NROWS: usize, const BITS: u8, const FRAME_COUNT: usize> DmaFrameBuffer<ROWS, COLS, NROWS, BITS, FRAME_COUNT>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, ready-to-use framebuffer.
This creates a new framebuffer and automatically formats it with proper timing signals. The framebuffer is immediately ready for pixel operations and DMA transfers.
§Panics
Panics if BITS
is greater than 8, as only 1-8 bit color depths are supported.
§Example
use hub75_framebuffer::{Color,plain::DmaFrameBuffer,compute_rows,compute_frame_count};
const ROWS: usize = 32;
const COLS: usize = 64;
const BITS: u8 = 3; // Color depth (8 brightness levels, 7 frames)
const NROWS: usize = compute_rows(ROWS); // Number of rows per scan
const FRAME_COUNT: usize = compute_frame_count(BITS); // Number of frames for BCM
let mut framebuffer = DmaFrameBuffer::<ROWS, COLS, NROWS, BITS, FRAME_COUNT>::new();
// No need to call format() - framebuffer is ready to use!
Sourcepub fn format(&mut self)
pub fn format(&mut self)
Perform full formatting of the framebuffer with timing and control signals.
This sets up all the timing and control signals needed for proper HUB75 operation.
This is automatically called by new()
, so you typically don’t need to call this
unless you want to completely reinitialize the framebuffer.
§Example
use hub75_framebuffer::{Color,plain::DmaFrameBuffer,compute_rows,compute_frame_count};
const ROWS: usize = 32;
const COLS: usize = 64;
const BITS: u8 = 3; // Color depth (8 brightness levels, 7 frames)
const NROWS: usize = compute_rows(ROWS); // Number of rows per scan
const FRAME_COUNT: usize = compute_frame_count(BITS); // Number of frames for BCM
let mut framebuffer = DmaFrameBuffer::<ROWS, COLS, NROWS, BITS, FRAME_COUNT>::new();
framebuffer.format(); // Reinitialize if needed
Sourcepub fn erase(&mut self)
pub fn erase(&mut self)
Fast erase operation that clears all pixel data while preserving timing signals.
This is much faster than format()
when you just want to clear the display
since it preserves all the timing and control signals that are already set up.
Use this for clearing between frames or when you want to start drawing fresh content.
§Example
use hub75_framebuffer::{Color,plain::DmaFrameBuffer,compute_rows,compute_frame_count};
const ROWS: usize = 32;
const COLS: usize = 64;
const BITS: u8 = 3; // Color depth (8 brightness levels, 7 frames)
const NROWS: usize = compute_rows(ROWS); // Number of rows per scan
const FRAME_COUNT: usize = compute_frame_count(BITS); // Number of frames for BCM
let mut framebuffer = DmaFrameBuffer::<ROWS, COLS, NROWS, BITS, FRAME_COUNT>::new();
framebuffer.erase();
Sourcepub fn set_pixel(&mut self, p: Point, color: Color)
pub fn set_pixel(&mut self, p: Point, color: Color)
Set a pixel in the framebuffer.
§Example
use hub75_framebuffer::{Color,plain::DmaFrameBuffer,compute_rows,compute_frame_count};
use embedded_graphics::prelude::*;
const ROWS: usize = 32;
const COLS: usize = 64;
const BITS: u8 = 3; // Color depth (8 brightness levels, 7 frames)
const NROWS: usize = compute_rows(ROWS); // Number of rows per scan
const FRAME_COUNT: usize = compute_frame_count(BITS); // Number of frames for BCM
let mut framebuffer = DmaFrameBuffer::<ROWS, COLS, NROWS, BITS, FRAME_COUNT>::new();
framebuffer.set_pixel(Point::new(10, 10), Color::RED);
Trait Implementations§
Source§impl<const ROWS: usize, const COLS: usize, const NROWS: usize, const BITS: u8, const FRAME_COUNT: usize> Clone for DmaFrameBuffer<ROWS, COLS, NROWS, BITS, FRAME_COUNT>
impl<const ROWS: usize, const COLS: usize, const NROWS: usize, const BITS: u8, const FRAME_COUNT: usize> Clone for DmaFrameBuffer<ROWS, COLS, NROWS, BITS, FRAME_COUNT>
Source§fn clone(&self) -> DmaFrameBuffer<ROWS, COLS, NROWS, BITS, FRAME_COUNT>
fn clone(&self) -> DmaFrameBuffer<ROWS, COLS, NROWS, BITS, FRAME_COUNT>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more