Initial
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# Import all board pins.
|
||||
from board import SCL, SDA, D4
|
||||
import busio
|
||||
import digitalio
|
||||
|
||||
# Import the SSD1305 module.
|
||||
import adafruit_ssd1305
|
||||
|
||||
# Define the Reset Pin
|
||||
oled_reset = digitalio.DigitalInOut(D4)
|
||||
|
||||
# Create the I2C interface.
|
||||
i2c = busio.I2C(SCL, SDA)
|
||||
|
||||
# Create the SSD1305 OLED class.
|
||||
# The first two parameters are the pixel width and pixel height. Change these
|
||||
# to the right size for your display!
|
||||
display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x3C, reset=oled_reset)
|
||||
|
||||
# Alternatively you can change the I2C address of the device with an addr parameter:
|
||||
# display = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, addr=0x31, reset=oled_reset)
|
||||
|
||||
# Clear the display. Always call show after changing pixels to make the display
|
||||
# update visible!
|
||||
display.fill(0)
|
||||
|
||||
display.show()
|
||||
@@ -0,0 +1,69 @@
|
||||
# SPDX-FileCopyrightText: <text> 2020 Tony DiCola, James DeVito,
|
||||
# and 2020 Melissa LeBlanc-Williams, for Adafruit Industries </text>
|
||||
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
# This example is for use on (Linux) computers that are using CPython with
|
||||
# Adafruit Blinka to support CircuitPython libraries. CircuitPython does
|
||||
# not support PIL/pillow (python imaging library)!
|
||||
|
||||
import time
|
||||
import subprocess
|
||||
from board import SCL, SDA, D4
|
||||
import busio
|
||||
import digitalio
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import adafruit_ssd1305
|
||||
|
||||
# Define the Reset Pin
|
||||
oled_reset = digitalio.DigitalInOut(D4)
|
||||
|
||||
# Create the I2C interface.
|
||||
i2c = busio.I2C(SCL, SDA)
|
||||
|
||||
# Create the SSD1305 OLED class.
|
||||
# The first two parameters are the pixel width and pixel height. Change these
|
||||
# to the right size for your display!
|
||||
disp = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, reset=oled_reset)
|
||||
|
||||
# Clear display.
|
||||
disp.fill(0)
|
||||
disp.show()
|
||||
|
||||
# Create blank image for drawing.
|
||||
# Make sure to create image with mode '1' for 1-bit color.
|
||||
width = disp.width
|
||||
height = disp.height
|
||||
image = Image.new("1", (width, height))
|
||||
|
||||
# Get drawing object to draw on image.
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# Draw a black filled box to clear the image.
|
||||
draw.rectangle((0, 0, width, height), outline=0, fill=0)
|
||||
|
||||
# Draw some shapes.
|
||||
# First define some constants to allow easy resizing of shapes.
|
||||
padding = 0
|
||||
top = padding
|
||||
bottom = height - padding
|
||||
# Move left to right keeping track of the current x position for drawing shapes.
|
||||
x = 0
|
||||
|
||||
|
||||
# Load default font.
|
||||
#def_font = ImageFont.load_default()
|
||||
|
||||
# Alternatively load a TTF font. Make sure the .ttf font file is in the
|
||||
# same directory as the python script!
|
||||
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
|
||||
font = ImageFont.truetype('8bit.ttf', 8)
|
||||
|
||||
# Write four lines of text.
|
||||
draw.text((0, 0), "Av Assist V2", font=font, fill=255)
|
||||
draw.text((0, 10), "IP ", font=font, fill=255)
|
||||
draw.text((0,20), "Aircraft ", font=font, fill=255)
|
||||
# Display image.
|
||||
disp.image(image)
|
||||
disp.show()
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
# SPDX-FileCopyrightText: <text> 2020 Tony DiCola, James DeVito,
|
||||
# and 2020 Melissa LeBlanc-Williams, for Adafruit Industries </text>
|
||||
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
# This example is for use on (Linux) computers that are using CPython with
|
||||
# Adafruit Blinka to support CircuitPython libraries. CircuitPython does
|
||||
# not support PIL/pillow (python imaging library)!
|
||||
|
||||
import time
|
||||
import subprocess
|
||||
from board import SCL, SDA, D4
|
||||
import busio
|
||||
import digitalio
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import adafruit_ssd1305
|
||||
import os
|
||||
import requests
|
||||
|
||||
# Define the Reset Pin
|
||||
oled_reset = digitalio.DigitalInOut(D4)
|
||||
|
||||
# Create the I2C interface.
|
||||
i2c = busio.I2C(SCL, SDA)
|
||||
|
||||
# Create the SSD1305 OLED class.
|
||||
# The first two parameters are the pixel width and pixel height. Change these
|
||||
# to the right size for your display!
|
||||
disp = adafruit_ssd1305.SSD1305_I2C(128, 32, i2c, reset=oled_reset)
|
||||
|
||||
# Clear display.
|
||||
disp.fill(0)
|
||||
disp.show()
|
||||
|
||||
# Create blank image for drawing.
|
||||
# Make sure to create image with mode '1' for 1-bit color.
|
||||
width = disp.width
|
||||
height = disp.height
|
||||
image = Image.new("1", (width, height))
|
||||
|
||||
# Get drawing object to draw on image.
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# Draw a black filled box to clear the image.
|
||||
draw.rectangle((0, 0, width, height), outline=0, fill=0)
|
||||
|
||||
# Draw some shapes.
|
||||
# First define some constants to allow easy resizing of shapes.
|
||||
padding = 0
|
||||
top = padding
|
||||
bottom = height - padding
|
||||
# Move left to right keeping track of the current x position for drawing shapes.
|
||||
x = 0
|
||||
|
||||
|
||||
# Load default font.
|
||||
def_font = ImageFont.load_default()
|
||||
|
||||
# Alternatively load a TTF font. Make sure the .ttf font file is in the
|
||||
# same directory as the python script!
|
||||
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
|
||||
font = ImageFont.truetype('superstar_memesbruh03.ttf', 16)
|
||||
font1 = ImageFont.truetype('8bit.ttf', 8)
|
||||
|
||||
# Write four lines of text.
|
||||
draw.text(((128-8*8)//2, 0), "AVIATION", font=font, fill=255)
|
||||
draw.text(((128-13*8)//2, 10), "ASSISTANT v.2", font=font, fill=255)
|
||||
|
||||
# Display image.
|
||||
disp.image(image)
|
||||
disp.show()
|
||||
time.sleep(3)
|
||||
draw.rectangle((0, 0, width, height), outline=0, fill=0)
|
||||
draw.text(((128-11*8)//2, 10), "STARTING UP", font=font, fill=255)
|
||||
disp.image(image)
|
||||
disp.show()
|
||||
|
||||
while True:
|
||||
# Stats
|
||||
IP = subprocess.check_output("hostname -I | cut -d' ' -f1", shell=True).decode("utf-8")
|
||||
UPTIME = subprocess.check_output("uptime", shell=True).decode("utf-8").split(" ")[4][:-1]
|
||||
if UPTIME == "min":
|
||||
UPTIME = str(subprocess.check_output("uptime", shell=True).decode("utf-8").split(" ")[3]) + " min"
|
||||
AIRCRAFT = 0
|
||||
for i in requests.get('http://127.0.0.1/tar1090/data/aircraft.json').json()['aircraft']:
|
||||
AIRCRAFT+=1
|
||||
|
||||
# Display image.
|
||||
draw.rectangle((0, 0, width, height), outline=0, fill=0)
|
||||
draw.text((5,0), "IP: "+IP, font=def_font, fill=255)
|
||||
draw.text((5,9), "AIRCRAFT: "+str(AIRCRAFT), font=def_font, fill=255)
|
||||
draw.text((5,18), "UPTIME: "+UPTIME, font=def_font, fill=255)
|
||||
disp.image(image)
|
||||
disp.show()
|
||||
time.sleep(1)
|
||||
Binary file not shown.
Reference in New Issue
Block a user