An arduino library to generate a modular browser based UI that can be hosted on an ESP32 based robot to interface with a robot through a browser. Developed by Team 3932: Dirty Mechanics members.
- Log console widgets
- Numerical input widgets
- Gamepad input map widget
- Customizable button widgets
- Tank drive control using WASD or arrow keys
- Display widgets that work with numbers and text
- Install the ESP32 boards and the ESP32 file system manager in the Arduino IDE. See here for instructions on installing the board in the Arduino IDE, and see here for instructions on how to install the file system uploader in the Arduino IDE.
- Install the library dependencies to your IDE: ESPAsyncWebServer, AsyncTCP, ArduinoJson
- Clone this repository.
- Open the
driverStation.ino
file in the Arduino IDE. This will allow your Arduino IDE to be positioned at the correct file location locally. - Using the
wifiSecrets_EXAMPLE.h
file as refference Change thessid
andpassword
to the name of your WiFi network so that the program can connect to your WiFi upon startup. Alternatively you can remove the line#include "wifiSecrets.h"
and directly set your ssid and password in your ino sketch. - Upload the
data
folder to the ESP32 filesystem. To do this, choose theTools > ESP32 Sketch Data Upload
option in the Arduino menu bar. Wait for this process to complete. You should see a message similar toLeaving...
orHard reseting...
when the process is done. - Upload the current file to the ESP32 through the Arduino IDE by using the
Upload
button (commonly styled as a right arrow) in the Arduino menu. Make sure the board is set toESP32 Dev Module
in your board settings. Again, you should see a message similar toLeaving...
orHard reseting...
when the process is done. - If you have bonjour or Avahi mDNS installed on your computer you can open
robot.local
in your browser. If the domain does not work on a windows device install Bonjour Browser. If this does not work, open up your serial monitor when the program is finished uploading. The robots assigned local IP will be printed. Enter this IP address into your web browser.
- When the dashboard is enabled the gamepad widget is hidden until a valid controller input and button press is detected
- Selecting either
WASD
orArrow Keys
input mode in settings will substitute for the gamePad widget using tank drive - You can press these buttons with a mouse or use your keyboards actual buttons
- To use the keyboard buttons simply click anywhere on this widget. Clicking anywhere off will stop the listening for keyboard button presses
- When you use the dashboard for the first time the widgets will be placed in rows. You can resize the length of buttons displays and inputs, the height of the gamepad map, and the size of consoles using the resizers in the four corners of all widgets.
- You can move all widgets draging them by their top banner.
- Using the lock in the top right will ensure every time you use the dashboard your widgets will stay the same.
- You can unlock the configuration make modifications and lock them again at any time.
- You can use the download button to save the console logs as a
.txt
file - The clear button will clear the console field and its save file.
- The widget configuration stores data for both position and size of widgets
- After creating a widget setup you can download your configuration to migrate to another computer or share with others
- You can upload position configurations here
- You can also reset your widget position configuration to default here
- Turning on
Grid
will snap widgets to a grid with the resolution specified by the slider from 1 to 40 pixels - Turning on
Snap To Edges
will cause widgets to snap to nearby widgets sides and corners
GamePad
mode allows for reading controller buttons and joysticks to control your robotWASD
andArrow Key
modes emulate gamepad joystick axes #1 and #3 for left and right respectively as a tank drive configuration- By default WASD and Arrow Key joystick emulation uses a value of
-100
for joystick up and100
for joystick down - Invert Y axis mode will invert all joystick Y axes
//DriverStationDashboard class that creates a driver station with the specified widgets
DriverStationDashboard::DriverStationDashboard(int btnCount, int inpCount, int dispCount, int consCount,
DashButton *dashButtons, DashInput *dashInputs, DashDisplay *dashDisplays, DashConsole *dashConsoles)
//Initialize the driver station webpage on your local network
void DriverStationDashboard::initialize(char *ssid, char *password)
//Returns true if the driver station is enabled
bool DriverStationDashboard::enabled(void)
struct DashButton { String btnName, bool momentaryType, bool defaultState, String onText, String offText, bool currentState };
struct DashInput { String inpName, double inpData };
struct DashDisplay { String dispName, char dispData[20] };
struct DashGamePad { bool gpButtons[16], int gpAxes[4] };
struct DashConsole { String consName, char consBuffer[1000], int bufferStart, int bufferEnd };
//Get the value of a specified input widget
double DriverStationDashboard::dashInput(int inpNum)
//Get the state of a specified dash button widget
bool DriverStationDashboard::dashButton(int btnNum)
//Get the value of a specified game pad button
bool DriverStationDashboard::gamePadButton(int btnNum)
//Get the value of a specified game pad axes
int DriverStationDashboard::gamePadAxes(int axesNum)
//Update a specified dash board display widget with text
void DriverStationDashboard::setDashDisplay(int dispNum, String dataToDisplay)
//Update a specified dash board display widget with a double
void DriverStationDashboard::setDashDisplay(int dispNum, double dataToDisplay)
//Update a specified dash board display widget with an int
void DriverStationDashboard::setDashDisplay(int dispNum, int dataToDisplay)
//Send data to a dash board console with a string
void DriverStationDashboard::sendToConsole(int consNum, String dataToDisplay)
//Send data to a dash board console with a double
void DriverStationDashboard::sendToConsole(int consNum, double dataToDisplay)
//Send data to a dash board console with an int
void DriverStationDashboard::sendToConsole(int consNum, int dataToDisplay)
Contributions are welcome. Please open an issue or make a pull request as needed.