├── picture ├── Pi TFT1.14 inch v1.0.jpg ├── Pi TFT 1.3 inch v1.0 _1.jpg ├── Pi TFT 1.3 inch v1.0_4.jpg └── Pi TFT1.14 inch v1.0_2.jpg └── code ├── Pi TFT 1.3 inch v1.0 test.py ├── Pi TFT1.14 inch v1.0 test.py ├── Pi TFT 1.3 inch v1.0 stats.py └── Pi TFT1.14 inch v1.0 stats.py /picture/Pi TFT1.14 inch v1.0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IOT-MCU/Mini-PiTFT-for-Raspberry-Pi/HEAD/picture/Pi TFT1.14 inch v1.0.jpg -------------------------------------------------------------------------------- /picture/Pi TFT 1.3 inch v1.0 _1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IOT-MCU/Mini-PiTFT-for-Raspberry-Pi/HEAD/picture/Pi TFT 1.3 inch v1.0 _1.jpg -------------------------------------------------------------------------------- /picture/Pi TFT 1.3 inch v1.0_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IOT-MCU/Mini-PiTFT-for-Raspberry-Pi/HEAD/picture/Pi TFT 1.3 inch v1.0_4.jpg -------------------------------------------------------------------------------- /picture/Pi TFT1.14 inch v1.0_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IOT-MCU/Mini-PiTFT-for-Raspberry-Pi/HEAD/picture/Pi TFT1.14 inch v1.0_2.jpg -------------------------------------------------------------------------------- /code/Pi TFT 1.3 inch v1.0 test.py: -------------------------------------------------------------------------------- 1 | import digitalio 2 | import board 3 | 4 | from adafruit_rgb_display.rgb import color565 5 | import adafruit_rgb_display.st7789 as st7789 6 | 7 | # Configuration for CS and DC pins for Raspberry Pi 8 | cs_pin = digitalio.DigitalInOut(board.CE0) 9 | dc_pin = digitalio.DigitalInOut(board.D25) 10 | reset_pin = None 11 | BAUDRATE = 64000000 # The pi can be very fast! 12 | # Create the ST7789 display: 13 | display = st7789.ST7789( 14 | board.SPI(), 15 | cs=cs_pin, 16 | dc=dc_pin, 17 | rst=reset_pin, 18 | baudrate=BAUDRATE, 19 | width=240, 20 | height=240, 21 | x_offset=0, 22 | y_offset=80, 23 | ) 24 | 25 | backlight = digitalio.DigitalInOut(board.D22) 26 | backlight.switch_to_output() 27 | backlight.value = True 28 | buttonA = digitalio.DigitalInOut(board.D23) 29 | buttonB = digitalio.DigitalInOut(board.D24) 30 | buttonA.switch_to_input() 31 | buttonB.switch_to_input() 32 | 33 | # Main loop: 34 | while True: 35 | if buttonA.value and buttonB.value: 36 | backlight.value = False # turn off backlight 37 | else: 38 | backlight.value = True # turn on backlight 39 | if buttonB.value and not buttonA.value: # just button A pressed 40 | display.fill(color565(255, 0, 0)) # red 41 | if buttonA.value and not buttonB.value: # just button B pressed 42 | display.fill(color565(0, 0, 255)) # blue 43 | if not buttonA.value and not buttonB.value: # none pressed 44 | display.fill(color565(0, 255, 0)) # green 45 | -------------------------------------------------------------------------------- /code/Pi TFT1.14 inch v1.0 test.py: -------------------------------------------------------------------------------- 1 | import digitalio 2 | import board 3 | 4 | from adafruit_rgb_display.rgb import color565 5 | import adafruit_rgb_display.st7789 as st7789 6 | 7 | # Configuration for CS and DC pins for Raspberry Pi 8 | cs_pin = digitalio.DigitalInOut(board.CE0) 9 | dc_pin = digitalio.DigitalInOut(board.D25) 10 | reset_pin = None 11 | BAUDRATE = 64000000 # The pi can be very fast! 12 | # Create the ST7789 display: 13 | display = st7789.ST7789( 14 | board.SPI(), 15 | cs=cs_pin, 16 | dc=dc_pin, 17 | rst=reset_pin, 18 | baudrate=BAUDRATE, 19 | width=135, 20 | height=240, 21 | x_offset=53, 22 | y_offset=40, 23 | ) 24 | 25 | backlight = digitalio.DigitalInOut(board.D22) 26 | backlight.switch_to_output() 27 | backlight.value = True 28 | buttonA = digitalio.DigitalInOut(board.D23) 29 | buttonB = digitalio.DigitalInOut(board.D24) 30 | buttonA.switch_to_input() 31 | buttonB.switch_to_input() 32 | 33 | # Main loop: 34 | while True: 35 | if buttonA.value and buttonB.value: 36 | backlight.value = False # turn off backlight 37 | else: 38 | backlight.value = True # turn on backlight 39 | if buttonB.value and not buttonA.value: # just button A pressed 40 | display.fill(color565(255, 0, 0)) # red 41 | if buttonA.value and not buttonB.value: # just button B pressed 42 | display.fill(color565(0, 0, 255)) # blue 43 | if not buttonA.value and not buttonB.value: # none pressed 44 | display.fill(color565(0, 255, 0)) # green 45 | -------------------------------------------------------------------------------- /code/Pi TFT 1.3 inch v1.0 stats.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import time 4 | import subprocess 5 | import digitalio 6 | import board 7 | from PIL import Image, ImageDraw, ImageFont 8 | import adafruit_rgb_display.st7789 as st7789 9 | 10 | 11 | # Configuration for CS and DC pins (these are FeatherWing defaults on M0/M4): 12 | cs_pin = digitalio.DigitalInOut(board.CE0) 13 | dc_pin = digitalio.DigitalInOut(board.D25) 14 | reset_pin = None 15 | 16 | # Config for display baudrate (default max is 24mhz): 17 | BAUDRATE = 64000000 18 | 19 | # Setup SPI bus using hardware SPI: 20 | spi = board.SPI() 21 | 22 | # Create the ST7789 display: 23 | disp = st7789.ST7789( 24 | spi, 25 | cs=cs_pin, 26 | dc=dc_pin, 27 | rst=reset_pin, 28 | baudrate=BAUDRATE, 29 | width=240, 30 | height=240, 31 | x_offset=0, 32 | y_offset=80, 33 | ) 34 | 35 | # Create blank image for drawing. 36 | # Make sure to create image with mode 'RGB' for full color. 37 | height = disp.width # we swap height/width to rotate it to landscape! 38 | width = disp.height 39 | image = Image.new("RGB", (width, height)) 40 | rotation = 90 41 | 42 | # Get drawing object to draw on image. 43 | draw = ImageDraw.Draw(image) 44 | 45 | # Draw a black filled box to clear the image. 46 | draw.rectangle((0, 0, width, height), outline=0, fill=(0, 0, 0)) 47 | disp.image(image, rotation) 48 | # Draw some shapes. 49 | # First define some constants to allow easy resizing of shapes. 50 | padding = -2 51 | top = padding 52 | bottom = height - padding 53 | # Move left to right keeping track of the current x position for drawing shapes. 54 | x = 0 55 | 56 | 57 | # Alternatively load a TTF font. Make sure the .ttf font file is in the 58 | # same directory as the python script! 59 | # Some other nice fonts to try: http://www.dafont.com/bitmap.php 60 | font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 24) 61 | 62 | # Turn on the backlight 63 | backlight = digitalio.DigitalInOut(board.D22) 64 | backlight.switch_to_output() 65 | backlight.value = True 66 | 67 | while True: 68 | # Draw a black filled box to clear the image. 69 | draw.rectangle((0, 0, width, height), outline=0, fill=0) 70 | 71 | # Shell scripts for system monitoring from here: 72 | # https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load 73 | cmd = "hostname -I | cut -d' ' -f1" 74 | IP = "IP: " + subprocess.check_output(cmd, shell=True).decode("utf-8") 75 | cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'" 76 | CPU = subprocess.check_output(cmd, shell=True).decode("utf-8") 77 | cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB %.2f%%\", $3,$2,$3*100/$2 }'" 78 | MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8") 79 | cmd = 'df -h | awk \'$NF=="/"{printf "Disk: %d/%d GB %s", $3,$2,$5}\'' 80 | Disk = subprocess.check_output(cmd, shell=True).decode("utf-8") 81 | cmd = "cat /sys/class/thermal/thermal_zone0/temp | awk '{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}'" # pylint: disable=line-too-long 82 | Temp = subprocess.check_output(cmd, shell=True).decode("utf-8") 83 | 84 | # Write four lines of text. 85 | y = top 86 | draw.text((x, y), IP, font=font, fill="#FFFFFF") 87 | y += font.getsize(IP)[1] 88 | draw.text((x, y), CPU, font=font, fill="#FFFF00") 89 | y += font.getsize(CPU)[1] 90 | draw.text((x, y), MemUsage, font=font, fill="#00FF00") 91 | y += font.getsize(MemUsage)[1] 92 | draw.text((x, y), Disk, font=font, fill="#0000FF") 93 | y += font.getsize(Disk)[1] 94 | draw.text((x, y), Temp, font=font, fill="#FF00FF") 95 | 96 | # Display image. 97 | disp.image(image, rotation) 98 | time.sleep(0.1) 99 | -------------------------------------------------------------------------------- /code/Pi TFT1.14 inch v1.0 stats.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import time 4 | import subprocess 5 | import digitalio 6 | import board 7 | from PIL import Image, ImageDraw, ImageFont 8 | import adafruit_rgb_display.st7789 as st7789 9 | 10 | 11 | # Configuration for CS and DC pins (these are FeatherWing defaults on M0/M4): 12 | cs_pin = digitalio.DigitalInOut(board.CE0) 13 | dc_pin = digitalio.DigitalInOut(board.D25) 14 | reset_pin = None 15 | 16 | # Config for display baudrate (default max is 24mhz): 17 | BAUDRATE = 64000000 18 | 19 | # Setup SPI bus using hardware SPI: 20 | spi = board.SPI() 21 | 22 | # Create the ST7789 display: 23 | disp = st7789.ST7789( 24 | spi, 25 | cs=cs_pin, 26 | dc=dc_pin, 27 | rst=reset_pin, 28 | baudrate=BAUDRATE, 29 | width=135, 30 | height=240, 31 | x_offset=53, 32 | y_offset=40, 33 | ) 34 | 35 | # Create blank image for drawing. 36 | # Make sure to create image with mode 'RGB' for full color. 37 | height = disp.width # we swap height/width to rotate it to landscape! 38 | width = disp.height 39 | image = Image.new("RGB", (width, height)) 40 | rotation = 90 41 | 42 | # Get drawing object to draw on image. 43 | draw = ImageDraw.Draw(image) 44 | 45 | # Draw a black filled box to clear the image. 46 | draw.rectangle((0, 0, width, height), outline=0, fill=(0, 0, 0)) 47 | disp.image(image, rotation) 48 | # Draw some shapes. 49 | # First define some constants to allow easy resizing of shapes. 50 | padding = -2 51 | top = padding 52 | bottom = height - padding 53 | # Move left to right keeping track of the current x position for drawing shapes. 54 | x = 0 55 | 56 | 57 | # Alternatively load a TTF font. Make sure the .ttf font file is in the 58 | # same directory as the python script! 59 | # Some other nice fonts to try: http://www.dafont.com/bitmap.php 60 | font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 24) 61 | 62 | # Turn on the backlight 63 | backlight = digitalio.DigitalInOut(board.D22) 64 | backlight.switch_to_output() 65 | backlight.value = True 66 | 67 | while True: 68 | # Draw a black filled box to clear the image. 69 | draw.rectangle((0, 0, width, height), outline=0, fill=0) 70 | 71 | # Shell scripts for system monitoring from here: 72 | # https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load 73 | cmd = "hostname -I | cut -d' ' -f1" 74 | IP = "IP: " + subprocess.check_output(cmd, shell=True).decode("utf-8") 75 | cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'" 76 | CPU = subprocess.check_output(cmd, shell=True).decode("utf-8") 77 | cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%s MB %.2f%%\", $3,$2,$3*100/$2 }'" 78 | MemUsage = subprocess.check_output(cmd, shell=True).decode("utf-8") 79 | cmd = 'df -h | awk \'$NF=="/"{printf "Disk: %d/%d GB %s", $3,$2,$5}\'' 80 | Disk = subprocess.check_output(cmd, shell=True).decode("utf-8") 81 | cmd = "cat /sys/class/thermal/thermal_zone0/temp | awk '{printf \"CPU Temp: %.1f C\", $(NF-0) / 1000}'" # pylint: disable=line-too-long 82 | Temp = subprocess.check_output(cmd, shell=True).decode("utf-8") 83 | 84 | # Write four lines of text. 85 | y = top 86 | draw.text((x, y), IP, font=font, fill="#FFFFFF") 87 | y += font.getsize(IP)[1] 88 | draw.text((x, y), CPU, font=font, fill="#FFFF00") 89 | y += font.getsize(CPU)[1] 90 | draw.text((x, y), MemUsage, font=font, fill="#00FF00") 91 | y += font.getsize(MemUsage)[1] 92 | draw.text((x, y), Disk, font=font, fill="#0000FF") 93 | y += font.getsize(Disk)[1] 94 | draw.text((x, y), Temp, font=font, fill="#FF00FF") 95 | 96 | # Display image. 97 | disp.image(image, rotation) 98 | time.sleep(0.1) 99 | --------------------------------------------------------------------------------