Send XY data every 30 ms

parent 0261f1fe
...@@ -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.91", version: "0.0.93",
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,
......
...@@ -42,7 +42,7 @@ let XyPanel = { ...@@ -42,7 +42,7 @@ let XyPanel = {
} }
}); });
that.timer = setInterval( function() { that.send_value(that.xy.values); }, 10); that.timer = setInterval( function() { that.send_value(that.xy.values); }, 30);
a.background = 'black'; a.background = 'black';
a.add(that.xy); a.add(that.xy);
...@@ -59,20 +59,17 @@ let XyPanel = { ...@@ -59,20 +59,17 @@ let XyPanel = {
send_value(values) { send_value(values) {
let d = new Date(); let x = Math.round(200 * (values[0].x - 0.5) * 3.14) / 100;
if (d.getTime() % 5 == 0) { let y = Math.round(200 * (values[0].y - 0.5) * 3.14) / 100;
let x = Math.round(200 * (values[0].x - 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));
}
......
Markdown is supported
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