Skip to content

Analog joystick doesn't properly work (at least with ESP32) #24

@WiseLord

Description

@WiseLord

I tried to build recent code 5ed49d2 for ESP32 and it works fine for push buttons.

Then, I tried to build it for case when analog joystick is used instead of buttons (considering changes in button pinout) and found that

Joystick doesn't properly work:

  • it always considers that one of "buttons" in pair is pressed, even when in central position.
  • only on of directions works (overrides "pressed" state of central position).

I debugged a bit and found that raw ADC values read from joystick are OK (about 510 when in central position, and about 40 or 980 when "pressed" - tried to output analogValue in Button:poll() function of PushButton.cpp). The problem is somewhere in application logic.

I tried to bisect and found that everything works well at commit b704cd4 but gets broken after commits 8d8b640 and e07a949.

My changes in config:

-#define KEYPAD_JOYSTICK_ANALOG        OFF //    OFF, JS1 for Jerry's analog joystick                                          Option
+#define KEYPAD_JOYSTICK_ANALOG        JS1 //    OFF, JS1 for Jerry's analog joystick                                          Option
 #define KEYPAD_JOYSTICK_HYSTERESIS    200 //    200, Sensitivity of joystick in ADC counts (larger is less sensitive)         Adjust
+#define B_PIN1_ACTIVE_STATE          HIGH // Swap N/S
+#define B_PIN2_ACTIVE_STATE          HIGH // Swap N/S

I also tried different hysteresis values (both smaller and bigger) and it didn't help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions