Skip to content

Instantly share code, notes, and snippets.

View kasperkamperman's full-sized avatar

Kasper Kamperman kasperkamperman

View GitHub Profile
@kasperkamperman
kasperkamperman / colorutils
Last active August 29, 2015 14:06
FastLed 2.1 - added saturation to ColorFromPalette (colorutils.cpp)
/* use this code in Arduino
for (int i=0; i <NUM_LEDS; i++)
{ leds[i] = ColorFromPalette( currentPalette, map(i, 0, NUM_LEDS, 0, 255), brightness, map(i, 0, NUM_LEDS, 0, 255));
}
*/
// blend doesn't seem to be implemented/necessary in CRGBPalette, so I left it out
// Probably this can be optimized? See questions in comments.
CRGB ColorFromPalette( const CRGBPalette256& pal, uint8_t index, uint8_t brightness, uint8_t saturation)
@kasperkamperman
kasperkamperman / gammacompare.ino
Last active January 10, 2018 16:05
Gamme curve compare with FastLED
// Gamma table HexaWS2811 placed at the bottom of the code
// dim_curve placed at the bottom of the code
extern const uint8_t gammaTable[];
extern const uint8_t dim_curve[];
#include "FastLED.h"
#define NUM_LEDS 5
#define DATA_PIN 11
@kasperkamperman
kasperkamperman / contrast_test.ino
Last active August 29, 2015 14:07
Change the contrast of input values.
// Check: https://plus.google.com/+KasperKamperman/posts/NmCDNXUVHYs
// #include "FastLED.h"
uint8_t inputValues[7] = {0, 30, 64, 128, 192, 221, 255};
int contrastValue = 8;
void setup() {
Serial.begin(57600);
@kasperkamperman
kasperkamperman / showClosestColorName.pde
Created January 27, 2015 15:49
Get the closest color name for a color
// get a colorname from a random color, for example to use as search string
// arrays can be filled with more descriptors
// a multidimensional array might be nice.
// Kasper Kamperman, 27-01-2015
// make sure the two arrays have the same length and the name describes the colorHex.
color [] colorHex = { #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff };
String [] colorName = { "red", "yellow", "green", "cyan", "blue", "purple" };
@kasperkamperman
kasperkamperman / plot.pde
Created March 27, 2015 19:43
circular buffer to store and plot values
// this code is not a working sketch
int circularBufferSize;
int circularBufferIndex;
int [][] circularBuffer;
circularBufferSize = 512;
circularBufferIndex = 0;
circularBuffer = new int [6][circularBufferSize];
@kasperkamperman
kasperkamperman / frameDifferenceProblem.pde
Created May 19, 2015 20:15
FrameDifference problem Processing OpenCV library
/*
Problem. Why I see a light image of me, while I do a difference on exactly the same
images.
OpenCV for Processing 0.5.2 by Greg Borenstein http://gregborenstein.com
Using Java OpenCV 2.4.5.0
Processing 3.0a4
*/
@kasperkamperman
kasperkamperman / frameDifferenceMat.pde
Created May 19, 2015 20:35
frameDifference with Mat OpenCV library for Processing
import org.opencv.core.Mat;
import gab.opencv.*;
import processing.video.*;
Capture video;
OpenCV opencv;
Mat cvLastFrameMat;
Mat cvThisFrameMat;
@kasperkamperman
kasperkamperman / motionButtonProcessingOpenCV.pde
Last active August 29, 2015 14:22
Buttons that can be triggered by Motion. Uses the OpenCV library for Processing.
/*
Frame Differencing example:
- including mirror effect
- you can place motion buttons on the screen
- in the setup we place the buttons in a grid.
- you probably need to tweak some variables in the MotionButton class.
Install the OpenCV for Processing library (Sketch > Import library):
https://github.com/atduskgreg/opencv-processing
@kasperkamperman
kasperkamperman / faceDetectProcessingOpenCV.pde
Created May 31, 2015 20:17
Face Detection on a mirrored webcam image. Track the position of the biggest face. Uses the OpenCV library for Processing.
/*
Face Detection example:
- including mirror effect
- track the position of the face
Install the OpenCV for Processing library (Sketch > Import library):
https://github.com/atduskgreg/opencv-processing
Check also the reference:
http://atduskgreg.github.io/opencv-processing/reference/
@kasperkamperman
kasperkamperman / fastled_serial_control.pde
Last active October 26, 2015 12:50
Use ControlP5 annotations to make a control panel for FastLED. Uses a protocol of 12 bytes.
/* Use ControlP5 annotations to make a control panel for FastLED.
Uses a protocol of 12 bytes.
Protocol description:
https://drive.google.com/file/d/0B3Tn6oRmh71oS3FNQ2hsODVwS1E
Arduino code:
https://gist.github.com/kasperkamperman/7e827bb481dfcdb4cb52
*/