There are two parts to this project. The ESP32 code, which sends controller data to the computer via serial, and the Loading Simulator 2022 game itself, which interprets the controller data and responds to it.
To run Loading Simulator 2022, simply open "index.html" in a browser that supports web serial e.g. Google Chrome. The system accepts data in JSON format with 4 data fields so you can build your own custom controller:
{
"b": Button value of 0 or 1,
"x": Joystick X value from 0 to 4095,
"y": Joystick Y value from 0 to 4095,
"p": Potentiometer value from 0 to 4095
}
When you open Loading Simulator, click on the top left corner to open a list of serial ports. Once you select a port, the system can receive controller data.
Pressing the Button displays a random loading message. Moving the joystick up and down moves the loading bar up and down. Moving the joystick left and right increases the loading progress asymptotically towards 100%. Turning the potentiometer changes the loading bar "redness".
The code to run is under the inputTester folder. The ESP32 code constantly sends sensor data via serial every 10ms. Pin number and connected components are as follows:
We are using the Arduino IDE. To enable IDE support for the ESP32, first open up Preferences and under "Additional Boards Manager URLs", add the following URL:
https://dl.espressif.com/dl/package_esp32_index.json
Then, go to "Tools/Board:/Board Manager" and install ESP32:
Then, go to "Tools/Manage Libraries" and search for tft_eSPI. Install it.
After that, go to "Tools/Board:" and select "TIGO T1".
Now, simply connect your board and click upload.