Skip to content

try to import bitbangio if busio SPI is not available #40

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

Closed
wants to merge 1 commit into from

Conversation

schelmo
Copy link
Contributor

@schelmo schelmo commented Oct 21, 2019

resubmitting #36 for reviewing (@siddacious)

@kattni kattni requested a review from siddacious January 8, 2020 19:00
@kattni
Copy link
Contributor

kattni commented Jan 29, 2020

@schelmo I'm unclear on the purpose of adding this. Hardware SPI is typically faster than bitbangio. What boards are you trying to use bitbangio on, and how are you testing this?

@schelmo
Copy link
Contributor Author

schelmo commented Jan 29, 2020

@kattni i needed this on a trinket 5V with a WS2801 strip, where the Hardware SPI was already used by something else
bitbangio was much faster than the _ds_writebytes() implementation

@kattni
Copy link
Contributor

kattni commented Jan 29, 2020

@schelmo The Trinket 5V does not run CircuitPython. Do you mean a Trinket M0? As well, is there a reason you're not using the Adafruit CircuitPython WS2801 library with your WS2801 strip?

Can you post an example of code that uses this? I am trying to sort out testing these changes.

@tannewt
Copy link
Member

tannewt commented Jan 29, 2020

@kattni bitbanging allows for dotstars on any pair of pins. To test, use a set of pins that doesn't work with busio.

@schelmo
Copy link
Contributor Author

schelmo commented Jan 29, 2020

sorry it was some time ago.
you are right it was a trinket m0 and yes it was about a dotstar strip not WS2801.
but it was just the same story.
like @tannewt said, just use some other non-SPI pins for trying out.

@kattni
Copy link
Contributor

kattni commented Jan 29, 2020

@schelmo @tannewt Thanks. Will get this tested.

@kevinjwalters
Copy link

kevinjwalters commented Jan 29, 2020

I tend to check which pins support it and then double check by inspecting self._spi, here's an example from a dusty Gemma M0 board with current hardware vs software example, note D2 / D1 use:

Adafruit CircuitPython 4.0.0-rc.1 on 2019-04-23; Adafruit Gemma M0 with samd21e18
>>>
>>>
>>> import board, adafruit_dotstar
>>> strip = adafruit_dotstar.DotStar(board.D2, board.D0, 144)
>>> type(strip._spi)
<class 'SPI'>
Adafruit CircuitPython 4.0.0-rc.1 on 2019-04-23; Adafruit Gemma M0 with samd21e18
>>> import board, adafruit_dotstar
>>> strip = adafruit_dotstar.DotStar(board.D1, board.D0, 144)
>>> type(strip._spi)
<class 'NoneType'>

Just to make it clear, I did those REPL commands with no dotstars connected, my long strip is on-loan at the moment.

@FoamyGuy
Copy link
Contributor

I should be able to test this over the weekend.

@schelmo
Copy link
Contributor Author

schelmo commented Jan 31, 2020

had time to look into it a bit more
i had to compile bitbangio support for the trinket m0 circuitpython (for that i had to disable some other features)
so to test this you need a board with bitbangio compiled in

btw i dont need these anymore. if it is too much work, we can close the PR

diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk
index 5c942901a..7b04e3d5a 100644
--- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk
@@ -10,6 +10,10 @@ INTERNAL_FLASH_FILESYSTEM = 1
 LONGINT_IMPL = NONE
 CIRCUITPY_SMALL_BUILD = 1

+CIRCUITPY_BITBANGIO = 1
+CIRCUITPY_USB_HID = 0
+CIRCUITPY_USB_MIDI = 0
+
 SUPEROPT_GC = 0

 CFLAGS_BOARD = --param max-inline-insns-auto=15```

@kattni
Copy link
Contributor

kattni commented Jan 31, 2020

@schelmo I appreciate that you took the time to make the contribution. It's great that this is here and documented, and anyone looking to do this in the future will have this available. However, the further we look into it, the more this feels like a very specific use case that likely wouldn't apply to more than a few situations. If you're ok with it, I think closing this PR would make sense. Consider leaving the branch in place for others if you're interested in doing so.

@schelmo
Copy link
Contributor Author

schelmo commented Jan 31, 2020

yeah sure

@schelmo schelmo closed this Jan 31, 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.

5 participants