From 8dc61713eb6c71fdbf033176b20b934aeb4c3dd6 Mon Sep 17 00:00:00 2001 From: ianovir Date: Sun, 29 Jan 2017 02:39:38 +0100 Subject: [PATCH] Added one single method to setup all pins This commit allows to set the states of all pins on the register by performing one single call. All pins' states can be included into a list which will be passed as argument to the new digitalWriteBundle() method. --- shiftpi.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/shiftpi.py b/shiftpi.py index 074b453..a91537d 100644 --- a/shiftpi.py +++ b/shiftpi.py @@ -93,7 +93,18 @@ def digitalWrite(pin, mode): _setPin(pin, mode) _execute() - + +def digitalWriteBundle(pinslist=[]): + ''' + Allows the user to set the states of all pins on the register by using a single list. + The position of each element in the list represents the pin number, while its value represents the mode of the pin (HIGH or LOW). + ''' + i = 1 + for pinMode in pinslist: + _setPin(i, pinMode) + i+=1 + _execute() + def delay(millis): ''' Used for creating a delay between commands