Teensy LC joystick routines delay in linux

sagreen83

Active member
I am working on a design that uses a teensylc, and some encoder wheels to send data to a linux system. The data is pretty simple. I'm sending a number from 1 to 1024 to the linux system via Joystick.X();

The following is linux side test code:

from evdev import InputDevice, categorize, ecodes
dev = InputDevice('/dev/input/event5')
print(dev)
for event in dev.read_loop():
if event.type == ecodes.EV_ABS:​
print(event)

The following is my Teensy side code:

// --------- Encoder A Movement
encbtnA->setEncoderHandler([&] (EncoderButton &btn){
int iTmp = 0;

if (btn.position() < ENC_FEED_OVR_MIN)
btn.resetPosition(ENC_FEED_OVR_MIN);​
else if (btn.position() > ENC_FEED_OVR_MAX)
btn.resetPosition(ENC_FEED_OVR_MAX);​
else
{
iTmp = (1024 / ENC_FEED_OVR_MAX) * btn.position();
Serial.printf("iTmp [%i] position[%i]\n", iTmp, btn.position());
Joystick.X(iTmp); // Sends Joystick X cordinates to pathpilot via HID. Translates to ABS_X​
}​
});

Note: ENC_FEED_OVER_MAX = 10 and btn.position is a number from 1 to 100. I am developing in platformio on the Raspberry Pi, and my USB type is set to USB_FLIGHTSIM_JOYSTICK.

If I run the server side python code on a raspberry PI, I get an event for every click of the encoder. I can go both ways with the encoder

If I run the same code on another linux system (mint), I only get an event about every 5 clicks, and when I turn it back the other way, I have to run as many clicks backwards, then an additional 5 to get an event to fire. Oddly enough, the problem seems to be related to the value I am sending in Joystick.X(). If I increase the multiplier to 40 I get an event for every click, but it still exibits the same problem going backwards.

Any thoughts on this? Why is it acting differently on these 2 linux systems? Why would the value I send make a difference?

Thanks,
Scott...
 
Update:

I ran an evtest on both linux systems... On the one that is working FUZZ for ABS_X is 0 (or not set) and on the one that is not working FUZZ for ABS_X is reported as 255.

Not sure if this is the problem, but is there a way to set FUZZ in the teensy code? Is this something that can be set on the hardware side? Not sure if that is something the device reports when it is detected.

Scott...
 
Has anyone used a teensy to connect to a Linux application using python and the EVDEV libraray? Seems odd that I am the only one having this problem.

Without being able to reset the EVDEV fuzz value to 0 makes the teensy almost unusable in this environment.

Scott...
 
Back
Top