Giter Site home page Giter Site logo

pxt-neoanim's Introduction

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.)

pxt-neoanim's People

Contributors

microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar pelikhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pxt-neoanim's Issues

Instructions are outdated

To get at the animation editor, I needed to go to "Advanced" -> "Extension", then search for "neoanim" and install the extension found. The rest of the instructions (Light -> Animation editor) are still correct.

Another issue, is that in the presented animation editor, I was invited to drag and drop an existing image. Since I had none at hand, I clicked the link "Paint your own animation" (or something similar), but that presented me with a mostly empty screen. Clicking back returns to the code editor, clicking lights -> animation editor again directs me at the empty screen again.

adafruit circuit playground express - blocks - javascript editor - mozilla firefox_012

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.