-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlight.txt
More file actions
1004 lines (954 loc) · 29.2 KB
/
light.txt
File metadata and controls
1004 lines (954 loc) · 29.2 KB
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
Page light
Attributes
ID : 0
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
Width : 480
Effect : load
Effect Priority : 0
Effect Time : 300
Locked : no
Swide up page ID : disabled
Swide down page ID : disabled
Swide left page ID : disabled
Swide right page ID: disabled
Fill : solid color
Back. Color : 0
Events
Preinitialize Event
dim=brightness
if(api==0)
{
page home_page_id
}else
{
vis light_b_press,1
vis lightslider,1
vis light_value,1
// #### OFF Button #####
vis temp_b_press,0
vis color_b_pres,0
// #### OFF Value #####
vis temp_value,0
vis light_value_2,0
// #### OFF Slider #####
vis tempslider,0
vis colorwheel,0
// #### Hide color & temp buttons #####
vis temp_touch,0
vis temp_value_2,0
vis temp_button,0
vis color_touch,0
vis color_button,0
}
button_back.font=button_back_font
sendme
Variable (int32) rgb565
Attributes
ID : 22
Scope: local
Value: 0
Variable (string) va1
Attributes
ID : 23
Scope : local
Text : newtxt
Max. Text Size: 20
Variable (string) va2
Attributes
ID : 24
Scope : local
Text : newtxt
Max. Text Size: 10
Variable (string) va3
Attributes
ID : 25
Scope : local
Text : newtxt
Max. Text Size: 10
Variable (int32) currenttab
Attributes
ID : 26
Scope: local
Value: 0
Variable (string) lightsetting
Attributes
ID : 30
Scope : local
Text :
Max. Text Size: 255
Number ring
Attributes
ID : 4
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 6
y coordinate : 150
Width : 21
Height : 40
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 1
Back. Color : 0
Font Color : 0
Horizontal Alignment : right
Vertical Alignment : center
Value : 0
Significant digits shown: all
Format : decimal
Word wrap : enabled
Horizontal Spacing : 0
Vertical Spacing : 0
Number field
Attributes
ID : 5
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 30
y coordinate : 150
Width : 21
Height : 40
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 1
Back. Color : 0
Font Color : 0
Horizontal Alignment : right
Vertical Alignment : center
Value : 0
Significant digits shown: all
Format : decimal
Word wrap : enabled
Horizontal Spacing : 0
Vertical Spacing : 0
Text light_value
Attributes
ID : 1
Scope : local
Dragging : 0
Send Component ID : disabled
Opacity : 127
x coordinate : 164
y coordinate : 43
Width : 83
Height : 20
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 2
Back. Color : 0
Font Color : 65535
Horizontal Alignment: center
Vertical Alignment : center
Input Type : character
Text :
Max. Text Size : 10
Word wrap : disabled
Horizontal Spacing : 0
Vertical Spacing : 0
Text page_label
Attributes
ID : 2
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 48
y coordinate : 8
Width : 300
Height : 30
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 2
Back. Color : 0
Font Color : 65535
Horizontal Alignment: left
Vertical Alignment : center
Input Type : character
Text :
Max. Text Size : 100
Word wrap : disabled
Horizontal Spacing : 0
Vertical Spacing : 0
Text temp_value
Attributes
ID : 14
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 164
y coordinate : 43
Width : 83
Height : 20
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 2
Back. Color : 0
Font Color : 65535
Horizontal Alignment: center
Vertical Alignment : center
Input Type : character
Text :
Max. Text Size : 10
Word wrap : disabled
Horizontal Spacing : 0
Vertical Spacing : 0
Text light_value_2
Attributes
ID : 27
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 331
y coordinate : 86
Width : 50
Height : 20
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 2
Back. Color : 0
Font Color : 65535
Horizontal Alignment: right
Vertical Alignment : center
Input Type : character
Text :
Max. Text Size : 10
Word wrap : disabled
Horizontal Spacing : 0
Vertical Spacing : 0
Text temp_value_2
Attributes
ID : 28
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 331
y coordinate : 151
Width : 50
Height : 20
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 2
Back. Color : 0
Font Color : 65535
Horizontal Alignment: right
Vertical Alignment : center
Input Type : character
Text :
Max. Text Size : 10
Word wrap : disabled
Horizontal Spacing : 0
Vertical Spacing : 0
Text icon_state
Attributes
ID : 29
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 12
y coordinate : 8
Width : 35
Height : 35
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 8
Back. Color : 0
Font Color : 65535
Horizontal Alignment: center
Vertical Alignment : center
Input Type : character
Text :
Max. Text Size : 10
Word wrap : disabled
Horizontal Spacing : 0
Vertical Spacing : 0
Text power_button
Attributes
ID : 32
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 15
y coordinate : 255
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : solid color
Style : flat
Associated Keyboard : none
Font ID : 10
Back. Color : 0
Font Color : 59196
Horizontal Alignment: center
Vertical Alignment : center
Input Type : character
Text : \xee\x90\xa4
Max. Text Size : 3
Word wrap : disabled
Horizontal Spacing : 0
Vertical Spacing : 0
Events
Touch Release Event
power_button.pco=31
Picture light_button
Attributes
ID : 8
Scope : local
Dragging : 0
Send Component ID: disabled
Opacity : 127
x coordinate : 389
y coordinate : 74
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Picture ID : 22
Picture color_button
Attributes
ID : 9
Scope : local
Dragging : 0
Send Component ID: disabled
Opacity : 127
x coordinate : 389
y coordinate : 201
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Picture ID : 26
Picture temp_button
Attributes
ID : 10
Scope : local
Dragging : 0
Send Component ID: disabled
Opacity : 127
x coordinate : 389
y coordinate : 138
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Picture ID : 24
Picture light_b_press
Attributes
ID : 11
Scope : local
Dragging : 0
Send Component ID: disabled
Opacity : 127
x coordinate : 389
y coordinate : 74
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Picture ID : 23
Picture temp_b_press
Attributes
ID : 12
Scope : local
Dragging : 0
Send Component ID: disabled
Opacity : 127
x coordinate : 389
y coordinate : 138
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Picture ID : 25
Picture color_b_pres
Attributes
ID : 13
Scope : local
Dragging : 0
Send Component ID: disabled
Opacity : 127
x coordinate : 389
y coordinate : 201
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Picture ID : 27
Picture colorwheel
Attributes
ID : 16
Scope : local
Dragging : 0
Send Component ID: on press and release
Opacity : 127
x coordinate : 106
y coordinate : 68
Width : 200
Height : 200
Effect : load
Effect Priority : 0
Effect Time : 300
Picture ID : 17
Events
Touch Press Event
// Circular Color Picker for Nextion (c) Max Zuidberg 2022
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Put this code in the touch press or release
// event of the pic component with the color wheel.
// Requires the two variables field.val and ring.val
//
// sya0 = x, sya1 = sya1
// Note the usage of the hidden sya0, sya1 variables
// within event code as local, temporary variable is fine.
sya0=tch0
sya1=tch1
//
// Convert absolute coordinates to coordinates relative to
// the color wheel center.
// sys0 = x_center, sys1 = y_center
sys0=colorwheel.w/2
sys0+=colorwheel.x
sys1=colorwheel.h/2
sys1+=colorwheel.y
sya0-=sys0
sya1-=sys1
//
// Determine ring
ring.val=0
// sys0 = r^2 = x^2 + y^2
sys0=sya0*sya0
sys1=sya1*sya1
sys0+=sys1
// repeat for all rings
if(sys0>=156)
{
ring.val++
}
if(sys0>=625)
{
ring.val++
}
if(sys0>=1406)
{
ring.val++
}
if(sys0>=2500)
{
ring.val++
}
if(sys0>=3906)
{
ring.val++
}
if(sys0>=5625)
{
ring.val++
}
if(sys0>=7656)
{
ring.val++
}
//
// Determine quadrant (0-3). Note: pixel y coords are inverted
// compared to mathematical y coords. But we want math. quadrants.
sya1*=-1
sys2=0
if(sya1<0)
{
sys2+=2
}
sys0=sya0*sya1
if(sys0<0)
{
sys2+=1
// In this case we also want to swap x and y otherwise the
// atan(abs(x/y)) (calculated below) gives values running
// "the wrong way" (cw instead of ccw).
sys1=sya1
sya1=sya0
sya0=sys1
}
//
field.val=sys2*6
//
// x,y sign is not required anymore
if(sya0<0)
{
sya0*=-1
}
if(sya1<0)
{
sya1*=-1
}
//
// Determine field in ring quadrant
// Factor 100000 chosen more or less arbitrarily.
// sys0 = 100000 * tan_a = 100000 * y / x
sys0=100000*sya1
sys0/=sya0
// repeat for all fields
if(sys0>=26794)
{
field.val++
}
if(sys0>=57735)
{
field.val++
}
if(sys0>=99999)
{
field.val++
}
if(sys0>=173205)
{
field.val++
}
if(sys0>=373205)
{
field.val++
}
covx r,va1.txt,0,0
covx g,va2.txt,0,0
covx b,va3.txt,0,0
va1.txt=""
va2.txt=""
va3.txt=""
Touch Release Event
// Adjust field.val "orientation" and offset to match the h value of the colors in the wheel
h=23-field.val// 0 <= field.val <= 23
// h is expected to be 0-6*256 (see hsv2rgb)
h*=6*256
h/=24// Number of fields
//
// s is expected to be 0-256 (see hsv2rgb)
s=ring.val*256
s/=8// Number of rings
// no "value" selectable; fix it to the maximum (matching the colors in the wheels shown.
v=255
click hsv2rgb,0
click rgb888to565,0
//colPreview.bco=rgb565.val
covx r,va1.txt,0,0
covx g,va2.txt,0,0
covx b,va3.txt,0,0
lightsetting.txt="light,rgb_color,"+va1.txt+","+va2.txt+","+va3.txt
printh 92
prints "localevent",0
printh 00
prints lightsetting.txt,0
printh 00
printh FF FF FF
va1.txt=""
va2.txt=""
va3.txt=""
Slider lightslider
Attributes
ID : 3
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 164
y coordinate : 67
Width : 85
Height : 235
Effect : load
Effect Priority : 0
Effect Time : 300
Direction : vertical
Fill : image
Cursor width : auto
Cursor height : 255
Back. Picture ID : 28
Slided Back. Picture ID: 29
Position : 0
Upper range limit : 100
Lower range limit : 0
Events
Touch Release Event
covx lightslider.val,va1.txt,0,0
light_value.txt=va1.txt+"%"
light_value_2.txt=va1.txt+"%"
lightsetting.txt="light,brightness_pct,"+va1.txt
printh 92
prints "localevent",0
printh 00
prints lightsetting.txt,0
printh 00
printh FF FF FF
Touch Move Event
covx lightslider.val,va1.txt,0,0
light_value.txt=va1.txt+"%"
light_value_2.txt=va1.txt+"%"
Slider tempslider
Attributes
ID : 15
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 164
y coordinate : 67
Width : 85
Height : 235
Effect : load
Effect Priority : 0
Effect Time : 300
Direction : vertical
Fill : image
Cursor width : auto
Cursor height : 255
Back. Picture ID : 21
Slided Back. Picture ID: 21
Position : 0
Upper range limit : 2000
Lower range limit : 6535
Events
Touch Release Event
covx tempslider.val,va1.txt,0,0
temp_value.txt=va1.txt
temp_value.txt+="K"
temp_value_2.txt=va1.txt
temp_value_2.txt+="K"
lightsetting.txt="light,color_temp_kelvin,"+va1.txt
printh 92
prints "localevent",0
printh 00
prints lightsetting.txt,0
printh 00
printh FF FF FF
Touch Move Event
covx tempslider.val,va1.txt,0,0
temp_value.txt=va1.txt
temp_value.txt+="K"
temp_value_2.txt=va1.txt
temp_value_2.txt+="K"
Button button_back
Attributes
ID : 31
Scope : local
Dragging : 0
Send Component ID : on press and release
Opacity : 127
x coordinate : 385
y coordinate : 0
Width : 95
Height : 48
Effect : load
Effect Priority : 0
Effect Time : 300
Fill : crop image
Font ID : 8
Cropped Back. Picture ID (Unpressed): 0
Back. Picture ID (Pressed) : 65535
Cropped Back. Picture ID (Pressed) : 0
Horizontal Alignment : center
Vertical Alignment : top
State : unpressed
Text : \xee\x85\x98
Max. Text Size : 3
Word wrap : disabled
Horizontal Spacing : 0
Vertical Spacing : 0
Events
Touch Press Event
page back_page_id
Hotspot hsv2rgb
Attributes
ID : 6
Scope : local
Dragging : 0
Send Component ID: on press and release
Opacity : 127
x coordinate : 5
y coordinate : 102
Width : 40
Height : 20
Effect : load
Effect Priority : 0
Effect Time : 300
Events
Touch Release Event
// https://de.wikipedia.org/wiki/HSV-Farbraum#Umrechnung_HSV_in_RGB
// The values range from 0..255 instead of 0..1
// h ranges from 0..(6*256)
if(s>=256)
{
s=255
}else if(s<0)
{
s=0
}
if(v>=256)
{
v=255
}else if(v<0)
{
v=0
}
f=h&0xff
p=256-s
p*=v
p=p>>8// / 256
q=s*f// 0-256*256 = 0-65536
q=65536-q
q*=v
q=q>>16
t=256-f
t*=s
t=65536-t
t*=v
t=t>>16
//
f=h>>8
if(f==1)
{
r=q
g=v
b=p
}else if(f==2)
{
r=p
g=v
b=t
}else if(f==3)
{
r=p
g=q
b=v
}else if(f==4)
{
r=t
g=p
b=v
}else if(f==5)
{
r=v
g=p
b=q
}else
{
r=v
g=t
b=p
}
Hotspot rgb888to565
Attributes
ID : 7
Scope : local
Dragging : 0
Send Component ID: on press and release
Opacity : 127
x coordinate : 5
y coordinate : 124
Width : 40
Height : 20
Effect : load
Effect Priority : 0
Effect Time : 300
Events
Touch Release Event
r=r&0xff
g=g&0xff
b=b&0xff
sys1=r>>3
sys2=sys1<<6
sys1=g>>2
sys2+=sys1
sys2=sys2<<5
sys1=b>>3
sys2+=sys1
rgb565.val=sys2
Hotspot light_touch
Attributes
ID : 17
Scope : local
Dragging : 0
Send Component ID: on press and release
Opacity : 127
x coordinate : 389
y coordinate : 74
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Events
Touch Press Event
vis light_b_press,1
vis lightslider,1
vis light_value,1
vis temp_value_2,1
// #### OFF Button #####
vis temp_b_press,0
vis color_b_pres,0
// #### OFF Value #####
vis temp_value,0
vis light_value_2,0
// #### OFF Slider #####
vis tempslider,0
vis colorwheel,0
Hotspot temp_touch
Attributes
ID : 18
Scope : local
Dragging : 0
Send Component ID: on press and release
Opacity : 127
x coordinate : 389
y coordinate : 138
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Events
Touch Press Event
vis temp_b_press,1
vis tempslider,1
vis temp_value,1
vis light_value_2,1
// #### OFF Button #####
vis light_b_press,0
vis color_b_pres,0
// #### OFF Value #####
vis light_value,0
vis temp_value_2,0
// #### OFF Slider #####
vis lightslider,0
vis colorwheel,0
Hotspot color_touch
Attributes
ID : 19
Scope : local
Dragging : 0
Send Component ID: on press and release
Opacity : 127
x coordinate : 389
y coordinate : 201
Width : 50
Height : 50
Effect : load
Effect Priority : 0
Effect Time : 300
Events
Touch Press Event
vis color_b_pres,1
vis colorwheel,1
vis light_value_2,1
// #### OFF Button #####
vis light_b_press,0
vis temp_b_press,0
// #### OFF Value #####
vis light_value,0
vis temp_value,0
vis temp_value_2,0
// #### OFF Slider #####
vis lightslider,0
vis tempslider,0
// #### OFF Color #####
Timer swipestore
Attributes
ID : 21
Scope : local
Period (ms): 50
Enabled : no
Events
Timer Event
swipex=tch0
swipey=tch1
TouchCap swipe
Attributes
ID : 20
Scope: local
Value: 0
Events
Touch Press Event
swipestore.en=1 // Start swipestore timer
Touch Release Event
swipestore.en=0
// Touch has ended, x
if(tch0==0)
{
swipec=swipex-tch2
// From Left to Right
if(swipec>swipedx)
{
//page
}
// Right to Left
swipec2=0-swipedx
if(swipec<swipec2)
{
//page
}
}
// Touch has ended, y
if(tch1==0)
{
swipec=swipey-tch3
// From Up to Down
if(swipec>100)
{
//page
}
// Down to Up
swipec2=0-swipedy
if(swipec<-100)
{