This is the dashboard I made for games, such as Euro Truck Simulator 2.
I'll now explain how this works in terms of hardware and how the software communicates
with the device.
So how's the hardware wired up ?
Well this is the Arduino board with the microprocessor. The board connects over USB to the computer.
These 10 data lines coming off, through the ribbon cable to get to the screen, the LCD
screen at the front. Servos wired up with a common ground and power,
it's just the data lines connect up to the board.
And these are 5 volt LEDs that I can plug directly into the board, and they'll share
common ground.
This diagram shows the data flow through the system. The game provides data to the plugin via the
telemetry API. The plugin then converts and packtises the
data and sends that over the serial port to the microprocessor, which unpacks the data
and signals the devices.
The telemetry plugin works by registering
to receive data and events from the game. The game then delivers the data and events
to the plugin. Types of data are the speed, the tachometer
(the RPM), the indicator light; and the event that I'm using in this plugin is the end of physics
frame event. The plugin then serialises the data into a
packet and then the packet is sent over serial cable to the microprocessor.
The microprocessor is listening on the serial port for the data.
That deserialises the packet then sends the data through to the different devices.
So the serial packet is quite a basic format. It uses the value FF or all ones for the sync
byte. Then the data bytes follow for the speed,
the RPM. The indicator and warning lights are packed
into a bitfield, and the text is sent through prefixed by the length of the text.
The reason for using a sync byte is so that the microprocessor can lock on to the beginning
of the packets. This does mean that the FF value can't appear
anywhere else in the data, the protocol could be changed to use a different format but this
is simple and it works. It's also broadcast only from the PC plugin
to the device, there is no acknowledgement of packet receipt from the microprocessor, the Arduino
board. If a packet is missed the next one contains
data to setup the system again incase the connection is lost.