Replies: 2 comments 4 replies
-
Hi Josh, *(I haven't had time to try and replicate, but at first glance of the code...) I think what is happening is that while currenttime < (starttime + duration):
self.print_message("while occurring")
#separate events by mouse
if device.path == self.patha:
#separate x and y events
if event.code == evdev.ecodes.REL_X:
# synchronisation events (which the mice output when x and y movements coincide)
# have the same event code as rel_x (i.e. 0). event.value is delta
if event.value != 0:
self.print_message("appending")
ax.append([event.value, event.timestamp]) Every time there is an event in the task, the api's One suggestions is to use FrameTrigger and Framelogger :https://pycontrol.readthedocs.io/en/latest/user-guide/synchronisation/#frame_trigger to reduce the number of events being processed by the state machine. Additionally you may need to use Python's asyncio or multithreading to avoid blocking code, or ensure that you have 10s in between events that would call Another option may be to use a optical mouse module and arduino library to read the data with a separate microcontroller, and then connect/output the data to a pyControl port adaptor board which would then be plugged directly into your pyControl breakout board and be treated like any other device. Or maybe you can adapt your treadmill to use a pyControl rotary encoder for positional tracking instead of using the optical mouse. Hope that gives you some ideas on how to progress. Let us know how it goes. Best, |
Beta Was this translation helpful? Give feedback.
-
I agree that connecting the optical mouse sensor directly to the pyboard is likely to give a beter solution that trying to route the data throught the API. It should be pretty straightforward to update @AtMostafa's implementation to work with the latest version of pyControl. One disadvantage of the PMW3360DM is that it has an SPI serial interface, and pyControl does not break out the pins needed for SPI to any of the standard pyControl breakout board ports. It might be possible to use the software SPI functionality in machine.softSPI but this would use more microcontroller resources. Annother option that looks interesting is the Sparkfun optical tracking sensor, which has an I2C serial interface (available on the standard pyControl breakout board ports 3 and 4), and a python library which should hopefully make developing a pyControl device class for it fairly straighforward. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am trying to use PyControl in conjunction with evdev via the PyControl API, and am encountering an issue that typically results in the PyControl_GUI no longer responding, force quit required.
I want to use PyControl to trigger acquisition on a camera and a 2p (using pulse), and I want to concurrently use evdev to read events from an optical computer mouse. As soon as I try to read events from the optical mouse, the GUI typically crashes with erratic behaviour. Most frequently it just stops responding, requiring a force quit. Occasionally the optical mouse reading events seem to occur, but the camera triggering fails, and occasionally it crashes and I get the error message: "Error: uncaught exception of type: <class 'BlockingIOError'>". I see this error is "Raised when an operation would block on an object (e.g. socket) set for non-blocking operation." If anyone has any advice, I would greatly appreciate it.
I have attached both relevant scripts (please save as .py, unsupported file type upload hence the .txt), which I have in the folders as specified in the API example.
I am using Python 3.12.3 on Ubuntu 22.04.4
Micropython version: 1.2
Framework version: 2.0.1
motor_input_task_clean.txt
treadmill_api_class.txt
Kind regards,
Josh
Beta Was this translation helpful? Give feedback.
All reactions