MacroPad Hotkeys Lights Off

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
BangDroid
 
Posts: 6
Joined: Thu Apr 15, 2021 12:03 am

MacroPad Hotkeys Lights Off

Post by BangDroid »

This post is more for posterity than seeking help for a specific issue. I've been using and modifying Phillip Burgess' Hotkeys code for the MacroPad and was looking for a way to have an all off screen - no LED's (easy) and no screen illumination (not so easy). I cam across a fairly recent thread here, that for whatever reason is now locked, so I couldn't reply to OP. I found a very simple solution that may be helpful to OP or any one else wanting to achieve the same thing, and if there's an even better less compromise solution it can be discussed here too.

Turning off the LED's and removing the key labels is easy - you just create a new .py file in the macro folder containing the app template but use 0x000000 for all LED colors and don't set any key labels or name the app dict. But you are still left with a bright white rectangle at the top of the screen.

My simple solution is to invert the colors of the rectangle and text. Where the rectangle was drawn with fill=0xFFFFFFF, it becomes 0x000000 and visa versa for the text line bellow it.

Code: Select all

# Set up displayio group with all the labels
group = displayio.Group()
for key_index in range(12):
    x = key_index % 3
    y = key_index // 3
    group.append(label.Label(terminalio.FONT, text='', color=0xFFFFFF,
                             anchored_position=((macropad.display.width - 1) * x / 2,
                                                macropad.display.height - 1 -
                                                (3 - y) * 12),
                             anchor_point=(x / 2, 1.0)))
group.append(Rect(0, 0, macropad.display.width, 12, fill=0x000000))
group.append(label.Label(terminalio.FONT, text='', color=0xFFFFFF,
                         anchored_position=(macropad.display.width//2, -2),
                         anchor_point=(0.5, 0.0)))
macropad.display.show(group)
This results in not having a stylized rectangle header at all, but personally I don't mind this at all. It's a compromise I am happy to live with. I did investigate setting it this way for only this specific layer, but I couldn't get it too work. I hope this it helpful for someone else too.

User avatar
visudo
 
Posts: 1
Joined: Fri Jan 28, 2022 11:57 pm

Re: MacroPad Hotkeys Lights Off

Post by visudo »

I'm glad you made this post, I've also been wanting an "all off" screen and was unable to come up with anything myself. Your post gave me just enough information to be able to come up with a solution to have an "all off" profile while still maintaining the white header for all other profiles.

Not the best solution I'm sure, but a solution nonetheless. And also pretty simple, just add 5 lines of code to code.py as outlined here:

First, in the #initilization area, create a new displayio group called "groupblank". I didn't bother defining the group any further than creating it because the point is to have nothing on the screen anyway.

Code: Select all

# Set up displayio group with all the labels
groupblank = displayio.Group()
group = displayio.Group()
for key_index in range(12):
Second, under the "switch" function, set up an if statement so that if the name of the profile is "blank" then the blank group we created will be used otherwise the normal group will be used

Code: Select all

    def switch(self):
        """ Activate application settings; update OLED labels and LED
            colors. """
        if self.name in 'blank':
            macropad.display.show(groupblank)
        else:
            macropad.display.show(group)
        group[13].text = self.name   # Application name
After that, just turn off the key LED's and remove the key labels as described in the previous post and set the app name to "blank"

Code: Select all

app = {                # REQUIRED dict, must be named 'app'
    'name' : 'blank', # Application name
    'macros' : [       # List of button macros...
        # COLOR    LABEL    KEY SEQUENCE
        # 1st row ----------
        (0x000000, '', ['']),
        (0x000000, '', ['']),

User avatar
BangDroid
 
Posts: 6
Joined: Thu Apr 15, 2021 12:03 am

Re: MacroPad Hotkeys Lights Off

Post by BangDroid »

Wow! Thank you so much for this contribution! This is a much better solution.
I'm very much a code noob, so it took me a little bit to actually understand it, but this is great!

I was also thinking about what the difference between the MacroPad and other USB devices is. When my PC shuts down and in standby mode, the USB ports still have power for charging devices like mice or phones etc. Presumably this is why the MacroPad maintains it's On status. But I have other devices like MIDI controllers, audio DAC and even an Arduino Nano for bias lighting, and they all turn off (low power mode?) when the system is in standby. So I'm wondering if there's some kind of signal or something that the others are getting and interpreting correctly but the MacroPad is missing/ignoring, or has not been implemented in the code.

Nonetheless, this is probably the easiest solution for an off/blank mode.

User avatar
MosesMaMi
 
Posts: 8
Joined: Tue Sep 28, 2021 5:26 am

Re: MacroPad Hotkeys Lights Off

Post by MosesMaMi »

Thank you both for sharing your code. It helped me to set up a screensaver function for my macropad.
In case you are interested in this: viewtopic.php?f=19&t=187974

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”