Skip to content

Commit

Permalink
unambiguous softcodes
Browse files Browse the repository at this point in the history
Co-Authored-By: Olivier Winter <[email protected]>
  • Loading branch information
bimac and oliche committed Jul 6, 2023
1 parent 3d4b1f3 commit 666def0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions iblrig/base_choice_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from iblrig import choiceworld
import iblrig.base_tasks
import iblrig.misc as misc
from iblrig.hardware import SOFTCODE

log = setup_logger('iblrig', level="INFO")

Expand Down Expand Up @@ -215,7 +216,7 @@ def get_state_machine_trial(self, i):
state_timer=0,
# state_change_conditions={"Port1In": "delay_initiation"},
state_change_conditions={"Tup": "delay_initiation"},
output_actions=[("SoftCode", 3), ("BNC1", 255)],
output_actions=[("SoftCode", SOFTCODE.TRIGGER_CAMERA), ("BNC1", 255)],
) # start camera
sma.add_state(
state_name="delay_initiation",
Expand Down Expand Up @@ -502,7 +503,7 @@ def get_state_machine_trial(self, i):
state_name="trial_start",
state_timer=3600,
state_change_conditions={"Port1In": "stim_on"},
output_actions=[self.bpod.actions.bonsai_hide_stim, ("SoftCode", 3), ("BNC1", 255)],
output_actions=[self.bpod.actions.bonsai_hide_stim, ("SoftCode", SOFTCODE.TRIGGER_CAMERA), ("BNC1", 255)],
) # sart camera
else:
sma.add_state(
Expand Down
13 changes: 10 additions & 3 deletions iblrig/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import logging
import time
from enum import IntEnum

import serial
import numpy as np
Expand All @@ -15,6 +16,12 @@
from pybpod_rotaryencoder_module.module_api import RotaryEncoderModule
from pybpodapi.bpod.bpod_io import BpodIO

SOFTCODE = IntEnum('SOFTCODE', [
'STOP_SOUND',
'PLAY_TONE',
'PLAY_NOISE',
'TRIGGER_CAMERA'])

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -74,9 +81,9 @@ def _define_message(self, module, message):

def define_xonar_sounds_actions(self):
self.actions.update({
'play_tone': ("SoftCode", 1),
'play_noise': ("SoftCode", 2),
'stop_sound': ("SoftCode", 0),
'play_tone': ("SoftCode", SOFTCODE.PLAY_TONE),
'play_noise': ("SoftCode", SOFTCODE.PLAY_NOISE),
'stop_sound': ("SoftCode", SOFTCODE.STOP_SOUND),
})

def define_harp_sounds_actions(self, go_tone_index=2, noise_index=3, sound_port='Serial3'):
Expand Down

0 comments on commit 666def0

Please sign in to comment.