Skip to content
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

Update examples #18

Merged
merged 1 commit into from Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 32 additions & 12 deletions examples/gif.py
Expand Up @@ -22,6 +22,7 @@
* square - 240x240 1.3" Square LCD
* round - 240x240 1.3" Round LCD (applies an offset)
* rect - 240x135 1.14" Rectangular LCD (applies an offset)
* dhmini - 320x240 2.0" Display HAT Mini
""".format(path=sys.argv[0]))
sys.exit(1)

Expand All @@ -32,18 +33,37 @@
except IndexError:
display_type = "square"

# Create TFT LCD display class.
disp = ST7789.ST7789(
height=135 if display_type == "rect" else 240,
rotation=0 if display_type == "rect" else 90,
port=0,
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT
dc=9,
backlight=19, # 18 for back BG slot, 19 for front BG slot.
spi_speed_hz=80 * 1000 * 1000,
offset_left=0 if display_type == "square" else 40,
offset_top=53 if display_type == "rect" else 0
)
# Create ST7789 LCD display class.

if display_type in ("square", "rect", "round"):
disp = ST7789.ST7789(
height=135 if display_type == "rect" else 240,
rotation=0 if display_type == "rect" else 90,
port=0,
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT
dc=9,
backlight=19, # 18 for back BG slot, 19 for front BG slot.
spi_speed_hz=80 * 1000 * 1000,
offset_left=0 if display_type == "square" else 40,
offset_top=53 if display_type == "rect" else 0
)

elif display_type == "dhmini":
disp = ST7789.ST7789(
height=240,
width=320,
rotation=180,
port=0,
cs=1,
dc=9,
backlight=13,
spi_speed_hz=60 * 1000 * 1000,
offset_left=0,
offset_top=0
)

else:
print ("Invalid display type!")

# Initialize display.
disp.begin()
Expand Down
42 changes: 31 additions & 11 deletions examples/image.py
Expand Up @@ -19,6 +19,7 @@
* square - 240x240 1.3" Square LCD
* round - 240x240 1.3" Round LCD (applies an offset)
* rect - 240x135 1.14" Rectangular LCD (applies an offset)
* dhmini - 320x240 2.0" Display HAT Mini
""".format(sys.argv[0]))
sys.exit(1)

Expand All @@ -30,17 +31,36 @@
display_type = "square"

# Create ST7789 LCD display class.
disp = ST7789.ST7789(
height=135 if display_type == "rect" else 240,
rotation=0 if display_type == "rect" else 90,
port=0,
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT
dc=9,
backlight=19, # 18 for back BG slot, 19 for front BG slot.
spi_speed_hz=80 * 1000 * 1000,
offset_left=0 if display_type == "square" else 40,
offset_top=53 if display_type == "rect" else 0
)

if display_type in ("square", "rect", "round"):
disp = ST7789.ST7789(
height=135 if display_type == "rect" else 240,
rotation=0 if display_type == "rect" else 90,
port=0,
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT
dc=9,
backlight=19, # 18 for back BG slot, 19 for front BG slot.
spi_speed_hz=80 * 1000 * 1000,
offset_left=0 if display_type == "square" else 40,
offset_top=53 if display_type == "rect" else 0
)

elif display_type == "dhmini":
disp = ST7789.ST7789(
height=240,
width=320,
rotation=180,
port=0,
cs=1,
dc=9,
backlight=13,
spi_speed_hz=60 * 1000 * 1000,
offset_left=0,
offset_top=0
)

else:
print ("Invalid display type!")

WIDTH = disp.width
HEIGHT = disp.height
Expand Down
42 changes: 31 additions & 11 deletions examples/scrolling-text.py
Expand Up @@ -24,6 +24,7 @@
* square - 240x240 1.3" Square LCD
* round - 240x240 1.3" Round LCD (applies an offset)
* rect - 240x135 1.14" Rectangular LCD (applies an offset)
* dhmini - 320x240 2.0" Display HAT Mini
""".format(sys.argv[0]))

try:
Expand All @@ -38,17 +39,36 @@


# Create ST7789 LCD display class.
disp = ST7789.ST7789(
height=135 if display_type == "rect" else 240,
rotation=0 if display_type == "rect" else 90,
port=0,
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT
dc=9,
backlight=19, # 18 for back BG slot, 19 for front BG slot.
spi_speed_hz=80 * 1000 * 1000,
offset_left=0 if display_type == "square" else 40,
offset_top=53 if display_type == "rect" else 0
)

if display_type in ("square", "rect", "round"):
disp = ST7789.ST7789(
height=135 if display_type == "rect" else 240,
rotation=0 if display_type == "rect" else 90,
port=0,
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT
dc=9,
backlight=19, # 18 for back BG slot, 19 for front BG slot.
spi_speed_hz=80 * 1000 * 1000,
offset_left=0 if display_type == "square" else 40,
offset_top=53 if display_type == "rect" else 0
)

elif display_type == "dhmini":
disp = ST7789.ST7789(
height=240,
width=320,
rotation=180,
port=0,
cs=1,
dc=9,
backlight=13,
spi_speed_hz=60 * 1000 * 1000,
offset_left=0,
offset_top=0
)

else:
print ("Invalid display type!")

# Initialize display.
disp.begin()
Expand Down
42 changes: 31 additions & 11 deletions examples/shapes.py
Expand Up @@ -20,6 +20,7 @@
* square - 240x240 1.3" Square LCD
* round - 240x240 1.3" Round LCD (applies an offset)
* rect - 240x135 1.14" Rectangular LCD (applies an offset)
* dhmini - 320x240 2.0" Display HAT Mini
""".format(sys.argv[0]))

try:
Expand All @@ -28,17 +29,36 @@
display_type = "square"

# Create ST7789 LCD display class.
disp = ST7789.ST7789(
height=135 if display_type == "rect" else 240,
rotation=0 if display_type == "rect" else 90,
port=0,
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT
dc=9,
backlight=19, # 18 for back BG slot, 19 for front BG slot.
spi_speed_hz=80 * 1000 * 1000,
offset_left=0 if display_type == "square" else 40,
offset_top=53 if display_type == "rect" else 0
)

if display_type in ("square", "rect", "round"):
disp = ST7789.ST7789(
height=135 if display_type == "rect" else 240,
rotation=0 if display_type == "rect" else 90,
port=0,
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT
dc=9,
backlight=19, # 18 for back BG slot, 19 for front BG slot.
spi_speed_hz=80 * 1000 * 1000,
offset_left=0 if display_type == "square" else 40,
offset_top=53 if display_type == "rect" else 0
)

elif display_type == "dhmini":
disp = ST7789.ST7789(
height=240,
width=320,
rotation=180,
port=0,
cs=1,
dc=9,
backlight=13,
spi_speed_hz=60 * 1000 * 1000,
offset_left=0,
offset_top=0
)

else:
print ("Invalid display type!")

# Initialize display.
disp.begin()
Expand Down