Skip to content

Commit

Permalink
Create verify_camera_trigger.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bimac committed Jul 26, 2023
1 parent 4b2b51e commit 840ed99
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions scripts/hardware_validation/verify_camera_trigger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from pathlib import Path

from pybpodapi.protocol import Bpod, StateMachine
from time import time
import types

import iblrig.base_tasks

last_time = time()


def softcode_handler(self, data):
global last_time
now = time()
d = 1 / (now - last_time)
last_time = now
print("{:.2f} Hz".format(d))


file_settings = Path(iblrig.__file__).parents[1].joinpath('settings', 'hardware_settings.yaml')
hardware_settings = iblrig.path_helper.load_settings_yaml(file_settings)
bpod = Bpod(hardware_settings['device_bpod']['COM_BPOD'])
bpod.softcode_handler_function = types.MethodType(softcode_handler, bpod)

sma = StateMachine(bpod)
sma.set_global_timer(1, 5)
sma.add_state(
state_name="start",
state_timer=0,
state_change_conditions={"Tup": "wait"},
output_actions=[("GlobalTimerTrig", 1),
("PWM1", 0)]
)
sma.add_state(
state_name="wait",
state_timer=0,
state_change_conditions={"Port1In": "flash",
"GlobalTimer1_End": "exit"},
output_actions=[("PWM1", 255)]
)
sma.add_state(
state_name="flash",
state_timer=0,
state_change_conditions={"Tup": "wait",
"GlobalTimer1_End": "exit"},
output_actions=[("PWM1", 255),
("SoftCode", 1)]
)

bpod.send_state_machine(sma)
bpod.run_state_machine(sma)

bpod.manual_override(2, 'PWM', 1, 0)
bpod.close()

0 comments on commit 840ed99

Please sign in to comment.