This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
74 lines (61 loc) · 1.87 KB
/
index.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<html>
<head>
<meta name="viewport" content="width=device-width" />
<link href='lcd.css' rel='stylesheet' type='text/css'>
<style>
body {
background: black;
}
.container {
top: 0;
bottom: 0;
left: 0;
right: 0;
position: absolute;
text-align: center;
color: red;
font-family: lcd;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//cdn.rawgit.com/davatron5000/FitText.js/master/jquery.fittext.js"></script>
<script src="release/stackmat.js"></script>
<script>
function msToClock(ms, showMillis) {
var div = Math.floor(ms/1000);
var min = Math.floor(div/60);
var sec = div%60;
var mils = Math.floor(ms%1000);
return min + ":" + pad(sec, 2) + "." + (showMillis ? pad(mils, 3) : pad(mils/10, 2));
}
// from http://stackoverflow.com/a/10074204
function pad(num, size) {
if (num.toString().length >= size) return num;
return ( Math.pow( 10, size ) + Math.floor(num) ).toString().substring( 1 );
}
$(document).ready(function() {
var timeArea = document.getElementById("timeArea");
Stackmat.initialize("release/fskube.js");
Stackmat.onstackmatstate = function(state) {
$("#info").text(Stackmat.getSampleRate() + "Hz");
if(state.on) {
// We seem to have issues decoding signals where both hands are down.
// This is a hack to ignore those signals and not update the timer.
$("#counter").text(msToClock(state.millis, state.generation == 3));
} else {
$("#counter").text("");
}
};
// This doesn't deal well with very long and thin viewports (we'll get a
// vertical scrollbar), but oh well.
$("#counter").fitText(0.6);
});
</script>
</head>
<body>
<div class="container">
<div id="info"></div>
<div id="counter"></div>
</div>
</body>
</html>