Circuit Playground TFT Gizmo schematic showing A3 controlling the backlight with a MOSFET transistor. A 10k pull-down resistor is present on A3.

There are two approaches to supporting the optional TFT Gizmo display on a Circuit Playground Bluefruit (CPB):

  1. Provide configuration data to turn on (enable) the display. For a board with an attached display the enable would be manually set in the configuration for that board.
  2. Detect the presence of the attached display.

The configuration approach could be implemented with a configuration file to cleanly separate the per-instance data from the code. Detection of the screen can either be an alternative approach or the two can be combined.

The Challenge of Detecting the TFT Gizmo

The TFT Gizmo connects to a Circuit Playground Bluefruit (or Circuit Playground Express) using four of the pads for the display interface and one other pad for the backlight control. All of those pads are set as outputs making the interface unidirectional as a whole. This is known as simplex communication. Unfortunately, this means there is no method via standard signalling to detect whether the TFT Gizmo is present or not.

The 10k pull-down resistor in the backlight circuitry shown in the schematic at the top of the page luckily provides a crude way to detect the presence of that resistor. The A3 pad can momentarily be configured as an input with the processor's internal weaker (higher resistance) pull-up competing with the pull-down resistor. The external pull-down resistor is likely to win and this provides a method of detecting the TFT Gizmo. It can be fooled by other things attached to A3 but this is good enough to differentiate between nothing and the TFT Gizmo.

A sample CircuitPython function to detect the TFT Gizmo is shown below.

Download: file
def tftGizmoPresent():
    """Determine if the TFT Gizmo is attached.
       The TFT's Gizmo circuitry for backlight
       features a 10k pull-down resistor.
       This attempts to verify the presence
       of the pull-down to determine
       if TFT Gizmo is present.
       This is likely to get confused if
       anything else is connected to pad A3.
       Only use this on Circuit Playground Express
       or Circuit Playground Bluefruit boards."""
    present = True
        with digitalio.DigitalInOut(board.A3) as backlight_pin:
            backlight_pin.pull = digitalio.Pull.UP
            present = not backlight_pin.value
    except ValueError:
        ### The Gizmo is already initialised, i.e. showing console output

    return present

This assumes that if A3 is already in use then the display is already active. Once the TFT Gizmo is used on a CPB (or CPX) it remains active until the power is removed.

This guide was first published on Sep 02, 2020. It was last updated on Sep 02, 2020.

This page (TFT Gizmo Detection) was last updated on Feb 04, 2021.

Text editor powered by tinymce.