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

scale orientation values

parent 78f998db
......@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def project do
[app: :grains,
version: "0.0.52",
version: "0.0.53",
elixir: "~> 1.2",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
......
......@@ -64,11 +64,11 @@ let AccelerationPanel = {
return Math.round( 60 * (i- 0.5) ) / 10;
});
if (!_.isEqual(scaled, this.old_values)) {
console.log(scaled);
let payload = {z: scaled[0]};
this.accelerationChannel.push("acceleration", payload)
.receive("error", e => console.log(e));
if (scaled[0] > 0) {
this.accelerationChannel.push("acceleration", payload)
.receive("error", e => console.log(e));
}
this.old_values = scaled;
}
......
......@@ -7,7 +7,7 @@ let OrientationPanel = {
sliders: {},
slider_titles: ["pitch", "roll"],
old_values: [0,0,0,0],
old_values: [0,0],
init(socket, domId) {
......@@ -65,9 +65,12 @@ let OrientationPanel = {
},
send_value(values) {
values[0] = ((values[0] - 0.3) / 0.7) - 0.5; // scale to normal movement range
values[1] = Math.pow((values[1] - 0.5), 3) * 8; // prefer larger amounts
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);
return Math.round(20 * i * Math.PI) / 10; // parseInt(i * 127);
});
if (!_.isEqual(scaled, this.old_values)) {
// console.log(scaled);
......
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