Sequence control of a trip computer / BCM

The first step was to read out the OBD2 values and control the display. Later, further sources will be added, whose data must be polled permanently.

These are:

  • Temperature sensors
  • GPS data
  • Real time clock
  • Buttons

The current state must now be calculated and the display is updated.

So what matters now is what the sequence control looks like. When I thought about it, I remembered a small project 14-15 years ago. At that time, I spend a few weeks working on 3D game development.

It’s not about 3D development as about the way games development work in generally. There’s always a game loop, an endless loop that keeps polling data, analyzing it, and creating the screen output.

while (gameIsRunning) {
  handleUserInput();
  calculateGameState();
  updateDisplay();
}

The more often the loop is run through, the more often the input can be evaluated and the more often the screen output is updated. This is decisive for the FPS and the responsiveness of the system.

I use this principle as well. (which is visible by the main loop of my script):

Each time the loop is executed, the pressed keys, OBD values and other data (temperature, …) are queried.

The function obd_reader.get_obd_values() does more than the name promises. Because this method determines all values (temperature, real-time clock, …) and carries out various calculations (for example: the average consumption).

Leave a Reply

Your email address will not be published. Required fields are marked *