Skip to content

Instantly share code, notes, and snippets.

View companje's full-sized avatar

Rick Companje companje

View GitHub Profile
@companje
companje / updtest.ino
Created April 2, 2014 09:20
UDP test
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
EthernetUDP udp;
void setup() {
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x36, 0x7D }; //MAC address of Arduino Ethernet
IPAddress ip(192, 168, 2, 177); //static IP-address of Arduino Ethernet
Ethernet.begin(mac,ip);
@companje
companje / ConvexHull.cpp
Last active August 29, 2015 13:59
ConvexHull in openFrameworks
//by Rick Companje
//based on Greg Borenstein's https://github.com/atduskgreg/Processing-Convex-Hull
#include "ofMain.h"
bool lexicalComparison(const ofPoint& v1, const ofPoint& v2) {
if (v1.x > v2.x) return true;
else if (v1.x < v2.x) return false;
else if (v1.y > v2.y) return true;
else return false;
@companje
companje / ButtonMatrix.ino
Created June 10, 2014 21:45
ButtonMatrix for Arduino without resistors or multiplexer chip
const int ROWS=3;
const int COLS=5;
bool buttons[ROWS][COLS];
int rowPins[] = {2,3,4};
int colPins[] = {5,6,7,8,9};
void setup() {
Serial.begin(9600);
for (int i=0; i<ROWS; i++) {
@companje
companje / arduino-socket-server.ino
Created July 3, 2014 08:06
Arduino socket server forwarding all data received on Serial port to all connected clients
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,2, 177);
IPAddress gateway(192,168, 2, 100);
IPAddress subnet(255, 255, 255, 0);
EthernetServer server(23);
@companje
companje / gsnake.asm
Created August 25, 2014 19:33
SNAKE.COM v1.00 by Rick Companje 17/12/1996
code Segment para public 'code'
assume cs:code,ds:code,es:code
locals ; remove if you want to assemble
jumps ; with Masm
.386
org 100h
YES equ 1
NO equ 0
@companje
companje / socketserver.js
Created August 27, 2014 08:38
socketserver.js experiment
var socket = require('socket.io')
var express = require('express')
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var printer = {
id: 0,
name: "Ultimaker-F1A23B"
@companje
companje / globe.cpp
Created September 23, 2014 11:24
openFrameworks code for mouse rotating globe with conversion from quaternions to latitude longitude
#include "ofMain.h"
class ofApp : public ofBaseApp {
public:
ofImage earth;
ofQuaternion qTo;
float angle;
ofVec3f axis;
var os=require('os');
var net=require('net');
var Gpio = require("onoff").Gpio;
var networkInterfaces=os.networkInterfaces();
var port = 8081;
var sockets = [];
var cols = [
new Gpio(7, 'in', 'both'),
new Gpio(8, 'in', 'both'),
@companje
companje / bell.sh
Last active August 29, 2015 14:08
vxl bell script
#!/bin/sh
usage() {
echo "Usage: $0 { on | off | install | reset | id | listen | log | kill | learn }"
}
on() {
echo 1 >/sys/class/gpio/gpio8/value
}
@companje
companje / shuttle_start.ino
Created November 7, 2014 09:20
Script to 'press' power button on Shuttle PC SH61R4
//This code runs on MSP430 LaunchPad MSP-EXP430G2 and is compiled+uploaded with Energia
void setup() {
pinMode(P1_4,INPUT); //POWER BTN
// pinMode(P1_5,OUTPUT); //LED output
pinMode(P2_0,INPUT); //LED input
pinMode(P1_0,OUTPUT); //feedback LED1
pinMode(P1_6,OUTPUT); //feedback LED2, represents state of P2_0