Skip to content

Commit debdae6

Browse files
committed
Examples changes for dynamic width and height
1 parent b07d03c commit debdae6

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

docs/examples.rst

Lines changed: 27 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import adafruit_touchscreen
1212
from adafruit_button import Button
1313

14+
display = board.DISPLAY
15+
1416
# These pins are used as both analog and digital! XL, XR and YU must be analog
1517
# and digital capable. YD just need to be digital
1618
ts = adafruit_touchscreen.Touchscreen(
@@ -19,7 +21,7 @@
1921
board.TOUCH_YD,
2022
board.TOUCH_YU,
2123
calibration=((5200, 59000), (5800, 57000)),
22-
size=(320, 240),
24+
size=(display.width, display.height),
2325
)
2426

2527
# the current working directory (where this file is)
@@ -37,15 +39,15 @@
3739

3840
# Make the display context
3941
splash = displayio.Group(max_size=20)
40-
board.DISPLAY.show(splash)
42+
display.show(splash)
4143
BUTTON_WIDTH = 80
4244
BUTTON_HEIGHT = 40
4345
BUTTON_MARGIN = 20
4446

4547
##########################################################################
4648
# Make a background color fill
4749

48-
color_bitmap = displayio.Bitmap(320, 240, 1)
50+
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
4951
color_palette = displayio.Palette(1)
5052
color_palette[0] = 0x404040
5153
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)

examples/display_button_simpletest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import adafruit_touchscreen
1111
from adafruit_button import Button
1212

13+
display = board.DISPLAY
14+
1315
# --| Button Config |-------------------------------------------------
1416
BUTTON_X = 110
1517
BUTTON_Y = 95
@@ -29,12 +31,12 @@
2931
board.TOUCH_YD,
3032
board.TOUCH_YU,
3133
calibration=((5200, 59000), (5800, 57000)),
32-
size=(320, 240),
34+
size=(display.width, display.height),
3335
)
3436

3537
# Make the display context
3638
splash = displayio.Group()
37-
board.DISPLAY.show(splash)
39+
display.show(splash)
3840

3941
# Make the button
4042
button = Button(

0 commit comments

Comments
 (0)