Code Monkey home page Code Monkey logo

Comments (7)

xiongyihui avatar xiongyihui commented on July 20, 2024

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.

from python-keyboard.

mehalter avatar mehalter commented on July 20, 2024

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?

from python-keyboard.

xiongyihui avatar xiongyihui commented on July 20, 2024

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)

from python-keyboard.

mehalter avatar mehalter commented on July 20, 2024

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

key = event & 0x7F

from python-keyboard.

xiongyihui avatar xiongyihui commented on July 20, 2024

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.

from python-keyboard.

mehalter avatar mehalter commented on July 20, 2024

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)

from python-keyboard.

mehalter avatar mehalter commented on July 20, 2024

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

from python-keyboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.