-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathdemo_lcd_extended_strings.py
executable file
·28 lines (24 loc) · 1.19 KB
/
demo_lcd_extended_strings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /usr/bin/env python
# Extended strings program. Writes and updates special (extended) strings
# with placeholders "{}" so, that it is possible to draw any character from the
# characters table using a caharcter code.
# Demo program for the I2C 16x2 Display from Ryanteck.uk
# Created by Matthew Timmons-Brown for The Raspberry Pi Guy YouTube channel
# Import necessary libraries for communication and display use
import drivers
from time import sleep
# Load the driver and set it to "display"
# If you use something from the driver library use the "display." prefix first
display = drivers.Lcd()
# Main body of code
try:
while True:
# Remember that your sentences can only be 16 characters long!
print("Writing simple string")
display.lcd_display_string("Simple string", 1) # Write line of text to first line of display
display.lcd_display_extended_string("Ext. str:{0xEF}{0xF6}{0xA5}{0xDF}{0xA3}", 2) # Write line of text to second line of display
sleep(2) # Give time for the message to be read
except KeyboardInterrupt:
# If there is a KeyboardInterrupt (when you press ctrl+c), exit the program and cleanup
print("Cleaning up!")
display.lcd_clear()