-
Notifications
You must be signed in to change notification settings - Fork 1.3k
UMFEATHERS2 - implement use of DotStar for status led #3930
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
Conversation
@jerryneedell LDO2 needs to be set to OUTPUT - See my comment in your issue about why the LED is dim with it being an input: |
@UnexpectedMaker Hmm -- setting that to OUTPUT will make it very unique to this board. Where would you suggest doing that? Should it also be enabled? |
This board is unique in that is has a second LDO and power control over the APA via it. |
It may not be necessary if we don't need to enable it. |
This can wait until @tannewt and/or @hierophect can look at it and comment. It was a great learning experience for me |
Not enabling the second LDO and relying on parasitic power via the CLK/DATA to make it light up is not really a solution I'm ok with. If there is no way to do this "at the board level" then use of the APA for this purpose should not be added. But none of this is really up to me, so getting feedback from the CPY team is going to be required :) |
If we want to implement this, I think we can add an "#ifdef CIRCUITPY_LDO2" block here https://github.com/adafruit/circuitpython/blob/main/supervisor/shared/rgb_led_status.c#L114 |
This should be doable at the board level. You can turn the second LDO on in |
@tannewt That seems like the right place to do this, but I think the intent is also for the user to be able to turn it off. @UnexpectedMaker Can you comment on that? Would enabling LDO2 in board_init() prevent the user from turning it off? Do you think this is worth implementing? I have found it very useful to have the status report from the LED - especially when using deep sleep since it is usually not connected to the REPL. If it crashes it is really nice to see where. What are your thoughts? |
You could enable sharing by copying how |
Unless I'm misunderstanding something, I don't see any reason that this pin (pin_GPIO21?) cannot be set to a different pin output default in board_init, and then accessed later by a user. If you set the pin to an output in board_init using the IDF functions, and add it to the never_reset array, it should be able to hold its value across resets without being part of the "claimed_pin" array that would prevent users from accessing it. You have to use the IDF functions directly, because there's no DigitalIO object, but I don't think that should be an issue? If the IDF has changed the output for a pin, shouldn't be anything stopping them from just making that same pin into a DigitalIO and either turn it off or giving themselves total manual control. Then next time the board resets, it'll run board_init again, and return the pin to an output state. But you might want to put in a pin reset before changing things in board_init just to be careful. |
@hierophect Can you point me to any examples of using the IDF functions within CircuitPython? |
In this case you would draw directly from what's used in DigitalIO.
(note those IDF files you'll need to include) I don't think this would be really any more janky than the kind of screen setup stuff we put in board_init already? But I could be wrong. |
Would it be necessary to do anything to revert these settings in board.deinit() |
@hierophect I tried adding the following to board_init()
If I then try to access the board.LDO2 pin from the REPL I get
This is due to : Is it necessary to put it in the never reset list? |
|
Do we want this to be reset or do we want it always to be set to an OUTPUT and enabled in board_init? |
If you don't put it in the never_reset list, the pin will be returned to an INPUT state whenever the board reset is called, which happens every time the vm resets. I don't know why pin_is_free is checking the never_reset tables, that is nonstandard port behavior and is not shared for the STM32, NRF or SAMD ports. It's not something we ever formally hashed out though. I'd recommend the |
Just to recap on the overall strategy here, since this terminology might be getting confusing:
Strategy here:
|
I pushed my latest changes, let me know if more needs to be done. |
Can you confirm the second LDO is outputting 3.3V with a multimeter? |
Yes. It is. |
Ok, maybe you have one of the earlier FeatherS2's I shipped that had some "visually duller APAs". Prob not anything to worry about if LDO2 is confirmed as on. |
It is fine when set to higher values |
Yeah, I usually run them at 50%. I switched suppliers in November last year and the current APAs I'm using seem to be considerably brighter and a little richer in colour. Interestingly, under the microscope, the 2 APAs look identical, and I cant find any information from either supplier about why the previous reel were dimmer at the lower brightness levels. Hardware is fun ;) |
the colors are set to 0x30 It is functional and very useful to see the status even if dim |
Does the APA102 have multiple manufacturers? My first thought would be clones, or legitimate licensees of the design that have variable quality control. I can't find anything online that verifies one way or the other though. |
At this point, I thin this is complete, unless you want something done in board_deinit() or if @tannewt has a concern with the change to the pin_is_free test... or anything else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a slight bug now because the user's pin state will leak on VM reset. I want do make this functionality more generic soon. So, this is good for now.
addresses #3922
For this PR, I used the common-hat/microcontroller/Pin.c from the atmel-samd port as a guide.
Hopefully I did not miss anything.
As noted int #3922 at power-on, the LDO2 pin is High but set as an INPUT
The PR does not change that. Is that OK?
The DotStar does reflect the status of CP -- blinking green before REPL -- Green in code.py and White in REPL
It is very dim, but useable.
I have run this on a umfeathers2 to verify the DotStar function.
I also created builds for the metros2 and ragtag to see if anything unexpected happened there. Nothing noted.