1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//! Framebuffer implementation for HUB75 LED matrix displays.
//!
//! This module provides two different framebuffer implementations optimized for
//! HUB75 LED matrix displays:
//!
//! 1. **Plain Implementation** (`plain` module)
//! - No additional hardware requirements
//! - Simpler implementation suitable for basic displays
//!
//! 2. **Latched Implementation** (`latched` module)
//! - Requires external latch hardware for address lines
//!
//! Both implementations:
//! - Have configurable row and column dimensions
//! - Support different color depths through Binary Code Modulation (BCM)
//! - Implement the `ReadBuffer` trait for DMA compatibility
//!
//! # Examples
//!
//! ```rust,no_run
//! use embedded_graphics::pixelcolor::Rgb888;
//! use esp_hal::dma::ReadBuffer;
//!
//! use crate::framebuffer::FrameBuffer;
//! use crate::framebuffer::MutableFrameBuffer;
//!
//! // Create a framebuffer with specific dimensions
//! const ROWS: usize = 32;
//! const COLS: usize = 64;
//! const NROWS: usize = ROWS / 2;
//! const BITS: u8 = 8;
//! const FRAME_COUNT: usize = (1 << BITS) - 1;
//! ```
use DrawTarget;
use Rgb888;
use ReadBuffer;
/// Color type used in the framebuffer
pub type Color = Rgb888;
/// Word size configuration for the framebuffer
/// Computes the NROWS value from ROWS for DmaFrameBuffer
///
/// # Arguments
///
/// * `rows` - Total number of rows in the display
///
/// # Returns
///
/// Number of rows needed internally for DmaFrameBuffer
pub const
/// Computes the number of frames needed for a given bit depth
///
/// This is used to determine how many frames are needed to achieve
/// the desired color depth through Binary Code Modulation (BCM).
///
/// # Arguments
///
/// * `bits` - Number of bits per color channel
///
/// # Returns
///
/// Number of frames required for the given bit depth
pub const
/// Trait for read-only framebuffers
///
/// This trait defines the basic functionality required for a framebuffer
/// that can be read from and transferred via DMA.
///
/// # Type Parameters
///
/// * `ROWS` - Total number of rows in the display
/// * `COLS` - Number of columns in the display
/// * `NROWS` - Number of rows processed in parallel
/// * `BITS` - Number of bits per color channel
/// * `FRAME_COUNT` - Number of frames needed for BCM
/// Trait for mutable framebuffers
///
/// This trait extends `FrameBuffer` with the ability to draw to the framebuffer
/// using the `embedded_graphics` drawing primitives.
///
/// # Type Parameters
///
/// * `ROWS` - Total number of rows in the display
/// * `COLS` - Number of columns in the display
/// * `NROWS` - Number of rows processed in parallel
/// * `BITS` - Number of bits per color channel
/// * `FRAME_COUNT` - Number of frames needed for BCM