MQTT Stopwatch / Display

MQTT Stopwatch / Display

The Config File (MQTT Stopwatch / Display)

The configuration file is used to hold most of the parameters that would be used to configure the display unit for your specific application. This allows the basic code to remain unchanged between applications.


# #############################################
# configuration parameters for MQTT Stopwatch
# #############################################

connected_device = "robot4"
waiting_to_start_message = "Waiting to Start"
challenge_done_message = "Challenge Done"
challenge_started_message = "Challenge Started"
welcome_banner_1 = "PiWars 2022"
welcome_banner_2 = "Barn Rats"
specialty_banner = "Manual Driving"

warning_time = 239      # after this many seconds, clock turns orange
too_long_time = 299     # after this many seconds, clock turns red

want_specialty_cmds = True
want_battery_message = True

This file is named "config.py" and is placed at the root of the filesystem (in the same folder that files such as "code.py" are placed). Note that the yellow box above scrolls in both vertical and horizontal directions, depending on the size of your browser window.

The stopwatch will work ok with the as-delivered config.py file. However you may edit it to change the display's behaviour to suit your own needs. If you change it, be sure to use a "programmer's editor", not a word processor which adds additional information that CircuitPython doesn't understand.

The connected_device parameter becomes the beginning part of all General and Specialty topic names in < a href="protocol.php">MQTT messages. This may help to identify messages from/to the target robot in a multi-robot playing field. If you do not wish to use this feature, keep the parameter, but set its value to the empty string, ie:

connected_device = ""

The waiting_to_start_message is triggered when the "stopwatch/clear" topic is received, similarly, the challenge_started_message and challenge_done_message are triggered by stopwatch start and stop topics. These banners are all shown on the bottom line of the display, in light blue.

The welcome_banner_1 and welcome_banner_2 banners are displayed when the "stopwatch/clear" topic is received, and when the display is first powered up. These are shown in orange, to the right of the time display. The welcome_banner_1 message is displayed in the upper row, the welcome_banner_2 on the bottom row.

The specialty_banner is displayed when any of the (optional) specialty topics are received (see the Message Protocol page for details). This are shown on the bottom line of the display, in purple.

Display of that specialty_banner is optional, based upon the value of the want_specialty_cmds parameter. If the value is True, then specialty commands will be processed; if it is False they will not. Don't forget that Python requires an inital capital on the True or False constant.

The stopwatch time value is normally shown in white characters. After warning_time seconds, it turns orange. After too_long_time seconds, it turns red.

The stopwatch time value is normally shown in white characters. After warning_time seconds, it turns oranage. After too_long_time seconds, it turns red.

The stopwatch time value is normally shown in white characters. After warning_time seconds, it turns oranage. After too_long_time seconds, it turns red.

Processing and display of the battery voltage is optional, based upon the value of the want_battery_message parameter. If the value is True (and the timer is running) then battery voltage messages will be processed; if it is False they will not. Don't forget that Python requires an inital capital on the True or False constant.