Skip to content

Commit 861889f

Browse files
Have gamma mode and bcm bit depth set at compile time rather than in config (#8)
1 parent ef92449 commit 861889f

File tree

15 files changed

+312
-413
lines changed

15 files changed

+312
-413
lines changed

components/hub75/Kconfig

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -205,30 +205,57 @@ menu "HUB75 RGB LED Matrix Driver"
205205
bool "DP3246"
206206
endchoice
207207

208-
choice HUB75_BIT_DEPTH
208+
choice
209209
prompt "Bit Depth"
210-
default HUB75_BIT_DEPTH_8
210+
default DEPTH_8
211211
help
212212
Color bit depth per channel (R/G/B).
213213

214214
Higher bit depth = better color gradients but slower refresh rate.
215+
Changes require full rebuild to regenerate LUT.
215216

216-
- 8-bit: 256 levels/channel, 16.7M colors (good balance)
217-
- 10-bit: 1024 levels/channel, 1.07B colors (better gradients)
218-
- 12-bit: 4096 levels/channel, 68.7B colors (best quality)
217+
- 6-bit: 64 levels/channel (fastest refresh)
218+
- 7-bit: 128 levels/channel
219+
- 8-bit: 256 levels/channel (good balance)
220+
- 9-bit: 512 levels/channel
221+
- 10-bit: 1024 levels/channel (recommended)
222+
- 11-bit: 2048 levels/channel
223+
- 12-bit: 4096 levels/channel (best quality)
219224

220225
Driver auto-adjusts BCM timing to maintain target refresh rate.
221226

222-
config HUB75_BIT_DEPTH_8
227+
config DEPTH_6
228+
bool "6-bit (Fastest)"
229+
230+
config DEPTH_7
231+
bool "7-bit"
232+
233+
config DEPTH_8
223234
bool "8-bit (Good Balance)"
224235

225-
config HUB75_BIT_DEPTH_10
226-
bool "10-bit (Better Gradients)"
236+
config DEPTH_9
237+
bool "9-bit"
238+
239+
config DEPTH_10
240+
bool "10-bit (Recommended)"
227241

228-
config HUB75_BIT_DEPTH_12
242+
config DEPTH_11
243+
bool "11-bit"
244+
245+
config DEPTH_12
229246
bool "12-bit (Best Quality)"
230247
endchoice
231248

249+
config HUB75_BIT_DEPTH
250+
int
251+
default 6 if DEPTH_6
252+
default 7 if DEPTH_7
253+
default 8 if DEPTH_8
254+
default 9 if DEPTH_9
255+
default 10 if DEPTH_10
256+
default 11 if DEPTH_11
257+
default 12 if DEPTH_12
258+
232259
choice HUB75_CLOCK_SPEED
233260
prompt "Output Clock Speed"
234261
default HUB75_CLK_20MHZ
@@ -614,30 +641,37 @@ menu "HUB75 RGB LED Matrix Driver"
614641

615642
menu "Color"
616643

617-
choice HUB75_GAMMA_MODE
644+
choice
618645
prompt "Gamma Correction Mode"
619-
default HUB75_GAMMA_CIE1931
646+
default GAMMA_CIE1931
620647
help
621648
Gamma correction mode for color output.
649+
Changes require full rebuild to regenerate LUT.
622650

623-
- CIE1931: Standard perceptual lightness curve (recommended)
624651
- Linear: No gamma correction (1:1 mapping)
625-
- None: Alias for Linear
652+
- CIE1931: Standard perceptual lightness curve (recommended)
653+
- Gamma 2.2: Standard gamma 2.2 correction
626654

627655
CIE1931 provides better visual color gradients by matching
628-
human perception of brightness. Linear/None provides direct
656+
human perception of brightness. Linear provides direct
629657
hardware mapping but may appear less smooth.
630658

631-
config HUB75_GAMMA_CIE1931
632-
bool "CIE1931 (Perceptual)"
633-
634-
config HUB75_GAMMA_LINEAR
659+
config GAMMA_LINEAR
635660
bool "Linear (No Correction)"
636661

637-
config HUB75_GAMMA_NONE
638-
bool "None (Same as Linear)"
662+
config GAMMA_CIE1931
663+
bool "CIE1931 (Perceptual)"
664+
665+
config GAMMA_2_2
666+
bool "Gamma 2.2"
639667
endchoice
640668

669+
config HUB75_GAMMA_MODE
670+
int
671+
default 0 if GAMMA_LINEAR
672+
default 1 if GAMMA_CIE1931
673+
default 2 if GAMMA_2_2
674+
641675
endmenu
642676

643677
# ========================================

components/hub75/README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,14 @@ Double buffering doubles memory usage but enables tear-free animation. PARLIO us
142142
- `uint8_t get_brightness()` - Get current brightness value
143143

144144
**Gamma Correction:**
145-
Gamma correction mode is set at initialization via `config.gamma_mode` and cannot be changed at runtime:
146-
- `Hub75GammaMode::NONE` - No gamma correction (linear)
147-
- `Hub75GammaMode::CIE1931` - CIE 1931 standard (recommended, default)
148-
- `Hub75GammaMode::GAMMA_2_2` - Gamma 2.2 correction
145+
Gamma correction mode is **compile-time only** (configured via menuconfig):
146+
- `HUB75_GAMMA_MODE=0` - Linear (no correction)
147+
- `HUB75_GAMMA_MODE=1` - CIE 1931 standard (recommended, default)
148+
- `HUB75_GAMMA_MODE=2` - Gamma 2.2
149+
150+
Configure via:
151+
- `idf.py menuconfig` → HUB75 → Color → Gamma Correction Mode
152+
- Or CMake: `target_compile_definitions(app PRIVATE HUB75_GAMMA_MODE=1)`
149153

150154
**Dual-Mode Brightness System:**
151155
- **Basis brightness** (0-255): Adjusts hardware OE (output enable) timing in DMA buffers
@@ -180,11 +184,18 @@ config.layout = PanelLayout::HORIZONTAL;
180184

181185
**Higher quality display:**
182186
```cpp
183-
config.bit_depth = 10; // Better gradients
187+
// Bit depth: Configure via menuconfig (6-12 bit available)
188+
// (idf.py menuconfig → HUB75 → Panel Settings → Bit Depth)
184189
config.double_buffer = true; // Tear-free updates
185190
config.min_refresh_rate = 90; // Smoother for cameras
186191
```
187192

193+
**Bit Depth Configuration:**
194+
Bit depth is **compile-time only** (6-12 bits supported):
195+
- Configure via `idf.py menuconfig` → HUB75 → Panel Settings → Bit Depth
196+
- Or CMake: `target_compile_definitions(app PRIVATE HUB75_BIT_DEPTH=10)`
197+
- Changes require full rebuild (regenerates LUT at compile time)
198+
188199
**For complete configuration reference** (all scan patterns, layouts, clock speeds, bit depth options, pin configuration, etc.), see **[MENUCONFIG.md](../../docs/MENUCONFIG.md)**.
189200

190201
## Multi-Panel Layouts

components/hub75/include/hub75_config.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,30 @@ extern "C" {
5454
#define HUB75_MAX_CHAINED_PANELS 8
5555
#endif
5656

57+
/**
58+
* Bit depth configuration (6-12 bits)
59+
* Set via menuconfig or override: -DHUB75_BIT_DEPTH=10
60+
*/
61+
#ifndef HUB75_BIT_DEPTH
62+
#ifdef CONFIG_HUB75_BIT_DEPTH
63+
#define HUB75_BIT_DEPTH CONFIG_HUB75_BIT_DEPTH
64+
#else
65+
#define HUB75_BIT_DEPTH 8 // Default if no Kconfig
66+
#endif
67+
#endif
68+
69+
/**
70+
* Gamma mode (0=LINEAR/NONE, 1=CIE1931, 2=GAMMA_2_2)
71+
* Set via menuconfig or override: -DHUB75_GAMMA_MODE=1
72+
*/
73+
#ifndef HUB75_GAMMA_MODE
74+
#ifdef CONFIG_HUB75_GAMMA_MODE
75+
#define HUB75_GAMMA_MODE CONFIG_HUB75_GAMMA_MODE
76+
#else
77+
#define HUB75_GAMMA_MODE 1 // Default: CIE1931
78+
#endif
79+
#endif
80+
5781
#ifdef __cplusplus
5882
}
5983
#endif

components/hub75/include/hub75_types.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313
extern "C" {
1414
#endif
1515

16-
/**
17-
* @brief Gamma correction mode
18-
*/
19-
enum class Hub75GammaMode {
20-
NONE = 0, // No gamma correction (linear)
21-
CIE1931, // CIE 1931 perceptual correction
22-
GAMMA_2_2, // Standard gamma 2.2
23-
};
24-
2516
/**
2617
* @brief Pixel buffer format for bulk drawing operations
2718
*/
@@ -197,7 +188,6 @@ struct Hub75Config {
197188
// ========================================
198189

199190
Hub75ClockSpeed output_clock_speed = Hub75ClockSpeed::HZ_20M; // Output clock speed (default: 20MHz)
200-
uint8_t bit_depth = 8; // BCM bit depth: 6-12 (default: 8)
201191
uint16_t min_refresh_rate = 60; // Minimum refresh rate in Hz (default: 60)
202192

203193
// ========================================
@@ -218,8 +208,7 @@ struct Hub75Config {
218208
// Color
219209
// ========================================
220210

221-
Hub75GammaMode gamma_mode = Hub75GammaMode::CIE1931; // Gamma correction mode (default: CIE1931)
222-
uint8_t brightness = 128; // Initial brightness 0-255 (default: 128)
211+
uint8_t brightness = 128; // Initial brightness 0-255 (default: 128)
223212
};
224213

225214
#ifdef __cplusplus

0 commit comments

Comments
 (0)