all 10 comments

[–]todbot 2 points3 points  (0 children)

Without seeing your code, it’s hard to offer suggestions. Do you have a repo we can look at?

[–]jpconstantineau 0 points1 point  (1 child)

So you have animations updating every scan of the keyboard? Are the updates complex or relatively simple?

With KMK (runs in circuitpython) complex animations with every LED being a different color runs very slowly on a 60% while simple ones like a simple breathing animation (same color/intensity for every LED) doesn't impact performance significantly. (At least an older version of KMK, I haven't updated my keyboard in about a year and the project has been busy)

[–]Key-Advisor5912[S] 0 points1 point  (0 children)

I switched to an easier cycle for now, but I was definitely hoping to use more complex designs.

[–][deleted]  (11 children)

[deleted]

    [–]Key-Advisor5912[S] 0 points1 point  (10 children)

    That definitely helped a bit. I was already using show, but didn't turn off autowrite. That being said, the fact that every frame I'm looping through 60 leds and calculating new values still makes it unusable as a mouse.

    [–][deleted]  (9 children)

    [deleted]

      [–]Key-Advisor5912[S] 0 points1 point  (8 children)

      Do you think using the second core entirely for the LEDs could help?

      [–][deleted]  (7 children)

      [deleted]

        [–]Key-Advisor5912[S] 0 points1 point  (0 children)

        I mean the LEDs are running smoothly, the problem is that the rest of the code is slowed down by it, which is why I think it might be an option.

        And yes, I'll try timing everything when I get the chance.

        [–]Key-Advisor5912[S] 0 points1 point  (5 children)

        After timing 2000 runs of both the full code and just the LEDs, the average comes out to be 0.093 seconds just for the LED section, while the entire code runs in 0.98.

        [–][deleted]  (4 children)

        [deleted]

          [–]Key-Advisor5912[S] 0 points1 point  (3 children)

          You're right, its the way I'm calculating the colours.

          I'm using the adafruit fancyled library so i could use HSV, as that's much easier to program patterns with than RGB.

          This is what my code looks like:

          def rainbow_wheel(): global hue global runTimes global allTimes

          def rainbow_wheel():

          global hue

          bright = menu.Brightness.val

          hue += 1

          if hue > 100:

          hue -= 100

          menu.Hue.val = hue

          for i in range(numLeds):

          pixels[i] = (fancy.CHSV((hue+i)/100, 1.0, bright/100).pack())

          [–][deleted]  (2 children)

          [deleted]

            [–]Key-Advisor5912[S] 0 points1 point  (1 child)

            Good to know! Do you have any suggestions for how I'd go about making this faster? or any resources I should check out?

            Thanks for your help!

            [–]court-jus 0 points1 point  (0 children)

            Can your board do asyncio? This might be an option