aboutsummaryrefslogtreecommitdiff
path: root/bin/lcdtemp.py
blob: b514bb6ccff4ac5a28136ff8800aaac5d46b3a08 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python3 
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""Simple test for 16x2 character lcd connected to an MCP23008 I2C LCD backpack."""
import time
import board # type: ignore
import adafruit_character_lcd.character_lcd_i2c as character_lcd # type: ignore
import subprocess

cmd = "hostname -I | cut -d' ' -f1"
IP = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "date +%X\ %d%b%y"
TimeDate = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = "/usr/local/merlot/bin/readtemp.py"
LocalTemp = subprocess.check_output(cmd, shell=True).decode("utf-8")
cmd = '/usr/local/merlot/bin/gathertemps.py'
PromData = subprocess.check_output(cmd, shell=True).decode("utf-8")
temps=PromData.split()

# Modify this if you have a different sized Character LCD
lcd_columns = 20
lcd_rows = 4

# Initialise I2C bus.
i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller

# Initialise the lcd class
lcd = character_lcd.Character_LCD_I2C(i2c, lcd_columns, lcd_rows)

# Turn backlight on
lcd.backlight = True
# Print a two line message
lcd.message = IP
# Wait 5s
time.sleep(5)
lcd.clear()
lcd.message = TimeDate
# Wait 5s
time.sleep(5)
lcd.clear()
lcd.cursor = True
lcd.message = LocalTemp
# Wait 5s
time.sleep(5)
# Display blinking cursor
lcd.clear()
lcd.blink = True
lcd.message = PromData
# Wait 5s
time.sleep(5)
lcd.blink = False
lcd.clear()
lcd.clear()
lcd.message = "Going to sleep\nCya later!"
time.sleep(5)
# Turn backlight off
lcd.backlight = False
time.sleep(2)