Browse Source

LCD added

Robert Burghard 11 months ago
parent
commit
6158ea8590
2 changed files with 30 additions and 0 deletions
  1. 27 0
      lcd.py
  2. 3 0
      main.py

+ 27 - 0
lcd.py

@@ -0,0 +1,27 @@
+from subprocess import Popen, PIPE
+from time import sleep, perf_counter
+from datetime import datetime
+import board
+import digitalio
+import adafruit_character_lcd.character_lcd as characterlcd
+
+
+lcd_columns = 16
+lcd_rows = 2
+
+lcd_rs = digitalio.DigitalInOut(board.D16)
+lcd_en = digitalio.DigitalInOut(board.D17)
+lcd_d4 = digitalio.DigitalInOut(board.D13)
+lcd_d5 = digitalio.DigitalInOut(board.D6)
+lcd_d6 = digitalio.DigitalInOut(board.D5)
+lcd_d7 = digitalio.DigitalInOut(board.D26)
+
+
+lcd = characterlcd.Character_LCD_Mono(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6,
+                                      lcd_d7, lcd_columns, lcd_rows)
+
+lcd.clear()
+
+
+def write(row1, row2):
+    lcd.message = row1.ljust(16)[:16] + "\n" + row2.ljust(16)[:16]

+ 3 - 0
main.py

@@ -1,5 +1,6 @@
 import time
 from mpd import MPDClient
+import lcd
 
 
 client = MPDClient()
@@ -22,9 +23,11 @@ def main():
         if station != info.get("name", ""):
             station = info.get("name", "")
             print(station)
+            lcd.write(station, title)
         if title != info.get("title", ""):
             title = info.get("title", "")
             print(title)
+            lcd.write(station, title)
         time.sleep(10)