Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grains
grains-web
Commits
cac71ada
Commit
cac71ada
authored
May 09, 2017
by
Jens-Christian Fischer
Browse files
scale orientation values
parent
78f998db
Changes
3
Hide whitespace changes
Inline
Side-by-side
mix.exs
View file @
cac71ada
...
...
@@ -3,7 +3,7 @@ defmodule Grains.Mixfile do
def
project
do
[
app:
:grains
,
version:
"0.0.5
2
"
,
version:
"0.0.5
3
"
,
elixir:
"~> 1.2"
,
elixirc_paths:
elixirc_paths
(
Mix
.
env
),
compilers:
[
:phoenix
,
:gettext
]
++
Mix
.
compilers
,
...
...
web/static/js/acceleration.js
View file @
cac71ada
...
...
@@ -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
;
}
...
...
web/static/js/orientation.js
View file @
cac71ada
...
...
@@ -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);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment