Display Management

class pico_synth_sandbox.display.Display(board)[source]

Bases: Task

Control the connected 16x2 character display (aka 1602). Hardware connections are abstracted and text writing and cursor management is simplified.

clear()[source]

Remove all text from display and hide and reset cursor position

hide_cursor()[source]

A quick method to hide the cursor.

Set whether or not the cursor should blink.

Parameters:

value (bool) – The blinking state of the cursor.

set_cursor_enabled(value)[source]

Set whether or not the cursor should be displayed.

Parameters:

value (bool) – The visibility of the cursor.

set_cursor_position(column=0, row=0, force=False)[source]

Set the position of the cursor.

Parameters:
  • column (int|tuple) – The x-position or column of the cursor which should be between 0 and 15. Can use a tuple of (x,y) to set both column and row.

  • row (int) – The y-position or row of the cursor which should be between 0 and 1.

  • force (bool) – Force the display to update the cursor position even if it hasn’t changed.

show_cursor(column=0, row=0)[source]

A quick method to ensure that the cursor is being displayed and set the position. Will not cause unnecessary display writes if called multiple times.

Parameters:
  • column (int) – The x-position or column of the cursor which should be between 0 and 15.

  • row (int) – The y-position or row of the cursor which should be between 0 and 1.

async update(reset_cursor=True)[source]

Write buffer to display. Must be called after any changes are made to the display for those changes to be visible.

Parameters:

reset_cursor (bool) – It is required to manipulate the cursor position in order to make writes to the display. By default, the cursor is reset to the previous position if needed for other applications. If you would like to keep the cursor at it’s newly written location, set this value as False.

write(value, position=(0, 0), length=None, right_aligned=False)[source]

Display a string or number on the display at the designated position. Can be truncated to a specified length and right-aligned.

Parameters:
  • value (string, float) – The message or number you would like to display. Any part of the string beyond the first 16 characters or the defined length will not be displayed.

  • position (tuple) – Use a tuple of two 0-based integers for the column and row of that you would like to write the value to. Ie: (x,y). The column (x) should be between 0 and 15 and the row (y) should be between 0 and 1.

  • length (int) – The length of the message you would like to write. By default, the length will be 16 or the length to the last column of the row from the designated x-position.

  • right_aligned – Whether or not you would like to align the data to the right padded by spaces as determined by the designated length.