-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_html.h
128 lines (112 loc) · 3 KB
/
index_html.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
static const char PROGMEM INDEX_HTML[] = R"rawliteral(
<!DOCTYPE html>
<html>
<title>Hi Res MIDI CC</title>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.slidecontainer {
width: 100%;
}
.slider {
-webkit-appearance: none;
width: 100%;
height: 100px;
background: #d3d3d3;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider:hover {
opacity: 1;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 100px;
height: 100px;
background: #04AA6D;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 100px;
height: 100px;
background: #04AA6D;
cursor: pointer;
}
</style>
</head>
<body>
<h1>HiRes CC Slider</h1>
<div class="slidecontainer">
<input type="range" min="0" max="16383" value="8192" class="slider" id="modulation">
<p>Modulation: <span id="modulation_value"></span></p>
<input type="range" min="0" max="16383" value="8192" class="slider" id="volume">
<p>Volume: <span id="volume_value"></span></p>
</div>
<script>
const WS_OPEN = 1;
const WS_CLOSED = 3;
var websock;
var websockQueue = [];
var connected = false;
function websock_send(json) {
if (websock.readyState === WS_OPEN) {
websock.send(json);
} else {
if (websock.readyState === WS_CLOSED) {
websock = new WebSocket('ws://' + window.location.hostname + ':81/');
}
websockQueue.push(json);
}
}
var slider = document.getElementById("modulation");
var output = document.getElementById("modulation_value");
output.innerHTML = slider.value;
slider.oninput = function() {
websock_send(JSON.stringify({name:this.id, hrcc_value:parseInt(this.value, 10)}));
output.innerHTML = this.value;
}
var volume = document.getElementById("volume");
var volume_value = document.getElementById("volume_value");
volume_value.innerHTML = volume.value;
volume.oninput = function() {
websock_send(JSON.stringify({name:this.id, hrcc_value:parseInt(this.value, 10)}));
volume_value.innerHTML = this.value;
}
//var pitchbend = document.getElementById("pitchbend");
//var pb_value = document.getElementById("pb_value");
//pb_value.innerHTML = pitchbend.value;
//
//pitchbend.oninput = function() {
// websock_send(JSON.stringify({name:this.id, hrcc_value:parseInt(this.value, 10)}));
// pb_value.innerHTML = this.value;
//}
function start() {
websock = new WebSocket('ws://' + window.location.hostname + ':81/');
websock.onopen = function(evt) {
console.log('websock onopen', evt);
connected = true;
for (var i = 0; i < websockQueue.length; i++) {
websock.send(websockQueue[i]);
}
websockQueue = [];
};
websock.onclose = function(evt) {
console.log('websock onclose', evt);
connected = false;
};
websock.onerror = function(evt) {
console.log('websock onerror', evt);
connected = false;
};
websock.onmessage = function(evt) {
console.log('websock onmessage', evt);
};
}
document.addEventListener("DOMContentLoaded", start);
</script>
</body>
</html>
)rawliteral";