pxt-common-packages 13.1.2 → 13.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/accelerometer/built/debug/binary.js +9 -10
- package/libs/azureiot/built/debug/binary.js +462 -497
- package/libs/cable/_locales/cable-strings.json +1 -0
- package/libs/color/built/debug/binary.js +9 -10
- package/libs/color-sensor/built/debug/binary.js +9 -10
- package/libs/controller/built/debug/binary.js +7349 -7898
- package/libs/controller---none/built/debug/binary.js +7329 -7876
- package/libs/core/built/debug/binary.js +1 -2
- package/libs/core---samd/built/debug/binary.js +9 -10
- package/libs/datalogger/built/debug/binary.js +64 -72
- package/libs/edge-connector/built/debug/binary.js +9 -10
- package/libs/esp32/built/debug/binary.js +463 -498
- package/libs/game/_locales/game-strings.json +8 -0
- package/libs/game/built/debug/binary.js +7268 -7812
- package/libs/gamepad/built/debug/binary.js +9 -10
- package/libs/infrared/_locales/infrared-strings.json +1 -0
- package/libs/keyboard/built/debug/binary.js +9 -10
- package/libs/lcd/built/debug/binary.js +9 -10
- package/libs/light/built/debug/binary.js +9 -10
- package/libs/light/defaultlights.ts +14 -14
- package/libs/light/docs/reference/light/animation.md +33 -0
- package/libs/light-spectrum-sensor/built/debug/binary.js +9 -10
- package/libs/lora/built/debug/binary.js +9 -10
- package/libs/matrix-keypad/built/debug/binary.js +9 -10
- package/libs/microphone/built/debug/binary.js +9 -10
- package/libs/mixer/melody.ts +2 -0
- package/libs/mouse/built/debug/binary.js +9 -10
- package/libs/mqtt/built/debug/binary.js +177 -193
- package/libs/music/built/debug/binary.js +9 -10
- package/libs/net/built/debug/binary.js +177 -193
- package/libs/net-game/built/debug/binary.js +8985 -9642
- package/libs/palette/built/debug/binary.js +7263 -7807
- package/libs/pixel/built/debug/binary.js +9 -10
- package/libs/power/built/debug/binary.js +9 -10
- package/libs/proximity/built/debug/binary.js +9 -10
- package/libs/pulse/built/debug/binary.js +9 -10
- package/libs/radio/_locales/radio-strings.json +5 -0
- package/libs/radio/built/debug/binary.js +9 -10
- package/libs/radio-broadcast/built/debug/binary.js +9 -10
- package/libs/rotary-encoder/built/debug/binary.js +9 -10
- package/libs/rotary-encoder/docs/reference/encoders/on-changed.md +29 -0
- package/libs/rotary-encoder/docs/reference/encoders/position.md +33 -0
- package/libs/rotary-encoder/rotary.cpp +2 -2
- package/libs/rotary-encoder/shims.d.ts +2 -2
- package/libs/screen/built/debug/binary.js +51 -58
- package/libs/servo/built/debug/binary.js +9 -10
- package/libs/sprite-scaling/built/debug/binary.js +7267 -7811
- package/libs/storyboard/built/debug/binary.js +7267 -7811
- package/libs/tests/built/debug/binary.js +16 -17
- package/libs/thermometer/built/debug/binary.js +9 -10
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// total=
|
|
1
|
+
// total=2916 new=27.64% cached=0.00% other=72.36%
|
|
2
2
|
(function (ectx) {
|
|
3
3
|
'use strict';
|
|
4
4
|
const runtime = ectx.runtime;
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P56980(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,27 +66,26 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___57224 = (undefined);
|
|
70
|
+
globals._pollEventQueue___57237 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P56980.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"pxt_modules/light/neopixel.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P56980.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P56980_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P56980, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
const breakpoints = setupDebugger(1, [])
|
|
90
89
|
|
|
91
|
-
return
|
|
90
|
+
return _main___P56980
|
|
92
91
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// total=
|
|
1
|
+
// total=2895 new=27.12% cached=0.00% other=72.88%
|
|
2
2
|
(function (ectx) {
|
|
3
3
|
'use strict';
|
|
4
4
|
const runtime = ectx.runtime;
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P63834(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,27 +66,26 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___64078 = (undefined);
|
|
70
|
+
globals._pollEventQueue___64091 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P63834.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"power.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P63834.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P63834_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P63834, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
const breakpoints = setupDebugger(1, [])
|
|
90
89
|
|
|
91
|
-
return
|
|
90
|
+
return _main___P63834
|
|
92
91
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// total=
|
|
1
|
+
// total=2909 new=27.29% cached=0.00% other=72.71%
|
|
2
2
|
(function (ectx) {
|
|
3
3
|
'use strict';
|
|
4
4
|
const runtime = ectx.runtime;
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P104840(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,27 +66,26 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___105084 = (undefined);
|
|
70
|
+
globals._pollEventQueue___105097 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P104840.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"vl53l0x.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P104840.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P104840_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P104840, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
const breakpoints = setupDebugger(1, [])
|
|
90
89
|
|
|
91
|
-
return
|
|
90
|
+
return _main___P104840
|
|
92
91
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// total=
|
|
1
|
+
// total=2909 new=27.47% cached=0.00% other=72.53%
|
|
2
2
|
(function (ectx) {
|
|
3
3
|
'use strict';
|
|
4
4
|
const runtime = ectx.runtime;
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P19412(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,27 +66,26 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___19656 = (undefined);
|
|
70
|
+
globals._pollEventQueue___19669 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P19412.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"pxt_modules/base/ns.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P19412.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P19412_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P19412, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
const breakpoints = setupDebugger(1, [])
|
|
90
89
|
|
|
91
|
-
return
|
|
90
|
+
return _main___P19412
|
|
92
91
|
})
|
|
@@ -5,9 +5,14 @@
|
|
|
5
5
|
"radio._packetProperty|block": "%note",
|
|
6
6
|
"radio.onDataReceived|block": "radio on data received",
|
|
7
7
|
"radio.onReceivedBuffer|block": "on radio received",
|
|
8
|
+
"radio.onReceivedBuffer|handlerParam|receivedBuffer": "receivedBuffer",
|
|
8
9
|
"radio.onReceivedNumber|block": "on radio received",
|
|
10
|
+
"radio.onReceivedNumber|handlerParam|receivedNumber": "receivedNumber",
|
|
9
11
|
"radio.onReceivedString|block": "on radio received",
|
|
12
|
+
"radio.onReceivedString|handlerParam|receivedString": "receivedString",
|
|
10
13
|
"radio.onReceivedValue|block": "on radio received",
|
|
14
|
+
"radio.onReceivedValue|handlerParam|name": "name",
|
|
15
|
+
"radio.onReceivedValue|handlerParam|value": "value",
|
|
11
16
|
"radio.raiseEvent|block": "radio raise event|from source %src=control_event_source_id|with value %value=control_event_value_id",
|
|
12
17
|
"radio.receivedPacket|block": "received packet %type=radio_packet_property",
|
|
13
18
|
"radio.sendNumber|block": "radio send number %value",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// total=
|
|
1
|
+
// total=2913 new=27.53% cached=0.00% other=72.47%
|
|
2
2
|
(function (ectx) {
|
|
3
3
|
'use strict';
|
|
4
4
|
const runtime = ectx.runtime;
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P193688(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,27 +66,26 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___193932 = (undefined);
|
|
70
|
+
globals._pollEventQueue___193945 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P193688.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"targetoverrides.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P193688.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P193688_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P193688, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
const breakpoints = setupDebugger(1, [])
|
|
90
89
|
|
|
91
|
-
return
|
|
90
|
+
return _main___P193688
|
|
92
91
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// total=
|
|
1
|
+
// total=2923 new=27.44% cached=0.00% other=72.56%
|
|
2
2
|
(function (ectx) {
|
|
3
3
|
'use strict';
|
|
4
4
|
const runtime = ectx.runtime;
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P195514(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,27 +66,26 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___195758 = (undefined);
|
|
70
|
+
globals._pollEventQueue___195771 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P195514.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"radio-broadcast.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P195514.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P195514_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P195514, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
const breakpoints = setupDebugger(1, [])
|
|
90
89
|
|
|
91
|
-
return
|
|
90
|
+
return _main___P195514
|
|
92
91
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// total=
|
|
1
|
+
// total=2922 new=27.45% cached=0.00% other=72.55%
|
|
2
2
|
(function (ectx) {
|
|
3
3
|
'use strict';
|
|
4
4
|
const runtime = ectx.runtime;
|
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P175672(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,27 +66,26 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___175916 = (undefined);
|
|
70
|
+
globals._pollEventQueue___175929 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P175672.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"targetoverrides.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P175672.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P175672_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P175672, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
const breakpoints = setupDebugger(1, [])
|
|
90
89
|
|
|
91
|
-
return
|
|
90
|
+
return _main___P175672
|
|
92
91
|
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# on Changed
|
|
2
|
+
|
|
3
|
+
Run some code when the rotary encoder changes position.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
encoders.createRotaryEncoder(pins.A2, pins.A1).onChanged(function () {})
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Example #example
|
|
10
|
+
|
|
11
|
+
Show the encoder position on the game console when it changes.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
const crank = encoders.createRotaryEncoder(pins.A2, pins.A1);
|
|
15
|
+
game.consoleOverlay.setVisible(true);
|
|
16
|
+
let sprite = sprites.create(sprites.castle.heroFrontAttack1)
|
|
17
|
+
crank.onChanged(function () {
|
|
18
|
+
console.log(crank.position())
|
|
19
|
+
sprite.x = screen.width / 2 + crank.position()
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## See also #seealso
|
|
24
|
+
|
|
25
|
+
[position](/reference/encoders/position)
|
|
26
|
+
|
|
27
|
+
```package
|
|
28
|
+
encoders
|
|
29
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# position
|
|
2
|
+
|
|
3
|
+
Get the current position rotary encoder.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
encoders.createRotaryEncoder(pins.A2, pins.A1).position( )
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Returns
|
|
10
|
+
|
|
11
|
+
* a [number](/types/number) that indicates the encoder's position.
|
|
12
|
+
|
|
13
|
+
## Example #example
|
|
14
|
+
|
|
15
|
+
Show the encoder position on the game console when it changes.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
const crank = encoders.createRotaryEncoder(pins.A2, pins.A1);
|
|
19
|
+
game.consoleOverlay.setVisible(true);
|
|
20
|
+
let sprite = sprites.create(sprites.castle.heroFrontAttack1)
|
|
21
|
+
crank.onChanged(function () {
|
|
22
|
+
console.log(crank.position())
|
|
23
|
+
sprite.x = screen.width / 2 + crank.position()
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## See also #seealso
|
|
28
|
+
|
|
29
|
+
[on changed](/reference/encoders/on-changed)
|
|
30
|
+
|
|
31
|
+
```package
|
|
32
|
+
encoders
|
|
33
|
+
```
|
|
@@ -78,7 +78,7 @@ namespace RotaryEncoderMethods {
|
|
|
78
78
|
*/
|
|
79
79
|
//% blockNamespace="encoders"
|
|
80
80
|
//% blockId=rotaryencoderonchaned block="on %this changed"
|
|
81
|
-
//% weight=80 blockGap=8
|
|
81
|
+
//% weight=80 blockGap=8 help=encoders/on-changed
|
|
82
82
|
void onChanged(RotaryEncoder encoder, Action body) {
|
|
83
83
|
registerWithDal(encoder->id, ROT_EV_CHANGED, body);
|
|
84
84
|
}
|
|
@@ -88,7 +88,7 @@ void onChanged(RotaryEncoder encoder, Action body) {
|
|
|
88
88
|
*/
|
|
89
89
|
//% blockNamespace="encoders"
|
|
90
90
|
//% blockId=rotaryencoderposition block="%this position"
|
|
91
|
-
//% weight=79 blockGap=8
|
|
91
|
+
//% weight=79 blockGap=8 help=encoders/position
|
|
92
92
|
int position(RotaryEncoder encoder) {
|
|
93
93
|
// the position always changes by 4 per tick
|
|
94
94
|
return encoder->position >> 2;
|
|
@@ -23,7 +23,7 @@ declare interface RotaryEncoder {
|
|
|
23
23
|
*/
|
|
24
24
|
//% blockNamespace="encoders"
|
|
25
25
|
//% blockId=rotaryencoderonchaned block="on %this changed"
|
|
26
|
-
//% weight=80 blockGap=8 shim=RotaryEncoderMethods::onChanged
|
|
26
|
+
//% weight=80 blockGap=8 help=encoders/on-changed shim=RotaryEncoderMethods::onChanged
|
|
27
27
|
onChanged(body: () => void): void;
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -31,7 +31,7 @@ declare interface RotaryEncoder {
|
|
|
31
31
|
*/
|
|
32
32
|
//% blockNamespace="encoders"
|
|
33
33
|
//% blockId=rotaryencoderposition block="%this position"
|
|
34
|
-
//% weight=79 blockGap=8 shim=RotaryEncoderMethods::position
|
|
34
|
+
//% weight=79 blockGap=8 help=encoders/position shim=RotaryEncoderMethods::position
|
|
35
35
|
position(): int32;
|
|
36
36
|
}
|
|
37
37
|
|