Пример #1
0
# !/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Example adapted from Josh Sanders' original version on Sanworks Bpod repository
"""

import time

from pybpodapi.protocol import Bpod

my_bpod = Bpod()

print("Send byte 65 on UART port 1 - by default, this is ASCII 'A'")
my_bpod.manual_override(Bpod.ChannelTypes.OUTPUT, Bpod.ChannelNames.SERIAL, 1,
                        65)
time.sleep(1)  # Wait 1s

print("Set byte 65 ('A') on UART port 1 to trigger a 3-byte message: 'BCD'")
my_bpod.load_serial_message(1, 65, [66, 67, 68])
# Now, the same command has a different result
my_bpod.manual_override(Bpod.ChannelTypes.OUTPUT,
                        Bpod.ChannelNames.SERIAL,
                        channel_number=1,
                        value=65)
time.sleep(1)  # Wait 1s

print("Reset the serial message library. Bytes will now pass through again.")
my_bpod.reset_serial_messages()
# Back to 'A'
my_bpod.manual_override(Bpod.ChannelTypes.OUTPUT,
                        Bpod.ChannelNames.SERIAL,
Пример #2
0
import time

from pybpodapi.protocol import Bpod

import examples.settings as settings



my_bpod = Bpod()

wait_active_time_ms = 2

### INPUTS - BNC (1, 2) ###
print("Set BNC1 (Input) to a value")
my_bpod.manual_override(Bpod.ChannelTypes.INPUT, Bpod.ChannelNames.BNC, channel_number=1, value=12)
time.sleep(wait_active_time_ms)

print("Set BNC2 (Input) to a value")
my_bpod.manual_override(Bpod.ChannelTypes.INPUT, Bpod.ChannelNames.BNC, channel_number=2, value=15)
time.sleep(wait_active_time_ms)

### INPUTS - PWM (1..4) ###
print("Set PWM1 (Input) to a value")
my_bpod.manual_override(Bpod.ChannelTypes.INPUT, 'Port', channel_number=1, value=12)
time.sleep(wait_active_time_ms)

print("Set PWM2 (Input) to a value")
my_bpod.manual_override(Bpod.ChannelTypes.INPUT, 'Port', channel_number=2, value=13)
time.sleep(wait_active_time_ms)
Пример #3
0
# !/usr/bin/python3
# -*- coding: utf-8 -*-

"""
Example adapted from Josh Sanders' original version on Sanworks Bpod repository
"""
from pybpodapi.protocol import Bpod, StateMachine

bpod = Bpod()

bpod.manual_override(2, 'Valve', 1, 0)

"""
sma = StateMachine(bpod)

sma.set_global_timer(
    timer_id=1, timer_duration=1.5, on_set_delay=0,
    channel=Bpod.OutputChannels.PWM1,
    #PulseWidthByte=255
)

sma.set_condition(2, 'GlobalTimer1', 1)

sma.add_state(
    state_name='Port2Light',
    state_timer=1,
    state_change_conditions={
        Bpod.Events.Tup:     'Port2Off', 
        Bpod.Events.Port1In: 'TriggerGlobalTimer'
    },