tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
599 stars 188 forks source link

microbitmatrix: add brightness levels for LED pixels #472

Closed breml closed 1 year ago

breml commented 1 year ago

This PR adds brightness levels for the LED pixels similar to the implementation present in the micro:bit MicroPython implementation.

Additionally, the code for V1 and V2 is harmonized and only the code that is really hardware (machine) dependent is in the respective v1/v2 file. All the generic code for the controll of the microbitmatrix is in the shared source file.

I tested this code on micro:bit V1 and V2 hardware.

CC: @conejoninja

deadprogram commented 1 year ago

@conejoninja any comments on this before we squash/merge?

conejoninja commented 1 year ago

Not yet, I had it on my TODO list, but my tinygo installation is broken and doesn't compile (there's a thread on #tinygo slack channel). Didn't have time to fix it yet, and therefor I couldn't test this PR on the real hardware. But changes looks good to me.

breml commented 1 year ago

Let me point out some of the "more" important changes in order to make the review easier for you:

One thing to mention: I did some quick tests in the TinyGo Playground with code that uses different brightness level and this did not work well there. I assume, that the physical effect of the LEDs to keep glow for a little while when there is no longer current on the respective pin is maybe not supported. Therefore it is worth mentioning, that the updated version of this driver might not work well with the Playground. That being said, the main target for this driver would be the use with the real physical device anyway.

I hope, this is helpful.

deadprogram commented 1 year ago

Thank you very much for working on this @breml now merging.