Skip to content

Basic RGB Patterns #10

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

Closed
wants to merge 17 commits into from
Closed

Basic RGB Patterns #10

wants to merge 17 commits into from

Conversation

mehalter
Copy link
Contributor

This adds a feature that allows you to change the default light of the keyboard and also turn on light on keypress. I have a few more ideas on patterns that I will look into implementing soon. Let me know what you think of the implementation. I think we should figure out a good place to move this code so that its easy to separate from the action of the keypress. Maybe out to its own function. But this is a good proof of concept

@mehalter
Copy link
Contributor Author

mehalter commented Sep 14, 2020

Along with the example I put in the code.py, here is a more advanced macro (here its MACRO(0) that lets you set up a cycle for the current RGB options with this in the code.py:

keyboard.set_default_color(r=0xFF, g=0, b=0xFF)
keyboard.rgb_mode = keyboard.RGB_TAP

def macro_handler(dev, n, is_down):
    if is_down and n == 0:
        if keyboard.rgb_mode == keyboard.RGB_TAP:
            keyboard.rgb_mode = keyboard.RGB_FILL
        elif keyboard.rgb_mode == keyboard.RGB_FILL:
            keyboard.rgb_mode = keyboard.RGB_EMPTY
            keyboard.backlight.on(*keyboard.default_color)
        elif keyboard.rgb_mode == keyboard.RGB_EMPTY:
            keyboard.rgb_mode = keyboard.RGB_OFF
            keyboard.backlight.on(*keyboard.default_color)
        elif keyboard.backlight.dev.any():
            keyboard.backlight.off()
        else:
            keyboard.rgb_mode = keyboard.RGB_TAP

UPDATED: updated macro to match the latest commit and cycle all of the available RGB options

@mehalter mehalter mentioned this pull request Sep 14, 2020
@mehalter
Copy link
Contributor Author

I cleaned up the implementation a little bit and separated out the RGB updating. This allows for the higher latency when the lights on keypress is enabled, but when it is set to false, the latency drops back down to 1/2 nanoseconds. Neither set ups has a noticeable lag tho even when typing at high speeds 120/130wpm which is good.

@mehalter mehalter changed the title RGB Light on Keypress Basic RGB Patterns Sep 14, 2020
@xiongyihui
Copy link
Contributor

I was thinking to add some new action codes to control the backlight. With backlight action codes, we could just modify the keymap without the macro handler.

@mehalter
Copy link
Contributor Author

Ah yeah I like that solution a lot better

@xiongyihui
Copy link
Contributor

Just added some keycodes to control RGB backlight. We can use RGB_MOD to change backlight modes.

@mehalter
Copy link
Contributor Author

Awesome! That is amazing! Thank you so much! I'll play around with this code a bit and look into what I can add. I'm really enjoying this keeb, thanks for all your hard work!

@mehalter mehalter closed this Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants