Skip to content

update the simpletest to generalize the display setup #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 52 additions & 50 deletions examples/display_shapes_sparkline_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,67 +29,69 @@
import random
import time
from adafruit_display_shapes.sparkline import Sparkline
from adafruit_ili9341 import ILI9341

from adafruit_display_text import label

import gc

# from sparkline import sparkline # use this if sparkline.py is used to define the sparkline Class


# Setup the LCD display

displayio.release_displays()


# setup the SPI bus
spi = board.SPI()
tft_cs = board.D9 # arbitrary, pin not used
tft_dc = board.D10
tft_backlight = board.D12
tft_reset = board.D11

while not spi.try_lock():
spi.configure(baudrate=32000000)
pass
spi.unlock()

display_bus = displayio.FourWire(
spi,
command=tft_dc,
chip_select=tft_cs,
reset=tft_reset,
baudrate=32000000,
polarity=1,
phase=1,
)

print("spi.frequency: {}".format(spi.frequency))

# Number of pixels in the display
DISPLAY_WIDTH = 320
DISPLAY_HEIGHT = 240

# create the display
display = ILI9341(
display_bus,
width=DISPLAY_WIDTH,
height=DISPLAY_HEIGHT,
rotation=180,
auto_refresh=True,
native_frames_per_second=90,
)

# reset the display to show nothing.
display.show(None)
if "DISPLAY" not in dir(board):
# Setup the LCD display with driver
from adafruit_ili9341 import ILI9341

displayio.release_displays()

# setup the SPI bus
spi = board.SPI()
tft_cs = board.D9 # arbitrary, pin not used
tft_dc = board.D10
tft_backlight = board.D12
tft_reset = board.D11

while not spi.try_lock():
spi.configure(baudrate=32000000)
pass
spi.unlock()

display_bus = displayio.FourWire(
spi,
command=tft_dc,
chip_select=tft_cs,
reset=tft_reset,
baudrate=32000000,
polarity=1,
phase=1,
)

print("spi.frequency: {}".format(spi.frequency))

# Number of pixels in the display
DISPLAY_WIDTH = 320
DISPLAY_HEIGHT = 240

# create the display
display = ILI9341(
display_bus,
width=DISPLAY_WIDTH,
height=DISPLAY_HEIGHT,
rotation=180,
auto_refresh=True,
native_frames_per_second=90,
)

# reset the display to show nothing.
display.show(None)
else:
# built-in display
display = board.DISPLAY

##########################################
# Create background bitmaps and sparklines
##########################################

# Baseline size of the sparkline chart, in pixels.
chartWidth = DISPLAY_WIDTH
chartHeight = DISPLAY_HEIGHT
chartWidth = display.width
chartHeight = display.height


# mySparkline1 uses a vertical y range between 0 to 10 and will contain a maximum of 40 items
Expand Down