io_pin
Pin #
Bases: IntEnum
De pins beschikbaar voor configuratie en uitlezen via de io pin service.
Pins 17 en 18 zijn niet beschikbaar
Source code in src/kaspersmicrobit/services/io_pin.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
PinAD #
Bases: Enum
De analoog-digitaal configuratie van een pin
Source code in src/kaspersmicrobit/services/io_pin.py
40 41 42 43 44 45 |
|
PinIO #
Bases: Enum
De input-output configuratie van een pin
Source code in src/kaspersmicrobit/services/io_pin.py
48 49 50 51 52 53 |
|
PinIOConfiguration #
Bases: PinConfiguration[PinIO]
De pin IO configuratie. Bevat voor iedere pin of die voor INPUT of OUTPUT gebruikt wordt
Source code in src/kaspersmicrobit/services/io_pin.py
94 95 96 97 98 99 100 101 102 103 |
|
PinADConfiguration #
Bases: PinConfiguration[PinAD]
De pin AD configuratie. Bevat voor iedere pin of die voor ANALOG of DIGITAL gebruik is
Source code in src/kaspersmicrobit/services/io_pin.py
106 107 108 109 110 111 112 113 114 115 |
|
PinValue
dataclass
#
De pin en zijn waarde
Attributes:
-
pin
(Pin
) –de pin
-
value
(int
) –de waarde van de pin (door hoe deze waarde verzonden wordt over bluetooth) verliest de waarde precisie (de minst significante 2 bits worden niet verzonden) dit betekent bvb dat een waarde 1-3 als 0 en 255 als 252 wordt verzonden.
Source code in src/kaspersmicrobit/services/io_pin.py
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 147 148 149 150 151 152 153 154 155 156 157 |
|
PwmControlData
dataclass
#
Een klasse om PWM opdrachten te geven aan de micro:bit
Attributes:
-
pin
(Pin
) –de pin waar de opdracht voor dient
-
value
(int
) –een waarde in het bereik (0-1024) (0 betekent uitgeschakeld)
-
period
(int
) –de periode in microseconden
Source code in src/kaspersmicrobit/services/io_pin.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
IOPinService #
Deze klasse bevat de functies die je kan aanspreken in verband met de io pins op de rand van de micro:bit
Dit zijn alle mogelijkheden aangeboden door de bluetooth io pin service
Zie ook: https://tech.microbit.org/hardware/edgeconnector/
Zie ook: https://www.micro-bit.nl/kennisbank-pinnen
Zie ook: https://lancaster-university.github.io/microbit-docs/ble/iopin-service/
Source code in src/kaspersmicrobit/services/io_pin.py
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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
is_available #
is_available() -> bool
Kijkt na of de I/O pin bluetooth service gevonden wordt op de geconnecteerde micro:bit.
Returns:
-
bool
–true als de I/O pin service gevonden werd, false indien niet.
Source code in src/kaspersmicrobit/services/io_pin.py
205 206 207 208 209 210 211 212 |
|
notify_data #
notify_data(callback: Callable[[List[PinValue]], None])
Deze methode kan je oproepen wanneer je verwittigd wil worden van de waarde van pins. Deze pins moet je voorafgaand geconfigureerd hebben als PinIO.INPUT pins vie write_io_configuration. Je wordt verwittigd wanneer de waarde wijzigt.
Parameters:
-
callback
(Callable[[List[PinValue]], None]
) –een functie die wordt opgeroepen met een lijst van PinValue objecten
Raises:
-
BluetoothServiceNotFound
–Wanneer de I/O pin service niet actief is op de micro:bit
-
BluetoothCharacteristicNotFound
–Wanneer de I/O pin service actief is, maar er geen manier was om de notificaties voor de pin data te activeren (komt normaal gezien niet voor)
Source code in src/kaspersmicrobit/services/io_pin.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
read_data #
read_data() -> List[PinValue]
Geeft de waarden voor iedere pin die geconfigureerd is als PinIO.INPUT via write_io_configuration.
Returns:
-
List[PinValue]
–Een lijst van input pins en hun bijhorende waarde
Raises:
-
BluetoothServiceNotFound
–Wanneer de I/O pin service niet actief is op de micro:bit
-
BluetoothCharacteristicNotFound
–Wanneer de I/O pin service actief is, maar er geen manier was om de pin data te lezen (komt normaal gezien niet voor)
Source code in src/kaspersmicrobit/services/io_pin.py
231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
write_data #
write_data(values: List[PinValue])
Schrijft waarden naar 1 of meer pins. Deze pins moet je voorafgaand geconfigureerd hebben als PinIO.OUTPUT pins via write_io_configuration. Wanneer jes chrijft naar een input pin zal dit genegeerd worden
Parameters:
-
values
(List[PinValue]
) –de output pins en hun bijhorende waarde
Raises:
-
BluetoothServiceNotFound
–Wanneer de I/O pin service niet actief is op de micro:bit
-
BluetoothCharacteristicNotFound
–Wanneer de I/O pin service actief is, maar er geen manier was om de pin data te schrijven (komt normaal gezien niet voor)
Source code in src/kaspersmicrobit/services/io_pin.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
|
read_ad_configuration #
read_ad_configuration() -> PinADConfiguration
Geeft voor iedere pin of die geconfigureerd is als een PinAD.DIGITAL of PinAD.ANALOG pin.
Returns:
-
PinADConfiguration
–De analoog-digitaal configuratie voor iedere pin
Raises:
-
BluetoothServiceNotFound
–Wanneer de I/O pin service niet actief is op de micro:bit
-
BluetoothCharacteristicNotFound
–Wanneer de I/O pin service actief is, maar er geen manier was om de pin analoog-digitaal configuratie te lezen (komt normaal gezien niet voor)
Source code in src/kaspersmicrobit/services/io_pin.py
262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
write_ad_configuration #
write_ad_configuration(config: PinADConfiguration)
Configureer iedere pin voor analoog of digitaal gebruik.
Parameters:
-
config
(PinADConfiguration
) –De analoog-digitaal configuratie voor iedere pin
Raises:
-
BluetoothServiceNotFound
–Wanneer de I/O pin service niet actief is op de micro:bit
-
BluetoothCharacteristicNotFound
–Wanneer de I/O pin service actief is, maar er geen manier was om de analoog-digitaal configuratie te schrijven (komt normaal gezien niet voor)
Source code in src/kaspersmicrobit/services/io_pin.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
read_io_configuration #
read_io_configuration() -> PinIOConfiguration
Geeft voor iedere pin of die geconfigureerd is als een PinIO.INPUT of PinIO.OUTPUT pin.
Returns:
-
PinIOConfiguration
–De input-output configuratie voor iedere pin
Raises:
-
BluetoothServiceNotFound
–Wanneer de I/O pin service niet actief is op de micro:bit
-
BluetoothCharacteristicNotFound
–Wanneer de I/O pin service actief is, maar er geen manier was om de input-output configuratie te lezen (komt normaal gezien niet voor)
Source code in src/kaspersmicrobit/services/io_pin.py
291 292 293 294 295 296 297 298 299 300 301 302 303 |
|
write_io_configuration #
write_io_configuration(config: PinIOConfiguration)
Configureer iedere pin voor input of output. Enkel waarden van pins die als PinIO.INPUT geconfigureerd worden kunnen uitgelezen worden met read_data, en enkel voor deze pins kan je updates krijgen met notify_data. Enkel naar pins die geconfigureerd zijn als PinIO.OUTPUT kan je waarden schrijven.
Parameters:
-
config
(PinIOConfiguration
) –De input-output configuratie voor iedere pin
Raises:
-
BluetoothServiceNotFound
–Wanneer de I/O pin service niet actief is op de micro:bit
-
BluetoothCharacteristicNotFound
–Wanneer de I/O pin service actief is, maar er geen manier was om de input-output configuratie te schrijven (komt normaal gezien niet voor)
Source code in src/kaspersmicrobit/services/io_pin.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
write_pwm_control_data #
write_pwm_control_data(
pwm_control1: PwmControlData,
pwm_control2: PwmControlData = None,
)
Schrijft Pulse Width Modulation opdrachten naar de micro:bit. 1 of 2 opdrachten kunnen tegelijk gegeven worden
Zie ook: https://microbit-micropython.readthedocs.io/en/latest/pin.html
Zie ook: https://www.micro-bit.nl/kennisbank-pinnen
Parameters:
-
pwm_control1
(PwmControlData
) –een PWM opdracht
-
pwm_control2
(PwmControlData
, default:None
) –een optionele PWM opdracht
Raises:
-
BluetoothServiceNotFound
–Wanneer de I/O pin service niet actief is op de micro:bit
-
BluetoothCharacteristicNotFound
–Wanneer de I/O pin service actief is, maar er geen manier was om de pwm control data te schrijven (komt normaal gezien niet voor)
Source code in src/kaspersmicrobit/services/io_pin.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|