A neopixel animation based on bitmaps - Beta
Перейти к файлу
microsoft-github-policy-service[bot] c545bb31d9
Microsoft mandatory file (#3)
2023-06-12 11:44:21 -07:00
.vscode initial drop 2017-05-18 09:19:35 -07:00
.gitignore initial drop 2017-05-18 09:19:35 -07:00
.travis.yml Expressive pixels support (#1) 2018-01-03 21:45:52 -08:00
LICENSE Initial commit 2017-05-18 08:24:49 -07:00
Makefile initial drop 2017-05-18 09:19:35 -07:00
README.md fixing readme 2018-01-03 21:48:18 -08:00
SECURITY.md Microsoft mandatory file (#3) 2023-06-12 11:44:21 -07:00
animationSheet.ts Expressive pixels support (#1) 2018-01-03 21:45:52 -08:00
icon.png added icon 2017-05-20 07:20:41 -07:00
index.html Expressive pixels support (#1) 2018-01-03 21:45:52 -08:00
pxt.json 0.4.1 2018-01-03 21:47:27 -08:00
test.png updated demo image 2017-05-19 22:09:11 -07:00
test.ts Expressive pixels support (#1) 2018-01-03 21:45:52 -08:00
tsconfig.json initial drop 2017-05-18 09:19:35 -07:00

README.md

neoanim

A neopixel animation based on bitmaps Build Status

Animation Sheet

Creates an animation from a pre-rendered set of frames

light.animationSheet(null)

Parameters

  • buffer, the buffer containing the data (more below)

Animation editor

From the https://makecode.adafruit.com editor,

  • click on Add Package
  • add neoanim
  • go to the Lights category and click on Animation Editor

Buffer format

The bitmap format should be specified as follows. All values are little endian.

  • magic number 0x2e0a2188, 4 bytes
  • palette size, 1 byte (npalette)
  • reserved padding, 1 byte
  • palette, npalette x 24bit RGB colors
  • frames, nleds x number of frames. A contiguous sequence of palette color indices.

Example

Generating your own animation

The following sample generates a buffer and uses it to create the animation.

const strip = light.createStrip();
const nleds = strip.length();
const ncolors = 3;
const nframes = 10;
const sheet = pins.createBuffer(6 + ncolors * 3 + nleds * nframes);
const palette = sheet.slice(6, ncolors * 3);
const frames = sheet.slice(6 + palette.length);

// magic number
sheet.setNumber(0, NumberFormat.UInt32LE, 0x2e0a21);
// palette
sheet[4] = ncolors;
palette[0] = 0xff; // red
palette[4] = 0xff; // green
palette[8] = 0xff; // blue
// filing up colors
let k = 0;
for (let i = 0; i < nleds; ++i) {
    for (let j = 0; j < nframes; ++j) {
        frames[k++] = i + j % ncolors;
    }
}
let anim = light.animationSheet(sheet);

loops.forever(() => {
    strip.showAnimation(anim, 10000);
})

License

MIT

Supported targets

  • for PXT/adafruit
  • for PXT/codal (The metadata above is needed for package search.)