Commit Graph

23 Commits

Author SHA1 Message Date
Jeff Epler 5e06c91244
Merge pull request #4716 from tyomitch/main
s/Circuit Python/CircuitPython/g
2021-05-08 08:47:29 -05:00
Artyom Skrobov 908d83d1f2 s/Circuit Python/CircuitPython/g
Some comments and messages used the non-standard spelling
2021-05-06 16:22:35 +03:00
Scott Shawcroft 3fda0c0a1b
Fix board builds and use MP_ERROR_TEXT in py and extmod 2021-05-05 17:51:52 -07:00
Scott Shawcroft 76033d5115
Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Jeff Epler dac4ac5d2a _pixelbuf: Respond to review comments
* Comment on the reason for scaling by 256
 * Divide by 256 instead of shifting
 * fix a cast; eliminate an unneeded roundf() to get a few bytes code back
2021-02-24 16:27:09 -06:00
Jeff Epler b7f5c277ad _pixelbuf: Increase performance of brightness-scaling
On the Pico, this increases the "fill rate" of
    pixels[:] = newvalues
considerably.  On a strip of 240 RGB LEDs, auto_write=False, the timings
are:

|| Brightness || Before || After || Improvement ||
|| 1.0        || 117 kpix/s || 307 kpix/s || 2.62x ||
|| 0.07       || 117 kpix/s || 273 kpix/s || 2.33x ||

It's worth noting that even the "before" rate is fast compared to the
time to transmit a single neopixel, but any time we can gain back
in the whole pipeline will let marginal animations work a little better.
To set all the pixels in this way and then show() gives a pleasant bump
to the framerate, from about 108Hz to 124Hz (1.15x)

The main source of speed-up is using integer math instead of floating
point math for the calculation of the post-scaled pixel values.  A slight
secondary gain is achieved by avoiding the scaling altogether when
the scale factor is 1.0.

Because the math is not exactly the same, some scaled pixel values may
change by +- 1 RGBW "step".  In practice, this is unlikely to matter.

The gains are bigger on the Pico and other M0 microcontrollers than M4
microcontrollers with floating point math in the hardware.

Happily, flash size is also improved a bit on the Pico build I did,
going from
> 542552 bytes used, 506024 bytes free in flash firmware space out of 1048576 bytes (1024.0kB).

to
> 542376 bytes used, 506200 bytes free in flash firmware space out of 1048576 bytes (1024.0kB).
2021-02-24 09:51:27 -06:00
Roy Hooper 1b7709f325 use the stack 2020-08-10 18:42:05 -04:00
Roy Hooper ef1782f85e fix trailing whitespace 2020-08-10 12:04:44 -04:00
Roy Hooper e73dba21d2 make pixelbuf handle floats and iterables 2020-08-07 18:42:06 -04:00
Roy Hooper dd980249c6 Allow setting RGBW pixels with RGB tuples 2020-05-24 20:35:13 -04:00
George Waters c592a2b4db
Simplify pixelbuf set_pixels function 2020-05-22 21:19:17 -04:00
George Waters f078055f59
Use mp_int_t for setting pixelbuf slice indices
When handling negative steps, start and stop need to be mp_int_t so they
can be checked against a potential negative value during the for loop
used to set the slice values.
2020-05-22 16:28:09 -04:00
George Waters 16ffc731f3
Implement negative step for pixelbuf slices 2020-05-21 21:57:45 -04:00
Jeff Epler 310f2ccdf4 Pixelbuf: subscr: Get correct pixel value
Previously, the 0th pixel's value was always returned
2020-03-18 10:25:20 -05:00
Scott Shawcroft 5e789b3850
Don't allocate the pre brightness buffer if brightness is 1.0 still 2020-01-27 15:10:32 -08:00
Scott Shawcroft 39971794dd
Encapsulate buffers inside PixelBuf and refactor it. 2020-01-24 18:23:07 -08:00
Roy Hooper 222dd29a14 Fix slice step. 2019-12-10 20:43:00 -05:00
Roy Hooper 2970680e6a fix show and fix step > 1 2019-10-20 19:54:25 -04:00
Roy Hooper 3cf9a475b9 fix 'white' byte for dotstars 2019-08-04 11:02:33 -04:00
Roy Hooper 31e4591691 WIP: refactor _pixelbuf to use strings instead of classes 2019-07-21 16:37:06 -04:00
Roy Hooper a62a1ae2bd WIP: refactor _pixelbuf to use strings instead of classes 2019-07-21 16:30:09 -04:00
Roy Hooper ffe734edf7 Fresh combined checkin of _pixelbuf library. 2019-01-13 23:51:13 -05:00