samwinslow / arduino-hid-examples

Experiments in HID devices with consumer-grade microcontrollers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

arduino-hid-examples

Experiments in HID devices with consumer-grade microcontrollers

Flight simulation

To enhance realism and practice procedures as a pilot would do in a real aircraft, it is sensible to mimic real equipment as closely as possible. The TeensyControls plugin is by far the easiest method to interface real hardware with X-Plane.

Hardware resources

  • Rotary encoders: Amazon
  • Artemis ATP board: Sparkfun — Note: would not recommend this board. Its circuit design and pinout is highly confusing and is poorly documented overall.
  • Teensy LC: PJRC

Libraries

  • TeensyControls plugin for X-Plane: PJRC • github
  • Teensy Encoder library (included with Teensy installer): PJRCgithub

Notes: Previous iterations

It is reasonably easy to use the standard Arduino USB Joystick libraries, and any combination of switches and buttons, to control X-Plane. I built a switch panel with SPST switches, debounced with Bounce2, and designed the code such that a rising/falling event would send a Joystick button press.

However, it felt hacky to do this because the problem is synchronizing the initial state of the switches with the initial state of X-Plane. There are too many caveats which end up with switches accidentally showing the opposite indication of the simulated switch state.

Bidirectional communication as provided by PaulStoffregen's libraries allow us to write the code in a much more declarative way, and to use a metaphor from web development, the microcontroller acts like a functional component in React that updates the state of its parent.

About

Experiments in HID devices with consumer-grade microcontrollers


Languages

Language:C++ 79.2%Language:C 20.8%