Controller Board for Tk Application

This class implements the controller base class API for local development purposes, providing alternative methods useful for development.

class firmware.board_tk.BoardTk(watchdog_enabled: bool = False)

Bases: BoardMock

This class implements the controller API in a way that makes it work well in local development, with the Tk screen class being used as the display. This behavior is similar to the mock class used for unit testing, so that is the base class here, but with some specific functions overridden.

developer_mode() bool

Returns whether the board is in developer mode, based solely on the watchdog_enabled arg in the constructor.

Returns:

True or False whether the board is in developer mode

ds18x20_read_temp(rom: bytes) float

Mocks the functionality of reading the temperature for a specific ROM on the one-wire connection. For this Tk controller, this function simply chooses a random number to return as the temperature.

Parameters:

rom – Ignored in this implementation

Returns:

A random temperature between -20 and +40, in degrees Celsius

run_forever() bool

Returns whether this controller should actually run “forever”. For this Tk hardware board, the answer is yes, the sensing system should run continually.

Returns:

True

sleep(seconds: float) None

Sleeps for a specified number of seconds. Unlike the mock base class, this actually sleeps, so that developers can see the actual behavior of the device and screen in real time.

Parameters:

seconds – Number of seconds to sleep

Returns:

Nothing

system_hang(seconds: int | None = None) None

Provides a single place for causing the system to “hang” for either an amount of seconds, or forever.

There are some scenarios where the system may need to hang for a few seconds, such as if an error pops up, and you want to hold the sensor for 30 seconds then let the machine reboot. That way the message may be seen on the sensor. In that case, call this with a positive integer number of seconds and the controller hangs that long.

There are some scenarios where the system may need to hang forever, such as if the sensor initialization fails immediately upon boot. In that case, call this with no argument, or None. The controller will hang forever.

Parameters:

seconds – Number of seconds to hang, or None to hang forever

Returns:

Nothing