circuitpython/shared-bindings
Jeff Epler f5c637dc10
Add adafruit_pixelmap.PixelMap
.. a fast helper for animations. It is similar to and inspired by the
PixelMap helper in Adafruit LED Animation library, but with an extremely
fast 'paste' method for setting a series of pixels. This is a common
operation for many animations, and can give a substantial speed improvement.

It's named `adafruit_pixelmap` so that we can package a compatible version
in pure Python for systems that can't fit it in C in flash, or for
Blinka.

This is a proof of concept and can make a very fast comet animation:
```python
import time
import adafruit_pixelbuf
import adafruti_pixelmap
import board
import neopixel
from supervisor import ticks_ms
from adafruit_led_animation.animation.solid import Solid
from adafruit_led_animation import color

pixel_pin = board.GP0
pixel_num = 96

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=1, auto_write=False, pixel_order="RGB")

evens = adafruit_pixelmap.PixelMap(pixels, tuple(range(0, pixel_num, 2)))
odd_indices = tuple((i, i+2) for i in range(1, pixel_num, 4))
print(odd_indices)
odds = adafruit_pixelbuf.PixelMap(pixels, odd_indices)
assert len(odds) == len(odd_indices)


comet_length = 16

comet1 = [color.calculate_intensity(color.GREEN, ((1+i) / comet_length) ** 2.4)
        for i in range(comet_length)]
comet2 = [color.calculate_intensity(color.PURPLE, ((1+i) / comet_length) ** 2.4)
        for i in range(comet_length)]

pos1 = 0
pos2 = 96//4

while True:
    evens.paste(comet1, pos1, wrap=True, reverse=False, others=0)
    pos1 = (pos1 + 1) % len(evens)

    odds.paste(comet2, pos2, wrap=True, reverse=True, others=0)
    pos2 = (pos2 - 1) % len(odds)
    pixels.show()

    m = ticks_ms()
    if m % 2000 > 1000:
        time.sleep(.02)
```
2022-11-11 07:54:33 -06:00
..
__future__ add annotations to __future__; don't generate __future__ stubs 2022-03-10 11:19:35 -05:00
_bleio add Characteristic.descriptors to locals dict 2022-10-26 12:34:33 -04:00
_eve Tweak black_bindings 2022-09-30 11:18:13 -05:00
_pew Tweak black_bindings 2022-09-30 11:18:13 -05:00
_stage Tweak black_bindings 2022-09-30 11:18:13 -05:00
adafruit_bus_device Tweak black_bindings 2022-09-30 11:18:13 -05:00
adafruit_pixelbuf Add adafruit_pixelmap.PixelMap 2022-11-11 07:54:33 -06:00
adafruit_pixelmap Add adafruit_pixelmap.PixelMap 2022-11-11 07:54:33 -06:00
aesio Tweak black_bindings 2022-09-30 11:18:13 -05:00
alarm wip 2022-10-27 22:42:04 -04:00
analogbufio Tweak black_bindings 2022-09-30 11:18:13 -05:00
analogio Fix formatting of "Limitations:" in a couple of modules 2022-10-26 12:33:16 -04:00
atexit Tweak black_bindings 2022-09-30 11:18:13 -05:00
audiobusio catalog implementation limitations in documentation 2022-10-21 13:58:34 -04:00
audiocore Tweak black_bindings 2022-09-30 11:18:13 -05:00
audioio Tweak black_bindings 2022-09-30 11:18:13 -05:00
audiomixer Tweak black_bindings 2022-09-30 11:18:13 -05:00
audiomp3 Tweak black_bindings 2022-09-30 11:18:13 -05:00
audiopwmio Tweak black_bindings 2022-09-30 11:18:13 -05:00
bitbangio Tweak black_bindings 2022-09-30 11:18:13 -05:00
bitmaptools Tweak black_bindings 2022-09-30 11:18:13 -05:00
bitops Tweak black_bindings 2022-09-30 11:18:13 -05:00
board Tweak black_bindings 2022-09-30 11:18:13 -05:00
busio Simplify argument checking to reduce translated strings 2022-11-07 12:37:11 -06:00
camera Tweak black_bindings 2022-09-30 11:18:13 -05:00
canio Tweak black_bindings 2022-09-30 11:18:13 -05:00
coproc coproc module enhancements 2022-10-22 19:08:49 +05:30
countio catalog implementation limitations in documentation 2022-10-21 13:58:34 -04:00
digitalio Tweak black_bindings 2022-09-30 11:18:13 -05:00
displayio Tweak black_bindings 2022-09-30 11:18:13 -05:00
dotenv fix some dotenv parsing 2022-10-03 21:56:11 -04:00
dualbank add storage extension python api 2022-10-13 09:53:33 +05:30
floppyio Tweak black_bindings 2022-09-30 11:18:13 -05:00
fontio Tweak black_bindings 2022-09-30 11:18:13 -05:00
framebufferio Tweak black_bindings 2022-09-30 11:18:13 -05:00
frequencyio Tweak black_bindings 2022-09-30 11:18:13 -05:00
getpass Tweak black_bindings 2022-09-30 11:18:13 -05:00
gifio Tweak black_bindings 2022-09-30 11:18:13 -05:00
gnss Tweak black_bindings 2022-09-30 11:18:13 -05:00
hashlib Tweak black_bindings 2022-09-30 11:18:13 -05:00
i2ctarget Update I2CTarget.c 2022-10-03 13:09:40 +01:00
imagecapture Tweak black_bindings 2022-09-30 11:18:13 -05:00
ipaddress Tweak black_bindings 2022-09-30 11:18:13 -05:00
is31fl3741 Tweak black_bindings 2022-09-30 11:18:13 -05:00
keypad Use micropython #defines for stream polling operations 2022-10-14 12:15:30 -05:00
math Tweak black_bindings 2022-09-30 11:18:13 -05:00
mdns Tweak black_bindings 2022-09-30 11:18:13 -05:00
memorymonitor Tweak black_bindings 2022-09-30 11:18:13 -05:00
microcontroller Fix formatting of "Limitations:" in a couple of modules 2022-10-26 12:33:16 -04:00
msgpack Tweak black_bindings 2022-09-30 11:18:13 -05:00
neopixel_write Tweak black_bindings 2022-09-30 11:18:13 -05:00
nvm restore nvm module 2022-10-06 13:18:19 -05:00
onewireio Tweak black_bindings 2022-09-30 11:18:13 -05:00
os catalog implementation limitations in documentation 2022-10-21 13:58:34 -04:00
paralleldisplay Tweak black_bindings 2022-09-30 11:18:13 -05:00
ps2io Tweak black_bindings 2022-09-30 11:18:13 -05:00
pulseio Tweak black_bindings 2022-09-30 11:18:13 -05:00
pwmio Tweak black_bindings 2022-09-30 11:18:13 -05:00
qrio Tweak black_bindings 2022-09-30 11:18:13 -05:00
rainbowio Tweak black_bindings 2022-09-30 11:18:13 -05:00
random Tweak black_bindings 2022-09-30 11:18:13 -05:00
rgbmatrix Tweak black_bindings 2022-09-30 11:18:13 -05:00
rotaryio Tweak black_bindings 2022-09-30 11:18:13 -05:00
rtc catalog implementation limitations in documentation 2022-10-21 13:58:34 -04:00
sdcardio Tweak black_bindings 2022-09-30 11:18:13 -05:00
sdioio Tweak black_bindings 2022-09-30 11:18:13 -05:00
sharpdisplay run black_bindings across all bindings 2022-09-27 15:21:42 -05:00
socketpool socketpool: make socket objects selectable 2022-11-05 12:05:19 -05:00
ssl Add support for SSL client certificate (load_cert_chain) 2022-10-10 15:10:53 -05:00
storage add storage extension python api 2022-10-13 09:53:33 +05:30
struct Tweak black_bindings 2022-09-30 11:18:13 -05:00
supervisor implement suggested change 2022-10-04 08:28:48 +05:30
synthio Tweak black_bindings 2022-09-30 11:18:13 -05:00
terminalio Fix type annotation mistake 2022-11-07 13:51:58 -06:00
time Tweak black_bindings 2022-09-30 11:18:13 -05:00
touchio Simplify argument checking to reduce translated strings 2022-11-07 12:37:11 -06:00
traceback format_traceback: Return list, as documented, and compatible with CPython 2022-10-13 09:38:43 -05:00
uheap Tweak black_bindings 2022-09-30 11:18:13 -05:00
usb Tweak black_bindings 2022-09-30 11:18:13 -05:00
usb_cdc Use micropython #defines for stream polling operations 2022-10-14 12:15:30 -05:00
usb_hid Simplify argument checking to reduce translated strings 2022-11-07 12:37:11 -06:00
usb_host Tweak black_bindings 2022-09-30 11:18:13 -05:00
usb_midi Use micropython #defines for stream polling operations 2022-10-14 12:15:30 -05:00
ustack Tweak black_bindings 2022-09-30 11:18:13 -05:00
vectorio Tweak black_bindings 2022-09-30 11:18:13 -05:00
watchdog Simplify argument checking to reduce translated strings 2022-11-07 12:37:11 -06:00
wifi handle scan channel bounds but note they do nothing for RP2040 CYW43 2022-10-07 16:22:17 -04:00
zlib Tweak black_bindings 2022-09-30 11:18:13 -05:00
help.rst Apply a Sphinx transform to make the core module docs look better 2020-08-07 00:01:31 +09:00
index.rst docs: Improve 5.0.x <-> main branch doc linkrot 2020-06-14 11:12:35 -05:00
support_matrix.rst add missing native modules to support matrix 2022-10-04 19:22:18 -04:00
util.c Conditionalize LTO 2022-05-27 12:59:54 -07:00
util.h Refactor deinit check to reduce code size. 2019-06-12 11:36:43 -07:00