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 / 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 / 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 / spotify_api.pde
Last active October 12, 2015 15:50
Get album cover data from Spotify
// https://developer.spotify.com/web-api/endpoint-reference/
JSONObject json;
PImage [] albumCovers;
//Bubble[] bubbles;
void setup() {
size(640,480);
@kasperkamperman
kasperkamperman / valueMonitorExample.pde
Created October 14, 2015 14:08
Value Monitor. Display a graph with values that you'd like to monitor.
/* Value Monitor Example
*/
ValueMonitor [] valueMonitorArray = new ValueMonitor[2];
void setup() {
size(640, 480);
frameRate(25);
// place ValueMonitor objects on the screen, for some graphical feedback
@kasperkamperman
kasperkamperman / minim_play_spotifypreview.pde
Last active October 15, 2015 19:44
With mimim you can directly play an mp3 from a url.
// https://developer.spotify.com/web-api/get-track/
// http://code.compartmental.net/minim/minim_method_loadfile.html
import ddf.minim.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer groove;
void setup()
@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
*/