The major part of the device consists of incremental rotary encoders. They convert the angular position or motion of a shaft to output signals. Simple and powerful electro-mechanical devices may be used to control and manipulate CGI x VFX x DIMs wireless, real time and online.
CONNECT ENCODER TO ESP32
When encoder shaft is rotated or button is pressed internal mechanism generates bounces for a short period of time. MC (microcontroller) should not interpret this noise as a valid signal change and must ignore it. While the valid signal should not be missed and each shaft tick is counted.
These are examples of CLK (yellow) and DT (blue) signals obtained from KY-040 encoder.
Bounces are about 250 μs and 75 μs.
Here is another example of a signal from ALPS encoder. The bounce appears when shaft slowly rotated CCW.
Searching for the most efficient and proper way to program encoders I found beautiful working solution by buxtronix. It uses state machines to read encoder and has inherent !debounce built in.
TESTING LIB ON MULTIPLE ENCODERS AND HUZZAH32
I started with connecting two ALPS encoders to HUZZAH32 board. It turns out this type of encoder uses half-step state table from the Rotary library. I modified the initial library code by adding few helper functions for interrupt handling procedure. Code is here.
TRANSMIT AND DISPLAY DATA
Communication between browser and the device is established through websockets. ESP32 is set to broadcast data in JSON format every 100 μs.
WiFi credentials can be updated directly from the device by using just 1 encoder. If login was successful creds are stored in EEPROM. Device always performs check for creds in EEPROM on boot. If creds are not there user is suggested to select AP and enter new password.
Real time collaboration between multiple users in one web application can be achieved with websocket protocol. ESP32 sends rotary encoders info with 10Hz frequency to server through websockets and server broadcasts received info through websockets to all web clients connected to it. Both esp32 and web clients and server can exchange data bidirectionally though the VFX controller doesn't need it. Also sending additional info could be time consuming so I avoid unnecessary data transmission to minimize latency.