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 29 30 31 32
| import time import Adafruit_CharLCD as LCD
lcd = LCD.Adafruit_CharLCDPlate()
lcd.create_char(1, [0, 0, 4, 14, 31, 0, 0, 0]) lcd.create_char(2, [0, 0, 31, 14, 4, 0, 0, 0]) lcd.create_char(3, [0, 2, 6, 14, 6, 2, 0, 0]) lcd.create_char(4, [0, 8, 12, 14, 12, 8, 0, 0])
lcd.clear() lcd.message('Press buttons...')
buttons = ( (LCD.LEFT, '\x03\nLeft' , (1,0,0)), (LCD.UP, '\x01\nUp' , (0,0,1)), (LCD.DOWN, '\x02\nDown' , (0,1,0)), (LCD.RIGHT, '\x04\nRight' , (1,0,1)) )
print('Press Ctrl-C to quit.') while True: for button in buttons: if lcd.is_pressed(button[0]): lcd.clear() lcd.message(button[1]) lcd.set_color(button[2][0], button[2][1], button[2][2])
|