コード例 #1
0
def sigterm_handler(signal, frame):
	lcd.clear()
	lcd.display_string("     BYE! :)    ", 1)
	sleep(1)
	lcd.backlight(0)
	sys.exit()
コード例 #2
0
import time
import serial
import RPi.GPIO as GPIO
import lcddriver as lcd

global ser

os.putenv('DISPLAY', ':0.0')

pygame.init()
pygame.joystick.init()
pygame.display.init()

lcd = lcd.lcd()

lcd.display_string("Enabling TeleOP", 1)
lcd.display_string("Initializing...", 2)
time.sleep(2)
lcd.clear()

print()
print(" -=- Tele Op Control Test -=- ")
print("          Version 1.0         ")
print()

#var to keep track of program state
shouldRun = True

print(" [INFO] Attempting to Connect to Xbox Controller")
try:
    j = pygame.joystick.Joystick(0)
コード例 #3
0
				lcd.display_string_pos(chr(min(4,math.floor((percentage-(x*100/6))/((100/6/4))+1))),row,9+x)
			else:  
				lcd.display_string_pos(" ",row,9+x)

def sigterm_handler(signal, frame):
	lcd.clear()
	lcd.display_string("     BYE! :)    ", 1)
	sleep(1)
	lcd.backlight(0)
	sys.exit()

signal.signal(signal.SIGTERM, sigterm_handler)

WAIT_TIME = 4
lcd.clear()
lcd.display_string(str.center(str(os.popen('hostname').readline())[:-1],16,' '),1)
lcd.display_string("    STARTING    ",2)
sleep(WAIT_TIME)
lcd.clear()

try:
	while (1):
		
		#CPU & RAM usage
		lcd.display_string("CPU   % "+chr(126)+"      "+chr(127),1)
		lcd.display_string("RAM   % "+chr(126)+"      "+chr(127),2)
		for x in range(WAIT_TIME):
			cpupct=ps.cpu_percent()
			rampct=ps.virtual_memory()[2]
			lcd.display_string_pos(str(math.floor(cpupct)).rjust(3),1,3)
			lcd.display_string_pos(str(math.floor(rampct)).rjust(3),2,3)
コード例 #4
0
# network status get function
def get_bytes(t, iface='enp2s0'):
    with open('/sys/class/net/' + iface + '/statistics/' + t + '_bytes', 'r') as f:
        data = f.read();
        return int(data)

# load lcd
lcd = lcd.lcd()

# test code
#lcd.display_string("11111111111111111111222222222222222222223333333333333333333344444444444444444444", 1)

# get hostname
#hostname=str(os.popen('hostname').readline())[:-1]

lcd.display_string("####################",1)
lcd.display_string("WELCOME TO ODROID H2",2)
lcd.display_string("LCD SERVICE STARTED.",3)
lcd.display_string("####################",4)


sleep(10)



while True:

  # foot powered coding
  #cpuUsage=str(round(float(os.popen('''grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage }' ''').readline()),2))
  #tot_m, used_m, free_m = map(int, os.popen('free -t -m').readlines()[-1].split()[1:])
  #percentMem=str(round(used_m/tot_m))
コード例 #5
0
import lcddriver as lcd
lcd.clear()
lcd.display_string("     BYE! :)    ", 1)
sleep(1)
lcd.backlight(0)
sys.exit()
コード例 #6
0
def attemptConnect():
    try:
        pygame.init()
        pygame.joystick.init()
        pygame.display.init()

        j = pygame.joystick.Joystick(0)
        j.init()
        print(' [INFO::CONTROLLER] Controller Connected: ' + j.get_name())
        joyName = j.get_name()
        lcd.clear()
        longString = "Controller Connected: " + joyName
        lcd.display_string(longString[0:15], 1)
        time.sleep(1)
        for i in range(0, len(longString) - 14):
            lcd.display_string(longString[i:i + 15], 1)
            time.sleep(.1)
        time.sleep(1)
        lcd.clear()

        lcd.display_string("Waiting for User", 1)
        lcd.display_string("Start+Select+A", 2)

    except pygame.error:
        print(
            ' [INFO::CONTROLLER] Failed to connect to controller... Program restarting in 5 seconds'
        )
        pygame.display.quit()
        pygame.quit()
        lcd.clear()
        for i in range(0, 5):
            lcd.display_string("No Controller!", 1)
            lcd.display_string("Refreshing: " + str(5 - i), 2)
            time.sleep(1)
        attemptConnect()
コード例 #7
0
import os
import sys
import pygame
from pygame import locals
import time
import lcddriver as lcd

print()
print(" -=- Controller Detector -=- ")
print("          Version 1.0        ")
print()

lcd = lcd.lcd()

lcd.display_string("Tele OP Ver: 1.0", 1)
lcd.display_string("Initializing...", 2)
time.sleep(2)
lcd.clear()

print(" [INFO] Attempting to Connect to Xbox Controller")

pygame.init()
pygame.joystick.init()
pygame.display.init()


def attemptConnect():
    try:
        pygame.init()
        pygame.joystick.init()
        pygame.display.init()
コード例 #8
0
# import modules
import lcddriver as lcd
import os
import psutil as ps
from time import time
from time import sleep
from datetime import datetime

lcd = lcd.lcd()

# lcd.display_string("####################",1)
lcd.display_string("STOP LCD...", 1)
lcd.display_string("SHUTDOWN...", 2)
# lcd.display_string("####################",4)

sleep(5)

lcd.clear()
lcd.backlight_off()
コード例 #9
0
  #percentMem=str(round(used_m/tot_m))

  # read hdd state from hdparm
  hddstate=str(os.popen('hdparm -C /dev/sda | grep state | cut -f 2 -d :').readline())[2:][:-1]

  if hddstate=="standby":
    hddstr="SLEEP"
  else :
    hddstr="WAKE"

  # line 1 print (hddstate, friendly name)
#   lcd.display_string("HDD:"+hddstr.rjust(5)+"  ODROID-H2", 1)

  # line 2 print (cpu, memory)
  # use psutil to get CPU usage and Memory Usage
  lcd.display_string("CPU:"+str(int(ps.cpu_percent())).rjust(2)+"%"+"  "+"MEM:"+str(int(ps.virtual_memory()[2])).rjust(2)+"%", 1)

  # get network speed for 1sec
#   tx1 = get_bytes('tx')
#   rx1 = get_bytes('rx') 
#   sleep(1)
#   tx2 = get_bytes('tx')
#   rx2 = get_bytes('rx')
#   tx_speed = (tx2 - tx1)/1000000.0
#   rx_speed = (rx2 - rx1)/1000000.0

  # line 3 print (network speed)
  # bps -> mpbs (*8)
#   lcd.display_string("TX: "+str(round(tx_speed*8)).zfill(3)+" RX: "+str(round(rx_speed*8)).zfill(3)+" Mbps", 3)

  # line 4 print (cputemp, date, time)
コード例 #10
0
# import modules
import lcddriver as lcd
import os
import psutil as ps
from time import time
from time import sleep
from datetime import datetime

lcd = lcd.lcd()

lcd.display_string("####################", 1)
lcd.display_string("STOP ODROIDLCD...", 2)
lcd.display_string("SYSTEM SHUTDOWN...", 3)
lcd.display_string("####################", 4)

sleep(5)

lcd.clear()
lcd.backlight_off()