Encoder Fix - FSM Quadrature State Machine
Fixes multiple encoder issues in FreeJoy firmware.
Problems fixed
- Ghost HID output when partially rotating and releasing the encoder
- Lost pulses on EC11 encoders due to time and direction blocking
- First step lost when quickly changing rotation direction
Solution
Replaced the original lookup table logic with a full quadrature FSM (Finite State Machine) for ENCODER_CONF_1x and ENCODER_CONF_2x modes.
- Bounce rejection is handled automatically by the FSM
- Direction changes are detected immediately without losing the first step
- ENCODER_CONF_4x keeps the original enc_array_4 logic, required for encoders like the ALPS RKJXT1F42001
Modified files
application/Src/encoders.capplication/Inc/common_types.h(addedfsm_statefield toencoder_state_tstruct)
Tested on
- EC16 (ENCODER_CONF_1x)
- EC11 (ENCODER_CONF_1x)
- ALPS RKJXT1F42001 (ENCODER_CONF_4x)
Installation
Flash FreeJoy.bin using FreeJoy Configurator, or FreeJoy.hex using ST-Link or similar programmer.