mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Removed redundant weakref references
Also tweaked a couple of minor bits (SPI bus init mask) and unused _get_address override
This commit is contained in:
@@ -7,7 +7,6 @@ from __future__ import (
|
|||||||
str = type('')
|
str = type('')
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import weakref
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import mmap
|
|||||||
import errno
|
import errno
|
||||||
import struct
|
import struct
|
||||||
import warnings
|
import warnings
|
||||||
import weakref
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from threading import Thread, Event, Lock
|
from threading import Thread, Event, Lock
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|||||||
@@ -179,9 +179,6 @@ class PiGPIOPin(PiPin):
|
|||||||
self.function = 'input'
|
self.function = 'input'
|
||||||
self.pull = 'up' if self.factory.pi_info.pulled_up('GPIO%d' % self.number) else 'floating'
|
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):
|
def _get_function(self):
|
||||||
return self.GPIO_FUNCTION_NAMES[self.factory.connection.get_mode(self.number)]
|
return self.GPIO_FUNCTION_NAMES[self.factory.connection.get_mode(self.number)]
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from __future__ import (
|
|||||||
str = type('')
|
str = type('')
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
import weakref
|
|
||||||
from RPi import GPIO
|
from RPi import GPIO
|
||||||
|
|
||||||
from .local import LocalPiFactory, LocalPiPin
|
from .local import LocalPiFactory, LocalPiPin
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ str = type('')
|
|||||||
|
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
import weakref
|
|
||||||
import RPIO
|
import RPIO
|
||||||
import RPIO.PWM
|
import RPIO.PWM
|
||||||
from RPIO.Exceptions import InvalidChannelException
|
from RPIO.Exceptions import InvalidChannelException
|
||||||
|
|||||||
@@ -64,9 +64,14 @@ class SPISoftwareBus(SharedMixin, Device):
|
|||||||
"""
|
"""
|
||||||
result = []
|
result = []
|
||||||
with self.lock:
|
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:
|
for write_word in data:
|
||||||
mask = 1 if lsb_first else 1 << (bits_per_word - 1)
|
mask = init_mask
|
||||||
read_word = 0
|
read_word = 0
|
||||||
for _ in range(bits_per_word):
|
for _ in range(bits_per_word):
|
||||||
if self.mosi is not None:
|
if self.mosi is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user