Skip to content

Commit 2fc6420

Browse files
committed
parlio tweaks
1 parent 0ad4fee commit 2fc6420

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

docs/moonbase/inputoutput.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Currently the following boards are defined. Not all are supported yet 🚧
1010

1111
For each board the following presets are defined:
1212

13-
* Modded: if any change to the default preset is made. Press off to go back to standard. If any pin is not default, modded will be set.
13+
* Modded: set when any pin differs from the selected board preset. Press off to return to the preset defaults.
1414
* Max Power in Watts: adjust the brightness to approach this max power, depending on the number of LEDs used. Default 10: 5V * 2A = 10W (so it runs fine on USB). Used by LED drivers, see [Drivers](../../moonlight/drivers/)
1515
* Jumper1: If the board contains a jumper, it can define pin behaviour. Eg. select between Infrared and Ethernet.
1616
* Pins: Assign functionality to gpio pins. Other modules and nodes use the pin assignments made here.
@@ -28,7 +28,7 @@ For each board the following presets are defined:
2828

2929
* Supported
3030
* LEDs: Used by LED drivers to setup LED outputs, see [Drivers](../../moonlight/drivers/)
31-
* Voltage and Current: Sets energy monitoring, see [System status](../../system/status) and , see [System Metrics](../../system/metrics)
31+
* Voltage and Current: Sets energy monitoring, see [System status](../../system/status) and [System Metrics](../../system/metrics)
3232
* Infrared: Used by IR driver, see [Drivers](../../moonlight/drivers/)
3333
* Button LightsOn: sets on/off in [Light Control](../../moonlight/lightscontrol/)
3434
* Relay LightsOn: sets on/off in [Light Control](../../moonlight/lightscontrol/)
@@ -71,10 +71,10 @@ For each board the following presets are defined:
7171

7272
* Choose the esp32-p4-nano board in the [MoonLight Installer](../../gettingstarted/installer/)
7373
* On new boards, the WiFi coprocessor needs to be updated first to a recent version, currently v2.0.17, see the link in the [MoonLight Installer](../../gettingstarted/installer/)
74-
* After install, select the MHC P4 shield board preset to have the pins assigned correctly.
75-
* Assuming 100W LED power!! Change if not!
76-
* Jumper1: off (default): 16 LED pins. On: 8 LED pins, 4 RS-485 pins and 4 exposed pins (set the switches on the board!)
77-
* Add the Parallel LED Driver, see [Drivers](../../moonlight/drivers/). It uses @troyhacks his parallel IO driver to drive all the 12 LED pins of the P4 shield.
74+
* After install, select the **MHC P4 Nano Shield** board preset to have the pins assigned correctly.
75+
* Assuming 100W LED power; change if needed.
76+
* Jumper1: off (default): 16 LED pins. On: 8 LED pins, 4 RS-485 pins and 4 exposed pins (set also the switches on the board).
77+
* Add the Parallel LED Driver, see [Drivers](../../moonlight/drivers/). It uses @troyhacks his parallel IO driver to drive all LED pins configured for the shield.
7878

7979
![ESP32-P4 shield](https://shop.myhome-control.de/thumbnail/87/41/c2/1762031307/WLED_ESP32_P4_Shield_02_1920x1326.jpg?ts=1762031315){: style="width:320px"}
8080

src/MoonLight/Nodes/Drivers/D_ParallelLEDDriver.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ class ParallelLEDDriver : public DriverNode {
6161
#else
6262
// LUTs are accessed directly within show_parlio via extern ledsDriver
6363
// No brightness parameter needed
64-
show_parlio(pins, layer->layerP->lights.header.nrOfLights, layer->layerP->lights.channels,
65-
// REMOVED: ledsDriver._brightness,
66-
layer->layerP->lights.header.channelsPerLight == 4, nrOfPins, layer->layerP->ledsPerPin[0], layer->layerP->lights.header.offsetRed, layer->layerP->lights.header.offsetGreen, layer->layerP->lights.header.offsetBlue);
64+
show_parlio(pins, layer->layerP->lights.header.nrOfLights, layer->layerP->lights.channels, layer->layerP->lights.header.channelsPerLight == 4, nrOfPins, layer->layerP->ledsPerPin[0], layer->layerP->lights.header.offsetRed, layer->layerP->lights.header.offsetGreen, layer->layerP->lights.header.offsetBlue);
6765
#endif
6866
}
6967
#else // ESP32_LEDSDRIVER
@@ -113,6 +111,8 @@ class ParallelLEDDriver : public DriverNode {
113111
updateControl("status", statusString.c_str());
114112
moduleNodes->requestUIUpdate = true;
115113

114+
// ESP32-P4: Uses parlio driver with direct LUT access (no explicit init needed)
115+
// Non-P4: Uses Yves driver with DMA buffer allocation and initled()
116116
#ifndef CONFIG_IDF_TARGET_ESP32P4 // Non P4: Yves driver
117117

118118
if (!initDone) {

src/MoonLight/Nodes/Drivers/parlio.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ namespace LedMatrixDetail {
2525

2626
// This intermediate step is common to all packing functions.
2727
// It transposes the data for 32 time-slices into a cache-friendly temporary buffer.
28-
inline void transpose_32_slices(uint32_t (&transposed_slices)[32], // Output buffer (on stack)
29-
const uint8_t* input_buffer, const uint32_t pixel_in_pin, const uint32_t component_in_pixel, const uint32_t pixels_per_pin, const uint32_t num_active_pins, const uint32_t COMPONENTS_PER_PIXEL, const uint32_t* waveform_cache, const uint8_t* brightness_cache) {
28+
inline void transpose_32_slices(uint32_t (&transposed_slices)[32], const uint8_t* input_buffer, const uint32_t pixel_in_pin, const uint32_t input_component, const uint32_t pixels_per_pin, const uint32_t num_active_pins, const uint32_t COMPONENTS_PER_PIXEL, const uint32_t* waveform_cache, const uint8_t* brightness_cache) {
3029
memset(transposed_slices, 0, sizeof(uint32_t) * 32);
3130

3231
for (uint32_t pin = 0; pin < num_active_pins; ++pin) {
3332
const uint32_t pixel_idx = (pin * pixels_per_pin) + pixel_in_pin;
34-
const uint32_t component_idx = (pixel_idx * COMPONENTS_PER_PIXEL) + component_in_pixel;
33+
const uint32_t component_idx = (pixel_idx * COMPONENTS_PER_PIXEL) + input_component; // ← Now uses input_component!
3534
const uint8_t data_byte = brightness_cache[input_buffer[component_idx]];
3635
const uint32_t waveform = waveform_cache[data_byte];
3736
const uint32_t pin_bit = (1 << pin);
@@ -205,24 +204,24 @@ void create_transposed_led_output_optimized(const uint8_t* input_buffer, uint16_
205204

206205
uint32_t transposed_slices[32];
207206

208-
// Select the appropriate LUT based on which INPUT channel we're processing
207+
// Select LUT based on INPUT component (which color we're reading from lights.channels)
209208
const uint8_t* brightness_cache;
210-
switch (component_in_pixel) {
209+
switch (input_component) { // ← Change 1: Use input_component
211210
case 0:
212-
brightness_cache = ledsDriver.__red_map;
211+
brightness_cache = ledsDriver.__red_map; // Position 0 in RGB array = RED
213212
break;
214213
case 1:
215-
brightness_cache = ledsDriver.__green_map;
214+
brightness_cache = ledsDriver.__green_map; // Position 1 in RGB array = GREEN
216215
break;
217216
case 2:
218-
brightness_cache = ledsDriver.__blue_map;
217+
brightness_cache = ledsDriver.__blue_map; // Position 2 in RGB array = BLUE
219218
break;
220219
case 3:
221220
brightness_cache = ledsDriver.__white_map;
222221
break;
223222
default:
224223
brightness_cache = ledsDriver.__red_map;
225-
break; // Fallback
224+
break;
226225
}
227226

228227
LedMatrixDetail::transpose_32_slices(transposed_slices, input_buffer, pixel_in_pin, input_component, pixels_per_pin, num_active_pins, COMPONENTS_PER_PIXEL, waveform_cache, brightness_cache);
@@ -429,7 +428,7 @@ uint8_t IRAM_ATTR __attribute__((hot)) show_parlio(uint8_t* parallelPins, uint32
429428
#endif
430429
parallel_buffer_repacked = (parallel_buffer_repacked == parallel_buffer_repacked1) ? parallel_buffer_repacked2 : parallel_buffer_repacked1;
431430

432-
if (after - before < 50) delayMicroseconds(20);
431+
// if (after - before < 50) delayMicroseconds(20);
433432

434433
// portENTER_CRITICAL(&parlio_spinlock);
435434
for (int i = 0; i < num_chunks && i < 4; ++i) {

0 commit comments

Comments
 (0)