Commit 52cc30da authored by Jens-Christian Fischer's avatar Jens-Christian Fischer
Browse files

better scaling of Web values

parent ff759421
......@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def project do
[app: :grains,
version: "0.0.36",
version: "0.0.37",
elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
......
......@@ -51,8 +51,6 @@ let AccelerationPanel = {
this.sliders[s] = new Interface.Slider({
bounds: [(1/nrSliders) * idx, .1, 1 / nrSliders, .5],
label: s,
min: -3.0,
max: 3.0
});
a.add(this.sliders[s]);
......@@ -64,7 +62,8 @@ let AccelerationPanel = {
send_value(values) {
let scaled = values.map(function(i) {
return i;
// scale to +/- 3 to one decimal
return Math.round( 60 * (i- 0.5) ) / 10;
});
if (!_.isEqual(scaled, this.old_values)) {
console.log(scaled);
......
......@@ -64,20 +64,21 @@ let OrientationPanel = {
},
send_value(values) {
let scaled = values.map(function(i) {
return 2*(i - 0.5) * Math.PI; // parseInt(i * 127);
});
if (!_.isEqual(scaled, this.old_values)) {
// console.log(scaled);
let payload = {pitch: scaled[0],
roll: scaled[1],
yaw: scaled[2],
heading: scaled[3]
};
this.orientationChannel.push("orientation", payload)
.receive("error", e => console.log(e));
this.old_values = scaled;
}
let scaled = values.map(function(i) {
// scale to +/- Pi to one decimal
return Math.round(20*(i - 0.5) * Math.PI) / 10; // parseInt(i * 127);
});
if (!_.isEqual(scaled, this.old_values)) {
// console.log(scaled);
let payload = {pitch: scaled[0],
roll: scaled[1],
yaw: scaled[2],
heading: scaled[3]
};
this.orientationChannel.push("orientation", payload)
.receive("error", e => console.log(e));
this.old_values = scaled;
}
......
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