Skip to content

Examples changes for dynamic display width and height #30

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 2 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,30 @@ Ensure your device works with this simple test.
.. literalinclude:: ../examples/display_button_simpletest.py
:caption: examples/display_button_simpletest.py
:linenos:

Button Color Properties
-----------------------

Demonstrate the different color possibilities present in the library

.. literalinclude:: ../examples/display_button_color_properties.py
:caption: examples/display_button_color_properties.py
:linenos:

Button Custom Font
------------------

Shows how to use different fonts with your button

.. literalinclude:: ../examples/display_button_customfont.py
:caption: examples/display_button_customfont.py
:linenos:

Soundboard
----------

A soundboard made with buttons

.. literalinclude:: ../examples/display_button_soundboard.py
:caption: examples/display_button_soundboard.py
:linenos:
2 changes: 1 addition & 1 deletion examples/display_button_color_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
board.TOUCH_YD,
board.TOUCH_YU,
calibration=((5200, 59000), (5800, 57000)),
size=(320, 240),
size=(display.width, display.height),
)

# Make the display context
Expand Down
8 changes: 5 additions & 3 deletions examples/display_button_customfont.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import adafruit_touchscreen
from adafruit_button import Button

display = board.DISPLAY

# These pins are used as both analog and digital! XL, XR and YU must be analog
# and digital capable. YD just need to be digital
ts = adafruit_touchscreen.Touchscreen(
Expand All @@ -19,7 +21,7 @@
board.TOUCH_YD,
board.TOUCH_YU,
calibration=((5200, 59000), (5800, 57000)),
size=(320, 240),
size=(display.width, display.height),
)

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

# Make the display context
splash = displayio.Group(max_size=20)
board.DISPLAY.show(splash)
display.show(splash)
BUTTON_WIDTH = 80
BUTTON_HEIGHT = 40
BUTTON_MARGIN = 20

##########################################################################
# Make a background color fill

color_bitmap = displayio.Bitmap(320, 240, 1)
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x404040
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
Expand Down
6 changes: 4 additions & 2 deletions examples/display_button_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import adafruit_touchscreen
from adafruit_button import Button

display = board.DISPLAY

# --| Button Config |-------------------------------------------------
BUTTON_X = 110
BUTTON_Y = 95
Expand All @@ -29,12 +31,12 @@
board.TOUCH_YD,
board.TOUCH_YU,
calibration=((5200, 59000), (5800, 57000)),
size=(320, 240),
size=(display.width, display.height),
)

# Make the display context
splash = displayio.Group()
board.DISPLAY.show(splash)
display.show(splash)

# Make the button
button = Button(
Expand Down