Gpio

class Gpio[source]

Bases: object

Controls two GPIO pins: one input and one output.

Both work at the same time, since they are different pins (set by the GPIO_IN and GPIO_OUT settings, in DEVICE ADDRESSES):

  • Input (GPIO_IN, default 26): while a task is running the pin is watched and self.trigger.trigger_on() is called when it goes from OFF to ON, and self.trigger.trigger_off() when it goes from ON to OFF. GPIO_IN_PULL decides what ON is: HIGH with the pull-down (DOWN, the default), LOW with the pull-up (UP). The watching runs only while a task is active, once its start() has finished. See GpioTriggerBase to customize what happens on trigger_on/trigger_off.

  • Output (GPIO_OUT, default 27): set_on() drives the pin HIGH and set_off() drives it LOW. Call them from anywhere (a task, a trigger, direct functions…); they work regardless of the input.

__init__() → None[source]

Initializes the Gpio instance (does not open the GPIO yet).

Methods

start() → None[source]

Starts watching the input pin for level changes.

stop() → None[source]

Stops watching the input pin and releases it.

set_on() → None[source]

Drives the output pin HIGH.

set_off() → None[source]

Drives the output pin LOW.