Allow setting full-on and full-off bits via set_all_on_off() #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
I use the PCA9685 for driving multichannel LED strips with animations. In every animation step, I update all on/off values with
set_all_on_off()
and afterwards useset_channel_full_on()
resp.set_channel_full_off()
for all channels that shall be full on/off. This got me issues with visible flickering of the full on/off channels.Thus, I want to be able to update all channels' on/off counter values and the full-on and full-off bits in a single I2C transaction.
Solution
I extended the allowed range of values in the slice arguments of
set_all_on_off()
, so it's possible to set the 13th bit (the full-on/full-off bit) for each individual channel. This is a backwards-compatible change.Alternatives
If you don't like the relaxed range check of the on/off values in the existing
set_all_on_off()
method, because of its mixed-up value semantics (I understand that setting a channel to full-off is semantically different from setting the off counter value), I can refactor the PR to add another method for this combined functionality. (Any ideas for the name?)This separate method could also take two additional
&[bool; 16]
slices for the full-on/full-off values, but I considered this is a bit inefficient and rather unergonomically to use.Alternatively, I thought about adding public constants
FULL_ON_BIT: u16
andFULL_OFF_VALUE: u16
to make the new combined functionality ofset_all_on_off()
easier to use.