Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 5 commits into from
Aug 1, 2017
Merged

ShiftIn/ShiftOut #11

merged 5 commits into from
Aug 1, 2017

Conversation

brentru
Copy link
Member

@brentru brentru commented Jul 24, 2017

Adds shiftIn and shiftOut methods to the SimpleIO library per suggestion #1

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.

Thanks for picking this up! Lots of little things to fix. Nothing major

simpleio.py Outdated
@@ -31,9 +31,73 @@
"""

import digitalio
import math
Copy link
Member

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:
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 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)
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 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
Copy link
Member

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
Copy link
Member

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:
Copy link
Member

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)
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

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

Invert this test too.

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.

Thanks for the updates! Looks good!

@tannewt tannewt merged commit 6e488af into adafruit:master Aug 1, 2017
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.

2 participants