-
Notifications
You must be signed in to change notification settings - Fork 20
ShiftIn/ShiftOut #11
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
ShiftIn/ShiftOut #11
Conversation
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.
Thanks for picking this up! Lots of little things to fix. Nothing major
simpleio.py
Outdated
@@ -31,9 +31,73 @@ | |||
""" | |||
|
|||
import digitalio | |||
import math |
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.
This is needed by neopixel below.
simpleio.py
Outdated
|
||
for i in range(0, 8): | ||
clock.value = True | ||
if msb_first == False: |
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'd reverse this:
if msb_first:
value |= ((dataPin.value) << (7-i))
else:
value |= ((dataPin.value) << i)
If tests that are positive are generally easier to read.
simpleio.py
Outdated
|
||
:param dataPin: pin on which to input each bit | ||
:param clock: toggles to signal dataPin reads | ||
:param msb_first: order to shift bits (least significant or most significant bit first) |
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'd change this comment to "True when the first bit is the most significant."
simpleio.py
Outdated
MSB. | ||
|
||
:param dataPin: pin on which to input each bit | ||
:param clock: toggles to signal dataPin reads |
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.
Please add types (digitalio.DigitalInOut) in here.
simpleio.py
Outdated
:param dataPin: value bits get output on this pin | ||
:param clock: toggled once the data pin is set | ||
:param msb_first: order to shift bits (least significant or most significant bit first) | ||
:param value: byte to be shifted |
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.
Types here too
simpleio.py
Outdated
:param msb_first: order to shift bits (least significant or most significant bit first) | ||
:param value: byte to be shifted | ||
|
||
Example for Metro Express: |
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.
Metro M0 Express
simpleio.py
Outdated
shiftOut(dataPin, clock, 'LSBFIRST', (valueSend>>8)) | ||
shiftOut(dataPin, clock, 'LSBFIRST', valueSend) | ||
shiftOut(dataPin, clock, 'MSBFIRST', (valueSend>>8)) | ||
shiftOut(dataPin, clock, 'MSBFIRST', valueSend) |
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.
Update these for the new parameter order please.
simpleio.py
Outdated
""" | ||
value = value&0xFF | ||
for i in range(0, 8): | ||
if msb_first == False: |
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.
Invert this test too.
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.
Thanks for the updates! Looks good!
Adds shiftIn and shiftOut methods to the SimpleIO library per suggestion #1