-
Notifications
You must be signed in to change notification settings - Fork 964
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
Support for generic 4pin RGB LEDs (both CC and CA) and NeoPixels, also RGB LED and vibration notification support for unPhone #3647
Conversation
…y computer is possessed by the devil determined to make me look foolish
Oh forgot to say, if there is an easy way to make this code more usable by other folks outside of the unPhone let me know |
I'd like to keep the I2C device types true to it's name. If we could just use macros to gate the behavior, that would ideal. Even better would be to create a generic HAS_RGB macro that could be controlled for any target with an RGB led on pre-defined gpio in the variant. It looks like you have some of that behavior abstracted in the unphone library though, so we would need to pull some of that into Meshtastic to be shared with other consuming variants. |
The wrinkle with the unphone is that two of the RGB led pins are on the i2c io expander, so we can't just use digitalwrite... I'll rework it to not use an i2c device type, and implement support for RGB LEDs separately from unphone support - I cant imagine many other boards are going to use our strategy! #ifdefs all the way!! 😁 |
Oooooh! That makes more sense :-) |
OK so good news is that it was fairly trivial to add support for RGB led's in the code... So please mark this as draft until we can get a real world confirmation, I mean it looks kinda right to me and I tried to make sure I didn't miss anything but, there's no test like a real test... Usage would be something like this in variant.h: // RGB LED configuration |
…'t find it after a few minutes of searching stack overflow
Hmm that's odd, it compiles in the heltec-wireless-paper environment for me... Is this comment enough to restart the CI checks? |
Ok I've finally been able to test and generic 4 pin LEDs seem to work as expected. |
I've added support for NeoPixels and tested them very briefly! Usuage would be like this:
|
OK so I've gone over various boards that seemed to have RGB leds and incomplete support and tried to get them working with this new approach. I have none of these available to test with. Boards that should now be supported and just work are: |
This PR introduces support for generic 4 wire RGB leds both Common Cathode and Common Anode types. Support is also provided for NeoPixels. Also RGB and vibration functions in Meshtastic to the unPhone.
Ambient lighting and external notifications are supported.
All the code is macro guarded (#ifdef etc) so should have no impact on firmware size for others etc.
To maximise code-reuse I removed #ifdef guards around the NCP5623 in DeviceType - hope that seems fitting let me know if not. Edit - now reversed! Edit - double reversed, as in reinstated!
Also, perhaps controversially, I put the RGBLED_CA (common anode) in as a DeviceType despite it flagrantly not being an I2C device at all! again just because it made the code a bit simpler elsewhere. Edit - also reversed!
Let me know if I've broken a good rule and I'll rework it accordinly.
By request I went through variants and tried to implement RGB led functions where these had been half completed.