triangula.lcd: Serial LCD Display Support

Triangula uses a simple 16x2 LCD display to provide feedback. This display is connected to the serial port of the Raspberry Pi, it can accept commands to change the cursor, the colour of the backlight, clear the display and to display text. Because the command set is slightly cryptic and because there appear to be timing issues, I’ve wrapped up this functionality into a simple Python class:

class triangula.lcd.LCD[source]

Handle the serial attached LCD display

To enable this display on the Raspberry Pi you need to first disable the serial console from raspi-config


Create a new serial connection and clear the display


Clear the display

Set the cursor to a flashing block


Disable the cursor


Set the cursor to a normal underscore character

set_backlight(red=0, green=0, blue=0)[source]

Set the backlight colour, red green and blue values all range from 0 to 10

  • red – Red value, int 0 to 10
  • green – Green value, int 0 to 10
  • blue – Blue value, int 0 to 10
set_text(row1=None, row2=None)[source]

Set the text for either or both rows, send the updated values to the display. In order to fit on our display both rows must be at most sixteen characters in length. The display controller actually accepts 40 character rows but the display won’t display them! This will trim any strings to 16 characters as that’s the maximum length of our rows

  • row1 – Text for row 1
  • row2 – Text for row 2