-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTML_settings.htm
1193 lines (1046 loc) · 33.8 KB
/
HTML_settings.htm
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// comments has to be "..../**comment*/...." "....<!--comment-->...." "....space//comment" to be cleaned by "HTML to h clean.py"
//http://192.168.4.1/pwm?pv=5v0t14v1023t16v1013t43v92t55v33t96T98 without leading zeroes
//!!
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#ifdef use_ESP32
#define bb "true"
#else
#define bb "false"
#endif
//assing constants
#define constantScript2 "*/ gNum_leds="STR(NUM_LEDS)";bESP32="bb";/*"
//#define constantScript "gNum_leds="STR(NUM_LEDS)";bESP32="bb";"
//there are LIMIT OF RAM and 22kb of this file now
const String str = R"HTM(
<!DOCTYPE html><html>
<head>
<style>
html {
text-align:center;
font-size: 1.5vh;
}
* {
/** font-size: 2vh;*/
font-family: Arial;
text-decoration: none;
}
.bgGr {background-color: #ccccdd; padding-top: 0.8vh; padding-bottom: 0.5rem;}
.bgOr {background-color: #ffeeaa; padding-top: 0.8vh; padding-bottom: 0.5rem;}
.divLin{
height:3px;
background-color:#aa0033;
transform-origin:left 50%;
position:absolute;
}
.tc{
text-align:center;
font-size: 3vh;
}
.pwm_p{
position: absolute;
width:6vh; height:6vh;
border-radius:5vh;
border:#aaff00;
/*border: 2px solid #aaff00;*/ /*73AD21*/
line-height: 6vh;
/**
display: table-cell;
vertical-align: middle;
*/
user-select: none;
text-align:center;
}
/**
.contn{
position: relative;
background-color: red;
}
*/
input[type=range] {
width: 100%;
-webkit-appearance: none;
/**margin: 0;*/
}
/**
input[type=range]:focus {
outline: none;
}*/
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 19px;
cursor: pointer;
box-shadow: 0 4px 4px rgba(0,0,0,0.3) inset;
border-radius: 20px;
border: 0.2px solid #010101;
}
input[type=range]::-webkit-slider-thumb {
box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
border: 1px solid #000000;
height: 20px;
width: 20px;
border-radius: 20px;
background: white;
cursor: pointer;
-webkit-appearance: none;
margin-top: -1px;
}
.grad2 input[type=range]::-webkit-slider-runnable-track {
/** background: linear-gradient(to right, #005fc2, #35A834 40%, #ffd400 65%, #FF6400);
background: #ff0000;*/
background: -moz-linear-gradient(right, #ff0000 0%, #fcf535 19%, #fcf535 19%, #00ff19 36%, #38ffee 52%, #0011ff 69%, #ff00fa 85%, #ff0004 100%);
background: -webkit-linear-gradient(right, #ff0000 0%,#fcf535 19%,#fcf535 19%,#00ff19 36%,#38ffee 52%,#0011ff 69%,#ff00fa 85%,#ff0004 100%);
background: linear-gradient(to right, #ff0000 0%,#fcf535 19%,#fcf535 19%,#00ff19 36%,#38ffee 52%,#0011ff 69%,#ff00fa 85%,#ff0004 100%);
/* filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff0000', endColorstr='#ff0004',GradientType=1 );*/
}
.tst {font-size:0.7rem; text-align: left;}
.rOptItem a {
padding: 8px 8px 8px 32px;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sett_item {
/*margin-bottom: -13px;*/
padding: 10px;
}
.ib { color:#00f;}
.ir { color:#f00;}
.ix { color:#ccc;}
.settNm {margin: -10px;}
h2 {color: #55acee; font-size: 1.4rem; margin: 0.8rem;}
h3 {color: #444444;font-size: 1.3rem; margin: 0.8rem;}
h4 {color: #444444;font-size: 0.8rem; margin: 0;}
i {font-size: 0.4rem;}
.sett_item p {display: inline ; background-color:#7df2e6; color: white; padding:0.3rem 2rem; color:#1379c5;} /** bg #34eedb c #085c9b #55acee 227cae 6px 24px;*/
.sett_item p.odd {padding: 0.3rem 6rem;}
a.btS {padding:0.3rem 0.7rem; margin: 4px 4px; font-size: 1rem; background-color: #aa55ff; } /**0.3rem 0.7rem;*/
a.btL {padding:0.3rem 0.7rem; margin: 4px 4px; font-size: 1rem;} /**34ffaa*/ /**0.3rem 0.7rem;*/
.bt {background-color: #3498db; color: white; padding: 0.7rem 1.1rem; border-radius: 0.4rem;} /** square btn + - around sett_item*/
.bt:hover {background-color: #aabb00; cursor:pointer;}
.on {background-color: #3498db;}
.on:active {background-color: #2980b9;}
.off {background-color: #34495e;}
.off:active {background-color: #2c3e50;}
.na {color: #333333; background-color: #000000;}
/**@media only screen and (max-device-width : 640px) {*/
.slider{
width: 95% !important;
margin:1.5vh; /**2vh; good value, but too long*/
}
/**
}
@media screen and (min-width: 1024px){
.slider{
width: 98%;
outline: none;
opacity: 0.6;
margin: 1vh;
}
.slider:hover {
opacity: 1;
}
}
*/
.link {
color: #55acee;
border-bottom: 2px dotted #55acee;
transition: .3s;
-webkit-transition: .3s;
-moz-transition: .3s;
-o-transition: .3s;
}
.link:hover {
color: #2ecc71;
border-bottom: 2px dotted #2ecc71;
}
.btn {
border-radius: 5px;
padding: 6px 10px;
/** font-size: 16px;*/
margin: 3px;
color: #fff;
position: relative;
display: inline-block;
}
.btn:active {
transform: translate(0px, 5px);
-webkit-transform: translate(0px, 5px);
box-shadow: 0px 1px 0px 0px;
}
.blue {
background-color: #55acee;
box-shadow: 0px 5px 0px 0px #3C93D5;
}
.blue:hover {
background-color: #6FC6FF;
}
.green {
background-color: #2ecc71;
box-shadow: 0px 5px 0px 0px #15B358;
}
.green:hover {
background-color: #48E68B;
}
.lime {
background-color: lime;
box-shadow: 0px 5px 0px 0px #15B358;
}
.lime:hover {
background-color: #88E68B;
}
.brown {
background-color: #98664B;
box-shadow: 0px 5px 0px 0px #483622;
}
.brown:hover {
background-color: #78864B;
}
.red {
background-color: #e74c3c;
box-shadow: 0px 5px 0px 0px #CE3323;
}
.red:hover {
background-color: #FF6656;
}
.purple {
background-color: #9b59b6;
box-shadow: 0px 5px 0px 0px #82409D;
}
.purple:hover {
background-color: #B573D0;
}
.orange {
background-color: #e67e22;
box-shadow: 0px 5px 0px 0px #CD6509;
}
.orange:hover {
background-color: #FF983C;
}
.yellow {
background-color: #f1c40f;
box-shadow: 0px 5px 0px 0px #D8AB00;
}
.yellow:hover {
background-color: #FFDE29;
}
div.scrollmenu{
/**background-color: #333;*/
overflow: auto;
white-space: nowrap;
}
.scrollmenuFlex {
display: flex;
/**flex-direction: column;*/
flex-wrap: wrap;
}
div.scrollmenu a {
display: block; /**inline-block; for horizontal*/
color: white;
padding: 0.2rem;
margin: 0.1rem;
}
div.scrollmenu a:hover {
background-color: #777;
}
.vertical-menu {
height: 400px;
overflow-y: auto;
}
.collap {
background-color: #999;
color: white;
cursor: pointer;
padding: 0.3rem;
width: 100%;
border: none;
text-align: left;
font-size: 1rem;
margin-top: 0.2rem;
font-size: 1.7rem;
}
.collap_content.open {display: block;}
.collap_active, .collap:hover {
background-color: #655;
}
.collap_content {
display: none;
overflow: hidden;
background-color: #f1f1f1;
}
/**
.gradRainbowRB{
background: linear-gradient(
to right,
rgb(255, 90, 90) 0%,
rgb(255, 255, 90) 35%,
rgb(90, 255, 90) 50%,
rgb(90, 255, 255) 65%,
rgb(90, 90, 255) 100%
);
}
.gradBG{
background: linear-gradient(
to bottom,
rgb(222, 222, 222) 0%,
rgb(255, 222, 222) 55%,
rgb(255, 122, 122) 62%,
rgb(122, 122, 255) 100%
);
}
*/
table, td {border:1px solid/**black*/;}
.pin
{
width:60px;
height:28px;
text-align: center;
}
.pin.on
{
background-color:#ffaacc;
animation: blinker 1s step-start infinite;
/**animation-timing-function: linear;*/
}
@keyframes blinker {
50% {opacity:0;}
}
/**
@keyframes mov
{
from {left: 0px;}
to {left: 200px;}
}*/
.pin.sel{border:3px solid black;}
</style>
<script type="text/javascript">
var valElemContainers;
function $(s){return document.getElementById(s);}
function $$(s){return document.getElementsByClassName(s);}
function updValsFromServer(nmVal_str)
{
var s= nmVal_str.split("=");
/**alert(nmVal_str+ "\r\n"+ s.length+"\r\n"+s[0]+"\r\n"+s[1]+"\r\n"+String.fromCharCode(s[1]));*/
if(s.length>1)
{
valElemContainers = $$("sett_item");
for(var i=0;i<valElemContainers.length;i++)
{
if(valElemContainers[i].getAttribute("value")!=s[0]) continue;
var valElem=valElemContainers[i].getElementsByTagName('i')[0];
/**var val=String.fromCharCode(s[1]);*/
if(s[1]!=valElem.innerText)
{
valElem.innerText=s[1];
valElem.className="ir";
valElemContainers[i].getElementsByClassName("slider")[0].value=s[1];
}
else
valElem.className="ib";
}
upd_sett_lnk();
/**### TODO fill linksNames without numbers, only names in seq */
/**if(s[0]=="effN") $("eff_nm_current").innerHTML=linksNames[s[1]]; */
}
}
function request(url)
{
const xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function()
{
if (xhr.status != 200)
{
$('tst').innerHTML+="<br/>"+xhr.status;
/**alert("returned:"+xhr + "\n"+ xhr.responseText + "\r\n"+ xhr.readyState + "\r\n"+ xhr.status);*/
}
/** //not need as we send all data, and have to check difference onload
var oldActives = $$("ir");
for (var i = 0; i < oldActives.length; i++)
{
oldActives[i].className="ib";
}
*/
var ss = xhr.responseText.split(",");
for (var i = 0; i < ss.length; i++)
{
updValsFromServer(ss[i]);
}
$('tst').innerHTML+="<br/>"+xhr.responseText;
};
xhr.send();
$('tst').innerHTML=url;
/** test
var tst="effN=12,effSpeed=6";
var ss = tst.split(",");
for (var i = 0; i < ss.length; i++)
{
updValsFromServer(ss[i]);
}
$('tst').innerHTML+=tst;
*/
}
/**! названия не меняются , можно сделать массив рус имен*/
/**TODO effQualityMark, eff geometry*/
/**this generated in PC serial GUI app btn_copy_switch_nms_click, based on switch_slot.h*/
const linksNames ={'fillStriped':11,'fillStriped1':12,'fillStripedFillRainbow':14,'fillStripedFillRainbow1':15,'fillByPalette':16,'fillByPalettesBlend_moving':17,'rainbow':18,'rainbowConfetti':19,'rainbowWithGlitter':20,'rainbow_beat':21,'randomBlinkRainbow':22,'randomBlinkRainbowFade':23,'rainbow_fill_slow':28,'rainbow_fill_slow1':29,'rainbow_beat1':31,'rainbow_beat2':32,'rainbowSegments_shift':33,'rainbowSegments_shift1':34,'rainbowSegments_shift2':35,'rainbowSegments_shiftSin':36,'rainbowSegments2':37,'rainbowCycle':39,'sinelon':40,'bpm':41,'juggle':42,'spawnPixel_moveAll':43,'fillFadeChangeAll':44,'fillFadeChangeAll_beat8':45,'fillFadeChangeAll_beatsin8':47,'fadeEvenUneven':48,'fadeEvenUnevenDif':49,'confetti':50,'confetti1':51,'confetti_move':52,'confetti_moveRemainFirstAdd':53,'confetti_moveRemainFirstBlend':54,'confetti_moveRemainFirstBlendByPos':55,'random_burst':56,'random_color_pop':57,'randomBlink':58,'color_bounce':62,'color_bounc_HueByPos':64,'color_bounce_multiple':65,'color_bounceFADE':66,'color_bounceFADE1':67,'CubeCornersLight':70,'CubeTest':71,'matrixCube2':72,'matrixCube':73,'movingBlendRGB':77,'pulse_one_color_all':87,'pulse_one_color_all_rev':88,'radiation':90,'Fire':96,'mover_lim_mark':101,'mover_lim_mark1':102,'beatWave':109,'confetti2':111,'confetti2_demo':112,'dot_beat':114,'dot_beat_area':115,'fill_grad':116,'inoise8_fire':117,'inoise8_mover':118,'inoise8_pal':119,'juggle_pal':120,'matrix_pal_demo':122,'matrix_ray':123,'noise16_1':124,'noise16_2':125,'noise16_3':126,'one_sine_pal_demo':128,'palettecrossfade':129,'plasma':130,'rainbow_beat2':131,'rainbow_march':132,'rainbow_march_demo':133,'sawtooth':136,'sinelon2':138,'three_sin_demo':139,'three_sin_pal_demo':140,'two_sin_pal_demo':141,'blend_test':144,'fill_colours':148,'animationA':149,'setColors_fill':151,'setColors_fill_tstRange':152,'setCurrentPalette':153,'setCurrentPalette_Test':154,'splitModeEditor':155,'confetti_density':157,'eff_sin_R_G_B':158,'eff_sin_R_G_B1':159,'eff_sin_R_G_B2':160,'waveSmooth':161,'palette_pipette':164,'test_palettes':165,'test_gradient':166,'test_blend':167,'fill_segments_anim':175,'fill_segments_anim1':176,'draw_sample':181,'soundmems_pal':201,'soundmems_noise':202,'mus_random_mov':203,'mus_random_mov1':204,'soundmems_wave':205,'soundmems_wave1':206,'soundmems_peak_ripple':207,'soundmems_fire':208,'mus_arduinoFFT':209,'mus_arduinoFFT1':210,'mus_arduinoFFT2':211,'test_easing':214,'wave_adj':215,'wave_H':216,'gen_wave_H_moveAll':217,'gen_wave_H_moveAll_blinkRand':218,'gen_wave_H_v2_moveAll_blinkRand':219,'matrix_test':220,'ems_lightsALL':224,'fillStriped2':225,'sinelon1':227,'fillStriped3':228,'fillStriped4':229,'fillStriped5':230,'random_len_cell_1':233,'random_len_cell_seemless':234,'PWM_Dimmer':239,'PinSequencer':240,'mode_switch':241,'fillStriped6':242,'fillStriped7':243,'fillStriped8':244,'fillStriped9':245,'nodo':247};
const settingNms = [];
//var arr = { "one": 1, "two": 2, "three": 3 };
//for(var key in arr)
// {
// var value = arr[key];
// document.write(key + " = " + value + '<br>');
// } //https://www.xul.fr/javascript/associative.php
function clickBtnEff(e){
//console.log(e);
//console.log(e.target);
e.preventDefault();
var link = e.target.getAttribute( "href" );
var re = /effN=(\w+)/;
var resul=re.exec(link);
if(resul!=null && resul.length>0)
{
var effnm=resul[1];
if(isNaN(effnm))// skip <a href="effN=123">
link = link.replace(effnm, linksNames[effnm]);//<a href="effN=eff1"> -to- <a href="effN=123">
}
/** linksNames[this.innerText]; */
request( "http://192.168.4.1/sett?"+link); //console.log(link);
return false;
}
function linksGenerator (container, selectNm){
for( var linkName in linksNames){
if(selectNm!=null && linkName.indexOf(selectNm)==-1) continue;
container.innerHTML+= "<a class='btn green' onmousedown='clickBtnEff(event)' href='effN="+linkName+"'>"+linkName+"</a>";
};
}
function linksGen_SL(container,sl,styl){
for(var i=0;i<10;i++)
container.innerHTML+= "<a class='"+styl+"' onmousedown='clickBtnEff(event)' href='"+sl+'='+i+"'>"+i+"</a>";
}
function setup()
{
var setts =$$("sett_item");
for(i = 0;i < setts.length; i++)
{
var settNm=setts[i].getAttribute('value');
var htm="";
var tx=setts[i].innerText;
var bEditable = tx!="-"; /** '-' is non editable or not implemented*/
if(bEditable)
htm+='<a class="sender item bt off" href="sett?'+settNm+'=0">-</a>';
var c="";
if(i%2==0) c+=" odd";
var txNew=(tx.length<3)?settNm:tx;
v='?';
//! if(settNm=="NUM_LEDS" && gNum_leds!=null)v=gNum_leds;
htm+='<p class="settNm '+c+'">'+txNew+' <i class="ix">'+v+'</i></p>';
if(bEditable)
htm+='<a class="sender item bt on" href="sett?'+settNm+'=1">+</a>';
setts[i].innerHTML=htm+'<input type="range" min="0" max="255" value="20" class="slider" oninput="showSliderVal(this);sendSliderVal(this)" onmousedown="sendSliderVal(this)">';
}
var as= $$('sender');
for(i = 0;i < as.length; i++)
{
aelem=as[i];
var link = aelem.getAttribute('href');
if(link=="effN") aelem.href=link+"="+aelem.innerText; //<a href="effN">eff1 -to- <a href="effN=eff1">eff1
//! as[i].setAttribute( "href", newstr);
as[i].onmousedown = clickBtnEff; //as[i].innerHTML+="*";
}
linksGenerator($("effs"));
linksGenerator($("effsCube"),'Cub');
linksGen_SL($("btS"),'s', 'bt btS');
linksGen_SL($("btL"),'l','bt btL green');
toggleSliders();/** hide */
var coll = $$("collap");
var i;
for (i = 0; i < coll.length; i++){
coll[i].addEventListener("mousedown", function(){
var content = this.nextElementSibling;
content.classList.toggle("open");
if (content.classList.contains("open"))this.scrollIntoView();
else window.scrollTo(0,0);
});
}
initTouch();
//$('tst').innerHTML=window.screen.availHeight+'<br/>'+window.screen.height
}
document.addEventListener('DOMContentLoaded',function(){setup();});
function touchHandler(ev)
{
var touches = ev.changedTouches,
first = touches[0],
type = "";
switch(ev.type)
{
case "touchstart": type = "mousedown"; break;
case "touchmove": type = "mousemove"; break;
case "touchend": type = "mouseup"; break;
default: return;
}
// initMouseEvent(type, canBubble, cancelable, view, clickCount,
// screenX, screenY, clientX, clientY, ctrlKey,
// altKey, shiftKey, metaKey, button, relatedTarget);
var simulatedEvent = document.createEvent("MouseEvent");
simulatedEvent.initMouseEvent(type, true, true, window, 1,
first.screenX, first.screenY,
first.clientX, first.clientY, false,
false, false, false, 0/*left*/, null);
first.target.dispatchEvent(simulatedEvent);
if (ev.cancelable) ev.preventDefault();
}
function initTouch()//!! toggle witn btn to scroll
{
document.addEventListener("touchstart", touchHandler, true);
document.addEventListener("touchmove", touchHandler, true);
document.addEventListener("touchend", touchHandler, true);
document.addEventListener("touchcancel", touchHandler, true);
}
function upd_sett_lnk(){
var el=$("sett_lnk");
/** #DOTO associative array, TODO test upd sliders pos with actual value from server after effN change */
var setts =$$("sett_item");
var str="http://192.168.4.1/sett?";
for(i = 0;i < setts.length; i++)
{
var settNm=setts[i].getAttribute("value");
var settVal=setts[i].getElementsByClassName("slider")[0].value;
str+=settNm+"="+settVal+"&";
}
el.setAttribute( "href",str );
el.innerHTML=str;
}
function showSliderVal(inp){
/**$("tst").innerHTML=inp.value;*/
}
function sendSliderVal(inp){
request('http://192.168.4.1/sett?'+inp.parentNode.getAttribute("value")+'='+inp.value);
}
function toggleSliders(){
toggleDisplay($$("slider"));
}
function toggleDisplay(els){
for (var i = 0; i < els.length; i++){
console.log(els[i].style.display)
if(els[i].style.visibility != 'hidden')
{
els[i].style.visibility = 'hidden';
els[i].style.margin = '0em';
}
else
{
els[i].style.visibility = 'visible';
els[i].style.margin = '1.5em';
}
}
/**
for (var i = 0; i < els.length; i++){
console.log(els[i].style.display)
if(els[i].style.display != 'block') els[i].style.display = 'block';
else els[i].style.display = 'none';
}*/
}
/** //toggleVisibility($$("slider"));
function toggleVisibility(els){
for (var i = 0; i < els.length; i++){
if(els[i].style.visibility != 'hidden') els[i].style.visibility = 'hidden';
else els[i].style.visibility = 'visible';
}
}
*/
</script>
</head>
<body>
<p class='tst'>
<a id="tst">test responce:</a><br/>
Current effect: <b id="eff_nm_current"></b> settings: <a id="sett_lnk">?</a>
</p>
<button type="button" class="collap">global</button>
<div class="gradRainbowRB collap_content">
<h2>HTML ws2812b control page <a href="#">v0.4</a> <a href="mailto:[email protected]?subject=2812,soft">[email protected]</a></h2>
<!-- <div class="rOpt"> --> <!--to make float -->
<p class="btn red sender rOptItem" href="P">Pause sending data</p>
<p class="btn blue rOptItem" onmousedown="toggleSliders()">togle sliders</p>
<!-- </div> -->
<!--class="bgGr" -->
<h4>show:</h3>
<div >
<a class="sender btn green" href="effN=10">N off</a>
<a class="sender btn green" href="effN=249">N random</a>
<!--<a class="sender btn green" href="effN=251">animate_to_slot1</a>-->
<a class="sender btn green" href="effN=252">animate_SW</a><br/>
<a class="sender btn green" href="effN=250">N random_demo_animated_SW</a>
<a class="sender btn green" href="effN=253">N predefined_show_seq</a><br/>
<a class="sender btn green" href="effN=254">N random_demo_fast_SW</a>
<a class="sender btn green" href="effN=255">N random_demo_SW</a><br/><br/>
</div>
<h4>map to matrix:</h3><i>Act like toggle switch, but now only one active. This post processing being applied after all:</i>
<div>
<a class="sender btn green" href="effN=242">bMap_type_matrix_zigZag_h</a>
<a class="sender btn green" href="effN=243">bMap_type_matrix_spiral_cw</a>
<a class="sender btn green" href="effN=244">bMap_type_matrix_labyrinth_cw</a>
<a class="sender btn green" href="effN=245">bMap_type_mirror_half</a>
<a class="sender btn green" href="effN=246">bMap_type_history</a>
</div>
</div>
<!--
<button type="button" class="collap">map to matrix</button>
<div class="bgGr collap_content"></div>
-->
<button type="button" class="collap">PWM dimmer</button>
<div class="gradBG collap_content open"><!--### -->
<hr/>
<!-- )HTM" constantScript2 R"HTM( -->
<table id="pcb" style="width:26vh;height:33vh"></table>
<!--
<button onmousedown="recalculate_vt_all(true)">send</button>
<button onmousedown="create_PWM_Plot()">create</button> -->
<!-- <svg id="svg" width="100%" height="50%" preserveAspectRatio="none" viewBox="0 -490 600 490"></svg> -->
<!-- <div id="svg_div"></div> -->
<div id="pwm_plot" style="position: relative; width:99%; height:400px">
<!-- 44% class="contn" -->
<!-- <div id="pwm_p0" style="position: absolute; width:20px; height20px; background-color:red">o</div> -->
<!-- <div class="pwm_p" id="pwm_m" style="background-color:ff8888">x</div> -->
<!-- <div class="pwm_p" id="pwm_M" style="background-color:#9999ff">x</div> -->
</div>
<script>
var pinClick_last;
var pwm_state=0;
var pwm_p_sel=5;//now selected pin
function pinClick()
{
if(pinClick_last!=null && pinClick_last!=this) pinClick_last.classList.remove('sel');
pinClick_last=this;
if(!this.classList.contains("sel"))
{
this.classList.add("sel");
pwm_p_sel=parseInt(this.innerHTML);
$("pinSelN").innerHTML=this.innerHTML;
}
else
{
//!! get state from MCU //https://stackoverflow.com/questions/1436438/how-do-you-set-clear-and-toggle-a-single-bit-in-javascript
var mask = 1 << parseInt(this.innerHTML);
var this_p=this.classList.toggle("on");
if(this_p)
pwm_state |= mask;
else
pwm_state &= ~mask;
request("http://192.168.4.1/pwm?pp="+pwm_state); //console.log(pwm_state)
}
}
function newP(x, y, nm){
p=$(x+"_"+y);
p.innerHTML=nm;//! '<input class="myclass" type="button" value="'+nm+'"/>' //display:inline-block;
p.onmousedown=pinClick; //onclick not work with touch tap
//p.addEventListener("click", () => { console.log("click")});
}
function fillTable(){
s="";
for(i=0;i<13;i++) //for(i=0;i<15;i++)
{
s+='<tr><td id="'+0+"_"+i+'" class="pin"/>';
if(i==0)s+='<td rowspan=13 id="pinSelN" class="tc"/>'; //15
s+='<td id="'+1+"_"+i+'" class="pin"/></tr>';
}
$('pcb').innerHTML+=s;
}
PWM_min=2;
PWM_max=4090; //## 1023
var bPWM_Plot_Exist=false;
draw_dx=100;
draw_y_mul=0.08;
var idN=0;
function createdivLine(elem, id, ax,ay, bx,by, size, opacity, color){
//var newdiv = document.createElement('div');
//newdiv.setAttribute('id', id);
//newdiv.style.height = (size||2) + "px";
//newdiv.style.background = color || "red";
//newdiv.style.opacity = opacity || 1;
//newdiv.style.transformOrigin = "left 50%";
//newdiv.style.position = "absolute";
//newdiv.className="divLin"
//elem.appendChild(newdiv);
return '<div id="'+id+'" class="divLin"></div>';
//console.log(d)
//moveDivLine(id, ax,ay, bx,by);
}
function moveDivLine(id, ax,ay, bx,by){
var length = Math.hypot(by-ay, bx-ax),
deg = Math.atan2(by-ay, bx-ax) * 180 / Math.PI;
newdiv=$(id);
newdiv.style.width = length + "px";
newdiv.style.transform = "rotate("+ deg +"deg)";
newdiv.style.left = ax + "px";
newdiv.style.top = ay + "px";
}
var p_m=0;
var p_M=9;
var p_Mlim=1023;
var pt_m=0;
var pt_M=9;
var pt_Mlim=1000;
aplot=$("pwm_plot");
function vh(v) {
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
return (v * h) / 100;
}
function vw(v) {
var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
return (v * w) / 100;
}
function dragElement(el){
var pos1=0,pos2=0,pos3=0,pos4=0;
/**
if ($(el.id + "header")){
// if present, the header is where you move the DIV from:
$(el.id + "header").onmousedown = dragMouseDown;
} else {
// otherwise, move the DIV from anywhere inside the DIV:
*/
el.onmousedown = dragMouseDown;
//}
function dragMouseDown(e){
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e){
e = e || window.event;
e.preventDefault();
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
el.style.top=(el.offsetTop-pos2)+"px";
el.style.left=(el.offsetLeft-pos1)+"px";
recalculate_vt(el);
ptN=PlotPoints[el.id];
if(ptN==0)// point of min
{
//el.innerHTML+="<br/>"+el.offsetLeft;
p_m=el.offsetTop;
pt_m=el.offsetLeft;
recalculate_vt_all(0);
}
else
if(ptN==plotPtM)// point of max
{
//el.innerHTML+="<br/>"+el.offsetLeft+" "+(el.offsetLeft-200)/(document.body.offsetWidth-20)*1000;
pwm_t_Mc=pwm_tc;
p_M=el.offsetTop; //!!probably need upd this first before save pwm_t_Mc and recalc it
pt_M=el.offsetLeft;
recalculate_vt_all(0);
}
/* //!? fix lines does not drawn on phone
else
{
var centerWx=vh(2);
if(PlotPoints[el.id]<plotPtM-1) //no connection to points of min and max
{
nm_next="pwm_p"+(PlotPoints[el.id]+1)
moveDivLine((el.id+"l"), el.offsetLeft+centerWx,el.offsetTop+centerWx, $(nm_next).offsetLeft+centerWx,$(nm_next).offsetTop+centerWx)
}
if(PlotPoints[el.id]>1)
{
nm_prev="pwm_p"+(PlotPoints[el.id]-1)
moveDivLine((nm_prev+"l"), el.offsetLeft+centerWx,el.offsetTop+centerWx, $(nm_prev).offsetLeft+centerWx,$(nm_prev).offsetTop+centerWx)
}
}
*/
//recalculate_vt_all(0); //send only on closeDragElement or every move //this slow down CPU
}
function closeDragElement(){
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
recalculate_vt_all(1);
}
}
var pwm_tc;//calculated time of current point
var pwm_t_Mc=10;//calculated time of max point == total length ms
function recalculate_vt(el){ //also store pwm_tc, that we use in last point as t Max
if((p_M-p_m)<1)p_M++;
v=Math.round((el.offsetTop-p_m)/(p_M-p_m)*p_Mlim );
v=Math.min(Math.max(v, 0), p_Mlim);//clamp
pwm_tc=Math.round((el.offsetLeft-pt_m)* ((pt_M-pt_m)/document.body.offsetWidth) );
pwm_tc=Math.min(Math.max(pwm_tc, 0), pt_Mlim);//clamp
el.innerHTML=v+"<br/>"+pwm_tc/10+"s";
return "v"+v+"t"+pwm_tc;
}
function recalculate_vt_all(bReq){
r="";//alert();
for(i=1;i<plotPtM;i++)
{
r+=recalculate_vt($("pwm_p"+i));
}
//https://arduino.stackexchange.com/questions/1013/how-do-i-split-an-incoming-string
if(bReq){
request("http://192.168.4.1/pwm?pv="+pwm_p_sel+r+"T"+pwm_t_Mc); // t/10 in MCU
//console.log(r);
}
}
//!!! min max points - set lim PWM also
PlotPoints=[];
plotPtM=6;
function createPlotPoint(){
var s="pwm_p";
strHTM=""
strHTMli=""
for(i=0;i<=plotPtM;i++)
{
nm=s+i;
c="background-color:"
if(i==0)c+="#9999ff;"
else
if(i==plotPtM)c+="#ff8888;"
else
{
c+="#ffffff;"
//strHTMli+=createdivLine(aplot,nm+"l", 20,20, 10,444);
}
PlotPoints[nm]=i;
strHTM+='<div class="pwm_p" id="'+s+i+'" style="left:'+i*vw(9)+'px;top:'+i*vh(2)+'px;'+c+'">o</div>';
}
aplot.innerHTML+=strHTMli;
$("pwm_plot").innerHTML+=strHTM;
for(i=0;i<=plotPtM;i++)
{ //console.log(nm)
nm=s+i;
dragElement($(nm));
}
}
function create_PWM_Plot(){
createPlotPoint();
//createdivLine(aplot,"a", 20,20, 10,444);
//createdivLine(a,"b", 10,10, 60,80, 5, 0.3, "#0bf");
//createdivLine(a,"c", 60,80, 70,50);
//reatediv(a,"d", 70,50, 150,90, null, null, "gold");
fillTable();
newP(0,3,10);
newP(0,4,9);
newP(1,0,16);
newP(1,1,5);
//newP(1,2,4); //! color FastLED
newP(1,3,0); //GPIO_0 //ESP-01
newP(1,4,2); //GPIO_2 //ESP-01
newP(1,7,14);
newP(1,8,12);
newP(1,9,13);
newP(1,10,15);
newP(1,11,3);
newP(1,12,1);
/**
if(!bPWM_Plot_Exist)
{
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute('style', 'border: 1px solid black');
svg.setAttribute('width', '600');
svg.setAttribute('height', '250');
svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
$("svg_div").appendChild(svg);
addLine(2,0,draw_dx,222);
appendNextLine(draw_dx,4090);
appendNextLine(draw_dx*2,444);
appendNextLine(draw_dx*3,111);
appendNextLine(draw_dx*4,2);
drawLine(0,0,800,0,"","black");
drawLine(0,-4096*draw_y_mul,800,-4096*draw_y_mul,"","black");
drawLine(0,0,0,-4096*draw_y_mul,"","black");
drawLine(0,-PWM_min*draw_y_mul,800,-PWM_min*draw_y_mul,"PWM_min","red");
drawLine(0,-PWM_max*draw_y_mul,800,-PWM_max*draw_y_mul,"PWM_max","red");
bPWM_Plot_Exist=true;
}
*/
}
/**
var ys=[];
var lines=[];
function appendNextLine(x9,y9)
{
var id=idN-1;