Using Teensy 4.1 or 3.2 and Mouse+Keyboard+Joystick profile
Arduino 1.8.19
Teensyduino 1.56
This is the latest code for the teensy 4.1 I've been using to test
The issue is not in the input as it's consistent when you look back at the log, the values are sequential, and consistent. The issue is how the input is perceived by applications X and Y are smooth and operate like mouse wheels, Z/ Scroll Wheel seems to be more buffered or more jerky... which for a mouse wheel would make sense, you're scrolling so you want some lines to be skipped to make scrolling faster. But it's throwing software that needs this as a 3'rd encoder like Mame Etc... The result is that it judders all over the place, now to eliminate this I moved the encoders around, and the problem stuck with blue, I then moved the wiring and whatever was connected to the mouse scroll wheel input was misbehaving no matter the physical connections or encoder. I tried this with a 3.2 first and then with the QuadEncoder.h library and the result is the same.
So the constant is the mouse input, not what's driving the value, or how it's wired.
I'd add a second teensy, but then I have to deal with identifying which mouse and axis is driving what. I'd also have 3 devices driving the x axis, the mouse and 2 teensy's, I suspect that the scroll wheel is configured differently in Teensy or the HID where this occurs. As I have turned off all mouse acceleration, it's possible the scroll wheel deals with an internal acceleration factor.
Arduino 1.8.19
Teensyduino 1.56
This is the latest code for the teensy 4.1 I've been using to test
Code:
/* Complete USB Joystick Example
Teensy Mouse Input Test, Print Each Axis
*/
#include "QuadEncoder.h"
int pullup = 1; // Weather or not to use a pullup resistor
// Change these pin numbers to the pins connected to your encoder.
// Allowable encoder pins:
// 0, 1, 2, 3, 4, 5, 7, 30, 31 and 33
// Encoder on channel 1 of 4 available
// Phase A (pin0), PhaseB(pin1), Pullup = pullup(variable)
QuadEncoder encRed(1, 0, 1, pullup);
// Encoder on channel 2 of 4 available
//Phase A (pin2), PhaseB(pin3), Pullups = pullup(variable)
QuadEncoder encYellow(2, 2, 3, pullup);
// Phase A (pin4), PhaseB(pin7), Pullups = pullup(variable)
QuadEncoder encBlue(3, 4, 7, pullup);
//!! Avoid using pins with LEDs attached
//Debug Enable
bool debug = false;
// Mouse Sensetivity for all 3 wheels as it's presumed you're using the same encoders
const float multiplier = 1.0;
void setup() {
// you can print to the serial monitor while the joystick is active!
if (debug) Serial.begin(9600);
// Setup Encoders
encRed.setInitConfig();
//Optional filter setup
encRed.EncConfig.filterCount = 5;
encRed.EncConfig.filterSamplePeriod = 255;
encRed.init();
encYellow.setInitConfig();
encYellow.EncConfig.filterCount = 5;
encYellow.EncConfig.filterSamplePeriod = 255;
encYellow.init();
encBlue.setInitConfig();
encBlue.EncConfig.filterCount = 5;
encBlue.EncConfig.filterSamplePeriod = 255;
encBlue.init();
}
//Set Default Movement Values for mouse axis
long positionRed = -999;
long positionYellow = -999;
long positionBlue = -999;
//Encoder History
int newRedEnc, newYellowEnc, newBlueEnc;
int oldRedEnc, oldYellowEnc, oldBlueEnc;
void loop() {
// Read The Encoders
newRedEnc = encRed.read();
newYellowEnc = encYellow.read();
newBlueEnc = encBlue.read();
// To Debug values being sent to the mouse driver, this doesn't show the behavior of the mouse.
// Values are sequential but mouse bahvior seems to skip values, like a scroll wheel.
if (debug) {
if ( newBlueEnc != oldBlueEnc || newYellowEnc != oldYellowEnc || newRedEnc != oldRedEnc){
Serial.print("Red : ");
Serial.print(newRedEnc);
Serial.print(" Yellow : ");
Serial.print(newYellowEnc);
Serial.print(" Blue : ");
Serial.println(newBlueEnc);
}
}
// Update Mouse (Steering Wheel) position(s) if it's changed
if (newRedEnc != oldRedEnc){
Mouse.move(newRedEnc - oldRedEnc, 0);
}
if (newYellowEnc != oldYellowEnc){
Mouse.move(0, newYellowEnc - oldYellowEnc);
}
if (newBlueEnc != oldBlueEnc){
Mouse.scroll( newBlueEnc - oldBlueEnc);
}
// Populate Old Values before moving on to the next sample
oldRedEnc = encRed.read();
oldYellowEnc = encYellow.read();
oldBlueEnc = encBlue.read();
// a brief delay, so this runs "only" 200 times per second
delay(2);
}
The issue is not in the input as it's consistent when you look back at the log, the values are sequential, and consistent. The issue is how the input is perceived by applications X and Y are smooth and operate like mouse wheels, Z/ Scroll Wheel seems to be more buffered or more jerky... which for a mouse wheel would make sense, you're scrolling so you want some lines to be skipped to make scrolling faster. But it's throwing software that needs this as a 3'rd encoder like Mame Etc... The result is that it judders all over the place, now to eliminate this I moved the encoders around, and the problem stuck with blue, I then moved the wiring and whatever was connected to the mouse scroll wheel input was misbehaving no matter the physical connections or encoder. I tried this with a 3.2 first and then with the QuadEncoder.h library and the result is the same.
So the constant is the mouse input, not what's driving the value, or how it's wired.
I'd add a second teensy, but then I have to deal with identifying which mouse and axis is driving what. I'd also have 3 devices driving the x axis, the mouse and 2 teensy's, I suspect that the scroll wheel is configured differently in Teensy or the HID where this occurs. As I have turned off all mouse acceleration, it's possible the scroll wheel deals with an internal acceleration factor.