Show ip on load

This commit is contained in:
Ruben 2018-01-05 00:10:44 +01:00
parent 4e1a633ba0
commit 212da04421
1 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import os
from si_prefix import si_format
import Adafruit_CharLCD as LCD
import urllib2
import socket
# Set FPS (though RPi is probably to slow to meet it ;-)
FPS = 1.0
@ -31,8 +33,12 @@ lcd_rows = 2
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
lcd_columns, lcd_rows, lcd_backlight)
# ip if config is needed over ssh. Username pi, Password: artwork1
ip = (([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")] or [[(s.connect(("8.8.8.8", 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) + ["no IP found"])[0]
lcd.clear()
lcd.message("Init scanner.")
lcd.message("Init scanner.\n{}".format(ip) )
time.sleep(6) # give some time to read the ip.
# Init camera
camera = picamera.PiCamera()