import time
import Adafruit_CharLCD as LCD
import subprocess

# Raspberry Pi pin configuration:
lcd_rs = 4
lcd_en = 17
lcd_d4 = 5
lcd_d5 = 6
lcd_d6 = 13
lcd_d7 = 19
lcd_backlight = 26

# Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows = 2

# Initialize the LCD using the pins above.
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)


def display_ip():
    lcd.clear()
    IP = str(subprocess.check_output(["hostname", "-I"]).split()[1]).replace("b", "").replace("'", "")
    lcd.message("Balance IP:")
    lcd.message("\n")
    lcd.message(IP)
    
#def display_weight(weight):
#    lcd.clear()
#    lcd.message("Uw gewicht:")
#    lcd.message("\n")
#    lcd.message(weight + "kg")
    



lcd.clear()
display_ip()
time.sleep(5)


