From 4efb12424509292323e60572f88f4770150c2e96 Mon Sep 17 00:00:00 2001 From: Adam Patt Date: Tue, 15 May 2018 15:14:22 -0400 Subject: [PATCH 1/7] https://github.com/adafruit/Adafruit_CircuitPython_SimpleIO/issues/10 - pass any submitted parameters supported by the underlying call --- simpleio.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/simpleio.py b/simpleio.py index 60870c9..5343039 100644 --- a/simpleio.py +++ b/simpleio.py @@ -230,9 +230,12 @@ class DigitalOut: """ Simple digital output that is valid until soft reset. """ - def __init__(self, pin): + def __init__(self, pin, value=None, drive_mode=None): + """ + """ + kwargs = {k: v for k, v in (('value', value), ('drive_mode', drive_mode)) if not v is None} self.iopin = digitalio.DigitalInOut(pin) - self.iopin.switch_to_output() + self.iopin.switch_to_output(**kwargs) @property def value(self): @@ -247,9 +250,10 @@ class DigitalIn: """ Simple digital input that is valid until soft reset. """ - def __init__(self, pin): + def __init__(self, pin, pull=None): + kwargs = {k: v for k, v in (('pull', pull),) if not v is None} self.iopin = digitalio.DigitalInOut(pin) - self.iopin.switch_to_input() + self.iopin.switch_to_input(**kwargs) @property def value(self): From b40cdbce742a5cf4d53c35d9261b2cd669c52c2a Mon Sep 17 00:00:00 2001 From: Adam Patt Date: Tue, 15 May 2018 15:27:57 -0400 Subject: [PATCH 2/7] update docstring --- simpleio.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/simpleio.py b/simpleio.py index 5343039..9e23a82 100644 --- a/simpleio.py +++ b/simpleio.py @@ -232,6 +232,8 @@ class DigitalOut: """ def __init__(self, pin, value=None, drive_mode=None): """ + value and drive_mode: if passed in will be passed to switch_to_output + see digitalio.DigitalInOut.switch_to_output for more details """ kwargs = {k: v for k, v in (('value', value), ('drive_mode', drive_mode)) if not v is None} self.iopin = digitalio.DigitalInOut(pin) @@ -251,6 +253,10 @@ class DigitalIn: Simple digital input that is valid until soft reset. """ def __init__(self, pin, pull=None): + """ + pull: if passed in will be passed to switch_to_input + see digitalio.DigitalInOut.switch_to_input for more details + """ kwargs = {k: v for k, v in (('pull', pull),) if not v is None} self.iopin = digitalio.DigitalInOut(pin) self.iopin.switch_to_input(**kwargs) From 47f5eb25d979219eae00771b1cf95af0b5d1c933 Mon Sep 17 00:00:00 2001 From: Adam Patt Date: Thu, 17 May 2018 21:44:09 -0400 Subject: [PATCH 3/7] changed signature and docstring --- simpleio.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/simpleio.py b/simpleio.py index 9e23a82..62ab5e0 100644 --- a/simpleio.py +++ b/simpleio.py @@ -232,8 +232,9 @@ class DigitalOut: """ def __init__(self, pin, value=None, drive_mode=None): """ - value and drive_mode: if passed in will be passed to switch_to_output - see digitalio.DigitalInOut.switch_to_output for more details + kwargs will be passed directly to switch_to_output + value (bool): default value to set upon switching + drive_mode (DriveMode): drive mode for the output """ kwargs = {k: v for k, v in (('value', value), ('drive_mode', drive_mode)) if not v is None} self.iopin = digitalio.DigitalInOut(pin) @@ -252,12 +253,11 @@ class DigitalIn: """ Simple digital input that is valid until soft reset. """ - def __init__(self, pin, pull=None): + def __init__(self, pin, **kwargs): """ - pull: if passed in will be passed to switch_to_input - see digitalio.DigitalInOut.switch_to_input for more details + kwargs will be passed directly to switch_to_input + pull (pull): pull configuration for the input """ - kwargs = {k: v for k, v in (('pull', pull),) if not v is None} self.iopin = digitalio.DigitalInOut(pin) self.iopin.switch_to_input(**kwargs) From 42a5a3771918b07dbe1c9f294e6905e31b1ccf7e Mon Sep 17 00:00:00 2001 From: Adam Patt Date: Thu, 17 May 2018 21:46:49 -0400 Subject: [PATCH 4/7] changed signature again --- simpleio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simpleio.py b/simpleio.py index 62ab5e0..dac75b9 100644 --- a/simpleio.py +++ b/simpleio.py @@ -230,7 +230,7 @@ class DigitalOut: """ Simple digital output that is valid until soft reset. """ - def __init__(self, pin, value=None, drive_mode=None): + def __init__(self, pin, **kwargs): """ kwargs will be passed directly to switch_to_output value (bool): default value to set upon switching From 2d969baf336e1b70df08204b807c5e793816bb35 Mon Sep 17 00:00:00 2001 From: Adam Patt Date: Thu, 17 May 2018 21:49:13 -0400 Subject: [PATCH 5/7] fixed body to match new signature --- simpleio.py | 1 - 1 file changed, 1 deletion(-) diff --git a/simpleio.py b/simpleio.py index dac75b9..2abf9b4 100644 --- a/simpleio.py +++ b/simpleio.py @@ -236,7 +236,6 @@ def __init__(self, pin, **kwargs): value (bool): default value to set upon switching drive_mode (DriveMode): drive mode for the output """ - kwargs = {k: v for k, v in (('value', value), ('drive_mode', drive_mode)) if not v is None} self.iopin = digitalio.DigitalInOut(pin) self.iopin.switch_to_output(**kwargs) From 5c0b8edace06cc3e1458e7e92179ebe703348463 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 18 May 2018 11:57:21 -0500 Subject: [PATCH 6/7] Combine docs Don't mention switch methods which are implementation details. --- simpleio.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/simpleio.py b/simpleio.py index 2abf9b4..6314bd7 100644 --- a/simpleio.py +++ b/simpleio.py @@ -228,14 +228,13 @@ def deinit(self): class DigitalOut: """ - Simple digital output that is valid until soft reset. + Simple digital output that is valid until reload. + + :param pin microcontroller.Pin: output pin + :param value bool: default value + :param drive_mode digitalio.DriveMode: drive mode for the output """ def __init__(self, pin, **kwargs): - """ - kwargs will be passed directly to switch_to_output - value (bool): default value to set upon switching - drive_mode (DriveMode): drive mode for the output - """ self.iopin = digitalio.DigitalInOut(pin) self.iopin.switch_to_output(**kwargs) @@ -250,13 +249,12 @@ def value(self, value): class DigitalIn: """ - Simple digital input that is valid until soft reset. + Simple digital input that is valid until reload. + + :param pin microcontroller.Pin: input pin + :param pull digitalio.Pull: pull configuration for the input """ def __init__(self, pin, **kwargs): - """ - kwargs will be passed directly to switch_to_input - pull (pull): pull configuration for the input - """ self.iopin = digitalio.DigitalInOut(pin) self.iopin.switch_to_input(**kwargs) From a5f72b41564aa1d70a9e21c4d82fc8229e37eceb Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 18 May 2018 12:07:13 -0500 Subject: [PATCH 7/7] Remove trailing whitespace --- simpleio.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simpleio.py b/simpleio.py index 6314bd7..7fdb3ab 100644 --- a/simpleio.py +++ b/simpleio.py @@ -229,7 +229,7 @@ def deinit(self): class DigitalOut: """ Simple digital output that is valid until reload. - + :param pin microcontroller.Pin: output pin :param value bool: default value :param drive_mode digitalio.DriveMode: drive mode for the output @@ -250,7 +250,7 @@ def value(self, value): class DigitalIn: """ Simple digital input that is valid until reload. - + :param pin microcontroller.Pin: input pin :param pull digitalio.Pull: pull configuration for the input """