Skip to content

Instantly share code, notes, and snippets.

View kriegsman's full-sized avatar

Mark Kriegsman kriegsman

  • Boston
View GitHub Profile
@kriegsman
kriegsman / ColorPower.1
Last active August 29, 2015 14:07
Comparison of 'total numeric light output' for RGB colors coming out of FastLEDv2.1 hsv2rgb_rainbow
EXPLANTION: This table shows the total light output for FastLED v2.1's "hsv2rgb_rainbow" function
for a variety of hue, saturation, and value inputs.
Each cell shows the sum of the Red, Green, and Blue values returned from the HSV-to-RGB conversion,
which we could call the 'total numeric light output' for that RGB color.
FINDINGS: For any given saturation and value, the 'total numeric light output' is basically constant
across all hues +/-1, with the exception of yellow and the hues near yellow, which have higher
power output -- by design.
NEXT: A question remains though: does "252,0,0" _appear_ brighter or dimmer than "126,126,0",
@kriegsman
kriegsman / ColorPower.spectrum
Created October 15, 2014 17:18
hsv2rgb_spectrum 'total numeric light output'
hsv2rgb_spectrum 'total numeric light output' across hues, saturations, and values.
(Same as hsv2rgb_raw, but with hues 0..255, instead of 0..191)
Each cell represents the total of R+G+B for the output of the hsv2rb conversion.
Findings: 'total numeric light output' is constant across all hues, +/-1.
N.B. this was, in fact, one of the target design paramaters of this algorithm.
Remaining open question: does 252,0,0 appear exactly as bright, or brighter, or
dimmer than 126,126,0 or 84,84,84, even though they all have the same 'total
numeric light output'.
@kriegsman
kriegsman / hsv2rgb_raw_kasper
Last active August 29, 2015 14:07
hsv2rgb_raw_kasper
hsv2rgb_raw_kasper 'total numeric light output' data.
This data is somewhat similar to the output of traditional hsv2rgb
algorithms, such as the one described on wikipedia, or Adafruit's
color "wheel" function. In this model, blended hues requiring a mix
of LEDs (e.g, aqua, hue=96, output=510) output almost twice as much
light as primary hues that use just one LED, (e.g. blue, hue=128,
output=255). This can result in the blended hues appearing brighter
than primary hues. In the case of Aqua, this algorithm turns the
Green LED on to 254 AND the Blue LED on to 254: two LEDs on at full power.
0008-d150: da fe d1 fe-d2 fe cb fe-c8 fe c2 fe-bf fe ba fe ........ ........
0008-d160: b6 fe b3 fe-ac fe aa fe-a4 fe 9f fe-9d fe 97 fe ........ ........
0008-d170: 92 fe 8f fe-89 fe 85 fe-80 fe 7c fe-77 fe 73 fe ........ ..|.w.s.
0008-d180: 6d fe 69 fe-65 fe 5e fe-5c fe 55 fe-51 fe 4f fe m.i.e.^. \.U.Q.O.
0008-d190: 43 fe 46 fe-3b fe 3b fe-33 fe 2e fe-2c fe 22 fe C.F.;.;. 3...,.".
0008-d1a0: 23 fe 18 fe-19 fe 0e fe-0e fe 06 fe-00 fe 01 fe #....... ........
0008-d1b0: f2 fd f8 fd-e8 fd ec fd-e0 fd e0 fd-d7 fd d4 fd ........ ........
0008-d1c0: cd fd ca fd-c3 fd be fd-b9 fd b4 fd-ae fd aa fd ........ ........
0008-d1d0: a3 fd 9f fd-99 fd 93 fd-90 fd 87 fd-85 fd 7e fd ........ ......~.
0008-d1e0: 79 fd 73 fd-6e fd 69 fd-62 fd 60 fd-56 fd 54 fd y.s.n.i. b.`.V.T.
@kriegsman
kriegsman / flt_max.c
Created November 3, 2014 18:33
FLT_MAX and DBL_MAX on IA64
#include <float.h>
#include <stdio.h>
#include <string.h>
// Output from gcc on Intel x64, all default settings:
// - float's can be up to 46 characters in %f output,
// - double's can be up to 316 characters in %lf output.
//
//
// printf("%f", FLT_MAX) = 340282346638528859811704183484516925440.000000, (46 chars)
@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 / 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 / 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 / rgb2hsv_approximate.ino
Last active August 29, 2015 14:12
rgb2hsv_approximate: approximate recovery of HSV values from an RGB input
(Code added to FastLED3.1 branch... find it there.)