microsoft / uf2-samdx1

USB Mass Storage bootloader (based on UF2) for SAMD21 and SAMD51
Other
251 stars 309 forks source link

Signaling - LED and Multi Color Led Refactor #48

Open stevenj opened 6 years ago

stevenj commented 6 years ago

My Target doesn't have any leds. It has a buzzer. So i added code to drive the buzzer, instead of a LED. But in the process I found the existing LED/Multi Color LED code is quite difficult to discern and is spread all over the place. So I refactored it, and created a new signal module to manage signalling. It can handle the RGB Leds, single flashing leds and also a piezo buzzer on a TCC. I am still testing this code, so this pull request is for review and comment before I finish it.

However, its a lot simpler than the old code, and a lot more flexible. It allows different pulse streams on leds and buzzers to be easily added for different status indications, without using much code. In fact, i built every target using this new signal handling and they are all smaller than before, sometimes significantly smaller:

board original size free new size free
circuitplay_m0 7412 320 7224 512
dadamachines-automat 7256 476 7232 504
eitech-robotics 7244 488 7220 516
feather_m0 7384 348 7224 512
feather_m4 8772 7148 8608 7316
gemma_m0 7412 320 7408 328
generic 7244 488 7220 516
grove-zero 7260 472 7232 504
itsybitsy_m0 7432 300 7436 300
metro_m0 7400 332 7224 512
metro_m4 8780 7140 8620 7304
metro_m4_revb 8776 7144 8612 7312
mkr1000 7256 476 7228 508
pirkey 7388 344 7392 344
sensebox-mcu 7248 484 7224 512
sparkfun-samd21-dev 7284 448 7260 476
sparkfun-samd21-mini 7288 444 7260 476
trinket_m0 7416 316 7412 324
wattuino-rc 7264 468 7236 500
zero 7244 488 7220 516
Controleo3 (using buzzer) ??? ??? 7300 436

I haven't got any of these boards, so if anyone would like to help me test the various configurations (the two RGB leds that are defined, and M4 boards, and boards with single leds) I would really appreciate it. Also, the flash timings at the moment are arbitrary, so if anyone has a better scheme to suggest for on/off times for various states, let me know.

mmoskal commented 6 years ago

@dhalbert would you be willing to take a look?

dhalbert commented 6 years ago

Sure, happy to test. I'll try it on Adafruit boards, and I have an Arduino Zero.