#[repr(C, align(4))]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 with external latch circuit support.
This implementation is optimized for memory usage and external latch circuit support:
- Uses 8-bit entries instead of 16-bit
- Separates address and data words
- Supports the external latch circuit for row selection
- 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:
- An array of frames, each containing the full panel data
- Each frame contains NROWS rows
- Each row contains both data and address words
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 framebuffer with the given number of frames. The framebuffer is automatically formatted and ready to use.
§Example
use hub75_framebuffer::{latched::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();
// Ready to use immediately
Sourcepub fn format(&mut self)
pub fn format(&mut self)
Format the framebuffer, setting up all control bits and clearing pixel data.
This method does a full format of all control bits and clears all pixel data.
Normally you don’t need to call this as new()
automatically formats the framebuffer.
§Example
use hub75_framebuffer::{Color,latched::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(); // Not needed - new() already calls this
Sourcepub fn erase(&mut self)
pub fn erase(&mut self)
Erase pixel colors while preserving control bits.
This is much faster than format()
and is the typical way to clear the display.
§Example
use hub75_framebuffer::{Color,latched::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();
// ... draw some pixels ...
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,latched::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