Commit 0261f1fe authored by Jens-Christian Fischer's avatar Jens-Christian Fischer
Browse files

XY Panel sends continous data

parent 38dbda53
...@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do ...@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def project do def project do
[app: :grains, [app: :grains,
version: "0.0.90", version: "0.0.91",
elixir: "~> 1.2", elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env), elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers, compilers: [:phoenix, :gettext] ++ Mix.compilers,
......
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
.interfacePanel { .interfacePanel {
display: block; display: block;
height: 450px; height: 400px;
width: 450px; width: 400px;
border: 1px solid blue; }
.interfacePanel_hidden {
display: none;
} }
.bpmPanel { .bpmPanel {
......
...@@ -22,6 +22,7 @@ export default class View extends MainView { ...@@ -22,6 +22,7 @@ export default class View extends MainView {
unmount() { unmount() {
super.unmount(); super.unmount();
XyPanel.stopTimer();
console.log("PlayerView unmounted"); console.log("PlayerView unmounted");
} }
......
...@@ -4,11 +4,13 @@ import _ from "underscore"; ...@@ -4,11 +4,13 @@ import _ from "underscore";
let XyPanel = { let XyPanel = {
xy: {},
xyChannel : null, xyChannel : null,
old_x: 0, old_x: 0,
old_y: 0, old_y: 0,
dot_id: 'na', dot_id: 'na',
timer: {},
init(socket, domId) { init(socket, domId) {
...@@ -27,7 +29,7 @@ let XyPanel = { ...@@ -27,7 +29,7 @@ let XyPanel = {
console.log("join xy: ", resp.dot_id); console.log("join xy: ", resp.dot_id);
that.dot_id = resp.dot_id; that.dot_id = resp.dot_id;
var a = new Interface.Panel({ background:"#000", container:document.getElementById(domId) }); var a = new Interface.Panel({ background:"#000", container:document.getElementById(domId) });
var xy = new Interface.XY({ that.xy = new Interface.XY({
childWidth: 45, childWidth: 45,
numChildren: 1, numChildren: 1,
childIds: [that.dot_id], childIds: [that.dot_id],
...@@ -36,18 +38,22 @@ let XyPanel = { ...@@ -36,18 +38,22 @@ let XyPanel = {
bounds:[0,0,1,1], bounds:[0,0,1,1],
onvaluechange: function() { onvaluechange: function() {
// just send the first array entry as we only have one dot to control // just send the first array entry as we only have one dot to control
that.send_value(this.values[0]); // that.send_value(this.values[0]);
} }
}); });
that.timer = setInterval( function() { that.send_value(that.xy.values); }, 10);
a.background = 'black'; a.background = 'black';
a.add(xy); console.log("adding xy"); a.add(that.xy);
// resp.values.forEach( (element) => { // resp.values.forEach( (element) => {
// this.setSliderValue(element); // this.setSliderValue(element);
// } ); // } );
}) })
.receive("error", reason => console.log("join failed", reason)); .receive("error", reason => console.log("join failed", reason));
console.log("adding xy"); console.log("adding xy");
}, },
...@@ -55,15 +61,15 @@ let XyPanel = { ...@@ -55,15 +61,15 @@ let XyPanel = {
let d = new Date(); let d = new Date();
if (d.getTime() % 5 == 0) { if (d.getTime() % 5 == 0) {
let x = Math.round(200 * (values.x - 0.5) * 3.14) / 100; let x = Math.round(200 * (values[0].x - 0.5) * 3.14) / 100;
let y = Math.round(200 * (values.y - 0.5) * 3.14) / 100; let y = Math.round(200 * (values[0].y - 0.5) * 3.14) / 100;
// console.log(scaled); // console.log(scaled);
let payload = {x: x, let payload = {x: x,
y: y y: y
}; };
console.log(payload); // console.log(payload);
this.xyChannel.push("xy", payload) this.xyChannel.push("xy", payload)
.receive("error", e => console.log(e)); .receive("error", e => console.log(e));
} }
...@@ -72,6 +78,11 @@ let XyPanel = { ...@@ -72,6 +78,11 @@ let XyPanel = {
}, },
stopTimer() {
clearInterval(this.timer);
}
}; };
export default XyPanel; export default XyPanel;
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
<div id="xyPanel" class="interfacePanel"></div> <div id="xyPanel" class="interfacePanel"></div>
<div id="accelerationPanel" class="interfacePanel"></div> <div id="accelerationPanel" class="interfacePanel_hidden"></div>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment