Skip to content

WIP: try (re)using the buffer in neopixel_write (BROKEN) #2449

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

Merged
merged 4 commits into from
Feb 22, 2020

Conversation

rhooper
Copy link

@rhooper rhooper commented Jan 4, 2020

This might address #2442
I'll leave it running overnight.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Why is PewPew also being update?


pattern_on_heap = true;
if (!pattern_on_heap || pixels_pattern_heap_size < pattern_size) {
if (pattern_on_heap) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (pattern_on_heap) {
if (pixels_pattern_heap_size < pattern_size) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the submodule and addressed this review.

@@ -116,6 +116,8 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout

uint32_t pattern_size = PATTERN_SIZE(numBytes);
uint16_t* pixels_pattern = NULL;
static uint16_t* pixels_pattern_heap = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure that this is reset to NULL when the heap is reset otherwise it'll break after a reload.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tannewt where can I find the heap reset code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a neopixel_write_reset and add it here: https://github.com/adafruit/circuitpython/blob/master/main.c#L190

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the neopixel_write_reset to the port only, as this is only for nrf. I called it from reset_port().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to stub it into other ports if that is simpler. I wouldn't be surprised if others needed it in the future.

@rhooper rhooper force-pushed the malloc-nrf-neopixel-write branch from ed288d9 to bf184d8 Compare January 8, 2020 20:08
@rhooper rhooper force-pushed the malloc-nrf-neopixel-write branch from bf184d8 to 4e040b0 Compare January 8, 2020 20:15
@rhooper
Copy link
Author

rhooper commented Jan 8, 2020

The board seems to be resetting on me after this change - hold tight for more testing.

@rhooper rhooper changed the title try (re)using the buffer in neopixel_write WIP: try (re)using the buffer in neopixel_write (BROKEN) Jan 9, 2020
@rhooper rhooper closed this Jan 19, 2020
@dhalbert
Copy link
Collaborator

@rhooper I am going to try to finish this off, since we should fix #2442 for 5.0.0. When you say:

The board seems to be resetting on me after this change - hold tight for more testing.
is that immediate or after a long running time again? I could run your complicated Christmas tree example without actually having any neopixels attached as a test.

@dhalbert dhalbert reopened this Feb 19, 2020
@dhalbert
Copy link
Collaborator

@rhooper I am going to try to finish this off, since we should fix #2442 for 5.0.0. When you say:

The board seems to be resetting on me after this change - hold tight for more testing.
is that immediate or after a long running time again? I could run your complicated Christmas tree example without actually having any neopixels attached as a test.

@rhooper
Copy link
Author

rhooper commented Feb 20, 2020

@dhalbert the old version of this PR (34c9e00) didn't clean up on reset. so I tried to do so like @tannewt requested in later commits. That resulted in crashes - I don't quit recall when.

To test for the soft reset without the patch, the simplest approach was to have large neopixel_write intermixed and other code. For example the stuff the tree code did with AggregatePixels in adafruit/Adafruit_CircuitPython_LED_Animation#10 . No pixels needed to be attached. The tree code triggered it faster by fragmenting memory.

@tannewt tannewt merged commit 23d6a3d into adafruit:master Feb 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants