22 lines
506 B
Python
22 lines
506 B
Python
|
import I2C_LCD_driver
|
||
|
import socket
|
||
|
import fcntl
|
||
|
import struct
|
||
|
import time
|
||
|
mylcd = I2C_LCD_driver.lcd()
|
||
|
|
||
|
def get_ip_address(ifname):
|
||
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||
|
return socket.inet_ntoa(fcntl.ioctl(
|
||
|
s.fileno(),
|
||
|
0x8915,
|
||
|
struct.pack('256s', ifname[:15])
|
||
|
)[20:24])
|
||
|
|
||
|
mylcd.lcd_display_string("IP Address:", 1)
|
||
|
|
||
|
mylcd.lcd_display_string(get_ip_address('wlan0'), 2)
|
||
|
|
||
|
while True:
|
||
|
mylcd.lcd_display_string("Time: %s" %time.strftime("%H:%M:%S"), 1)
|