Skip to content

Commit 7c1a136

Browse files
authored
Merge pull request #15 from kattni/rotation
Adding rotation demo.
2 parents 8986d63 + 6e73a61 commit 7c1a136

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/macropad_rotation.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2021 Kattni Rembor for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
"""
5+
MacroPad rotation demo. Rotates the display 90 degrees and remaps the NeoPixels and keys to match.
6+
Lights up the associated pixel when the key is pressed. Displays the key number pressed and the
7+
rotary encoder relative position on the display.
8+
"""
9+
from rainbowio import colorwheel
10+
from adafruit_macropad import MacroPad
11+
12+
macropad = MacroPad(rotation=90)
13+
14+
text_lines = macropad.display_text(title="MacroPad \nInfo")
15+
16+
while True:
17+
key_event = macropad.keys.events.get()
18+
if key_event:
19+
if key_event.pressed:
20+
text_lines[1].text = "Key {}!".format(key_event.key_number)
21+
macropad.pixels[key_event.key_number] = colorwheel(
22+
int(255 / 12) * key_event.key_number
23+
)
24+
else:
25+
macropad.pixels.fill((0, 0, 0))
26+
text_lines[2].text = "Encoder {}".format(macropad.encoder)
27+
text_lines.show()

0 commit comments

Comments
 (0)