Skip to content

Commit 0379390

Browse files
Add support for 4-bit and 5-bit color depth (#42)
Extends the minimum supported bit depth from 6-bit to 4-bit, enabling higher refresh rates on large panel arrays at the cost of reduced color gradation. Changes: - Update static_assert in color_lut.h to allow BitDepth >= 4 - Add DEPTH_4 and DEPTH_5 options to Kconfig with descriptive help text - Update documentation (COLOR_GAMMA.md, MENUCONFIG.md, README.md) with new bit depth options and use case guidance
1 parent ffc0247 commit 0379390

File tree

6 files changed

+46
-12
lines changed

6 files changed

+46
-12
lines changed

components/hub75/Kconfig

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ menu "HUB75 RGB LED Matrix Driver"
214214
Higher bit depth = better color gradients but slower refresh rate.
215215
Changes require full rebuild to regenerate LUT.
216216

217-
- 6-bit: 64 levels/channel (fastest refresh)
217+
- 4-bit: 16 levels/channel (maximum refresh, limited colors)
218+
- 5-bit: 32 levels/channel
219+
- 6-bit: 64 levels/channel (fast refresh)
218220
- 7-bit: 128 levels/channel
219221
- 8-bit: 256 levels/channel (good balance)
220222
- 9-bit: 512 levels/channel
@@ -224,8 +226,21 @@ menu "HUB75 RGB LED Matrix Driver"
224226

225227
Driver auto-adjusts BCM timing to maintain target refresh rate.
226228

229+
config DEPTH_4
230+
bool "4-bit (Maximum Refresh)"
231+
help
232+
16 levels per channel (4,096 total colors).
233+
Use for very large panel arrays where refresh rate is critical.
234+
Visible banding in gradients is expected.
235+
236+
config DEPTH_5
237+
bool "5-bit"
238+
help
239+
32 levels per channel (32,768 total colors).
240+
Good balance between refresh rate and color quality for large displays.
241+
227242
config DEPTH_6
228-
bool "6-bit (Fastest)"
243+
bool "6-bit (Fast)"
229244

230245
config DEPTH_7
231246
bool "7-bit"
@@ -248,6 +263,8 @@ menu "HUB75 RGB LED Matrix Driver"
248263

249264
config HUB75_BIT_DEPTH
250265
int
266+
default 4 if DEPTH_4
267+
default 5 if DEPTH_5
251268
default 6 if DEPTH_6
252269
default 7 if DEPTH_7
253270
default 8 if DEPTH_8

components/hub75/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ config.layout = Hub75PanelLayout::HORIZONTAL;
204204

205205
**Higher quality display:**
206206
```cpp
207-
// Bit depth: Configure via menuconfig (6-12 bit available)
207+
// Bit depth: Configure via menuconfig (4-12 bit available)
208208
// (idf.py menuconfig → HUB75 → Panel Settings → Bit Depth)
209209
config.double_buffer = true; // Tear-free updates
210210
config.min_refresh_rate = 90; // Smoother for cameras
@@ -218,7 +218,7 @@ config.rotation = Hub75Rotation::ROTATE_90; // 90° clockwise
218218
```
219219

220220
**Bit Depth Configuration:**
221-
Bit depth is **compile-time only** (6-12 bits supported):
221+
Bit depth is **compile-time only** (4-12 bits supported):
222222
- Configure via `idf.py menuconfig` → HUB75 → Panel Settings → Bit Depth
223223
- Or CMake: `target_compile_definitions(app PRIVATE HUB75_BIT_DEPTH=10)`
224224
- Changes require full rebuild (regenerates LUT at compile time)

components/hub75/include/hub75_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extern "C" {
5555
#endif
5656

5757
/**
58-
* Bit depth configuration (6-12 bits)
58+
* Bit depth configuration (4-12 bits)
5959
* Set via menuconfig or override: -DHUB75_BIT_DEPTH=10
6060
*/
6161
#ifndef HUB75_BIT_DEPTH

components/hub75/src/color/color_lut.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ constexpr double cie1931(double lightness) {
112112

113113
/**
114114
* @brief Generate CIE 1931 lookup table at compile time
115-
* @tparam BitDepth Target bit depth (6-12)
115+
* @tparam BitDepth Target bit depth (4-12)
116116
* @return std::array of 256 values scaled to BitDepth range
117117
*/
118118
template<uint8_t BitDepth> constexpr std::array<uint16_t, 256> generate_cie1931_lut() {
119-
static_assert(BitDepth >= 6 && BitDepth <= 12, "Bit depth must be 6-12");
119+
static_assert(BitDepth >= 4 && BitDepth <= 12, "Bit depth must be 4-12");
120120

121121
constexpr uint16_t max_val = (1 << BitDepth) - 1;
122122
std::array<uint16_t, 256> lut{};
@@ -138,7 +138,7 @@ template<uint8_t BitDepth> constexpr std::array<uint16_t, 256> generate_cie1931_
138138
* @brief Generate Gamma 2.2 lookup table at compile time
139139
*/
140140
template<uint8_t BitDepth> constexpr std::array<uint16_t, 256> generate_gamma22_lut() {
141-
static_assert(BitDepth >= 6 && BitDepth <= 12, "Bit depth must be 6-12");
141+
static_assert(BitDepth >= 4 && BitDepth <= 12, "Bit depth must be 4-12");
142142

143143
constexpr uint16_t max_val = (1 << BitDepth) - 1;
144144
std::array<uint16_t, 256> lut{};
@@ -158,7 +158,7 @@ template<uint8_t BitDepth> constexpr std::array<uint16_t, 256> generate_gamma22_
158158
* @brief Generate Linear lookup table at compile time
159159
*/
160160
template<uint8_t BitDepth> constexpr std::array<uint16_t, 256> generate_linear_lut() {
161-
static_assert(BitDepth >= 6 && BitDepth <= 12, "Bit depth must be 6-12");
161+
static_assert(BitDepth >= 4 && BitDepth <= 12, "Bit depth must be 4-12");
162162

163163
constexpr uint16_t max_val = (1 << BitDepth) - 1;
164164
std::array<uint16_t, 256> lut{};

docs/COLOR_GAMMA.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ Driver uses **CIE 1931** by default (better for LEDs). Future: configurable gamm
8080

8181
| Depth | Colors | Levels/Channel | Gradient Quality | Memory | Refresh Rate |
8282
|-------|--------|----------------|------------------|--------|--------------|
83-
| **8-bit** | 16.7M | 256 | Good | Baseline | Fast |
84-
| **10-bit** | 1.07B | 1024 | Better | +25% | Medium |
85-
| **12-bit** | 68.7B | 4096 | Best | +50% | Slower |
83+
| **4-bit** | 4K | 16 | Limited | -50% | Maximum |
84+
| **5-bit** | 32K | 32 | Basic | -37% | Very Fast |
85+
| **6-bit** | 262K | 64 | Acceptable | -25% | Fast |
86+
| **8-bit** | 16.7M | 256 | Good | Baseline | Medium |
87+
| **10-bit** | 1.07B | 1024 | Better | +25% | Slower |
88+
| **12-bit** | 68.7B | 4096 | Best | +50% | Slowest |
8689

8790
### Trade-offs
8891

@@ -96,6 +99,17 @@ Driver uses **CIE 1931** by default (better for LEDs). Future: configurable gamm
9699

97100
### When to Use Each Depth
98101

102+
**4-bit / 5-bit**:
103+
- Very large panel arrays where refresh rate is critical
104+
- Simple graphics, text displays, status indicators
105+
- Visible banding in gradients is expected
106+
- Maximum refresh rate for smooth animations on large displays
107+
108+
**6-bit**:
109+
- Large multi-panel setups needing high refresh
110+
- Gaming displays, fast animations
111+
- Acceptable gradient quality with CIE 1931 correction
112+
99113
**8-bit**:
100114
- General use, animations, gaming displays
101115
- Fast refresh (120+ Hz achievable)

docs/MENUCONFIG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ Choose which example to build in main/:
141141
- **Type**: choice
142142
- **Default**: 8-bit
143143
- **Options**:
144+
- `4-bit` - 16 levels/channel (maximum refresh, limited colors)
145+
- `5-bit` - 32 levels/channel (very fast refresh)
146+
- `6-bit` - 64 levels/channel (fast refresh)
144147
- `8-bit` - 256 levels/channel (good balance)
145148
- `10-bit` - 1024 levels/channel (better gradients)
146149
- `12-bit` - 4096 levels/channel (best quality)

0 commit comments

Comments
 (0)