1 import RPi.GPIO as GPIO
2 from RPLCD.gpio import CharLCD
7 from signal import signal, SIGINT
10 lcd = CharLCD(cols=20, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23], numbering_mode=GPIO.BOARD)
13 def handler(signal_received, frame):
15 print('SIGINT or CTRL-C detected. Exiting gracefully')
18 def get_ip_address(ifname):
19 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
20 return socket.inet_ntoa(fcntl.ioctl(
23 struct.pack('256s', ifname[:15])
26 if __name__ == '__main__':
27 signal(SIGINT, handler)
31 lcd.write_string("Time: %s" %time.strftime("%H:%M:%S"))
32 lcd.cursor_pos = (1, 0)
33 lcd.write_string("Date: %s" %time.strftime("%m/%d/%Y"))
36 lcd.write_string("IP Address:")
37 lcd.cursor_pos = (1, 0)
38 lcd.write_string(get_ip_address('eth0'))
42 #lcd.write_string(u'Hello world!')
44 #lcd.write_string(u'Hello world!')