Skip to content
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

RGB Light Patterns #9

Open
mehalter opened this issue Sep 13, 2020 · 7 comments
Open

RGB Light Patterns #9

mehalter opened this issue Sep 13, 2020 · 7 comments

Comments

@mehalter
Copy link
Contributor

I have been playing around with the Backlight API and I have had success turning on all the colors and making some simple patterns. Although I haven't figured out how to get the patterns running in the background. Is there any way to do this currently? To have some small code that generates a pattern to change the lights while the keyboard stays functional. Or even a way to program lighting as a reaction to pressing a key?

@xiongyihui
Copy link
Contributor

We can add a blacklight update function after matrix.wait(), and add a timeout to matrix.wait

matrix.wait(10)
# change backlight
backlight.update()

Another way is moving backlight into circuitpython firmware. Use timer's callback to update the backlight. It will be better, but will take more time to implement.

@mehalter
Copy link
Contributor Author

I have been doing some initial playing around with this. Initially just playing around with adding the lines

self.backlight.pixel(key, 0xFF, 0x00, 0x00)
self.backlight.update()

at this line

self.press(action_code)

I'm having some weird behavior depending on where I put something like self.backlight.update(). If I put it right after the wait like you said, I get some nasty errors that I don't quite understand yet and cause the keyboard not to run. Do you have any idea why putting the update function or pixel setting in different locations in that function causes it to error out?

@xiongyihui
Copy link
Contributor

The 7th bit of key is 1 when the key is released. Should change self.backlight.pixel(key, 0xFF, 0x00, 0x00) to self.backlight.pixel(key & 0x7F, 0xFF, 0x00, 0x00)

@mehalter
Copy link
Contributor Author

Do you mean what was happening in this line? Or should I be doing it again?

key = event & 0x7F

@xiongyihui
Copy link
Contributor

Oh, not need to do it again. I don't see any difference when putting self.backlight.update() in different locations.

I tried to replace the get function to:

    def get(self):
        key = self.matrix.get()
        if key & 0x80 == 0:
            self.heatmap[key] += 1
            self.backlight.pixel(key, 0, 0x80, 0)
        else:
            self.backlight.pixel(key & 0x7F, 0, 0, 0)
        self.backlight.update()
        return key

Do you mind to create a branch to share your code? So I can check it.

@mehalter
Copy link
Contributor Author

mehalter commented Sep 14, 2020

It turned out to be another issue. I was able to fix it. I am currently using something similar to what you put except a check to see if it's the spacebar and in that case light up all 3 LEDs (56, 61, 62) and it's working great and the latency while it went up isn't noticeable during use (7 nanoseconds)

@mehalter
Copy link
Contributor Author

I just opened up a PR with the current state of this development (#10)

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

No branches or pull requests

2 participants