Skip to content
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

drivers: led_strip: apa102: brightness & end frame #74073

Closed
wants to merge 2 commits into from

Conversation

fouge
Copy link
Contributor

@fouge fouge commented Jun 11, 2024

  • use scratch byte to set brightness
  • fix end frame in case more than 64 LEDs

use scratch byte in struct led_rgb to set brightness

Signed-off-by: Cyril Fougeray <cyril.fougeray@toolsforhumanity.com>
@fouge fouge requested a review from mbolivar-ampere as a code owner June 11, 2024 11:41
@zephyrbot zephyrbot added the area: LED Label to identify LED subsystem label Jun 11, 2024
@fouge fouge force-pushed the worldcoin/apa102 branch from d0571eb to 9819036 Compare June 11, 2024 11:54
end frame used to supply clock pulses so that
data goes to next led

Signed-off-by: Cyril Fougeray <cyril.fougeray@toolsforhumanity.com>
@fouge fouge force-pushed the worldcoin/apa102 branch from 9819036 to 85209f6 Compare June 11, 2024 12:02
Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fouge,

Thanks for this PR.

It is not correct to use the scratch byte to pass the brightness. It is a hack :) As specified in the API, this is simply a placeholder for some drivers, to help serialize 3 RGB bytes into 4 bytes (wire format). Drivers are not free to assign the usage they want to this parameter.

Please, can you explain what is the gain in supporting the global brightness register for this chip ? You already have 255 levels of brightness for each color channel...

Note that the ->update_channels() API method could be implemented to offer control of more registers to users.

BUILD_ASSERT(sizeof(struct led_rgb) == 4);
uint8_t ones[((size / sizeof(struct led_rgb)) / sizeof(uint8_t) / 2) + 1];

memset(ones, 0xFF, sizeof(ones));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a bug with the current code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, not enough 1 are sent in case there are more than 64 LEDs in the strip. The following LED after the 64th are not actuated.

It's not correctly documented in the APA102 datasheet

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Please fill a bug report and submit a separate PR to fix it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fouge. Are you moving forward on this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonguinot simonguinot self-assigned this Jun 12, 2024
* number of clock pulses required is exactly half the total number
* of LEDs in the string
*/
BUILD_ASSERT(sizeof(struct led_rgb) == 4);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a problem, but it is customary not to write BUILD_ASSERT inside a function.
I think it would be better to put it inside APA102_DEVICE macro.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#76533 split into another PR to remove how brightness is being used

@fouge
Copy link
Contributor Author

fouge commented Jul 31, 2024

superseded by #76533

@fouge fouge closed this Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LED Label to identify LED subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants