Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
doc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

images/sitelogo.png

PFx Brick Python API

https://travis-ci.org/fx-bricks/pfx-brick-py.svg?branch=master https://img.shields.io/github/issues/fx-bricks/pfx-brick-py.svg?style=flat

This repository contains a python package API for developing python scripts and applications which communicate with the PFx Brick. This package supports both USB and Bluetooth LE connections to the PFx Brick and is supported for Windows, macOS and linux.

Getting Started

Requirements

Installation

The pfxbrick package can be installed with pip:

$ pip install pfxbrick

or directly from the source code:

$ git clone https://github.com/fx-bricks/pfx-brick-py.git
$ cd pfx-brick-py
$ python setup.py install

Basic Usage

After installation, the package can imported:

$ python
>>> import pfxbrick
>>> pfxbrick.__version__

An example of the package can be seen below

import time
from pfxbrick import *

# Open a PFx Brick session instance
brick = PFxBrick()
brick.open()

# Get the PFx Brick configuration settings
brick.get_config()
brick.print_config()

# Get the user defined name of the PFx Brick
brick.get_name()
print(brick.name)

# Change the user defined name
brick.set_name('My Cool Brick')

# Turn on some lights for 5 sec
brick.light_on([1, 2, 7, 8])
time.sleep(5)
brick.light_off([1, 2, 7, 8])

# Set motor channel A to 50% speed gradually
for speed in range(50):
    brick.set_motor_speed([1], speed)
    time.sleep(0.1)
brick.stop_motor([1])

# Play an audio file with indefinite repeat
brick.repeat_audio_file("LongBeep1")
time.sleep(5)
brick.stop_audio_file("LongBeep1")

# End the session
brick.close()

Documentation

If you want to learn more about PFx Brick, check out our website.