Skip to content

Commit

Permalink
Merge pull request #18 from helgibbons/master
Browse files Browse the repository at this point in the history
Update examples
  • Loading branch information
Gadgetoid authored Nov 2, 2021
2 parents eb38e0a + f49307b commit 04d5333
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 45 deletions.
44 changes: 32 additions & 12 deletions examples/gif.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 04d5333

Please sign in to comment.