Skip to content

Instantly share code, notes, and snippets.

View kriegsman's full-sized avatar

Mark Kriegsman kriegsman

  • Boston
View GitHub Profile
/* Generate HTML page in C -- my first REAL Web App */
/* Mark Kriegsman, January 31, 2007 */
#define HTML_ENTITY(n,v) int n = v
HTML_ENTITY(gt,'>');
HTML_ENTITY(lt,'<');
HTML_ENTITY(P,'\n');
HTML_ENTITY(HTML,'\0');
@kriegsman
kriegsman / RWBGlitter.ino
Created June 30, 2014 17:04
Red, White, and Blue stripes with "glitter" flashes sketch (for FastLED v2.1 or later)
#include<FastLED.h>
// Red, White, and Blue stripes with "glitter" flashes
// Mark Kriegsman, June 30, 2014
// requires FastLED v2.1 or later
#define NUM_LEDS 30
#define LED_PIN 5
#define COLOR_ORDER GRB
#define BRIGHTNESS 64
@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.
@kriegsman
kriegsman / XYShades
Last active May 3, 2020 14:08
XY matrix functions for RGB Shades Kickstarter
#include <FastLED.h>
// Use Version 2.1 or later https://github.com/FastLED/FastLED/tree/FastLED2.1
// ZIP file https://github.com/FastLED/FastLED/archive/FastLED2.1.zip
// RGB Shades data output to LEDs on pin 5
#define LED_PIN 5
// RGB Shades color order
#define COLOR_ORDER GRB
#define CHIPSET WS2811
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 / SmartMatrixSwirl.ino
Created November 13, 2014 03:15
SmartMatrix + FastLED v3.1 demo
#include <SmartMatrix.h>
#include <FastLED.h>
const uint8_t kMatrixWidth = 32;
const uint8_t kMatrixHeight = 32;
const uint8_t kBorderWidth = 2;
#define NUM_LEDS (kMatrixWidth*kMatrixHeight)
CRGB leds[NUM_LEDS];
@kriegsman
kriegsman / SquareSwirl.ino
Created November 13, 2014 19:21
FastLED 3.1 2-D blur demo on 8x8 matrix
#include <FastLED.h>
#define LED_PIN 6
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
const uint8_t kSquareWidth = 8;
const uint8_t kBorderWidth = 1;
#define NUM_LEDS (kSquareWidth*kSquareWidth)