PFx Brick API Reference¶
The PFx Brick API has a top level PFxBrick
class object. An instance of PFxBrick
is used to open, maintain, and close an operating session with a PFx Brick. This class internally contains several supporting child classes used as convenient containers for related data. In particular, it contains a PFxConfig
and PFxDir
class which store configuration and file system data respectively.
The PFxAction
class is used to specify actions the PFx Brick can perform including motor control, lighting effects, and sound effects. It has many supporting methods to conveniently specify popular actions. A host application can also directly modify the field attributes of a PFxAction
instance to specify a detailed action description. Details of specifying these fields can be found in the PFx Brick Interface Control Document (ICD).
This page summarizes the main functional groups of functionality contained in this API in sections that follow.
Connection USB¶
Functions to establish a USB connected session with a PFx Brick.
|
Enumerate and optionally print a list PFx Bricks currently connected to the USB bus. |
|
Opens a USB communication session with a PFx Brick. |
Closes a USB communication session with a PFx Brick. |
Connection BLE¶
Functions to establish a BLE connected session with a PFx Brick.
|
Performs a Bluetooth scan for available peripheral devices which advertise themselves as PFx Bricks. |
|
Resolves a list of scanned candidate Bluetooth devices into valid PFx Brick devices. |
|
Opens a BLE communication session with a PFx Brick. |
|
Closes a BLE communication session with a PFx Brick. |
- async ble_device_scanner(scan_time=3.0, min_devices=1, scan_timeout=30.0, filters=None, silent=False, verbose=False)[source]¶
Performs a Bluetooth scan for available peripheral devices which advertise themselves as PFx Bricks.
This coroutine will search for the required number of devices in scan_time chunks up until the scan_timeout interval has elapsed.
- Parameters
scan_time –
float
scan time interval to look for devicesmin_devices –
int
minimum number of devices to look for before returningscan_timeout –
float
timeout interval for finding the required min_devicesfilters –
list
or str optional device name filters, e.g. “16 MB”silent –
boolean
a flag to disable printing of statusverbose –
boolean
a flag to print a verbose list of advertising devices
- Returns
[
BLEDevice
] a list of PFx Brick device objects described in a Bleak BLEDevice class.
- async find_ble_pfxbricks(devices, connect_interval=5.0, timeout=30.0, silent=False)[source]¶
Resolves a list of scanned candidate Bluetooth devices into valid PFx Brick devices.
- Parameters
devices – [
BLEDevice
] a list of candidate PFx Brick device objectsconnect_interval –
float
time interval to wait for connectiontimeout –
float
timeout interval for attempting a device connectionsilent –
boolean
a flag to disable printing of status
- Returns
[
dict
] a list of dictionary objects for each PFx Brick verified by connection. The dictionary contains keys for “address”, “serial_no” and “name”.
Information¶
Functions to get information and status from the PFx Brick.
|
Requests the version of Interface Control Document (ICD) the connected PFx Brick supports using the PFX_CMD_GET_ICD_REV ICD message. |
Requests the top level operational status of the PFx Brick |
|
Prints the top level operational status information retrieved by a previous call to the get_status method. |
|
Retrieves the user defined name of the PFx Brick using the PFX_CMD_GET_NAME ICD message. |
|
|
Sets the user defined name of the PFx Brick using the PFX_CMD_SET_NAME ICD message. |
Returns the current state of the PFx Brick operating parameters. |
|
Returns the current state of the PFx Brick file system. |
|
Returns the current state of the PFx Brick Bluetooth radio module. |
Configuration¶
Functions which query and modify PFx Brick configuration and settings.
Retrieves configuration settings from the PFx Brick using the PFX_CMD_GET_CONFIG ICD message. |
|
Writes the contents of the |
|
Prints a summary representation of the PFx Brick configuration settings which were retrieved by a previous call to get_config. |
|
Resets the PFx Brick configuration settings to factory defaults. |
Event/Action LUT¶
Functions which query and modify the event/action look up table in the PFx Brick.
|
Retrieves the stored action associated with a particular [eventID / IR channel] event. |
|
Retrieves a stored action indexed by address rather than a combination of eventID and IR channel. |
|
Sets a new stored action associated with a particular [eventID / IR channel] event. |
|
Sets a new stored action in the event/action LUT at the address specified. |
File System¶
Functions which interact with the PFx Brick file system.
Reads the PFx Brick file system directory. |
|
|
Copies a file from the host to the PFx Brick. |
|
Copies a file from the PFx Brick to the host. |
|
Removes a file from the PFx Brick file system. |
|
Formats the PFx Brick file system, erasing all files. |
|
Renames a file on the file system. |
|
Sets the upper 8-bit attribute field of a file's directory entry. |
|
Returns a numeric file ID from either a string filename or integer file ID. |
Actions¶
Functions which specify and perform common actions.
|
Executes a passed action data structure. |
Motor Actions¶
|
A convenience wrapper for PFxAction().set_motor_speed |
A convenience wrapper for PFxAction().stop_motor |
|
Populates an action to set the speed of specified motor channel(s). |
Populates an action to stop the specifed motor channel(s). |
Light Actions¶
A convenience wrapper for PFxAction().light_on |
|
A convenience wrapper for PFxAction().light_off |
|
A convenience wrapper for PFxAction().light_toggle |
|
|
A convenience wrapper for PFxAction().set_brightness |
|
A convenience wrapper for PFxAction().light_fx |
|
A convenience wrapper for PFxAction().combo_light_fx |
Populates an action to turn on selected light outputs. |
|
Populates an action to turn off selected light outputs. |
|
Populates an action to toggle the state of selected light outputs. |
|
|
Populates an action to set the brightness of selected light outputs. |
|
Populates an action with a user specified light effect and associated parameters. |
|
Populates an action with a user specified combination light effect and associated parameters. |
Sound Actions¶
|
A convenience wrapper for PFxAction().sound_fx |
|
A convenience wrapper for PFxAction().repeat_audio_file |
|
A convenience wrapper for PFxAction().stop_audio_file |
|
A convenience wrapper for PFxAction().set_volume |
|
A convenience wrapper for PFxAction().sound_fx |
|
Populates an action to play an audio file once. |
|
Populates an action for repeated playback of an audio file. |
|
Populates an action to stop playback of an audio file. |
|
Populates an action to set the audio volume. |
|
Populates an action with a user specified sound effect and associated parameters. |
Running scripts¶
|
Runs a specified script file on the PFx Brick filesystem. |
Stops all script execution. |
BLE Notifications¶
|
Enables user selected notifications to be sent asynchronously from the PFx Brick. |
Disables asynchronous notifications sent from the PFx Brick. |