-
Notifications
You must be signed in to change notification settings - Fork 1
/
move.html
34 lines (30 loc) · 931 Bytes
/
move.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<pre id='log'>
</pre>
<script src="/socket.io/socket.io.js"></script>
<script src="/js/nxt.js"></script>
<script>
var logEl = document.getElementById('log');
function log(msg) {
if (logEl) {
logEl.textContent = msg + "\n" + logEl.textContent;
}
}
///////////////////////////////////////////////////////////////
function play(e) {
e.preventDefault();
log("Turning motor A through 760 degrees");
// port, power, mode, reg_mode, turn_ratio, run_state, tacho_limit
nxt.set_output_state(nxt.MOTOR_A, 100, nxt.MOTORON, nxt.REGULATION_MODE_IDLE, 0, nxt.MOTOR_RUN_STATE_RUNNING, 760)
window.onmousemove = play;
}
function stop() {
window.onmousemove = null;
}
window.onmousedown = play;
window.onmouseup = stop;
///////////////////////////////////////////////////////////////
log("Connecting");
socket.on('welcome', function (data) {
log('Connected');
});
</script>