back to localhost
Esse commit está contido em:
+3
-2
@@ -14,11 +14,12 @@ Running the Server
|
||||
- Plugin the board
|
||||
- `python udp_server.py --json`
|
||||
- Optionally use `python udp_client.py --json` to verify data is coming through
|
||||
- Make sure you have socket.io (or run `npm install socket.io`)
|
||||
- Run `npm install` to make sure you have the dependencies
|
||||
- Run `node socket_server.js`
|
||||
- Visit [http://localhost:8880](http://localhost:8880) to see your brain waves
|
||||
- Visit [http://127.0.0.1:8880](http://127.0.0.1:8880) to see your brain waves
|
||||
- Optionally use `python socket_client.py` to view the Web Socket data coming back into Python (requires socketio-client)
|
||||
|
||||
Running the Python server/client without the --json flag will cause the OpenBCISample object to be used as the data transmission mechanism. This is for people that want to do some processing in Python.
|
||||
|
||||
Dependency List
|
||||
--------------
|
||||
|
||||
+107
-4
@@ -1,7 +1,110 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
|
||||
svg {
|
||||
font: 10px sans-serif;
|
||||
}
|
||||
|
||||
.line {
|
||||
fill: none;
|
||||
stroke: #000;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
|
||||
.axis path,
|
||||
.axis line {
|
||||
fill: none;
|
||||
stroke: #000;
|
||||
shape-rendering: crispEdges;
|
||||
}
|
||||
|
||||
</style>
|
||||
<body>
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="http://d3js.org/d3.v3.min.js"></script>
|
||||
<script>
|
||||
var socket = io.connect('http://10.0.1.194');
|
||||
socket.on('openbci', function (data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
function Wave() {
|
||||
var n = 200;
|
||||
this.data = d3.range(n).map(function () { return 0; });
|
||||
|
||||
var margin = {top: 0, right: 20, bottom: 0, left: 40},
|
||||
width = 960 - margin.left - margin.right,
|
||||
height = 100 - margin.top - margin.bottom;
|
||||
|
||||
this.x = d3.scale.linear()
|
||||
.domain([0, n - 1])
|
||||
.range([0, width]);
|
||||
var x = this.x;
|
||||
|
||||
var y = d3.scale.linear()
|
||||
.domain([-2000000, 2000000])
|
||||
.range([height, 0]);
|
||||
|
||||
this.line = d3.svg.line()
|
||||
.x(function(d, i) { return x(i); })
|
||||
.y(function(d, i) { return y(d); });
|
||||
|
||||
var svg = d3.select("body").append("svg")
|
||||
.attr("width", width + margin.left + margin.right)
|
||||
.attr("height", height + margin.top + margin.bottom)
|
||||
.append("g")
|
||||
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
||||
|
||||
svg.append("defs").append("clipPath")
|
||||
.attr("id", "clip")
|
||||
.append("rect")
|
||||
.attr("width", width)
|
||||
.attr("height", height);
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "x axis")
|
||||
.attr("transform", "translate(0," + y(0) + ")")
|
||||
.call(d3.svg.axis().scale(this.x).orient("bottom"));
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "y axis")
|
||||
.call(d3.svg.axis().scale(y).orient("left"));
|
||||
|
||||
this.path = svg.append("g")
|
||||
.attr("clip-path", "url(#clip)")
|
||||
.append("path")
|
||||
.datum(this.data)
|
||||
.attr("class", "line")
|
||||
.attr("d", this.line);
|
||||
}
|
||||
|
||||
Wave.prototype.sample = function(s) {
|
||||
this.data.push(s);
|
||||
// redraw the line, and slide it to the left
|
||||
this.path
|
||||
.attr("d", this.line)
|
||||
.attr("transform", null)
|
||||
.transition()
|
||||
.duration(10)
|
||||
.ease("linear")
|
||||
.attr("transform", "translate(" + this.x(-1) + ",0)");
|
||||
|
||||
// pop the old data point off the front
|
||||
this.data.shift();
|
||||
};
|
||||
|
||||
var waves = [];
|
||||
for (var i = 0; i < 8; i++) {
|
||||
waves.push(new Wave());
|
||||
}
|
||||
|
||||
var process = 1;
|
||||
|
||||
var socket = io.connect('http://127.0.0.1');
|
||||
socket.on('openbci', function (sample) {
|
||||
if (process % 3 == 0) {
|
||||
for (var i = 0; i < 8; i++) {
|
||||
waves[i].sample(sample[i])
|
||||
}
|
||||
process = 1;
|
||||
}
|
||||
process++;
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "openbci",
|
||||
"version": "0.0.1",
|
||||
"description": "A Python and Node.js warpper around OpenBCI",
|
||||
"main": "socket_server.js",
|
||||
"dependencies": {
|
||||
"socket.io": "^0.9.16",
|
||||
"node-static": "^0.7.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"socket.io": "0.9.16"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/theRealWardo/Python_OpenBCI.git"
|
||||
},
|
||||
"keywords": [
|
||||
"OpenBCI",
|
||||
"brain",
|
||||
"EEG"
|
||||
],
|
||||
"author": "Matt Ward",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/theRealWardo/Python_OpenBCI/issues"
|
||||
},
|
||||
"homepage": "https://github.com/theRealWardo/Python_OpenBCI"
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ var io = require('socket.io');
|
||||
|
||||
var UDP_HOST = '127.0.0.1',
|
||||
UDP_PORT = 8888,
|
||||
SERVER_HOST = '10.0.1.194',
|
||||
SERVER_HOST = '127.0.0.1',
|
||||
SERVER_PORT = 8880,
|
||||
HTDOCS_PATH = '/htdocs';
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário