Moderators: adafruit_support_bill, adafruit
def ShowKernel():
if DEBUG:
print('in ShowKernel')
lcd.clear()
lcd.message(commands.getoutput("/bin/uname -sr"))
while 1:
if lcd.buttonPressed(lcd.LEFT):
break
sleep(0.25) line1 = commands.getoutput("/bin/uname -mo")
line2 = commands.getoutput("/bin/uname -r")
lcd.message(line1 + '\n' + line2) line1 = commands.getoutput("/bin/uname -mo").split('\n')
line2 = commands.getoutput("/bin/uname -r").split('\n')
lcd.message(line1[0] + '\n' + line2[0])def DoReboot():
lcd.clear()
lcd.message('Are you sure?\nPress Sel for Y')
while 1:
if lcd.buttonPressed(lcd.LEFT):
break
if lcd.buttonPressed(lcd.SELECT):
lcd.clear()
lcd.backlight(lcd.OFF)
commands.getoutput("sudo shutdown -r now")
quit()
sleep(0.25)
def DoEnableUSB():
lcd.clear()
lcd.message('Are you sure?\nPress Sel for Y')
while 1:
if lcd.buttonPressed(lcd.LEFT):
break
if lcd.buttonPressed(lcd.SELECT):
lcd.clear()
commands.getoutput("echo 0x1 > /sys/devices/platform/bcm2708_usb/buspower")
break
sleep(0.25)
def DoDisableUSB():
lcd.clear()
lcd.message('Are you sure?\nPress Sel for Y')
while 1:
if lcd.buttonPressed(lcd.LEFT):
break
if lcd.buttonPressed(lcd.SELECT):
lcd.clear()
commands.getoutput("echo 0x0 > /sys/devices/platform/bcm2708_usb/buspower")
break
sleep(0.25)
def UpTime():
try:
f = open( "/proc/uptime" )
contents = f.read().split()
f.close()
except:
return "Cannot open file"
total_seconds = float(contents[0])
MINUTE = 60
HOUR = MINUTE * 60
DAY = HOUR * 24
days = int( total_seconds / DAY )
hours = int( ( total_seconds % DAY ) / HOUR )
minutes = int( ( total_seconds % HOUR ) / MINUTE )
seconds = int( total_seconds % MINUTE )
string = "Uptime:\n"
if days > 0:
string += str(days) + "d "
if len(string) > 0 or hours > 0:
string += str(hours) + "h "
if len(string) > 0 or minutes > 0:
string += str(minutes) + "m "
string += str(seconds) + "s"
return string;
def ShowUptime():
if DEBUG:
print('in ShowUptime')
lcd.clear()
while not(lcd.buttonPressed(lcd.LEFT)):
sleep(0.25)
lcd.home()
lcd.message(UpTime())
def ShowKernel():
if DEBUG:
print('in ShowKernel')
lcd.clear()
line1 = commands.getoutput("/bin/uname -mo").split('\n')
line2 = commands.getoutput("/bin/uname -r").split('\n')
lcd.message(line1[0] + '\n' + line2[0])
while 1:
if lcd.buttonPressed(lcd.LEFT):
break
sleep(0.25)
def ShowIPAddress():
if DEBUG:
print('in ShowIPAddress')
lcd.clear()
line1 = commands.getoutput("/bin/hostname")
line2 = commands.getoutput("/sbin/ifconfig").split('\n')[1].split()[1][5:]
lcd.message(line1 + '\n' + line2)
while 1:
if lcd.buttonPressed(lcd.LEFT):
break
sleep(0.25)
while 1:
if (lcd.buttonPressed(lcd.LEFT)):
display.update('l')
display.display()
if (lcd.buttonPressed(lcd.UP)):
display.update('u')
display.display()
if (lcd.buttonPressed(lcd.DOWN)):
display.update('d')
display.display()
if (lcd.buttonPressed(lcd.RIGHT)):
display.update('r')
display.display()
if (lcd.buttonPressed(lcd.SELECT)):
display.update('s')
display.display()
# Add the line below
sleep(.25)
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFOReturn to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit
Users browsing this forum: ArekKindAcere and 11 guests