def __init__(self, DIMENSIONS=(800, 450)): """DIMENSIONS is a tuple (WIDTH, HEIGHT) of the field.""" # OBJECTS WIDTH = DIMENSIONS[0] self.players = [Player(0, WIDTH), Player(1, WIDTH)] self.ball = Ball() # DATA self.pressed_keys = set() # set has no duplicates self.quit_key = pyglet.window.key.Q self.speed = 6 # in pixels per frame self.ball_speed = self.speed * 2.5 self.WIDTH, self.HEIGHT = DIMENSIONS # STATE VARS self.paused = False self.i = 0 # "frame count" for debug self.ems_device = openEMSstim.openEMSstim(serial_port,19200) self.left_player_lost_stimulation = ems_command(1,100,2000) self.right_player_lost_stimulation = ems_command(2,100,2000)
# This program enables to send commands via USB to the openEMSstim board # NOTE: To use it you will need to adjust the COM_port to whatever your operating system reported for the arduino connection (Windows will be something like COM3, check on Device Manager, while unix will be /dev/tty.usbsomething) from time import sleep from pyEMS import openEMSstim from pyEMS.EMSCommand import ems_command my_ems_board = openEMSstim.openEMSstim("/dev/tty.usbserial-A98VFLTL",19200) while 1: choice = int(raw_input("1 or 2? EMS with full intensity on that channel for 2 seconds")) my_ems_board.send(ems_command(choice,100,9000))
#native imports import sys from time import sleep #import openEMSstim modules sys.path.append("../") from pyEMS import openEMSstim from pyEMS.EMSCommand import ems_command #create a ems_device ems_device = openEMSstim.openEMSstim("/dev/tty.wchusbserial1410",19200) if ems_device: #check if was created properly print("Device Found") print("Will send: Channel 1, Intensity=1 (out of 100), Duration=1000 (1 second)") command_1 = ems_command(1,1,1000) ems_device.send(command_1) sleep(1) print("Will send: Channel 2, Intensity=1 (out of 100), Duration=1000 (1 second)") command_2 = ems_command(2,1,1000) ems_device.send(command_2) sleep(1) print("Will send: Channel 1 + 2 (two commands) with Intensity=40 (out of 100), Duration=2000 (2 seconds)") command_1 = ems_command(1,40,2000) command_2 = ems_command(2,40,2000) ems_device.send(command_1) ems_device.send(command_2) sleep(2) print("Done testing. Closing") ems_device.shutdown() #
serial_port = "/dev/tty.wchusbserial14210" import os from time import sleep from pyEMS import openEMSstim from pyEMS.EMSCommand import ems_command from pyEMS.channel import Channel from pyEMS.preset import Preset if sys.version_info >= (3, 0): import configparser else: import ConfigParser # create a new openEMSstim board my_ems_board = openEMSstim.openEMSstim( serial_port, 19200 ) #adjust serial_port above, do not change baudrate if you don't know why def ConfigSectionMap(config, section): dict1 = {} options = config.options(section) for option in options: try: dict1[option] = config.get(section, option) if dict1[option] == -1: DebugPrint("skip: %s" % option) except: print("exception on %s!" % option) dict1[option] = None return dict1
# This program enables to send commands via USB to the openEMSstim board # NOTE: To use it you will need to adjust the COM_port to whatever your operating system reported for the arduino connection (Windows will be something like COM3, check on Device Manager, while unix will be /dev/tty.usbsomething) from time import sleep from pyEMS import openEMSstim from pyEMS.EMSCommand import ems_command my_ems_board = openEMSstim.openEMSstim("/dev/tty.wchusbserial14220",19200) while 1: choice = int(raw_input("1 or 2? EMS with full intensity on that channel for 2 seconds")) my_ems_board.send(ems_command(choice,100,2000))
# This program enables to send commands via USB to the openEMSstim board # NOTE: To use it you will need to adjust the COM_port to whatever your operating system reported for the arduino connection (Windows will be something like COM3, check on Device Manager, while unix will be /dev/tty.usbsomething) from time import sleep from pyEMS import openEMSstim from pyEMS.EMSCommand import ems_command my_ems_board = openEMSstim.openEMSstim("/dev/tty.usbserial-1410", 19200) while 1: choice = int( raw_input( "1 or 2? EMS with full intensity on that channel for 0.5 seconds")) my_ems_board.send(ems_command(choice, 100, 5000))
else: serial_port = "/dev/tty.wchusbserial14210" import os from time import sleep from pyEMS import openEMSstim from pyEMS.EMSCommand import ems_command from pyEMS.channel import Channel from pyEMS.preset import Preset if sys.version_info >= (3, 0): import configparser else: import ConfigParser # create a new openEMSstim board my_ems_board = openEMSstim.openEMSstim(serial_port,19200) #adjust serial_port above, do not change baudrate if you don't know why def ConfigSectionMap(config, section): dict1 = {} options = config.options(section) for option in options: try: dict1[option] = config.get(section, option) if dict1[option] == -1: DebugPrint("skip: %s" % option) except: print("exception on %s!" % option) dict1[option] = None return dict1 # check for EMS params on calibration file
#native imports import sys from time import sleep #import openEMSstim modules sys.path.append("../") from pyEMS import openEMSstim from pyEMS.EMSCommand import ems_command #create a ems_device ems_device = openEMSstim.openEMSstim("/dev/tty.wchusbserial1410", 19200) if ems_device: #check if was created properly print("Device Found") print( "Will send: Channel 1, Intensity=1 (out of 100), Duration=1000 (1 second)" ) command_1 = ems_command(1, 1, 1000) ems_device.send(command_1) sleep(1) print( "Will send: Channel 2, Intensity=1 (out of 100), Duration=1000 (1 second)" ) command_2 = ems_command(2, 1, 1000) ems_device.send(command_2) sleep(1) print( "Will send: Channel 1 + 2 (two commands) with Intensity=40 (out of 100), Duration=2000 (2 seconds)" ) command_1 = ems_command(1, 40, 2000) command_2 = ems_command(2, 40, 2000) ems_device.send(command_1)