Skip to content
flyingbits edited this page Dec 20, 2023 · 6 revisions

PyBBIO's basic routines:

run(setup, loop)

Pass this your setup() and loop() functions to start your program. (Not defined when running PyBBIO in Python's interactive interpreter.)

stop()

A convenient way to have a PyBBIO program stop itself; simply raises a KeyboardInterrupt. (Not defined when running PyBBIO in Python's interactive interpreter.)

addToCleanup(routine)

Takes a callable object and adds it to PyBBIO's cleanup routines so it will be called after ctrl-c is pressed or stop() is called (or the interpreter exits when running interactively). This is an easy way to save data to a file, kill a thread, etc. User cleanup is called in the order it is registered.

millis()

Returns roughly the number of milliseconds passed since run() was called.

micros()

Returns roughly the number of microseconds passed since run() was called.

delay(ms)

This pauses a program for the given number of milliseconds.

delayMicroseconds(us)

This pauses a program for the given number of microseconds.


bbio_init()

Runs PyBBIO initialization. This is called automatically by run() before user's setup() routine, and is also called automatically when PyBBIO is imported in Python's interactive interpreter. The only time this should be called explicitly is when using PyBBIO in a program without using the run() routine. See Using PyBBIO.

bbio_cleanup()

Runs PyBBIO's cleanup routine, as well as any user cleanup scheduled with addToCleanup(). This is called automatically by run() after user's loop() routine has exited, and is also called automatically when exiting the interactive interpreter if PyBBIO has been imported. The only time this should be called explicitly is when using PyBBIO in a program without using the run() routine. See Using PyBBIO.