xxxxxxxxxx
33
// Visualization of data from EVM board:
// https://github.com/mitmedialab/TI_EVM_logger
var host = 'localhost:8080';
var socket;
var SensorValues = [];
function setup() {
createCanvas(600, 600);
socket = new WebSocket('ws://' + host);
socket.onmessage = readMessage;
}
// visualization of a circle moving in function of the data
function draw() {
background(255, 95);
x = (100 + float(SensorValues[1]) - float(SensorValues[3])) / 2;
x = map(x, 0,100, 0,width);
y = (100 + float(SensorValues[2]) - float(SensorValues[0])) / 2;
y = map(y, 0,100, 0,width);
ellipse(x,y, 30,30);
}
function readMessage(event) {
// make an array of strings (percentages):
SensorValues = split(event.data, ',');
}