Hardware Reference
In-Depth Information
therefore, we are only using the transmit lines from BBB. Commands are written to the at-
tached microcontroller, which in turn drives the display. The datasheet, available on the
SparkFun website, describes all of the commands. In general, the procedure is to move the
virtual cursor on the display and then send the text.
SparkFun has a more complete quick start guide on the serial LCD at ht-
tps://www.sparkfun.com/tutorials/246 . The example code is for an Arduino, but porting it
to Python is straightforward if you follow the example of the bridge LCD in this chapter.
Similar to the GPIO example, the serial port in the Adafruit library can be used as fol-
import Adafruit_BBIO.UART as UART
import serial
class FrontPanelDisplay(object):
def __init__(self):
self.uart = 'UART4'
self.port = serial.Serial(port="/dev/ttyO4",
The display will automatically wrap lines if the text you are trying to display is longer
than sixteen characters. Therefore, you have to manage the LCD to ensure that it displays
correctly. For example, let's take a look at the display_graph method that is respons-
ible for producing the bandwidth graph:
up_str = '{0:<16}'.format('Up: ' + self.block_char * up)
dn_str = '{0:<16}'.format('Down: ' + self.block_char * down)
The first line clears the screen and resets the cursor to the top-left corner of the 16x2 dis-
play. Next, we format the two lines to display the graph using the special block character
on the LCD. This line is left justified and is filled with whitespace up to sixteen charac-
Search WWH ::

Custom Search