Reference

Note

Functions and classes in pifacerelayplus.core have been imported into the main namespace. pifacerelayplus.PiFaceRelayPlus is the same as pifacerelayplus.core.PiFaceRelayPlus.

class pifacerelayplus.core.InputEventListener(chip)

Listens for events on the input port and calls the mapped callback functions.

>>> def print_flag(event):
...     print(event.interrupt_flag)
...
>>> listener = pifacerelayplus.InputEventListener()
>>> listener.register(0, pifacerelayplus.IODIR_ON, print_flag)
>>> listener.activate()
class pifacerelayplus.core.MotorDC(pin1, pin2)

A motor driver attached to a PiFace Relay Plus. Uses DRV8835.

brake()

Stop the motor.

coast()

Sets the motor so that it is coasting.

forward()

Sets the motor so that it is moving forward.

reverse()

Sets the motor so that it is moving in reverse.

exception pifacerelayplus.core.MotorForwardReverseError(state_into, state_from)

Too much current flows when instantly reversing motor direction.

exception pifacerelayplus.core.MotorTooSoonError

This exception is thrown when more than one motor is turned on within a small time window as it will draw too much current and reset the Raspberry Pi.

class pifacerelayplus.core.PiFaceRelayPlus(plus_board=None, hardware_addr=0, bus=0, chip_select=0, init_board=True)

A PiFace Relay Plus board.

Example:

>>> pfrp = pifacerelayplus.PiFaceRelayPlus(pifacerelayplus.MOTOR)
>>> pfrp.inputs[2].value
0
>>> pfrp.relays[3].turn_on()
>>> pfrp.motor[2].forward()
disable_interrupts()

Disables interrupts.

enable_interrupts()

Enables interrupts.

init_board(gpioa_conf={'pullup': 0, 'direction': 0, 'value': 0}, gpiob_conf={'pullup': 255, 'direction': 255, 'value': 0})

Initialise the board with given GPIO configurations.