Skip to content

Adding rotation demo. #15

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 1 commit into from
Jul 28, 2021
Merged
Changes from all commits
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 examples/macropad_rotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: Copyright (c) 2021 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
"""
MacroPad rotation demo. Rotates the display 90 degrees and remaps the NeoPixels and keys to match.
Lights up the associated pixel when the key is pressed. Displays the key number pressed and the
rotary encoder relative position on the display.
"""
from rainbowio import colorwheel
from adafruit_macropad import MacroPad

macropad = MacroPad(rotation=90)

text_lines = macropad.display_text(title="MacroPad \nInfo")

while True:
key_event = macropad.keys.events.get()
if key_event:
if key_event.pressed:
text_lines[1].text = "Key {}!".format(key_event.key_number)
macropad.pixels[key_event.key_number] = colorwheel(
int(255 / 12) * key_event.key_number
)
else:
macropad.pixels.fill((0, 0, 0))
text_lines[2].text = "Encoder {}".format(macropad.encoder)
text_lines.show()