mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2025-01-24 04:49:26 +00:00
43 lines
963 B
Python
Executable File
43 lines
963 B
Python
Executable File
# Import LCD library
|
|
from RPLCD import i2c
|
|
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
pid = os.getpid()
|
|
|
|
|
|
cmnd = "ps -ef|grep lcd_control|grep -v grep |grep -v {}|wc -l".format(pid)
|
|
status, output = subprocess.getstatusoutput(cmnd)
|
|
|
|
print(output)
|
|
if int(output) > 0:
|
|
print("Running already!")
|
|
#sys.exit()
|
|
# constants to initialise the LCD
|
|
lcdmode = 'i2c'
|
|
cols = 20
|
|
rows = 4
|
|
charmap = 'A00'
|
|
i2c_expander = 'PCF8574'
|
|
|
|
# Generally 27 is the address;Find yours using: i2cdetect -y 1
|
|
address = 0x27
|
|
port = 0 # 0 on an older Raspberry Pi
|
|
|
|
# Initialise the LCD
|
|
lcd = i2c.CharLCD(i2c_expander, address, port=port, charmap=charmap,
|
|
cols=cols, rows=rows)
|
|
line1 = f'{"####": <20}'
|
|
line2 = f'{"Restarting.....": <20}'
|
|
line3 = f'{"####": <20}'
|
|
line4 = f'{"####": <20}'
|
|
lcd.backlight_enabled = True
|
|
lcd.cursor_pos = (0, 0)
|
|
lcd.write_string(line1)
|
|
lcd.crlf()
|
|
lcd.write_string(line2)
|
|
lcd.crlf()
|
|
lcd.write_string(line3)
|
|
lcd.crlf()
|
|
lcd.write_string(line4) |