-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlcd_message
More file actions
executable file
·34 lines (30 loc) · 1.26 KB
/
lcd_message
File metadata and controls
executable file
·34 lines (30 loc) · 1.26 KB
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
#!/usr/bin/python3
import sys
import time
import argparse
import pylcdproc
default_host = 'localhost'
default_port = 13666
default_duration = 10
def main():
parser = argparse.ArgumentParser(description="Display message on LCDd server")
parser.add_argument("message", nargs='*', help="message to display")
parser.add_argument("-t", "--time", type=int, default=default_duration,
help="duration to display message, in seconds (default: " + str(default_duration) + ")")
parser.add_argument("-H", "--host", default=default_host,
help="host to connect to (default: " + default_host + ")")
parser.add_argument("-p", "--port", type=int, default=default_port,
help="port to connect to (default: " + str(default_port) + ")")
parser.add_argument("-d", "--debug", action="store_true",
help="enable debugging")
args = parser.parse_args()
lcd = pylcdproc.ScrollingTextLCD("lcd_message", host=args.host, port=args.port, debug=args.debug)
message = " ".join(args.message)
print("displaying message:", message)
lcd.display(message)
try:
time.sleep(args.time)
except KeyboardInterrupt:
sys.exit(1)
if __name__ == "__main__":
main()