Skip to content

Commit 2c43e36

Browse files
authored
Merge pull request #30 from jposada202020/dynamic_screen
Examples changes for dynamic display width and height
2 parents b07d03c + dd4fea4 commit 2c43e36

File tree

4 files changed

+44
-7
lines changed

4 files changed

+44
-7
lines changed

docs/examples.rst

+27
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,30 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/display_button_simpletest.py
77
:caption: examples/display_button_simpletest.py
88
:linenos:
9+
10+
Button Color Properties
11+
-----------------------
12+
13+
Demonstrate the different color possibilities present in the library
14+
15+
.. literalinclude:: ../examples/display_button_color_properties.py
16+
:caption: examples/display_button_color_properties.py
17+
:linenos:
18+
19+
Button Custom Font
20+
------------------
21+
22+
Shows how to use different fonts with your button
23+
24+
.. literalinclude:: ../examples/display_button_customfont.py
25+
:caption: examples/display_button_customfont.py
26+
:linenos:
27+
28+
Soundboard
29+
----------
30+
31+
A soundboard made with buttons
32+
33+
.. literalinclude:: ../examples/display_button_soundboard.py
34+
:caption: examples/display_button_soundboard.py
35+
:linenos:

examples/display_button_color_properties.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import adafruit_touchscreen
1313
from adafruit_button import Button
1414

15-
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
15+
# use built in display (MagTag, PyPortal, PyGamer, PyBadge, CLUE, etc.)
1616
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
1717
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
1818
display = board.DISPLAY
@@ -36,7 +36,7 @@
3636
board.TOUCH_YD,
3737
board.TOUCH_YU,
3838
calibration=((5200, 59000), (5800, 57000)),
39-
size=(320, 240),
39+
size=(display.width, display.height),
4040
)
4141

4242
# Make the display context

examples/display_button_customfont.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
import adafruit_touchscreen
1212
from adafruit_button import Button
1313

14+
# use built in display (MagTag, PyPortal, PyGamer, PyBadge, CLUE, etc.)
15+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
16+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
17+
display = board.DISPLAY
18+
1419
# These pins are used as both analog and digital! XL, XR and YU must be analog
1520
# and digital capable. YD just need to be digital
1621
ts = adafruit_touchscreen.Touchscreen(
@@ -19,7 +24,7 @@
1924
board.TOUCH_YD,
2025
board.TOUCH_YU,
2126
calibration=((5200, 59000), (5800, 57000)),
22-
size=(320, 240),
27+
size=(display.width, display.height),
2328
)
2429

2530
# the current working directory (where this file is)
@@ -37,15 +42,15 @@
3742

3843
# Make the display context
3944
splash = displayio.Group(max_size=20)
40-
board.DISPLAY.show(splash)
45+
display.show(splash)
4146
BUTTON_WIDTH = 80
4247
BUTTON_HEIGHT = 40
4348
BUTTON_MARGIN = 20
4449

4550
##########################################################################
4651
# Make a background color fill
4752

48-
color_bitmap = displayio.Bitmap(320, 240, 1)
53+
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
4954
color_palette = displayio.Palette(1)
5055
color_palette[0] = 0x404040
5156
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)

examples/display_button_simpletest.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
import adafruit_touchscreen
1111
from adafruit_button import Button
1212

13+
# use built in display (MagTag, PyPortal, PyGamer, PyBadge, CLUE, etc.)
14+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
15+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
16+
display = board.DISPLAY
17+
1318
# --| Button Config |-------------------------------------------------
1419
BUTTON_X = 110
1520
BUTTON_Y = 95
@@ -29,12 +34,12 @@
2934
board.TOUCH_YD,
3035
board.TOUCH_YU,
3136
calibration=((5200, 59000), (5800, 57000)),
32-
size=(320, 240),
37+
size=(display.width, display.height),
3338
)
3439

3540
# Make the display context
3641
splash = displayio.Group()
37-
board.DISPLAY.show(splash)
42+
display.show(splash)
3843

3944
# Make the button
4045
button = Button(

0 commit comments

Comments
 (0)