Exemple #1
0
    # Draw a black filled box to clear the image.
    draw.rectangle((0, 0, width, height), outline=0, fill=0)

    # Shell scripts for system monitoring from here : https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load
    cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
    CPU = subprocess.check_output(cmd, shell=True)
    cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%sMB %.2f%%\", $3,$2,$3*100/$2 }'"
    MemUsage = subprocess.check_output(cmd, shell=True)
    cmd = "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%dGB %s\", $3,$2,$5}'"
    Disk = subprocess.check_output(cmd, shell=True)

    # Write two lines of text.

    draw.text((x, top),
              "eth0: " + str(get_ip_address('eth0')),
              font=font,
              fill=255)
    draw.text((x, top + 8),
              "wlan0: " + str(get_ip_address('wlan0')),
              font=font,
              fill=255)
    #draw.text((x, top+16),    str(MemUsage.decode('utf-8')),  font=font, fill=255)
    draw.text((x, top + 16),
              "battery: " + str(battery()) + ' volts',
              font=font,
              fill=255)
    draw.text((x, top + 25), str(Disk.decode('utf-8')), font=font, fill=255)

    # Display image.
    disp.image(image)
Exemple #2
0
# Load default font.
font = ImageFont.load_default()


while True:

    value=ads.readVoltage(4)/1000.0

    # Draw a black filled box to clear the image.
    draw.rectangle((0,0,width,height), outline=0, fill=0)

    # Shell scripts for system monitoring from here : https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load
    cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
    CPU = subprocess.check_output(cmd, shell = True )
    cmd = "free -m | awk 'NR==2{printf \"Mem:%s/%sMB %.1f%%\", $3,$2,$3*100/$2 }'"
    MemUsage = subprocess.check_output(cmd, shell = True )
    cmd = "df -h | awk '$NF==\"/\"{printf \"Disk:%d/%dGB %s\", $3,$2,$5}'"
    Disk = subprocess.check_output(cmd, shell = True )

    # Write two lines of text.

    draw.text((x, top),       "eth0: " + str(get_ip_address('eth0')),  font=font, fill=255)
    draw.text((x, top+8),     "wlan0: " + str(get_ip_address('wlan0')), font=font, fill=255)
    draw.text((x, top+16),    str(MemUsage.decode('utf-8')),  font=font, fill=255)
    draw.text((x, top+25),    str(Disk.decode('utf-8')) + (" %.1f")%value,  font=font, fill=255)

    # Display image.
    disp.image(image)
    disp.display()
    time.sleep(1)
Exemple #3
0
# 128x32 display with hardware I2C:
import Adafruit_SSD1306
from PIL import Image, ImageDraw, ImageFont
from jetbot.utils.utils import get_ip_address
disp = Adafruit_SSD1306.SSD1306_128_32(rst=None, i2c_bus=1, gpio=1)
disp.begin()
print("ready")
disp.clear()
disp.display()
print("cleared")
width = disp.width
height = disp.height
image = Image.new('1', (width, height))
draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, width, height), outline=0, fill=0)
font = ImageFont.load_default()
#draw.text((0,0), "eth0: " + str(get_ip_address('eth0')),  font=font, fill=255)
draw.text((0, 8),
          "wlan0: " + str(get_ip_address('wlan0')),
          font=font,
          fill=255)
draw.text((0, 16), "hallo", font=font, fill=255)
disp.image(image)
disp.display()
print("used")
Exemple #4
0
    cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%sMB %.2f%%\", $3,$2,$3*100/$2 }'"
    MemUsage = subprocess.check_output(cmd, shell=True)
    cmd = "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%dGB %s\", $3,$2,$5}'"
    Disk = subprocess.check_output(cmd, shell=True)

    # Write two lines of text.

    try:
        cmd = "cat /home/jetbot/jethead-stats.txt"
        jethead_stats = str(
            subprocess.check_output(cmd, shell=True).decode('utf-8'))
    except:
        jethead_stats = "unknown"

    draw.text((x, top),
              "eth0: " + str(get_ip_address('eth0')),
              font=font,
              fill=255)
    #draw.text((x, top+8),     "wlan0: " + str(get_ip_address('wlan0')), font=font, fill=255)
    draw.text((x, top + 8), "jethead: " + jethead_stats, font=font, fill=255)
    draw.text((x, top + 16),
              str(MemUsage.decode('utf-8')),
              font=font,
              fill=255)
    draw.text((x, top + 25), str(Disk.decode('utf-8')), font=font, fill=255)

    # Display image.
    disp.image(image)
    disp.display()
    time.sleep(1)
Exemple #5
0
        # Could replace line spacing with disp2.getFontHeight, but doesn't scale properly

        # Screen Width
        import qwiic_micro_oled
        LCDWIDTH = qwiic_micro_oled._LCDWIDTH
    except OSError as err:
        print("OS error: {0}".format(err))
        time.sleep(5)

while True:
    # Check Eth0, Wlan0, and Wlan1 Connections---------------------------------
    a = 0  # Indexing of Connections

    # Checks for Ethernet Connection
    try:
        eth = get_ip_address('eth0')
        if eth != None:
            a = a + 1
    except Exception as e:
        print(e)

    # Checks for WiFi Connection on wlan0
    try:
        wlan0 = get_ip_address('wlan0')
        if wlan0 != None:
            a = a + 2
    except Exception as e:
        print(e)

    # Checks for WiFi Connection on wlan1
    try:
Exemple #6
0
disp.set_font_type(0)  # Set Font
# Could replace line spacing with disp.getFontHeight, but doesn't scale properly

# Display Flame (set in begin function)-------------------------------------
disp.display()
time.sleep(5)  #Pause 10 sec

while True:
    # Checks Eth0 and Wlan0 Connections---------------------------------
    a = 0
    b = 0
    c = 0

    # Checks for Ethernet Connection
    try:
        eth = get_ip_address('eth0')
        if eth != None:
            a = a + 1

        #Check String Length
        if len(eth) > 10:
            # Find '.' to loop numerals
            while b != -1:
                x1 = LCDWIDTH - disp._font.width * (len(eth) - b)
                i = b + 1
                b = eth.find('.', i)

    except Exception as e:
        print(e)

    # Checks for WiFi Connection