lcd.py 735 B

123456789101112131415161718192021222324252627
  1. from subprocess import Popen, PIPE
  2. from time import sleep, perf_counter
  3. from datetime import datetime
  4. import board
  5. import digitalio
  6. import adafruit_character_lcd.character_lcd as characterlcd
  7. lcd_columns = 16
  8. lcd_rows = 2
  9. lcd_rs = digitalio.DigitalInOut(board.D16)
  10. lcd_en = digitalio.DigitalInOut(board.D17)
  11. lcd_d4 = digitalio.DigitalInOut(board.D13)
  12. lcd_d5 = digitalio.DigitalInOut(board.D6)
  13. lcd_d6 = digitalio.DigitalInOut(board.D5)
  14. lcd_d7 = digitalio.DigitalInOut(board.D26)
  15. lcd = characterlcd.Character_LCD_Mono(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6,
  16. lcd_d7, lcd_columns, lcd_rows)
  17. lcd.clear()
  18. def write(row1, row2):
  19. lcd.message = row1.ljust(16)[:16] + "\n" + row2.ljust(16)[:16]