GPIO
This class provides high-level access to the instrument's digital pins. The API is defined in pypalmsens.GPIO, and pypalmsens.GPIOAsync for asynchronous workflows.
The intended usage of these classes is via the InstrumentManager.gpio and InstrumentManager.gpio attributes.
Example:
>>> import pypalmsens as ps
>>> with ps.connect() as manager:
... print("Outputs:", manager.gpio.writable_pins)
... print("Inputs :", manager.gpio.readable_pins)
... manager.gpio.write_many([0,1,2], level='high')
Outputs: [0, 1, 2, 3]
Inputs : [0]
For more information how to use these classes, see the documentation here.
Classes:
pypalmsens.GPIO
GPIO(manager: InstrumentManager)
Digital general-purpose input/output (GPIO) interface.
This class provides high-level access to the instrument's digital pins. Pin numbering is hardware-specific. Consult the instrument manual for the physical mapping.
Note that the internal numbering of the pins exposed by this class
may differ from the documented pins numbering, e.g. d0 or d3.
The pin numbering is interally consistent.
For MethodSCRIPT devices, the underlying libraries auto-configures read/write direction on read/write instructions.
For explicit control, use the low-level MethodSCRIPT primitives directly:
Methods:
-
read–Read the logic level of a single digital input pin.
-
read_many–Read the logic levels of multiple digital input pins.
-
toggle–Invert the logic level of a single digital output pin.
-
toggle_many–Invert the logic level of multiple digital output pins.
-
write–Set the logic level of a single digital output pin.
-
write_many–Set the logic level of multiple digital output pins.
Attributes:
-
readable_pins(list[int]) –Return the pin numbers that support digital input.
-
writable_pins(list[int]) –Return the pin numbers that support digital output.
Source code in src/pypalmsens/_instruments/gpio.py
107 108 | |
readable_pins
property
writable_pins
property
read
Read the logic level of a single digital input pin.
The pin configuration is automatically switched to input if needed.
Check your device documentation for the available input pins.
Parameters:
-
(pinint) –Pin number to read.
Returns:
-
level({'low', 'high'}) –Current logic level of the requested pin.
Raises:
-
PinNotSupportedError:–If
pinis not a supported input pin.
Source code in src/pypalmsens/_instruments/gpio.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
read_many
Read the logic levels of multiple digital input pins.
Parameters:
Returns:
-
levels(list of {'low', 'high'}) –Logic levels corresponding to the requested
pins, in the same order.
Raises:
-
PinNotSupportedError–If any pin in
pinsis not a supported input pin.
Source code in src/pypalmsens/_instruments/gpio.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
toggle
Invert the logic level of a single digital output pin.
A high state becomes low and vice-versa.
Parameters:
-
(pinint) –Pin number to toggle.
Returns:
-
None–
Raises:
-
PinNotSupportedError–If
pinis not a supported output pin.
Source code in src/pypalmsens/_instruments/gpio.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
toggle_many
Invert the logic level of multiple digital output pins.
Each pin is toggled independently: high becomes low
and low becomes high.
Parameters:
Raises:
-
PinNotSupportedError–If any pin in
pinsis not a supported output pin.
Source code in src/pypalmsens/_instruments/gpio.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
write
Set the logic level of a single digital output pin.
Parameters:
-
(pinint) –Pin number to write.
-
(level('low', 'high'), default:'low') –Logic level to set. Default is
'high'.
Raises:
-
PinNotSupportedError:–If
pinis not a supported input pin.
Source code in src/pypalmsens/_instruments/gpio.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
write_many
Set the logic level of multiple digital output pins.
Parameters:
-
(pinsSequence[int]) –Pin numbers to write.
-
(level('low', 'high'), default:'low') –Logic level to set on all specified pins. Default is
'high'.
Raises:
-
PinNotSupportedError–If any pin in
pinsis not a supported output pin.
Source code in src/pypalmsens/_instruments/gpio.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
pypalmsens.GPIOAsync
GPIOAsync(manager: InstrumentManagerAsync)
Digital general-purpose input/output (GPIO) interface.
This class provides high-level access to the instrument's digital pins. Pin numbering is hardware-specific. Consult the instrument manual for the physical mapping.
Note that the pins are typically referred to as d0 or d3.
These correspond to pins 0 and 3 in this interface, respectively.
For MethodSCRIPT devices, the underlying libraries auto-configures read/write direction on read/write instructions.
For explicit control, use the low-level MethodSCRIPT primitives directly:
Methods:
-
read_async–Read the logic level of a single digital input pin.
-
read_many_async–Read the logic levels of multiple digital input pins.
-
toggle_async–Invert the logic level of a single digital output pin.
-
toggle_many_async–Invert the logic level of multiple digital output pins.
-
write_async–Set the logic level of a single digital output pin.
-
write_many_async–Set the logic level of multiple digital output pins.
Attributes:
-
readable_pins(list[int]) –Return the pin numbers that support digital input.
-
writable_pins(list[int]) –Return the pin numbers that support digital output.
Source code in src/pypalmsens/_instruments/gpio_async.py
33 34 | |
readable_pins
property
writable_pins
property
read_async
async
Read the logic level of a single digital input pin.
The pin configuration is automatically switched to input if needed.
Check your device documentation for the available input pins.
Parameters:
-
(pinint) –Pin number to read.
Returns:
-
level({'low', 'high'}) –Current logic level of the requested pin.
Raises:
-
PinNotSupportedError:–If
pinis not a supported input pin.
Source code in src/pypalmsens/_instruments/gpio_async.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
read_many_async
async
Read the logic levels of multiple digital input pins.
Parameters:
Returns:
-
levels(list of {'low', 'high'}) –Logic levels corresponding to the requested
pins, in the same order.
Raises:
-
PinNotSupportedError–If any pin in
pinsis not a supported input pin.
Source code in src/pypalmsens/_instruments/gpio_async.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
toggle_async
async
Invert the logic level of a single digital output pin.
A high state becomes low and vice-versa.
Parameters:
-
(pinint) –Pin number to toggle.
Returns:
-
None–
Raises:
-
PinNotSupportedError–If
pinis not a supported output pin.
Source code in src/pypalmsens/_instruments/gpio_async.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
toggle_many_async
async
Invert the logic level of multiple digital output pins.
Each pin is toggled independently: high becomes low
and low becomes high.
Parameters:
Raises:
-
PinNotSupportedError–If any pin in
pinsis not a supported output pin.
Source code in src/pypalmsens/_instruments/gpio_async.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
write_async
async
Set the logic level of a single digital output pin.
Parameters:
-
(pinint) –Pin number to write.
-
(level('low', 'high'), default:'low') –Logic level to set. Default is
'high'.
Raises:
-
PinNotSupportedError:–If
pinis not a supported input pin.
Source code in src/pypalmsens/_instruments/gpio_async.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
write_many_async
async
Set the logic level of multiple digital output pins.
Parameters:
-
(pinsSequence[int]) –Pin numbers to write.
-
(level('low', 'high'), default:'low') –Logic level to set on all specified pins. Default is
'high'.
Raises:
-
PinNotSupportedError–If any pin in
pinsis not a supported output pin.
Source code in src/pypalmsens/_instruments/gpio_async.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |