From 4d79dc74dba6e48738d024d725a8d48fed731546 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Fri, 21 Oct 2016 10:43:58 +0100 Subject: [PATCH] Removed redundant weakref references Also tweaked a couple of minor bits (SPI bus init mask) and unused _get_address override --- gpiozero/pins/local.py | 1 - gpiozero/pins/native.py | 1 - gpiozero/pins/pigpiod.py | 3 --- gpiozero/pins/rpigpio.py | 1 - gpiozero/pins/rpio.py | 1 - gpiozero/pins/spi.py | 9 +++++++-- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/gpiozero/pins/local.py b/gpiozero/pins/local.py index f61f4eb..17310c6 100644 --- a/gpiozero/pins/local.py +++ b/gpiozero/pins/local.py @@ -7,7 +7,6 @@ from __future__ import ( str = type('') import io -import weakref import warnings try: diff --git a/gpiozero/pins/native.py b/gpiozero/pins/native.py index 12bc5a9..2fd14ec 100644 --- a/gpiozero/pins/native.py +++ b/gpiozero/pins/native.py @@ -13,7 +13,6 @@ import mmap import errno import struct import warnings -import weakref from time import sleep from threading import Thread, Event, Lock from collections import Counter diff --git a/gpiozero/pins/pigpiod.py b/gpiozero/pins/pigpiod.py index d36b059..5418e2c 100644 --- a/gpiozero/pins/pigpiod.py +++ b/gpiozero/pins/pigpiod.py @@ -179,9 +179,6 @@ class PiGPIOPin(PiPin): self.function = 'input' self.pull = 'up' if self.factory.pi_info.pulled_up('GPIO%d' % self.number) else 'floating' - def _get_address(self): - return self.factory.address + ('GPIO%d' % self.number,) - def _get_function(self): return self.GPIO_FUNCTION_NAMES[self.factory.connection.get_mode(self.number)] diff --git a/gpiozero/pins/rpigpio.py b/gpiozero/pins/rpigpio.py index 679b8c2..1b073a4 100644 --- a/gpiozero/pins/rpigpio.py +++ b/gpiozero/pins/rpigpio.py @@ -7,7 +7,6 @@ from __future__ import ( str = type('') import warnings -import weakref from RPi import GPIO from .local import LocalPiFactory, LocalPiPin diff --git a/gpiozero/pins/rpio.py b/gpiozero/pins/rpio.py index 2413b57..5f8d740 100644 --- a/gpiozero/pins/rpio.py +++ b/gpiozero/pins/rpio.py @@ -8,7 +8,6 @@ str = type('') import warnings -import weakref import RPIO import RPIO.PWM from RPIO.Exceptions import InvalidChannelException diff --git a/gpiozero/pins/spi.py b/gpiozero/pins/spi.py index a92ff5c..fff2a85 100644 --- a/gpiozero/pins/spi.py +++ b/gpiozero/pins/spi.py @@ -64,9 +64,14 @@ class SPISoftwareBus(SharedMixin, Device): """ result = [] with self.lock: - shift = operator.lshift if lsb_first else operator.rshift + if lsb_first: + shift = operator.lshift + init_mask = 1 + else: + shift = operator.rshift + init_mask = 1 << (bits_per_word - 1) for write_word in data: - mask = 1 if lsb_first else 1 << (bits_per_word - 1) + mask = init_mask read_word = 0 for _ in range(bits_per_word): if self.mosi is not None: