Skip to content

Commit 6e73a61

Browse files
committed
Adding rotation demo.
1 parent 8986d63 commit 6e73a61

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/macropad_rotation.py

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