Skip to content

Instantly share code, notes, and snippets.

View kasperkamperman's full-sized avatar

Kasper Kamperman kasperkamperman

View GitHub Profile
@kasperkamperman
kasperkamperman / application.cpp
Created March 11, 2016 14:19
Example implementation to receive commands over TCP on your Photon running FastLED animations.
/*
Example implementation to receive commands over TCP on your Photon running FastLED animations.
FastLED is not implemented you have to do that yourself.
It makes use of this Serial cmd protocol concept:
https://gist.github.com/kasperkamperman/7e827bb481dfcdb4cb52
See this Processing sketch to send TCP Data. Modify the IPAddress to the local address of the Photon.
https://gist.github.com/kasperkamperman/1f185758519fa3131ea0
@kasperkamperman
kasperkamperman / fastled_serial_control_tcp.pde
Last active March 11, 2016 14:35
Control panel for FastLED to send command data over TCP. Modify the protocol for your own needs.
/* Use ControlP5 annotations to make a control panel for FastLED.
Uses a protocol of 12 bytes.
This sends data over TCP to your Photon:
Protocol description:
https://drive.google.com/file/d/0B3Tn6oRmh71oS3FNQ2hsODVwS1E
Particle Photon code:
https://gist.github.com/kasperkamperman/89f67f049a2ec45a5c9c
@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).
@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 / 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;
/*
* 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 / 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
@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 / 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 / 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