Exemplo n.º 1
0
#! /usr/bin/env python3
 
# PFx Brick example script to demonstrate multiple scripted actions

import hid
import time
import random
from pfxbrick import PFxBrick, PFxAction
from pfxbrick.pfx import *

brick = PFxBrick()
brick.open()

audiofile = 2
max_speed = 100

# start looped audio playback and set volume
brick.test_action(PFxAction().repeat_audio_file(audiofile))
brick.test_action(PFxAction().set_volume(75))

# ramp up the motor speed gradually to max_speed
for x in range(max_speed):
    brick.test_action(PFxAction().set_motor_speed([1], x))
    # show a random light pattern
    y = random.randint(1,8)
    brick.test_action(PFxAction().light_toggle([y]))
    time.sleep(0.1)

# ramp down the motor speed gradually to 0%

for x in range(max_speed):
Exemplo n.º 2
0
#! /usr/bin/env python3

# PFx Brick example script to retrieve basic information about the
# brick including its identity and configuration settings.

import hid

from pfxbrick import PFxBrick, find_bricks

bricks = find_bricks(True)
print("%d PFx Bricks found" % (len(bricks)))

if bricks:
    for b in bricks:
        brick = PFxBrick()
        res = brick.open(b)
        if not res:
            print("Unable to open session to PFx Brick")
        else:
            print("PFx Brick Status / Identity")
            print("===========================")
            print("PFx Brick ICD version : %s" % (brick.get_icd_rev()))
            brick.get_name()
            print("PFx Brick name        : %s" % (brick.name))
            brick.get_status()
            brick.print_status()
            print("PFx Brick Configuration")
            print("=======================")
            brick.get_config()
            brick.print_config()
            brick.close()