Skip to content

Store a list of arrays at each location so duplicates aren't lost #1844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

geekykayaker
Copy link
Contributor

@geekykayaker geekykayaker commented Mar 2, 2025

Summary

Some Nanoleaf LEDs are in a strip
The Nanoleaf code calculates a position for each LED and stores each LED ID in a map, keying of X,Y.
With the layouts provided, LEDs have "overlapping" positions in X,Y in the corners.
This means that multiple LEDs land in the same map entry, overwriting existing IDs in the map.

At the end of the Nanoleaf init function is code to check the size of the map matches the number of LEDs.
In my setup, this was failing because of the 'overwritten' IDs aren't counted.

To fix this I've changed the value of the Map to be a vector of IDs, which allows for duplicates to be tracked correctly.
I've also improved the logging slightly to show that duplicates have been found.

This change is expected to have zero impact on any previously working configuration, as all the vectors will have size 1

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of web configuration, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing setups:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's body (e.g. Fixes: #xxx[,#xxx], where "xxx" is the issue number)

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated (docs/docs/en)
  • Related tests have been updated

PLEASE DON'T FORGET TO ADD YOUR CHANGES TO CHANGELOG.MD

  • Yes, CHANGELOG.md is also updated

To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

@Lord-Grey
Copy link
Collaborator

@geekykayaker Thank you so much for your contribution and improving the Nanoleaf codebase.
Have you had the chance to check, if the "Generate Layout" code in the UI works correctly for the overlapping panel scenario?

I assume so, but would like to be on the save side :)

function nanoleafGeneratelayout(panelLayout, panelOrderTopDown, panelOrderLeftRight) {

@Lord-Grey Lord-Grey moved this from Backlog to In Progress in Output Devices Mar 9, 2025
@geekykayaker
Copy link
Contributor Author

Actually, there are further issues with this set up…
The kit I’m using is the Nanoleaf 4D that came with a camera.
It looks like the Nanoleaf controller itself remaps the LEDs, because when Hyperion lights up the LEDs sequentially the Nanoleaf lights don’t light up sequentially, but every LED did appear to light at some point in the sequence.
For Hyperion to work, I’d have to manually enter the coordinates of each remapped LED, and which would have been very manual and hard to calibrate.
Instead, I have cut up the LED strip to try and wire to my own controller, so unfortunately I can’t do further testing.
I still think that doing “something” is better that failing with an “error”, but appreciate this change doesn’t fix everything.

@geekykayaker geekykayaker removed their assignment Mar 9, 2025
@Lord-Grey
Copy link
Collaborator

For Hyperion to work, I’d have to manually enter the coordinates of each remapped LED, and which would have been very manual and hard to calibrate.

This would have to be addressed by the layout generation...
...but anyway, thanks for the fix that the device will not fail.

@Lord-Grey Lord-Grey merged commit d66e915 into hyperion-project:master Mar 9, 2025
16 of 18 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Output Devices Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants