Tweaked examples

This commit is contained in:
Phil Howard
2019-02-21 10:16:51 +00:00
parent bb6c8e0964
commit 8ad9712247
3 changed files with 29 additions and 4 deletions

View File

@@ -20,6 +20,7 @@
# THE SOFTWARE. # THE SOFTWARE.
import time import time
import math import math
import sys
from PIL import Image from PIL import Image
from PIL import ImageDraw from PIL import ImageDraw
@@ -27,6 +28,18 @@ import ST7735 as ST7735
SPI_SPEED_MHZ = 10 # Higher speed = higher framerate SPI_SPEED_MHZ = 10 # Higher speed = higher framerate
if len(sys.argv) > 1:
SPI_SPEED_MHZ = int(sys.argv[1])
print("""
framerate.py - Test LCD framerate.
If you're using Breakout Garden, plug the 0.96" LCD (SPI)
breakout into the rear slot.
Running at: {}MHz
""".format(SPI_SPEED_MHZ))
# Create ST7735 LCD display class. # Create ST7735 LCD display class.
disp = ST7735.ST7735( disp = ST7735.ST7735(
port=0, port=0,
@@ -34,7 +47,7 @@ disp = ST7735.ST7735(
dc=9, dc=9,
backlight=18, backlight=18,
rotation=90, rotation=90,
spi_speed_hz=10 * 1000000 spi_speed_hz=SPI_SPEED_MHZ * 1000000
) )
WIDTH = disp.width WIDTH = disp.width
@@ -65,7 +78,7 @@ while True:
count += 1 count += 1
time_current = time.time() - time_start time_current = time.time() - time_start
if count % 120 == 0: if count % 120 == 0:
print("Time: {}, Frames: {}, FPS: {}".format( print("Time: {:8.3f}, Frames: {:6d}, FPS: {:8.3f}".format(
time_current, time_current,
count, count,
count / time_current)) count / time_current))

View File

@@ -23,6 +23,13 @@ import ST7735
import time import time
import sys import sys
print("""
gif.py - Display a gif on the LCD.
If you're using Breakout Garden, plug the 0.96" LCD (SPI)
breakout into the rear slot.
""")
if len(sys.argv) > 1: if len(sys.argv) > 1:
image_file = sys.argv[1] image_file = sys.argv[1]
else: else:

View File

@@ -23,6 +23,13 @@ import sys
from PIL import Image from PIL import Image
import ST7735 as ST7735 import ST7735 as ST7735
print("""
image.py - Display an image on the LCD.
If you're using Breakout Garden, plug the 0.96" LCD (SPI)
breakout into the rear slot.
""")
if len(sys.argv) < 2: if len(sys.argv) < 2:
print("Usage: {} <image_file>".format(sys.argv[0])) print("Usage: {} <image_file>".format(sys.argv[0]))
sys.exit(1) sys.exit(1)
@@ -42,8 +49,6 @@ disp = ST7735.ST7735(
WIDTH = disp.width WIDTH = disp.width
HEIGHT = disp.height HEIGHT = disp.height
print(WIDTH, HEIGHT)
# Initialize display. # Initialize display.
disp.begin() disp.begin()