devices icon indicating copy to clipboard operation
devices copied to clipboard

apa102: allow to specify SPI Mode in Opts

Open alexgth opened this issue 4 years ago • 9 comments

Some devices such as the secondary SPI Port of the Raspberry Pi 3 don't support the default SPI Mode 3. This Change allows to set the SPI Mode to any other by changing the Opts.

alexgth avatar Aug 10 '21 12:08 alexgth

Hi! Thanks for the contribution! Sorry I dropped it in my emails.

Frankly, I think I'd prefer to just switch to Mode0 and not make it an option. What is the downside?

maruel avatar Aug 20 '21 00:08 maruel

Codecov Report

Merging #16 (20c235b) into main (440ba6e) will not change coverage. The diff coverage is 100.0%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main     #16   +/-   ##
=====================================
  Coverage   59.8%   59.8%           
=====================================
  Files         48      48           
  Lines       4331    4331           
=====================================
  Hits        2590    2590           
  Misses      1608    1608           
  Partials     133     133           
Impacted Files Coverage Δ
apa102/apa102.go 93.8% <100.0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 440ba6e...20c235b. Read the comment docs.

codecov-commenter avatar Aug 20 '21 00:08 codecov-commenter

Ignore the test failure, I need to redo the way I do forward-testing.

maruel avatar Aug 20 '21 00:08 maruel

I'm not sure wether or not there might be some weird behaviour on the LED side of things due to the clock polarity being inverted. Whenever I accessed less LEDs than i connected the one LED after the last one was bright white, which might be because of the LEDs protocol (more likely for my understanding) or because of the SPI Mode. I unfortunately can't test it as I don't have access to the hardware anymore.

alexgth avatar Aug 30 '21 11:08 alexgth

@maruel: Are we sure that no other user of this library uses mode 3? @alexgth: :wave:

sahib avatar Aug 30 '21 12:08 sahib

Frankly I'd simply use Mode1 and see if anyone complains on the next release. Users can always revert back to the previous release if it breaks them and we will add a bool flag at that point.

maruel avatar Aug 30 '21 14:08 maruel

@maruel: if users note that something is broken soon enough :sweat_smile: I guess the approach in this PR has the potential to save some tears. I was initially asking because I darkly recalled that we tried some LED strips initially on the first SPI port of a rpi3 (current approach uses second port), where mode 3 (old default) was working, but mode 1 not. That led to my guess that changing the default will break things for people.

sahib avatar Aug 31 '21 07:08 sahib

Sorry for the delay, lots of things happening here.

Thanks for the data point about some LEDs not working with mode3. I'd still prefer to use a bool defaulting to false so that a constructing a Opt{} by hand still works. Right now with this change constructing a Opt{} will result in spi.Mode0, which doesn't work. Please document the flag to explain the specific use case, and the fact that some LEDs may not work when the bool is set to true.

I've finally fixed the github actions checks, so please git fetch and git rebase first. Thanks!

maruel avatar Sep 12 '21 14:09 maruel

Revisiting this PR: I'd really prefer to use a bool instead of a spi.Mode; this way the default bool value in Go (false) is the right one.

maruel avatar Oct 16 '21 22:10 maruel