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():
The following is my Teensy side code:
// --------- Encoder A Movement
encbtnA->setEncoderHandler([&] (EncoderButton &btn){
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...
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)
{
});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
}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...