Skip to content

Instantly share code, notes, and snippets.

View kriegsman's full-sized avatar

Mark Kriegsman kriegsman

  • Boston
View GitHub Profile
@kriegsman
kriegsman / random8
Last active August 29, 2015 14:09
Analysis of "random8"
In order to evaluate the true randomness of "random8", I generated 64K of random bytes using random8, and ran it through "ent" to analyze the entropy:
Entropy = 8.000000 bits per byte.
Optimum compression would reduce the size
of this 65536 byte file by 0 percent.
Chi square distribution for 65536 samples is 0.00, and randomly
would exceed this value more than than 99.99 percent of the times.
@kriegsman
kriegsman / RedGreenPalette.ino
Last active December 2, 2017 16:41
Example showing how to make a simple striped palette, and use it to animated blended color bars
#include <FastLED.h>
// Example showing how to make a simple striped color palette,
// and use it to animated blended color bars
#define LED_PIN 3
#define NUM_LEDS 30
CRGB leds[NUM_LEDS];
CRGBPalette16 currentPalette;
@kriegsman
kriegsman / BrianBasic.ino
Created November 25, 2014 13:52
Rainbow color wash demo sketch for Brian
#include <FastLED.h>
#define LED_PIN 3
#define LED_TYPE WS2811
#define COLOR_ORDER RGB
#define COLOR_CORRECTION CRGB(255,172,240)
#define BRIGHTNESS 64
#define NUM_LEDS 100
@kriegsman
kriegsman / uqadd8x4.cpp
Last active August 29, 2015 14:10
C wrapper for ARM uqadd8
// See also __uqadd8
static inline uint8x4_t uqadd8x4 (uint8x4_t xs, uint8x4_t ys)
{
uint8x4_t sums;
asm volatile(
"uqadd8 %[sums], %[xs], %[ys]"
: [sums] "=r" (sums)
: [xs] "%r" (xs), [ys] "r" (ys));
return sums;
@kriegsman
kriegsman / SoftTwinkles.ino
Last active January 4, 2022 02:44
Soft, warm twinkles. Super short code, super complicated theory of operation.
#include "FastLED.h"
#define LED_PIN 3
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS 30
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 120
#define DENSITY 80
@kriegsman
kriegsman / ColorTwinkles.ino
Last active January 29, 2021 17:48
Twinkling 'holiday' lights that fade in and out.
#include "FastLED.h"
#define LED_PIN 3
#define LED_TYPE WS2811
#define COLOR_ORDER RGB
#define NUM_LEDS 50
CRGB leds[NUM_LEDS];
// Twinkling 'holiday' lights that fade up and down in brightness.
// Colors are chosen from a palette; a few palettes are provided.
@kriegsman
kriegsman / DemoReel100.ino
Last active April 15, 2023 09:22
FastLED "100-line" demo reel
#include "FastLED.h"
// FastLED "100-lines-of-code" demo reel, showing just a few
// of the kinds of animation patterns you can quickly and easily
// compose using FastLED.
//
// This example also shows one easy way to define multiple
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014
@kriegsman
kriegsman / PaletteCrossfade.ino
Last active March 2, 2024 01:37
How to cross-fade between color palettes using nblendPaletteTowardPalette
#include <FastLED.h>
#define LED_PIN 3
#define NUM_LEDS 30
#define BRIGHTNESS 96
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 100
@kriegsman
kriegsman / Fireworks5x8.ino
Created December 31, 2014 17:01
2-D fireworks simulation (originally designed and tuned for an 5x8 matrix, but scalable)
#include "FastLED.h"
// Quick and dirty 2-D fireworks simulation
// Originaly designed (and tuned for) an Adafruit 5x8 WS2811 shield
// by Mark Kriegsman, July 2013
// (and not updated since, so it's a little stale,
// but it's a good starting point, if rather uncommented.)
#define NUM_LEDS 40
CRGB leds[NUM_LEDS];
@kriegsman
kriegsman / Fireworks16x16.ino
Created December 31, 2014 17:04
2-D Fireworks simulation tuned for 16x16 matrix
#include "FastLED.h"
// Quick and dirty 2-D fireworks simulation
// Originaly designed (and tuned for) a 16x16 matrix
// by Mark Kriegsman, July 2013
// (and not updated since, so it's a little stale,
// but it's a good starting point, if rather uncommented.)
#define PIXEL_WIDTH 15
#define PIXEL_HEIGHT 16