Skip to content
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 any number of strands from 1 to 8; make demo more like arduino demo #4

Merged
merged 6 commits into from
Nov 16, 2022

Conversation

jepler
Copy link
Member

@jepler jepler commented Nov 14, 2022

Also closes #5

This requires slightly different PIO code, because a variable number
of bits have to be thrown away
This shows a phase shifted chase animation on each strip, each in
a different color.
@jepler
Copy link
Member Author

jepler commented Nov 15, 2022

@gamblor21 do you want to test this PR with fewer than 8 pins?

@gamblor21
Copy link
Member

@gamblor21 do you want to test this PR with fewer than 8 pins?

Hope to test it tomorrow

Copy link
Member

@gamblor21 gamblor21 left a comment

Choose a reason for hiding this comment

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

Nice way of accounting for less then 8 strands. One issue though - bitops.bit_tranpose does not work for 1 strand (works 2-8).

I did test my setup (which is 1 strand) but setting num_strands to 2 and doubled the pixels and it did work. But either the library has to exclude 1 strand or bit_transpose needs a tweak or a 3rd PIO program that handles just 1 strand with a different data format.

Good news, filling 300 pixels (well 600 but half the fake ones) went from 73fps to about 182fps so I think getting it to work even for 1 strand may have worth.

@gamblor21
Copy link
Member

I did manage to make a quick core change to bitops.bit_transpose to handle one strand. I can make a PR for it tomorrow (too late now) but basically in shared-module/bitops/__init__.c in transpose_var change the end of the switch to:

        case 2:
            y |= *src << 8;
            src -= src_stride;
            MP_FALLTHROUGH;
        case 1:
            y |= *src;

and in the shared-bindings change the check to 1 instead of 2 as the minimum num_strands.

Also noticed there are some print statements still in the code.

@jepler jepler changed the title Support any number of strands up to 8; make demo more like arduino demo Support any number of strands from 2 to 8; make demo more like arduino demo Nov 16, 2022
@jepler
Copy link
Member Author

jepler commented Nov 16, 2022

You're not wrong to want support for 1 strip using background writes! Let's make that a separate issue, especially in case it requires a core change.

However, I think I'd rather have a separate program for 1 strip, because the extra memory usage and processing time for the bit_transpose operation can be eliminated entirely. A 2nd copy of the data is still needed in order to be free from tearing (writing a partially updated strip) but not a copy that's enlarged by 8x because each bit becomes a full byte! And it means no core change is required.

(a smaller savings could be had for 2 to 4 strands, with a core change, but I'm less convinced this is worth it)

@jepler jepler mentioned this pull request Nov 16, 2022
@jepler
Copy link
Member Author

jepler commented Nov 16, 2022

I've filed an issue for the 1 strand case, so hopefully you can approve this PR as it stands.

assembled = adafruit_pioasm.assemble(_PROGRAM8)
else:
program = _PROGRAMN.format(num_strands, 8 - num_strands)
print(program)
Copy link
Member

Choose a reason for hiding this comment

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

Debugging print left behind. Also on line 171. Otherwise looks great.

.. this calls for a different memory layout to save memory size in the
'background' buffer
@jepler
Copy link
Member Author

jepler commented Nov 16, 2022

I went ahead and added 1-strand support, but changed the structure a bit so it probably deserves a full re-test

I tested the 1-strand version on the neopixel bff. The text scroller demo running unthrottled increases from 167 to 210fps! (and just commenting out pixels.show also gives 210fps 🤣 )

@jepler jepler changed the title Support any number of strands from 2 to 8; make demo more like arduino demo Support any number of strands from 1 to 8; make demo more like arduino demo Nov 16, 2022
@jepler
Copy link
Member Author

jepler commented Nov 16, 2022

There was a mistake in my benchmarking of the neobff text scroller. The actual frame rates were 928fps (neopxl8 background) and 446fps (standard neopixel) 🚀

Copy link
Member

@gamblor21 gamblor21 left a comment

Choose a reason for hiding this comment

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

Tested with 1 and 2 strands, both worked great.

1 strand measure a speed-up from 73.2fps to 99.6fps over 300 neopixels. A 36% increase in speed.

@gamblor21 gamblor21 merged commit 76a1b5d into main Nov 16, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 28, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPxl8 to 0.2.0 from 0.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_NeoPxl8#4 from adafruit/enhancements

Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 1.12.18 from 1.12.17:
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#81 from BiffoBear/detect_5500_error

Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 1.1.0 from 1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#22 from paul-1/my-main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
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.

Support num_strands=1
2 participants