docs: Update lessons_learned.md with Ambilight color mapping details

This commit is contained in:
Tobias J. Endres 2025-08-16 00:55:55 +02:00
parent 3425fe26b5
commit 0a5186bc70

View File

@ -274,4 +274,35 @@ To improve the diagnostic script, we can:
**Phase 3: Integrate into HyperionGrabber**
### Ambilight Color Mapping Implementation
**Goal:** Implement initial Ambilight color mapping in `Hyperion_Grabber_Wayland_QT` to visually reflect screen content on LEDs.
**Challenges & Solutions:**
1. **Combining Old `hyperiongrabber.cpp` with New `WledClient`:**
* **Problem:** Reverting `hyperiongrabber.cpp` to an older commit (where LED activity was present but flickering) caused compilation errors due to incompatibility with the updated `WledClient` (which now expects `setLedsColor(const QVector<QColor> &colors)` instead of `sendImage(const QImage &image)`).
* **Solution:** Modified `hyperiongrabber.cpp` to use the current `WledClient`'s `setLedsColor` method. Initially, a dummy `QVector<QColor>` (all white) was sent to ensure compilation.
2. **Basic Region Sampling and Color Assignment:**
* **Problem:** The `HyperionGrabber` was previously sending the entire `scaledImage` to the WLED client, not performing Ambilight-specific region sampling.
* **Solution:** Implemented a simplified Ambilight color mapping logic within `hyperiongrabber.cpp`. This involves:
* Hardcoding a basic LED layout (e.g., 10 LEDs on top, right, bottom, left).
* Calculating sampling points within the `scaledImage` for each LED.
* Using `scaledImage.pixelColor(x, y)` to get the color at each sampling point.
* Collecting these sampled colors into a `QVector<QColor>`.
* Sending this `QVector<QColor>` to `_client_p->setLedsColor()`.
**Implementation Details:**
* Modified `hyperiongrabber.cpp` to replace the `_client_p->sendImage(scaledImage)` call with the new Ambilight color mapping logic.
* Added `#include <QVector>` to `hyperiongrabber.cpp` for `QVector<QColor>`.
* Added a dummy `setLedsColor` method to `debugclient.h` to ensure compilation when `DEBUG_MODE` is enabled.
* Resolved naming mismatch: Changed `_wledClient_p` to `_client_p` in `hyperiongrabber.cpp` to align with `hyperiongrabber.h`.
**Current Status:**
* The `Hyperion_Grabber_Wayland_QT` now performs basic Ambilight color mapping, and LEDs react to screen changes.
* Flickering might still be present, as the `_changeThreshold_m` (for static screen detection) has not yet been re-implemented or adjusted in this version of `hyperiongrabber.cpp`.
* **Step 5: Refine `HyperionGrabber`'s LED Mapping:** Once the LED mapping is definitively established and documented, we will integrate this knowledge into `HyperionGrabber` to correctly sample screen regions and send data to WLED.