circuitpython/shared-module
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
..
_bleio message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
_eve Additional missing-prototypes fixes 2021-11-10 10:55:53 -06:00
_stage Stage: add support for viewport scrolling 2021-10-09 00:05:49 +02:00
adafruit_bus_device common-hal I2C combined write_read 2022-01-31 22:03:30 -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 run code formatting script 2021-03-15 19:27:36 +05:30
atexit Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
audiocore Conditionalize LTO 2022-05-27 12:59:54 -07:00
audioio bring MixerVoice back to building state; update documentation 2019-08-03 11:20:06 -05:00
audiomixer message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
audiomp3 Conditionalize LTO 2022-05-27 12:59:54 -07:00
audiopwmio audiopwmio: Add the shared files for this new module 2019-07-26 07:52:37 -05:00
bitbangio Conditionalize LTO 2022-05-27 12:59:54 -07:00
bitmaptools Fix freeze on bitmaptools.dither 2022-03-04 17:06:07 +09:00
bitops Merge MicroPython 1.14 into CircuitPython 2021-05-11 15:07:40 -07:00
board Conditionalize LTO 2022-05-27 12:59:54 -07:00
canio Enable -Werror=missing-prototypes on espressif port 2021-11-10 11:07:45 -06:00
displayio Fix with PWM for brightness slowing devices down 2022-09-11 20:34:53 -05:00
dotenv Fix parsing long dotenv values 2022-10-13 16:41:30 -05:00
floppyio Add floppyio for rp2040 2022-01-17 16:34:47 -06:00
fontio Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
framebufferio Remove support for auto-brightness 2022-08-09 22:40:21 -04:00
getpass Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
gifio use mp_get_stream_raise, it's more specific 2021-11-20 08:53:04 -05:00
imagecapture ParallelImageCapture: Add continuous capture on espressif 2021-11-03 11:02:46 -05:00
ipaddress run code formatting script 2021-03-15 19:27:36 +05:30
is31fl3741 Two small fixes, remove hardcoded height and non-scale issues 2022-08-19 15:13:38 -05:00
keypad refactor keypad to share more code 2022-04-05 14:50:30 -05:00
memorymonitor run code formatting script 2021-03-15 19:27:36 +05:30
msgpack Conditionalize LTO 2022-05-27 12:59:54 -07:00
onewireio Move OneWire to onewireio from busio 2021-08-12 10:47:14 -07:00
os Updated utime() to take a 2-tuple instead of a plain int 2022-09-22 00:56:44 -07:00
paralleldisplay Initial broadcom port for Raspberry Pi 2021-11-22 14:54:44 -08:00
qrio Add support for RGB565 images in qrio 2022-08-10 11:13:26 -05:00
rainbowio appease ci 2022-02-10 17:14:07 -08:00
random Additional missing-prototypes fixes 2021-11-10 10:55:53 -06:00
rgbmatrix merge 7.3.0-rc.1 changes to main 2022-05-20 15:37:56 -04:00
rotaryio Additional missing-prototypes fixes 2021-11-10 10:55:53 -06:00
sdcardio print addl debug message 2021-12-08 21:03:06 -06:00
sharpdisplay allow multiple board buses 2021-12-11 23:07:21 +05:30
storage add storage extension python api 2022-10-13 09:53:33 +05:30
struct Conditionalize LTO 2022-05-27 12:59:54 -07:00
supervisor finish status bar internal simplification 2022-09-27 15:14:40 -04:00
synthio message consolidation and more use of validators 2022-05-19 15:38:37 -04:00
terminalio finish status bar internal simplification 2022-09-27 15:14:40 -04:00
time Additional missing-prototypes fixes 2021-11-10 10:55:53 -06:00
touchio Touchin.c - fix clean up in constructor before exception is thrown 2022-08-10 21:49:18 +02:00
traceback Reduce code duplication in traceback module 2021-08-09 08:27:28 -05:00
uheap Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
usb Tweaks from review 2022-03-11 10:51:50 -08:00
usb_cdc Fix USB issues caused by early usb_cdc.Serial read 2022-10-21 20:42:26 -07:00
usb_hid shared-module/usb_hid: Fix behavior of Device.get_last_received_report() 2022-08-24 01:34:51 -04:00
usb_midi Conditionalize LTO 2022-05-27 12:59:54 -07:00
ustack run code formatting script 2021-03-15 19:27:36 +05:30
vectorio simplify logic in _clobber_points_list 2022-09-22 08:39:34 -05:00
zlib Removing DecompIO 2022-03-23 17:02:58 -05:00