Skip to content

Instantly share code, notes, and snippets.

View kasperkamperman's full-sized avatar

Kasper Kamperman kasperkamperman

View GitHub Profile
@kasperkamperman
kasperkamperman / fastled_serial_control.ino
Last active April 21, 2016 15:44
Example to receive serial commands for use with FastLED. FastLED itself is not implemented. This just replies the received command.
/* Structure to receive 12 byte commands.
* Protocol idea:
* https://drive.google.com/file/d/0B3Tn6oRmh71oS3FNQ2hsODVwS1E
*
* Processing program to send commands:
* https://gist.github.com/kasperkamperman/6c7c256f7042a3ca5118
*
* Thanks to Daniel Garcia for the command structure example.
*/
@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 / 16bit_hsb_lookup.ino
Last active November 28, 2015 09:00
Get RGB values based on a 16bit hue input value. A lookup table is used with 256 values and in between we interpolate with lerp16by8 (FastLED library).
/*
Implementation of a 16bit HSB lookup table.
The table is rendered with a Processing sketch where HSB is converted to RGB.
*/
#include<FastLED.h>
const uint32_t HSBLUT[] = {
0xFFFF0000, 0xFFFF0500, 0xFFFF0B00, 0xFFFF1100, 0xFFFF1700, 0xFFFF1D00, 0xFFFF2300, 0xFFFF2900, 0xFFFF2F00, 0xFFFF3500, 0xFFFF3B00, 0xFFFF4100, 0xFFFF4700, 0xFFFF4D00, 0xFFFF5300, 0xFFFF5900,
@kasperkamperman
kasperkamperman / test_sqrt_blending.ino
Last active January 22, 2016 09:26
Test with sqrt blending color values using FastLED functions.
// sqrt blending test
// http://scottsievert.com/blog/2015/04/24/image-sqrt/
// https://plus.google.com/+KasperKamperman/posts/jkACVWijSDN
// algorithms sqrt32 from: http://stackoverflow.com/questions/1100090/looking-for-an-efficient-integer-square-root-algorithm-for-arm-thumb2
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 128
/*
* oscP5sendreceive by andreas schlegel
* example shows how to send and receive osc messages.
* oscP5 website at http://www.sojamo.de/oscP5
* modified by Kasper Kamperman
* OSC explanation video: https://youtu.be/0uOR2idKvrM
*/
import oscP5.*;
import netP5.*;
@kasperkamperman
kasperkamperman / oscP5receiver.pde
Created January 10, 2016 15:54
Example for OSC explanation video: https://youtu.be/0uOR2idKvrM
/**
* OSC receive program
* Uses OscP5 library
* OSC explanation video: https://youtu.be/0uOR2idKvrM
*/
import oscP5.*;
import netP5.*;
OscP5 oscP5;
@kasperkamperman
kasperkamperman / PhotonTimingTest.ino
Last active March 31, 2016 18:32
Test FastLED.show timing on different Particle Photon pins.
/*
Measurement of the FastLED.show() routine.
Soft SPI is only supported till now on the Photon.
However non-SPI pins seem to be 140us faster then when using the SPI pins.
Using those SPI pins in hardware design might be interesting for future compatibility
when hardware SPI gets supported.
Below the timing test of different pin combinations. The APA102 is updated at 16Mhz.
*/
@kasperkamperman
kasperkamperman / udpTimeOut.ino
Last active March 2, 2016 21:44
Particle UDP time out?
/*
When no packets are received Udp.parsePacket() takes 997us (about 1ms)
When a packet is received it takes 17us.
I think there is a timeout. It would be nice if we can set that with a function like: setTimeOut (like on Arduino with the Serial port).
I'd like to set it on microsecond level.
You can try this script by sending for example OSC data (I used TouchOSC).
When you receive data it displays a '/' (first character in an OSC string).