Skip to content

Instantly share code, notes, and snippets.

@eightlines
eightlines / ofApp.cpp
Created June 27, 2017 15:07
Open Frameworks - Trying to implement ofSoundStream from a sub class
#include "ofApp.h"
ofApp *ofApp::_app = 0;
ofApp::ofApp() { _app = this; }
void ofApp::setup() {
}
@eightlines
eightlines / client.js
Created May 15, 2016 03:03
ofxSocketIO Communication Bug
var socket = io.connect();
var connected = false;
var connectionId = '';
socket.on('init', function (data) {
if (data.status == 'ready') {
connected = true;
connectionId = data.clientId;
document.getElementById('debug').innerHTML = 'Connected: ID ' + connectionId;
@eightlines
eightlines / LEDServo.ino
Last active August 29, 2015 14:19
Rotates a servo while fading the LEDs
#include <Streaming.h>
#include <Servo.h>
#include <Adafruit_NeoPixel.h>
Servo servo; // D9
Adafruit_NeoPixel leds = Adafruit_NeoPixel(15, 7, NEO_GRB + NEO_KHZ800);
unsigned long millisServo = 0;
unsigned long millisLed = 0;
unsigned long millisLedFade = 0;
@eightlines
eightlines / FadeCandySyphon.pde
Last active February 28, 2019 15:20
FadeCandy Syphon Display
import codeanticode.syphon.*;
OPC opc;
SyphonClient client;
PImage dot;
PImage img;
void setup() {
size(640, 360, P3D);
client = new SyphonClient(this);
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@eightlines
eightlines / NeoPixelFade
Last active August 29, 2015 13:57
A modification of ColorCrossFader from the Arduino Playground to work with Adafruit NeoPixels. This script is using a 7 pixel strip. Adjust the #define to suit.
#include <Streaming.h>
#include <Adafruit_NeoPixel.h>
#define BAUD 9600
#define LEDPIN 9
long pMillis = 0;
long interval = 5;
int fadeCallback = 0;
@eightlines
eightlines / ofApp.cpp
Created October 9, 2013 14:30
Test case for oF 0.8 escape quits app regression.
#include "ofApp.h"
void ofApp::setup(){
ofSetEscapeQuitsApp(false);
}
@eightlines
eightlines / DIMager.cpp
Created September 5, 2013 14:05
Omek Beckon SDK for Panasonic for openFrameworks
#include "DIMager.h"
DIMager::DIMager() {
motionSensor = IMotionSensor::createCameraSensor();
if (!motionSensor) cout << "Camera not found." << endl;
sensor = motionSensor->getSensor();
if(!sensor->isAlive()) cout << "Failed to initialize." << endl;
motionSensor->setVerbosityLevel(3, "log4cxx.cfg");
@eightlines
eightlines / gist:5118487
Created March 8, 2013 18:06
openFrameworks: When ofSetLineWidth is greater than 0 the corners don't line up. This script lines up the corner of the rectangle based on the Line Width.
void ofFrameRect(ofRectangle r, float lw, bool innerStroke = true) {
ofNoFill();
ofSetLineWidth(lw);
lw = ((innerStroke) ? -1 : 1) * lw / 2;
ofLine(r.x, r.y, r.x + r.width, r.y);
ofLine(r.x + r.width + lw, r.y, r.x + r.width + lw, r.y + r.height);
ofLine(r.x + r.width + lw, r.y + r.height + lw, r.x, r.y + r.height + lw);
ofLine(r.x + lw, r.y + r.height, r.x + lw, r.y + lw);
}
@eightlines
eightlines / RoboBrrdPhotoCell.ino
Created January 22, 2013 03:26
Adjusts RoboBrrd's eye color based on the ambient light within the room. The RGB-HSV Color Wheel Script by Eduardo A. Flores Verduzco provides the Color Wheel functionality. Adjust the upper and lower Photo Cell limit thresholds to manipulate the degree to which the color changes.
#include <Streaming.h>
const int r = 3; // R PIN
const int g = 5; // G PIN
const int b = 6; // B PIN
const int leds[] = {r, g, b}; // RGB PINS
const int photoCellL = A0; // LEFT PHOTOCELL
const int photoCellR = A1; // RIGHT PHOTOCELL