-
Notifications
You must be signed in to change notification settings - Fork 18
/
tiles.ts
1543 lines (1462 loc) · 58.2 KB
/
tiles.ts
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
namespace microcode {
// eventually, we should get rid of these constants and use the Tid enum
// Once a tid is assigned, it can NEVER BE CHANGED OR REPURPOSED.
// Every tid must be unique in the set of all tids.
export const TID_SENSOR_START_PAGE = "S1"
export const TID_SENSOR_PRESS = "S2"
export const TID_SENSOR_RELEASE = "S2B"
export const TID_SENSOR_ACCELEROMETER = "S3"
export const TID_SENSOR_TIMER = "S4"
export const TID_SENSOR_LIGHT = "S5"
export const TID_SENSOR_TEMP = "S6"
export const TID_SENSOR_RADIO_RECEIVE = "S7"
export const TID_SENSOR_MICROPHONE = "S8"
export const TID_SENSOR_CUP_X_WRITTEN = "S9A"
export const TID_SENSOR_CUP_Y_WRITTEN = "S9B"
export const TID_SENSOR_CUP_Z_WRITTEN = "S9C"
export const TID_SENSOR_MAGNET = "S10"
export const TID_SENSOR_SLIDER = "S11"
export const TID_SENSOR_ROTARY = "S12"
export const TID_SENSOR_CAR_WALL = "S13"
export const TID_SENSOR_LINE = "S14"
export const TID_SENSOR_LED_LIGHT = "S15"
export const TID_SENSOR_MOISTURE = "S16"
export const TID_SENSOR_DISTANCE = "S17"
export const TID_SENSOR_REFLECTED = "S18"
// filters for TID_SENSOR_PRESS
export const TID_FILTER_PIN_0 = "F0"
export const TID_FILTER_PIN_1 = "F1"
export const TID_FILTER_PIN_2 = "F2"
export const TID_FILTER_BUTTON_A = "F3"
export const TID_FILTER_BUTTON_B = "F4"
export const TID_FILTER_KITA_KEY_1 = "F5"
export const TID_FILTER_KITA_KEY_2 = "F6"
export const TID_FILTER_LOGO = "F7"
export const TID_FILTER_COIN_1 = "F8"
export const TID_FILTER_COIN_2 = "F9"
export const TID_FILTER_COIN_3 = "F10"
export const TID_FILTER_COIN_4 = "F11"
export const TID_FILTER_COIN_5 = "F12"
export const TID_FILTER_TIMESPAN_SHORT = "F13"
export const TID_FILTER_TIMESPAN_LONG = "F14"
export const TID_FILTER_LOUD = "F15"
export const TID_FILTER_QUIET = "F16"
export const TID_FILTER_ACCEL = "F17"
export const TID_FILTER_ACCEL_SHAKE = "F17_shake"
export const TID_FILTER_ACCEL_TILT_UP = "F17_tilt_up"
export const TID_FILTER_ACCEL_TILT_DOWN = "F17_tilt_down"
export const TID_FILTER_ACCEL_TILT_LEFT = "F17_tilt_left"
export const TID_FILTER_ACCEL_TILT_RIGHT = "F17_tilt_right"
export const TID_FILTER_ACCEL_FACE_UP = "F17_face_up"
export const TID_FILTER_ACCEL_FACE_DOWN = "F17_face_down"
export const TID_FILTER_TIMESPAN_RANDOM = "F18"
export const TID_FILTER_TIMESPAN_VERY_LONG = "F19"
export const TID_FILTER_CUP_X_READ = "F20A"
export const TID_FILTER_CUP_Y_READ = "F20B"
export const TID_FILTER_CUP_Z_READ = "F20C"
export const TID_FILTER_ROTARY_LEFT = "F21L"
export const TID_FILTER_ROTARY_RIGHT = "F21R"
export const TID_FILTER_TEMP_WARMER = "F22U"
export const TID_FILTER_TEMP_COLDER = "F22D"
export const TID_FILTER_LINE_LEFT = "F23L"
export const TID_FILTER_LINE_RIGHT = "F23R"
export const TID_FILTER_LINE_BOTH = "F23B"
export const TID_FILTER_LINE_NEITHER = "F23N"
export const TID_FILTER_LINE_NEITHER_LEFT = "F23NL"
export const TID_FILTER_LINE_NEITHER_RIGHT = "F23NR"
export const TID_FILTER_ON = "F24"
export const TID_FILTER_OFF = "F25"
export const TID_ACTUATOR_SWITCH_PAGE = "A1"
export const TID_ACTUATOR_SPEAKER = "A2"
export const TID_ACTUATOR_MICROPHONE = "A3" // dead but don't delete
export const TID_ACTUATOR_MUSIC = "A4"
export const TID_ACTUATOR_PAINT = "A5"
export const TID_ACTUATOR_RADIO_SEND = "A6"
export const TID_ACTUATOR_RADIO_SET_GROUP = "A6A"
export const TID_ACTUATOR_RGB_LED = "A8"
export const TID_ACTUATOR_CUP_X_ASSIGN = "A9A"
export const TID_ACTUATOR_CUP_Y_ASSIGN = "A9B"
export const TID_ACTUATOR_CUP_Z_ASSIGN = "A9C"
export const TID_ACTUATOR_SHOW_NUMBER = "A10"
export const TID_MODIFIER_PAGE_1 = "M1"
export const TID_MODIFIER_PAGE_2 = "M2"
export const TID_MODIFIER_PAGE_3 = "M3"
export const TID_MODIFIER_PAGE_4 = "M4"
export const TID_MODIFIER_PAGE_5 = "M5"
export const TID_MODIFIER_COIN_1 = "M6"
export const TID_MODIFIER_COIN_2 = "M7"
export const TID_MODIFIER_COIN_3 = "M8"
export const TID_MODIFIER_COIN_4 = "M9"
export const TID_MODIFIER_COIN_5 = "M10"
export const TID_MODIFIER_ICON_EDITOR = "M15"
export const TID_MODIFIER_COLOR_RED = "M16"
export const TID_MODIFIER_COLOR_DARKPURPLE = "M17"
export const TID_MODIFIER_EMOJI_GIGGLE = "M19giggle"
export const TID_MODIFIER_EMOJI_HAPPY = "M19happy"
export const TID_MODIFIER_EMOJI_HELLO = "M19hello"
export const TID_MODIFIER_EMOJI_MYSTERIOUS = "M19mysterious"
export const TID_MODIFIER_EMOJI_SAD = "M19sad"
export const TID_MODIFIER_EMOJI_SLIDE = "M19slide"
export const TID_MODIFIER_EMOJI_SOARING = "M19soaring"
export const TID_MODIFIER_EMOJI_SPRING = "M19spring"
export const TID_MODIFIER_EMOJI_TWINKLE = "M19twinkle"
export const TID_MODIFIER_EMOJI_YAWN = "M19yawn"
export const TID_MODIFIER_CUP_X_READ = "M20A"
export const TID_MODIFIER_CUP_Y_READ = "M20B"
export const TID_MODIFIER_CUP_Z_READ = "M20C"
export const TID_MODIFIER_RADIO_VALUE = "M21"
export const TID_MODIFIER_RANDOM_TOSS = "M22"
export const TID_MODIFIER_LOOP = "M23"
export const TID_MODIFIER_MELODY_EDITOR = "M24"
export const TID_MODIFIER_TEMP_READ = "M25"
export const TID_MODIFIER_RGB_LED_COLOR_X = "A20_"
export const TID_MODIFIER_RGB_LED_COLOR_1 = "A20_1"
export const TID_MODIFIER_RGB_LED_COLOR_2 = "A20_2"
export const TID_MODIFIER_RGB_LED_COLOR_3 = "A20_3"
export const TID_MODIFIER_RGB_LED_COLOR_4 = "A20_4"
export const TID_MODIFIER_RGB_LED_COLOR_5 = "A20_5"
export const TID_MODIFIER_RGB_LED_COLOR_6 = "A20_6"
export const TID_MODIFIER_RGB_LED_COLOR_RAINBOW = "A20_rainbow"
export const TID_MODIFIER_RGB_LED_COLOR_SPARKLE = "A20_sparkle"
export const TID_ACTUATOR_SERVO_SET_ANGLE = "A21_"
export const TID_ACTUATOR_RELAY = "A22"
export const TID_ACTUATOR_SERVO_POWER = "A23"
export const TID_ACTUATOR_CAR = "CAR"
export const TID_MODIFIER_CAR_FORWARD = "CAR1"
export const TID_MODIFIER_CAR_REVERSE = "CAR2"
export const TID_MODIFIER_CAR_TURN_LEFT = "CAR3"
export const TID_MODIFIER_CAR_TURN_RIGHT = "CAR4"
export const TID_MODIFIER_CAR_STOP = "CAR5"
export const TID_MODIFIER_CAR_FORWARD_FAST = "CAR6"
export const TID_MODIFIER_CAR_SPIN_LEFT = "CAR7"
export const TID_MODIFIER_CAR_SPIN_RIGHT = "CAR8"
export const TID_MODIFIER_CAR_LED_COLOR_1 = "CAR9"
export const TID_MODIFIER_CAR_LED_COLOR_2 = "CAR10"
export const TID_MODIFIER_CAR_LED_COLOR_3 = "CAR11"
export const TID_MODIFIER_CAR_LED_COLOR_4 = "CAR12"
export const TID_MODIFIER_CAR_ARM_OPEN = "CAR13"
export const TID_MODIFIER_CAR_ARM_CLOSE = "CAR14"
export const TID_MODIFIER_ON = "M26"
export const TID_MODIFIER_OFF = "M27"
// DO NOT CHANGE THESE NUMBERS
export enum Tid {
// we need markers to indicate the end of a program, page
END_OF_PROG = 0,
END_OF_PAGE,
SENSOR_START = 10,
TID_SENSOR_START_PAGE = 10,
TID_SENSOR_PRESS = 11,
TID_SENSOR_RELEASE = 12,
TID_SENSOR_ACCELEROMETER = 13,
TID_SENSOR_TIMER = 14,
TID_SENSOR_LIGHT = 15, // this is jacdac only
TID_SENSOR_TEMP = 16,
TID_SENSOR_RADIO_RECEIVE = 17,
TID_SENSOR_MICROPHONE = 18,
TID_SENSOR_CUP_X_WRITTEN = 19,
TID_SENSOR_CUP_Y_WRITTEN = 20,
TID_SENSOR_CUP_Z_WRITTEN = 21,
TID_SENSOR_MAGNET = 22,
TID_SENSOR_SLIDER = 23,
TID_SENSOR_ROTARY = 24,
TID_SENSOR_CAR_WALL = 25,
TID_SENSOR_LINE = 26,
TID_SENSOR_LED_LIGHT = 27, // this built-in light sensor on microbit
TID_SENSOR_MOISTURE = 28,
TID_SENSOR_DISTANCE = 29,
TID_SENSOR_REFLECTED = 30,
SENSOR_END = 30,
ACTUATOR_START = 40,
TID_ACTUATOR_SWITCH_PAGE = 40,
TID_ACTUATOR_SPEAKER = 41,
TID_ACTUATOR_MICROPHONE = 42, // dead, but don't delete
TID_ACTUATOR_MUSIC = 43,
TID_ACTUATOR_PAINT = 44,
TID_ACTUATOR_RADIO_SEND = 45,
TID_ACTUATOR_RADIO_SET_GROUP = 46,
TID_ACTUATOR_RGB_LED = 47,
TID_ACTUATOR_CUP_X_ASSIGN = 48,
TID_ACTUATOR_CUP_Y_ASSIGN = 49,
TID_ACTUATOR_CUP_Z_ASSIGN = 50,
TID_ACTUATOR_SHOW_NUMBER = 51,
TID_ACTUATOR_CAR = 52,
TID_ACTUATOR_SERVO_SET_ANGLE = 53,
TID_ACTUATOR_RELAY = 54,
TID_ACTUATOR_SERVO_POWER = 55,
ACTUATOR_END = 55,
FILTER_START = 70,
PRESS_RELEASE_START = 70,
TID_FILTER_PIN_0 = 70,
TID_FILTER_PIN_1 = 71,
TID_FILTER_PIN_2 = 72,
TID_FILTER_BUTTON_A = 73,
TID_FILTER_BUTTON_B = 74,
TID_FILTER_KITA_KEY_1 = 75,
TID_FILTER_KITA_KEY_2 = 76,
TID_FILTER_LOGO = 77,
PRESS_RELEASE_END = 77,
//
TID_FILTER_COIN_1 = 78,
TID_FILTER_COIN_2 = 79,
TID_FILTER_COIN_3 = 80,
TID_FILTER_COIN_4 = 81,
TID_FILTER_COIN_5 = 82,
//
TID_FILTER_TIMESPAN_SHORT = 83,
TID_FILTER_TIMESPAN_LONG = 84,
TID_FILTER_TIMESPAN_RANDOM = 85,
TID_FILTER_TIMESPAN_VERY_LONG = 86,
//
TID_FILTER_LOUD = 87,
TID_FILTER_QUIET = 88,
//
TID_FILTER_ACCEL = 89, // dead (AFAIK)
ACCELEROMETER_START = 90,
TID_FILTER_ACCEL_SHAKE = 90,
TID_FILTER_ACCEL_TILT_UP = 91,
TID_FILTER_ACCEL_TILT_DOWN = 92,
TID_FILTER_ACCEL_TILT_LEFT = 93,
TID_FILTER_ACCEL_TILT_RIGHT = 94,
ACCELEROMETER_END = 94,
//
TID_FILTER_CUP_X_READ = 95,
TID_FILTER_CUP_Y_READ = 96,
TID_FILTER_CUP_Z_READ = 97,
//
TID_FILTER_ROTARY_LEFT = 98,
TID_FILTER_ROTARY_RIGHT = 99,
//
TID_FILTER_TEMP_WARMER = 100,
TID_FILTER_TEMP_COLDER = 101,
//
LINE_START = 102,
TID_FILTER_LINE_LEFT = 102,
TID_FILTER_LINE_RIGHT = 103,
TID_FILTER_LINE_BOTH = 104,
TID_FILTER_LINE_NEITHER = 105,
TID_FILTER_LINE_NEITHER_LEFT = 106,
TID_FILTER_LINE_NEITHER_RIGHT = 107,
LINE_END = 107,
ACCELEROMETER_START2 = 108,
TID_FILTER_ACCEL_FACE_UP = 108,
TID_FILTER_ACCEL_FACE_DOWN = 109,
ACCELEROMETER_END2 = 109,
TID_FILTER_ON = 110,
TID_FILTER_OFF = 111,
FILTER_END = 111,
MODIFIER_START = 150,
//
TID_MODIFIER_PAGE_1 = 150,
TID_MODIFIER_PAGE_2 = 151,
TID_MODIFIER_PAGE_3 = 152,
TID_MODIFIER_PAGE_4 = 153,
TID_MODIFIER_PAGE_5 = 154,
//
TID_MODIFIER_COIN_1 = 155,
TID_MODIFIER_COIN_2 = 156,
TID_MODIFIER_COIN_3 = 157,
TID_MODIFIER_COIN_4 = 158,
TID_MODIFIER_COIN_5 = 159,
//
TID_MODIFIER_ICON_EDITOR = 160,
TID_MODIFIER_COLOR_RED = 161,
TID_MODIFIER_COLOR_DARKPURPLE = 162,
//
EMOJI_BEGIN = 163,
TID_MODIFIER_EMOJI_GIGGLE = 163,
TID_MODIFIER_EMOJI_HAPPY = 164,
TID_MODIFIER_EMOJI_HELLO = 165,
TID_MODIFIER_EMOJI_MYSTERIOUS = 166,
TID_MODIFIER_EMOJI_SAD = 167,
TID_MODIFIER_EMOJI_SLIDE = 168,
TID_MODIFIER_EMOJI_SOARING = 169,
TID_MODIFIER_EMOJI_SPRING = 170,
TID_MODIFIER_EMOJI_TWINKLE = 171,
TID_MODIFIER_EMOJI_YAWN = 172,
EMOJI_END = 172,
//
TID_MODIFIER_CUP_X_READ = 173,
TID_MODIFIER_CUP_Y_READ = 174,
TID_MODIFIER_CUP_Z_READ = 175,
TID_MODIFIER_RADIO_VALUE = 176,
TID_MODIFIER_RANDOM_TOSS = 177,
TID_MODIFIER_LOOP = 178,
TID_MODIFIER_MELODY_EDITOR = 179,
TID_MODIFIER_TEMP_READ = 180,
//
TID_MODIFIER_RGB_LED_COLOR_X = 181,
TID_MODIFIER_RGB_LED_COLOR_1 = 182,
TID_MODIFIER_RGB_LED_COLOR_2 = 183,
TID_MODIFIER_RGB_LED_COLOR_3 = 184,
TID_MODIFIER_RGB_LED_COLOR_4 = 185,
TID_MODIFIER_RGB_LED_COLOR_5 = 186,
TID_MODIFIER_RGB_LED_COLOR_6 = 187,
TID_MODIFIER_RGB_LED_COLOR_RAINBOW = 188,
TID_MODIFIER_RGB_LED_COLOR_SPARKLE = 189,
//
CAR_MODIFIER_BEGIN = 190,
TID_MODIFIER_CAR_FORWARD = 190,
TID_MODIFIER_CAR_REVERSE = 191,
TID_MODIFIER_CAR_TURN_LEFT = 192,
TID_MODIFIER_CAR_TURN_RIGHT = 193,
TID_MODIFIER_CAR_STOP = 194,
TID_MODIFIER_CAR_FORWARD_FAST = 195,
TID_MODIFIER_CAR_SPIN_LEFT = 196,
TID_MODIFIER_CAR_SPIN_RIGHT = 197,
TID_MODIFIER_CAR_LED_COLOR_1 = 198,
TID_MODIFIER_CAR_LED_COLOR_2 = 199,
TID_MODIFIER_CAR_LED_COLOR_3 = 200,
TID_MODIFIER_CAR_LED_COLOR_4 = 201,
TID_MODIFIER_CAR_ARM_OPEN = 202,
TID_MODIFIER_CAR_ARM_CLOSE = 203,
CAR_MODIFIER_END = 203,
TID_MODIFIER_ON = 204,
TID_MODIFIER_OFF = 205,
MODIFER_END = 205,
}
type RangeMap = { [id: string]: [Tid, Tid] }
export const ranges: RangeMap = {
sensors: [Tid.SENSOR_START, Tid.SENSOR_END],
filters: [Tid.FILTER_START, Tid.FILTER_END],
actuators: [Tid.ACTUATOR_START, Tid.ACTUATOR_END],
modifiers: [Tid.MODIFIER_START, Tid.MODIFER_END],
}
export function tidToString(e: Tid) {
switch (e) {
case Tid.TID_SENSOR_START_PAGE:
return TID_SENSOR_START_PAGE
case Tid.TID_SENSOR_PRESS:
return TID_SENSOR_PRESS
case Tid.TID_SENSOR_RELEASE:
return TID_SENSOR_RELEASE
case Tid.TID_SENSOR_ACCELEROMETER:
return TID_SENSOR_ACCELEROMETER
case Tid.TID_SENSOR_TIMER:
return TID_SENSOR_TIMER
case Tid.TID_SENSOR_LIGHT:
return TID_SENSOR_LIGHT
case Tid.TID_SENSOR_LED_LIGHT:
return TID_SENSOR_LED_LIGHT
case Tid.TID_SENSOR_TEMP:
return TID_SENSOR_TEMP
case Tid.TID_SENSOR_RADIO_RECEIVE:
return TID_SENSOR_RADIO_RECEIVE
case Tid.TID_SENSOR_MICROPHONE:
return TID_SENSOR_MICROPHONE
case Tid.TID_SENSOR_CUP_X_WRITTEN:
return TID_SENSOR_CUP_X_WRITTEN
case Tid.TID_SENSOR_CUP_Y_WRITTEN:
return TID_SENSOR_CUP_Y_WRITTEN
case Tid.TID_SENSOR_CUP_Z_WRITTEN:
return TID_SENSOR_CUP_Z_WRITTEN
case Tid.TID_SENSOR_MAGNET:
return TID_SENSOR_MAGNET
case Tid.TID_SENSOR_SLIDER:
return TID_SENSOR_SLIDER
case Tid.TID_SENSOR_ROTARY:
return TID_SENSOR_ROTARY
case Tid.TID_SENSOR_CAR_WALL:
return TID_SENSOR_CAR_WALL
case Tid.TID_SENSOR_LINE:
return TID_SENSOR_LINE
case Tid.TID_SENSOR_MOISTURE:
return TID_SENSOR_MOISTURE
case Tid.TID_SENSOR_DISTANCE:
return TID_SENSOR_DISTANCE
case Tid.TID_SENSOR_REFLECTED:
return TID_SENSOR_REFLECTED
case Tid.TID_FILTER_PIN_0:
return TID_FILTER_PIN_0
case Tid.TID_FILTER_PIN_1:
return TID_FILTER_PIN_1
case Tid.TID_FILTER_PIN_2:
return TID_FILTER_PIN_2
case Tid.TID_FILTER_BUTTON_A:
return TID_FILTER_BUTTON_A
case Tid.TID_FILTER_BUTTON_B:
return TID_FILTER_BUTTON_B
case Tid.TID_FILTER_KITA_KEY_1:
return TID_FILTER_KITA_KEY_1
case Tid.TID_FILTER_KITA_KEY_2:
return TID_FILTER_KITA_KEY_2
case Tid.TID_FILTER_LOGO:
return TID_FILTER_LOGO
case Tid.TID_FILTER_COIN_1:
return TID_FILTER_COIN_1
case Tid.TID_FILTER_COIN_2:
return TID_FILTER_COIN_2
case Tid.TID_FILTER_COIN_3:
return TID_FILTER_COIN_3
case Tid.TID_FILTER_COIN_4:
return TID_FILTER_COIN_4
case Tid.TID_FILTER_COIN_5:
return TID_FILTER_COIN_5
case Tid.TID_FILTER_TIMESPAN_SHORT:
return TID_FILTER_TIMESPAN_SHORT
case Tid.TID_FILTER_TIMESPAN_LONG:
return TID_FILTER_TIMESPAN_LONG
case Tid.TID_FILTER_LOUD:
return TID_FILTER_LOUD
case Tid.TID_FILTER_QUIET:
return TID_FILTER_QUIET
case Tid.TID_FILTER_ACCEL:
return TID_FILTER_ACCEL
case Tid.TID_FILTER_ACCEL_SHAKE:
return TID_FILTER_ACCEL_SHAKE
case Tid.TID_FILTER_ACCEL_TILT_UP:
return TID_FILTER_ACCEL_TILT_UP
case Tid.TID_FILTER_ACCEL_TILT_DOWN:
return TID_FILTER_ACCEL_TILT_DOWN
case Tid.TID_FILTER_ACCEL_TILT_LEFT:
return TID_FILTER_ACCEL_TILT_LEFT
case Tid.TID_FILTER_ACCEL_FACE_DOWN:
return TID_FILTER_ACCEL_FACE_DOWN
case Tid.TID_FILTER_ACCEL_FACE_UP:
return TID_FILTER_ACCEL_FACE_UP
case Tid.TID_FILTER_ACCEL_TILT_RIGHT:
return TID_FILTER_ACCEL_TILT_RIGHT
case Tid.TID_FILTER_TIMESPAN_RANDOM:
return TID_FILTER_TIMESPAN_RANDOM
case Tid.TID_FILTER_TIMESPAN_VERY_LONG:
return TID_FILTER_TIMESPAN_VERY_LONG
case Tid.TID_FILTER_CUP_X_READ:
return TID_FILTER_CUP_X_READ
case Tid.TID_FILTER_CUP_Y_READ:
return TID_FILTER_CUP_Y_READ
case Tid.TID_FILTER_CUP_Z_READ:
return TID_FILTER_CUP_Z_READ
case Tid.TID_FILTER_ROTARY_LEFT:
return TID_FILTER_ROTARY_LEFT
case Tid.TID_FILTER_ROTARY_RIGHT:
return TID_FILTER_ROTARY_RIGHT
case Tid.TID_FILTER_TEMP_WARMER:
return TID_FILTER_TEMP_WARMER
case Tid.TID_FILTER_TEMP_COLDER:
return TID_FILTER_TEMP_COLDER
case Tid.TID_FILTER_LINE_LEFT:
return TID_FILTER_LINE_LEFT
case Tid.TID_FILTER_LINE_RIGHT:
return TID_FILTER_LINE_RIGHT
case Tid.TID_FILTER_LINE_BOTH:
return TID_FILTER_LINE_BOTH
case Tid.TID_FILTER_LINE_NEITHER:
return TID_FILTER_LINE_NEITHER
case Tid.TID_FILTER_LINE_NEITHER_LEFT:
return TID_FILTER_LINE_NEITHER_LEFT
case Tid.TID_FILTER_LINE_NEITHER_RIGHT:
return TID_FILTER_LINE_NEITHER_RIGHT
case Tid.TID_ACTUATOR_SWITCH_PAGE:
return TID_ACTUATOR_SWITCH_PAGE
case Tid.TID_ACTUATOR_SPEAKER:
return TID_ACTUATOR_SPEAKER
case Tid.TID_ACTUATOR_MUSIC:
return TID_ACTUATOR_MUSIC
case Tid.TID_ACTUATOR_PAINT:
return TID_ACTUATOR_PAINT
case Tid.TID_ACTUATOR_RADIO_SEND:
return TID_ACTUATOR_RADIO_SEND
case Tid.TID_ACTUATOR_RADIO_SET_GROUP:
return TID_ACTUATOR_RADIO_SET_GROUP
case Tid.TID_ACTUATOR_RGB_LED:
return TID_ACTUATOR_RGB_LED
case Tid.TID_ACTUATOR_CUP_X_ASSIGN:
return TID_ACTUATOR_CUP_X_ASSIGN
case Tid.TID_ACTUATOR_CUP_Y_ASSIGN:
return TID_ACTUATOR_CUP_Y_ASSIGN
case Tid.TID_ACTUATOR_CUP_Z_ASSIGN:
return TID_ACTUATOR_CUP_Z_ASSIGN
case Tid.TID_ACTUATOR_SHOW_NUMBER:
return TID_ACTUATOR_SHOW_NUMBER
case Tid.TID_MODIFIER_PAGE_1:
return TID_MODIFIER_PAGE_1
case Tid.TID_MODIFIER_PAGE_2:
return TID_MODIFIER_PAGE_2
case Tid.TID_MODIFIER_PAGE_3:
return TID_MODIFIER_PAGE_3
case Tid.TID_MODIFIER_PAGE_4:
return TID_MODIFIER_PAGE_4
case Tid.TID_MODIFIER_PAGE_5:
return TID_MODIFIER_PAGE_5
case Tid.TID_MODIFIER_COIN_1:
return TID_MODIFIER_COIN_1
case Tid.TID_MODIFIER_COIN_2:
return TID_MODIFIER_COIN_2
case Tid.TID_MODIFIER_COIN_3:
return TID_MODIFIER_COIN_3
case Tid.TID_MODIFIER_COIN_4:
return TID_MODIFIER_COIN_4
case Tid.TID_MODIFIER_COIN_5:
return TID_MODIFIER_COIN_5
case Tid.TID_MODIFIER_ICON_EDITOR:
return TID_MODIFIER_ICON_EDITOR
case Tid.TID_MODIFIER_COLOR_RED:
return TID_MODIFIER_COLOR_RED
case Tid.TID_MODIFIER_COLOR_DARKPURPLE:
return TID_MODIFIER_COLOR_DARKPURPLE
case Tid.TID_MODIFIER_EMOJI_GIGGLE:
return TID_MODIFIER_EMOJI_GIGGLE
case Tid.TID_MODIFIER_EMOJI_HAPPY:
return TID_MODIFIER_EMOJI_HAPPY
case Tid.TID_MODIFIER_EMOJI_HELLO:
return TID_MODIFIER_EMOJI_HELLO
case Tid.TID_MODIFIER_EMOJI_MYSTERIOUS:
return TID_MODIFIER_EMOJI_MYSTERIOUS
case Tid.TID_MODIFIER_EMOJI_SAD:
return TID_MODIFIER_EMOJI_SAD
case Tid.TID_MODIFIER_EMOJI_SLIDE:
return TID_MODIFIER_EMOJI_SLIDE
case Tid.TID_MODIFIER_EMOJI_SOARING:
return TID_MODIFIER_EMOJI_SOARING
case Tid.TID_MODIFIER_EMOJI_SPRING:
return TID_MODIFIER_EMOJI_SPRING
case Tid.TID_MODIFIER_EMOJI_TWINKLE:
return TID_MODIFIER_EMOJI_TWINKLE
case Tid.TID_MODIFIER_EMOJI_YAWN:
return TID_MODIFIER_EMOJI_YAWN
case Tid.TID_MODIFIER_CUP_X_READ:
return TID_MODIFIER_CUP_X_READ
case Tid.TID_MODIFIER_CUP_Y_READ:
return TID_MODIFIER_CUP_Y_READ
case Tid.TID_MODIFIER_CUP_Z_READ:
return TID_MODIFIER_CUP_Z_READ
case Tid.TID_MODIFIER_RADIO_VALUE:
return TID_MODIFIER_RADIO_VALUE
case Tid.TID_MODIFIER_RANDOM_TOSS:
return TID_MODIFIER_RANDOM_TOSS
case Tid.TID_MODIFIER_LOOP:
return TID_MODIFIER_LOOP
case Tid.TID_MODIFIER_MELODY_EDITOR:
return TID_MODIFIER_MELODY_EDITOR
case Tid.TID_MODIFIER_TEMP_READ:
return TID_MODIFIER_TEMP_READ
case Tid.TID_MODIFIER_RGB_LED_COLOR_X:
return TID_MODIFIER_RGB_LED_COLOR_X
case Tid.TID_MODIFIER_RGB_LED_COLOR_1:
return TID_MODIFIER_RGB_LED_COLOR_1
case Tid.TID_MODIFIER_RGB_LED_COLOR_2:
return TID_MODIFIER_RGB_LED_COLOR_2
case Tid.TID_MODIFIER_RGB_LED_COLOR_3:
return TID_MODIFIER_RGB_LED_COLOR_3
case Tid.TID_MODIFIER_RGB_LED_COLOR_4:
return TID_MODIFIER_RGB_LED_COLOR_4
case Tid.TID_MODIFIER_RGB_LED_COLOR_5:
return TID_MODIFIER_RGB_LED_COLOR_5
case Tid.TID_MODIFIER_RGB_LED_COLOR_6:
return TID_MODIFIER_RGB_LED_COLOR_6
case Tid.TID_MODIFIER_RGB_LED_COLOR_RAINBOW:
return TID_MODIFIER_RGB_LED_COLOR_RAINBOW
case Tid.TID_MODIFIER_RGB_LED_COLOR_SPARKLE:
return TID_MODIFIER_RGB_LED_COLOR_SPARKLE
case Tid.TID_ACTUATOR_SERVO_SET_ANGLE:
return TID_ACTUATOR_SERVO_SET_ANGLE
case Tid.TID_ACTUATOR_SERVO_POWER:
return TID_ACTUATOR_SERVO_POWER
case Tid.TID_ACTUATOR_RELAY:
return TID_ACTUATOR_RELAY
case Tid.TID_ACTUATOR_CAR:
return TID_ACTUATOR_CAR
case Tid.TID_MODIFIER_CAR_FORWARD:
return TID_MODIFIER_CAR_FORWARD
case Tid.TID_MODIFIER_CAR_REVERSE:
return TID_MODIFIER_CAR_REVERSE
case Tid.TID_MODIFIER_CAR_TURN_LEFT:
return TID_MODIFIER_CAR_TURN_LEFT
case Tid.TID_MODIFIER_CAR_TURN_RIGHT:
return TID_MODIFIER_CAR_TURN_RIGHT
case Tid.TID_MODIFIER_CAR_STOP:
return TID_MODIFIER_CAR_STOP
case Tid.TID_MODIFIER_CAR_FORWARD_FAST:
return TID_MODIFIER_CAR_FORWARD_FAST
case Tid.TID_MODIFIER_CAR_SPIN_LEFT:
return TID_MODIFIER_CAR_SPIN_LEFT
case Tid.TID_MODIFIER_CAR_SPIN_RIGHT:
return TID_MODIFIER_CAR_SPIN_RIGHT
case Tid.TID_MODIFIER_CAR_LED_COLOR_1:
return TID_MODIFIER_CAR_LED_COLOR_1
case Tid.TID_MODIFIER_CAR_LED_COLOR_2:
return TID_MODIFIER_CAR_LED_COLOR_2
case Tid.TID_MODIFIER_CAR_LED_COLOR_3:
return TID_MODIFIER_CAR_LED_COLOR_3
case Tid.TID_MODIFIER_CAR_LED_COLOR_4:
return TID_MODIFIER_CAR_LED_COLOR_4
case Tid.TID_MODIFIER_CAR_ARM_OPEN:
return TID_MODIFIER_CAR_ARM_OPEN
case Tid.TID_MODIFIER_CAR_ARM_CLOSE:
return TID_MODIFIER_CAR_ARM_CLOSE
case Tid.TID_MODIFIER_ON:
return TID_MODIFIER_ON
case Tid.TID_MODIFIER_OFF:
return TID_MODIFIER_OFF
case Tid.TID_FILTER_ON:
return TID_FILTER_ON
case Tid.TID_FILTER_OFF:
return TID_FILTER_OFF
default:
assert(false, "unknown tid: " + e)
return undefined
}
}
export function isSensor(tid: Tid) {
return tid >= Tid.SENSOR_START && tid <= Tid.SENSOR_END
}
export function isFilter(tid: Tid) {
return tid >= Tid.FILTER_START && tid <= Tid.FILTER_END
}
export function isActuator(tid: Tid) {
return tid >= Tid.ACTUATOR_START && tid <= Tid.ACTUATOR_END
}
export function isModifier(tid: Tid) {
return tid >= Tid.MODIFIER_START && tid <= Tid.MODIFER_END
}
function isPressReleaseEvent(tidEnum: Tid) {
return (
Tid.PRESS_RELEASE_START <= tidEnum &&
tidEnum <= Tid.PRESS_RELEASE_END
)
}
function isAccelerometerEvent(tidEnum: Tid) {
return (
(Tid.ACCELEROMETER_START <= tidEnum &&
tidEnum <= Tid.ACCELEROMETER_END) ||
(Tid.ACCELEROMETER_START2 <= tidEnum &&
tidEnum <= Tid.ACCELEROMETER_END2)
)
}
function isLineEvent(tidEnum: Tid) {
return Tid.LINE_START <= tidEnum && tidEnum <= Tid.LINE_END
}
function isFilterConstant(tidEnum: Tid) {
return (
Tid.TID_FILTER_COIN_1 <= tidEnum && tidEnum <= Tid.TID_FILTER_COIN_5
)
}
function isFilterVariable(tidEnum: Tid) {
return (
Tid.TID_FILTER_CUP_X_READ <= tidEnum &&
tidEnum <= Tid.TID_FILTER_CUP_Z_READ
)
}
function isModifierConstant(tidEnum: Tid) {
return (
Tid.TID_MODIFIER_COIN_1 <= tidEnum &&
tidEnum <= Tid.TID_MODIFIER_COIN_5
)
}
function isModifierVariable(tidEnum: Tid) {
return (
Tid.TID_MODIFIER_CUP_X_READ <= tidEnum &&
tidEnum <= Tid.TID_MODIFIER_CUP_Z_READ
)
}
function isTimespan(tidEnum: Tid) {
return (
Tid.TID_FILTER_TIMESPAN_SHORT <= tidEnum &&
tidEnum <= Tid.TID_FILTER_TIMESPAN_VERY_LONG
)
}
function isEmoji(tidEnum: Tid) {
return Tid.EMOJI_BEGIN <= tidEnum && tidEnum <= Tid.EMOJI_END
}
function isPage(tidEnum: Tid) {
return (
Tid.TID_MODIFIER_PAGE_1 <= tidEnum &&
tidEnum <= Tid.TID_MODIFIER_PAGE_5
)
}
function isLedColor(tidEnum: Tid) {
return (
Tid.TID_MODIFIER_RGB_LED_COLOR_1 <= tidEnum &&
tidEnum <= Tid.TID_MODIFIER_RGB_LED_COLOR_6
)
}
function isLedModifier(tidEnum: Tid) {
return (
isLedColor(tidEnum) ||
tidEnum == Tid.TID_MODIFIER_RGB_LED_COLOR_RAINBOW ||
tidEnum == Tid.TID_MODIFIER_RGB_LED_COLOR_SPARKLE
)
}
function isCarModifier(tidEnum: Tid) {
return (
Tid.CAR_MODIFIER_BEGIN <= tidEnum && tidEnum <= Tid.CAR_MODIFIER_END
)
}
export function isTerminal(tile: Tile) {
const tid = getTid(tile)
// the following sensors and actuators are terminal
if (
tid == Tid.TID_SENSOR_CAR_WALL ||
tid == Tid.TID_SENSOR_SLIDER ||
tid == Tid.TID_ACTUATOR_SWITCH_PAGE ||
tid == Tid.TID_ACTUATOR_RELAY ||
tid == Tid.TID_SENSOR_LIGHT ||
tid == Tid.TID_SENSOR_LED_LIGHT ||
tid == Tid.TID_SENSOR_MICROPHONE ||
tid == Tid.TID_SENSOR_MAGNET ||
tid == Tid.TID_SENSOR_LINE ||
tid == Tid.TID_SENSOR_DISTANCE ||
tid == Tid.TID_SENSOR_REFLECTED ||
tid == Tid.TID_ACTUATOR_SERVO_POWER ||
tid == Tid.TID_SENSOR_MOISTURE
)
return true
// everything else except some filters is not terminal
if (!isFilter(tid)) return false
// the following filters are not terminal
if (isFilterConstant(tid) || isTimespan(tid) || isFilterVariable(tid))
return false
// all other filters are terminal
return true
}
export function isVisible(tile: Tile) {
const tid = getTid(tile)
// these tids are dead
if (tid == Tid.TID_ACTUATOR_MICROPHONE || tid == Tid.TID_FILTER_ACCEL)
return false
const ext = jdExternalClass(tile)
if (ext && !jacs.debugOut) {
const count = jdc.numServiceInstances(ext)
// special case for buttons, which already exist on micro:bit (6 of them)
// we also have light sensor on board micro:bit (1 of them), as well as in Kit A
return ext == jacs.ServiceClass.Button
? count > 6
: ext == jacs.ServiceClass.LightLevel
? count > 1
: count > 0
}
return true
}
export function defaultModifier(tid: Tid): Tile {
switch (tid) {
case Tid.TID_ACTUATOR_RELAY:
case Tid.TID_ACTUATOR_SERVO_POWER:
return Tid.TID_MODIFIER_OFF
case Tid.TID_ACTUATOR_SPEAKER:
return Tid.TID_MODIFIER_EMOJI_GIGGLE
case Tid.TID_ACTUATOR_CAR:
return Tid.TID_MODIFIER_CAR_STOP
case Tid.TID_ACTUATOR_RGB_LED:
return Tid.TID_MODIFIER_RGB_LED_COLOR_RAINBOW
case Tid.TID_ACTUATOR_PAINT: {
return getEditor(Tid.TID_MODIFIER_ICON_EDITOR)
}
case Tid.TID_ACTUATOR_MUSIC: {
return getEditor(Tid.TID_MODIFIER_MELODY_EDITOR)
}
default:
return undefined
}
}
export function buttonStyle(tile: Tile): ButtonStyle {
return getFieldEditor(tile)
? ButtonStyles.Transparent
: ButtonStyles.FlatWhite
}
export function priority(tile: Tile): number {
const tid = getTid(tile)
if (isFilter(tid)) {
if (isFilterConstant(tid) || isPressReleaseEvent(tid))
return jdParam(tid)
if (isLineEvent(tid)) {
if (tid == Tid.TID_FILTER_LINE_BOTH) return 101
else return tid
}
switch (tid) {
case Tid.TID_FILTER_TIMESPAN_SHORT:
return 10
case Tid.TID_FILTER_TIMESPAN_LONG:
return 20
case Tid.TID_FILTER_TIMESPAN_VERY_LONG:
return 30
case Tid.TID_FILTER_TIMESPAN_RANDOM:
return 40
}
return tid
} else if (isModifier(tid)) {
if (tid == Tid.TID_MODIFIER_LOOP)
// loop always at end
return 1000
return tid
}
switch (tid) {
// sensors
case Tid.TID_SENSOR_PRESS:
return 9
case Tid.TID_SENSOR_RELEASE:
return 10
case Tid.TID_SENSOR_ACCELEROMETER:
return 20
case Tid.TID_SENSOR_MICROPHONE:
return 30
case Tid.TID_SENSOR_TEMP:
return 40
case Tid.TID_SENSOR_LED_LIGHT:
return 50
case Tid.TID_SENSOR_RADIO_RECEIVE:
return 100
case Tid.TID_SENSOR_TIMER:
return 110
case Tid.TID_SENSOR_START_PAGE:
return 108
case Tid.TID_SENSOR_CUP_X_WRITTEN:
return 200
case Tid.TID_SENSOR_CUP_Y_WRITTEN:
return 201
case Tid.TID_SENSOR_CUP_Z_WRITTEN:
return 202
// Robot car
case Tid.TID_SENSOR_CAR_WALL:
return 300
case Tid.TID_SENSOR_LINE:
return 301
// Jacdac
case Tid.TID_SENSOR_SLIDER:
return 500
case Tid.TID_SENSOR_ROTARY:
return 501
case Tid.TID_SENSOR_LIGHT:
return 502
case Tid.TID_SENSOR_ROTARY:
return 503
case Tid.TID_SENSOR_REFLECTED:
return 504
case Tid.TID_SENSOR_DISTANCE:
return 505
case Tid.TID_SENSOR_MOISTURE:
return 506
case Tid.TID_ACTUATOR_PAINT:
return 10
case Tid.TID_ACTUATOR_SHOW_NUMBER:
return 15
case Tid.TID_ACTUATOR_SPEAKER:
return 20
case Tid.TID_ACTUATOR_MUSIC:
return 22
case Tid.TID_ACTUATOR_RADIO_SEND:
return 100
case Tid.TID_ACTUATOR_RADIO_SET_GROUP:
return 105
case Tid.TID_ACTUATOR_SWITCH_PAGE:
return 110
case Tid.TID_ACTUATOR_CUP_X_ASSIGN:
return 200
case Tid.TID_ACTUATOR_CUP_Y_ASSIGN:
return 201
case Tid.TID_ACTUATOR_CUP_Z_ASSIGN:
return 202
// car
case Tid.TID_ACTUATOR_CAR:
return 500
// jacdac
case Tid.TID_ACTUATOR_RGB_LED:
return 600
case Tid.TID_ACTUATOR_SERVO_POWER:
return 601
case Tid.TID_ACTUATOR_SERVO_SET_ANGLE:
return 602
case Tid.TID_ACTUATOR_RELAY:
return 603
}
return 1000
}
const only5 = [
Tid.TID_FILTER_COIN_1,
Tid.TID_FILTER_COIN_2,
Tid.TID_FILTER_COIN_3,
Tid.TID_FILTER_COIN_4,
Tid.TID_FILTER_COIN_5,
]
export function getConstraints(tile: Tile): Constraints {
const tid = getTid(tile)
switch (tid) {
case Tid.TID_SENSOR_PRESS:
case Tid.TID_SENSOR_RELEASE:
return { allow: ["press_event"] }
case Tid.TID_SENSOR_START_PAGE:
return { allow: ["timespan"] }
case Tid.TID_SENSOR_CUP_X_WRITTEN:
return {
allow: ["value_in"],
disallow: [Tid.TID_FILTER_CUP_X_READ],
}
case Tid.TID_SENSOR_CUP_Y_WRITTEN:
return {
allow: ["value_in"],
disallow: [Tid.TID_FILTER_CUP_Y_READ],
}
case Tid.TID_SENSOR_CUP_Z_WRITTEN:
return {
allow: ["value_in"],
disallow: [Tid.TID_FILTER_CUP_Z_READ],
}
case Tid.TID_SENSOR_RADIO_RECEIVE:
return {
allow: ["value_in"],
provides: [Tid.TID_SENSOR_RADIO_RECEIVE],
}
case Tid.TID_SENSOR_SLIDER:
case Tid.TID_SENSOR_CAR_WALL:
case Tid.TID_SENSOR_MAGNET:
case Tid.TID_SENSOR_LIGHT:
case Tid.TID_SENSOR_LED_LIGHT:
case Tid.TID_SENSOR_DISTANCE:
case Tid.TID_SENSOR_MOISTURE:
return { allow: only5 }
case Tid.TID_SENSOR_REFLECTED:
// return { allow: only5 }
return { allow: ["on_off_event"] }
case Tid.TID_SENSOR_MICROPHONE:
return { allow: only5.concat([Tid.TID_FILTER_LOUD]) }
case Tid.TID_SENSOR_TEMP:
return { allow: ["temperature_event"] }
case Tid.TID_SENSOR_ROTARY:
return { allow: ["rotary_event"] }
case Tid.TID_SENSOR_LINE:
return { allow: ["line"] }
case Tid.TID_SENSOR_TIMER:
return { allow: ["timespan"] }
case Tid.TID_SENSOR_ACCELEROMETER:
return { allow: ["accel_event"] }
case Tid.TID_ACTUATOR_PAINT:
return { allow: ["icon_editor", "loop"] }
case Tid.TID_ACTUATOR_SPEAKER:
return { allow: ["sound_emoji", "loop"] }
case Tid.TID_ACTUATOR_MUSIC:
return { allow: ["melody_editor", "loop"] }
case Tid.TID_ACTUATOR_RADIO_SEND:
case Tid.TID_ACTUATOR_SHOW_NUMBER:
case Tid.TID_ACTUATOR_CUP_X_ASSIGN:
case Tid.TID_ACTUATOR_CUP_Y_ASSIGN:
case Tid.TID_ACTUATOR_CUP_Z_ASSIGN:
return { allow: ["value_out", "constant"] }
case Tid.TID_ACTUATOR_RGB_LED:
return { allow: ["rgb_led", "loop"] }
case Tid.TID_ACTUATOR_SERVO_SET_ANGLE:
case Tid.TID_ACTUATOR_RADIO_SET_GROUP: