Efficient interfacing with Psychopy
Posted: Tue Nov 12, 2019 3:46 am
Hi there,
I am new to working with Phidgets and with Python so this question may be very basic. I am attempting to write a program which takes voltage ratio info from 5 sensors (one for each finger) and uses this to control the position of a shape presented on screen using Psychopy.
I have a working code (see below), but it seems to be very slow and inefficient as I only see the cursors move ~2x per second. The code below is executed every frame. It takes the new voltage ratio, subtracts that from the baseline voltage ratio, and then uses this to calculate the new position variable. The position of the shape is then also updated each frame (code not shown here).
Is there a better way to do this? I thought perhaps to use an event handler might be better, but I have struggled to use the event handler function to create a variable which I can then use outside the function. Also I should mention slow frame rate does not seem to be an inherent problem of the monitor, I can present other things at much higher time resolution.
Thanks in advance!
I am new to working with Phidgets and with Python so this question may be very basic. I am attempting to write a program which takes voltage ratio info from 5 sensors (one for each finger) and uses this to control the position of a shape presented on screen using Psychopy.
I have a working code (see below), but it seems to be very slow and inefficient as I only see the cursors move ~2x per second. The code below is executed every frame. It takes the new voltage ratio, subtracts that from the baseline voltage ratio, and then uses this to calculate the new position variable. The position of the shape is then also updated each frame (code not shown here).
Code: Select all
newRthumb= voltageRatioRthumb.getVoltageRatio()
newRindex= voltageRatioRindex.getVoltageRatio()
newRmiddle= voltageRatioRmiddle.getVoltageRatio()
newRring= voltageRatioRring.getVoltageRatio()
newRlittle= voltageRatioRlittle.getVoltageRatio()
BLedRthumb=newRthumb-BLRthumb
BLedRindex=newRindex-BLRindex
BLedRmiddle=newRmiddle-BLRmiddle
BLedRring=newRring-BLRring
BLedRlittle=newRlittle-BLRlittle
PosRthumb =(BLedRthumb/0.000125)-0.75
PosRindex =(BLedRindex/0.000125)-0.75
PosRmiddle =(BLedRmiddle/0.000125)-0.75
PosRring =(BLedRring/0.000125)-0.75
PosRlittle =(BLedRlittle/0.000125)-0.75
Thanks in advance!