-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindexfront.html
executable file
·203 lines (195 loc) · 6.38 KB
/
indexfront.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.colorpicker{
width: 70%;
height: 200px;
padding: 16px 20px;
border: none;
border-radius: 4px;
}
.btn{
border: none;
border-radius: 4px;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 5px 2px;
cursor: pointer;
}
#grid {
display: grid;
grid-template-rows: 1fr 1fr 1fr 1fr;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 1vw;
width: 70%;
}
#grid > .btn{
font-size: 2vw;
padding: 1em;
background: #4CAF50;
text-align: center;
}
.offButton{
background: #f46161;
}
.slider {
border: none;
border-radius: 10px;
-webkit-appearance: none;
width: 70%;
height: 30px;
background: #d3d3d3;
outline: none;
opacity: 0.6;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider:hover {
opacity: 1;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
border: none;
border-radius: 15px;
width: 40px;
height: 35px;
background: #4CAF50;
cursor: pointer;
}
.slider::-moz-range-thumb {
border: none;
border-radius: 15px;
width: 40px;
height: 35px;
background: #4CAF50;
cursor: pointer;
}
</style>
</head>
<body>
<center>
LED Control:
<br/>
<p>Select color: <span id="colorLabel"></span></p>
<input type="color" id="favcolor" name="favcolor" value="#ff0000" class="colorpicker" oninput="sendRGB()">
<br/>
<p>Effect Speed (less = faster): <span id="delayLabel"></span></p>
<input class="slider" id="delayValue" type="range" min="0" max="100" step="1" oninput="sendDelay()"/>
<br/>
<p>Effect Scale: <span id="scaleLabel"></span></p>
<input class="slider" id="scaleValue" type="range" min="-8" max="8" step="1" oninput="sendScale()"/>
<br/>
<div id="grid">
<input type="button" value="Running ON" id="running" class="btn">
<input type="button" value="Rainbow Cycle ON" id="rainbowcycle" class="btn">
<input type="button" value="Fire ON" id="fire" class="btn">
<input type="button" value="Rainbow Loop ON" id="rainbowloop" class="btn">
<input type="button" value="Rainbow Loop 2 ON" id="rainbowloop2" class="btn">
<input type="button" value="Random Burst ON" id="randomburst" class="btn">
<input type="button" value="Random Color Pop ON" id="randomcolorpop" class="btn">
<input type="button" value="Rainbow Fade ON" id="rainbowfade" class="btn">
<input type="button" value="RGB Propeller ON" id="rgbpropeller" class="btn">
<input type="button" value="Color Bounce Fade ON" id="colorbouncefade" class="btn">
<input type="button" value="EMS Lights ON" id="emslights" class="btn">
<input type="button" value="Pulse ON" id="pulse" class="btn">
</div>
<br/>
<form><input type="button" value="OFF" id="offbutton" class="btn offButton"></form>
<br/>
</center>
</body>
<script>
// var connection = new WebSocket('ws://' + location.hostname + ':81/', ['arduino']);
// connection.onopen = function() {
// connection.send('Connect ' + new Date());
// };
// connection.onerror = function(error) {
// console.log('WebSocket Error ', error);
// };
// connection.onmessage = function(e) {
// console.log('Server: ', e.data);
// };
const Slider = function(id, labelId) {
this.sliderObject = document.getElementById(id)
this.sliderLabel = document.getElementById(labelId)
}
Slider.prototype.log = function(key) {
this.sliderLabel.innerHTML = this.sliderObject.value
this.sendValue = key + this.sliderObject.value
console.log(this.sendValue);
}
// Slider.prototype.send = function(key) {
// this.sliderLabel.innerHTML = this.sliderObject.value
// this.sendValue = key + this.sliderObject.value
// connection.send(this.sendValue);
// }
const colorInput = new Slider('favcolor', 'colorLabel')
const delayInput = new Slider('delayValue', 'delayLabel')
const scaleInput = new Slider('scaleValue', 'scaleLabel')
let allFxBtns = []
updateButton = (buttonObject, label, message) => {
if (buttonObject.value == label){
buttonObject.value = 'OFF'
buttonObject.style.background = '#f46161'
for(let btn of allFxBtns){
if(btn.buttonObject !== buttonObject){
btn.buttonObject.value = btn.label
btn.buttonObject.style.background = '#4caf50'
}
}
console.log(message)
// connection.send(message)
}
else{
buttonObject.value = label
buttonObject.style.background = '#4caf50'
console.log('OFF')
// connection.send('allblack')
}
}
const Button = function(id) {
this.buttonObject = document.getElementById(id)
allFxBtns.push(this)
this.label = this.buttonObject.value
this.buttonObject.addEventListener('click', () => {updateButton(this.buttonObject, this.label, id)})
}
const runButton = new Button('running')
const rainButton = new Button('rainbowcycle')
const fireButton = new Button('fire')
const rainbowloopButton = new Button('rainbowloop')
const rainbowloop2Button = new Button('rainbowloop2')
const randomburstButton = new Button('randomburst')
const randomcolorpopButton = new Button('randomcolorpop')
const rainbowfadeButton = new Button('rainbowfade')
const rgbpropellerButton = new Button('rgbpropeller')
const colorbouncefadeButton = new Button('colorbouncefade')
const emslightsButton = new Button('emslights')
const pulseButton = new Button('pulse')
function sendRGB(){
colorInput.log('');
// colorInput.send('');
}
function sendDelay(){
delayInput.log('T');
// delayInput.send('T');
}
function sendScale(){
scaleInput.log('S');
// scaleInput.send('S');
}
const offButton = document.getElementById('offbutton')
offButton.addEventListener('click', sendOff);
function sendOff() {
// connection.send('allblack')
for(let btn of allFxBtns){
btn.buttonObject.value = btn.label
btn.buttonObject.style.background = '#4caf50'
}
console.log('all off');
}
</script>
</html>