Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
0f3de6cf07 | |||
21195e4abf | |||
c992100a38 | |||
20a4673f98 | |||
966fd81870 | |||
cb9d2aeb39 | |||
3cee55f4c2 | |||
3815d2fd3b | |||
1453b7e0a3 | |||
6fb5c54280 | |||
9d5ca35e83 | |||
893dd0f9c4 | |||
c3419c0b74 | |||
a4164470d8 | |||
54cb076002 | |||
dbd3eb464b | |||
fddc4e647a | |||
798a351f15 | |||
e61dffff03 | |||
b9f5096480 | |||
9912d68c8b | |||
951b9be6e4 | |||
f64bf57000 | |||
f1242724b5 | |||
cd0c9df86e | |||
337d42287a | |||
ce3383f1b7 | |||
e51721303a | |||
50f6c77fdb | |||
5ed0135124 | |||
892a2d585f | |||
9890f2340a | |||
109b809909 |
@ -14,7 +14,7 @@ function accelerate() {
|
||||
}
|
||||
function update() {
|
||||
brick.clearScreen()
|
||||
brick.printLine("speed: " + speed, 1)
|
||||
brick.showString("speed: " + speed, 1)
|
||||
motors.largeBC.setSpeed(speed)
|
||||
}
|
||||
sensors.touch2.onEvent(TouchSensorEvent.Pressed, function () {
|
||||
|
@ -7,5 +7,5 @@ loops.forever(function () {
|
||||
})
|
||||
motors.largeBC.setSpeed(-20);
|
||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
|
||||
motors.stopAllMotors();
|
||||
motors.largeBC.stop();
|
||||
```
|
||||
|
@ -9,5 +9,5 @@ loops.forever(function () {
|
||||
})
|
||||
motors.largeBC.setSpeed(-20);
|
||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
|
||||
motors.stopAllMotors();
|
||||
motors.largeBC.stop();
|
||||
```
|
||||
|
@ -4,10 +4,9 @@
|
||||
let beep = false
|
||||
beep = true
|
||||
control.runInBackground(function () {
|
||||
motors.largeB.setSpeed(-20)
|
||||
motors.largeC.setSpeed(-20)
|
||||
motors.largeBC.setSpeed(-20)
|
||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
|
||||
motors.stopAllMotors()
|
||||
motors.largeBC.stop()
|
||||
beep = false
|
||||
})
|
||||
control.runInBackground(function () {
|
||||
|
109
docs/static/avatar.svg
vendored
Normal file
109
docs/static/avatar.svg
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1"
|
||||
id="svg2" inkscape:version="0.91 r13725" sodipodi:docname="avatar.svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32"
|
||||
style="enable-background:new 0 0 32 32;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#303030;}
|
||||
</style>
|
||||
<sodipodi:namedview bordercolor="#666666" borderopacity="1" gridtolerance="10" guidetolerance="10" id="namedview15" inkscape:current-layer="svg2" inkscape:cx="16" inkscape:cy="16" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-height="661" inkscape:window-maximized="0" inkscape:window-width="997" inkscape:window-x="0" inkscape:window-y="0" inkscape:zoom="5.2149125" objecttolerance="10" pagecolor="#ffffff" showgrid="false">
|
||||
</sodipodi:namedview>
|
||||
<g id="avatar_mf" transform="translate(-5304.979 8145.745)">
|
||||
<path id="Path_180" class="st0" d="M5317.1-8125.6c0.2,0,0.3-0.1,0.5-0.1l2.9-0.6c1.3-0.3,2.5-0.5,3.8-0.8c0.5-0.1,1-0.2,1.5-0.3
|
||||
c0.1,0,0.1,0,0.1-0.1c0-0.5,0-1-0.1-1.5c-0.1-0.6-0.2-1.1-0.3-1.7c-0.1-0.4-0.1-0.8-0.2-1.2c-0.1-0.7-0.2-1.4-0.3-2
|
||||
c-0.1-0.6-0.2-1.1-0.3-1.7c0-0.2-0.2-0.4-0.4-0.4c0,0,0,0-0.1,0c-0.2,0-0.5,0.1-0.7,0.1c-0.5,0.1-1,0.1-1.5,0.2
|
||||
c-0.5,0.1-1,0.1-1.6,0.2c-0.5,0.1-1,0.1-1.4,0.2c-0.2,0-0.3,0-0.5,0.1c-0.2,0-0.4,0.2-0.5,0.4c0,0.2-0.1,0.4-0.1,0.5
|
||||
c0,0.4-0.1,0.8-0.1,1.2c-0.1,0.5-0.1,1-0.2,1.5c0,0.4-0.1,0.9-0.1,1.3l-0.1,1.3l-0.1,1.3c-0.1,0.5-0.1,1-0.2,1.5
|
||||
C5317.1-8126,5317.1-8125.8,5317.1-8125.6z"/>
|
||||
<path id="Path_181" class="st0" d="M5316.1-8140c0,0.6,0.1,1.2,0.1,1.8c0,0.4,0.2,0.8,0.6,1c0.3,0.2,0.7,0.3,1.1,0.3
|
||||
c0.7,0.1,1.4,0.1,2.1,0c0.6,0,1.2-0.1,1.8-0.2c0.4,0,0.9-0.2,1.2-0.5c0.3-0.3,0.5-0.7,0.5-1.1c0-1.2,0-2.3-0.1-3.5
|
||||
c0-0.3-0.1-0.6-0.3-0.8c-0.3-0.4-0.8-0.6-1.4-0.6c0,0,0,0-0.1,0c-0.2,0.1-0.4,0.1-0.6,0.1c-0.9,0-1.8,0.1-2.7,0.1
|
||||
c-0.1,0-0.3,0-0.4,0c-0.4-0.1-0.8,0-1.2,0.2c-0.4,0.2-0.6,0.6-0.7,1c0,0.1,0,0.2,0,0.3C5316-8141.2,5316.1-8140.6,5316.1-8140
|
||||
L5316.1-8140z"/>
|
||||
<path id="Path_182" class="st0" d="M5312-8129.2c0,0.6,0,1.2,0,1.8c0,0.1,0,0.1,0.1,0.1c0.3,0,0.6,0.1,0.9,0.1c0.3,0,0.7,0,1,0
|
||||
c0.1,0,0.2,0,0.3,0c0.1,0,0.1,0,0.1-0.1c0.1-0.4,0.2-0.8,0.2-1.2c0.1-0.5,0.2-1,0.3-1.4c0-0.1,0.1-0.1,0.1-0.1
|
||||
c0.4-0.2,0.8-0.5,1.2-0.8c0.4-0.4,0.7-0.9,0.8-1.5c0.1-0.6,0-1.2-0.4-1.7c-0.2-0.3-0.6-0.4-0.9-0.3c-0.3,0.1-0.6,0.3-0.9,0.5
|
||||
c-0.7,0.6-1.5,1.2-2.2,1.8c-0.3,0.2-0.5,0.5-0.6,0.8c0,0.2-0.1,0.4-0.1,0.6C5311.9-8130.2,5311.9-8129.7,5312-8129.2
|
||||
C5311.9-8129.2,5312-8129.2,5312-8129.2z"/>
|
||||
<path id="Path_183" class="st0" d="M5315.5-8124.7c0,0.2-0.1,0.5-0.1,0.7c-0.1,0.5-0.4,0.9-0.8,1.1c0,0,0,0,0,0
|
||||
c-0.1,0-0.2,0.2-0.2,0.3c-0.4,1.4-0.9,2.7-1.3,4.1c0,0,0,0.1,0,0.1c0.8,1.1,1.6,2.2,2.4,3.3c0,0,0,0,0.1,0.1
|
||||
c0.1-0.2,0.1-0.3,0.2-0.5c0.1-0.3,0.2-0.5,0.3-0.8c0,0,0-0.1,0-0.1c-0.2-0.3-0.5-0.7-0.7-1c0,0,0-0.1,0-0.2
|
||||
c0.3-0.9,0.6-1.7,0.9-2.6c0,0,0-0.1,0.1-0.1c0.5-0.2,0.9-0.6,1.1-1.1c0.1-0.3,0.1-0.7,0.1-1.1c0-0.4-0.1-0.8-0.3-1.2
|
||||
c-0.2-0.4-0.5-0.8-1-1C5315.9-8124.7,5315.7-8124.7,5315.5-8124.7z"/>
|
||||
<path id="Path_184" class="st0" d="M5314.7-8134.2c0.1-0.1,0.2-0.1,0.3-0.2c0.3-0.2,0.7-0.3,1-0.3c0.4,0,0.7,0.2,0.8,0.6
|
||||
c0.6,1.1,0.5,2.4-0.4,3.3c-0.4,0.4-0.8,0.7-1.3,1c0,0-0.1,0.1-0.1,0.1c-0.2,0.8-0.3,1.6-0.5,2.5c0,0,0,0.1,0,0.1
|
||||
c0,0.2,0,0.2-0.2,0.2c-0.1,0-0.1,0-0.2,0c0,0.1,0,0.2,0,0.3c0,0,0,0,0.1,0.1l1.9,0.7c0.2,0.1,0.4,0.2,0.7,0.2c0-0.1,0-0.2,0-0.2
|
||||
c0-0.3,0-0.6,0-0.8l0.2-1.5l0.2-1.5c0.1-0.5,0.1-1,0.2-1.5c0.1-0.5,0.1-1.1,0.2-1.6c0.1-0.5,0.1-1,0.2-1.5c0-0.2,0-0.4,0-0.6
|
||||
c0-0.2-0.1-0.4-0.3-0.4c0,0,0,0,0,0c-0.1,0-0.1,0-0.2,0c-0.6-0.1-1.2-0.2-1.9-0.3c-0.1,0-0.2,0-0.3,0c-0.1,0-0.2,0.1-0.3,0.3
|
||||
C5314.8-8135,5314.7-8134.6,5314.7-8134.2z"/>
|
||||
<path id="Path_185" class="st0" d="M5324.5-8117.2c-0.2-0.7-0.5-1.3-0.7-2l-0.7,0.3c0,0-0.1,0-0.1,0c-0.1,0.1-0.2,0-0.2-0.1
|
||||
c-0.1-0.3-0.2-0.5-0.3-0.8c-0.2-0.7-0.5-1.4-0.7-2.1c0,0,0-0.1,0-0.1c0,0,0,0.1-0.1,0.1c-0.1,0.2-0.3,0.3-0.5,0.5c0,0-0.1,0-0.1,0
|
||||
c-0.3,0.1-0.6,0.1-0.8,0.2c0,0-0.1,0-0.1,0c0,0.2-0.1,0.3-0.1,0.5c0.6,1.5,1.1,3.1,1.7,4.6c0,0,0,0,0,0.1
|
||||
C5322.7-8116.3,5323.6-8116.7,5324.5-8117.2z"/>
|
||||
<path id="Path_186" class="st0" d="M5325.4-8123.1c-0.7,0.2-1.3,0.3-2,0.5c-0.5,0.1-0.9,0.2-1.4,0.3c-0.1,0-0.2,0.1-0.1,0.2
|
||||
c0,0,0,0,0,0.1c0.2,0.5,0.3,0.9,0.5,1.4c0.2,0.5,0.4,1.1,0.6,1.6c0,0,0,0,0,0c0.1-0.1,0.2-0.1,0.3-0.2c0.2-0.1,0.3-0.2,0.5-0.2
|
||||
c0.2-0.1,0.4-0.1,0.6-0.2c0.7-0.2,1.5-0.4,2.2-0.6c0,0,0,0,0.1,0C5326.3-8121.1,5325.9-8122.1,5325.4-8123.1z"/>
|
||||
<path id="Path_187" class="st0" d="M5320.7-8124.4c-0.4,0.1-0.8,0.2-1.2,0.3c-0.6,0.1-1.3,0.3-1.9,0.4c0,0-0.1,0-0.1,0
|
||||
c-0.1,0-0.2-0.1-0.3-0.1c0,0,0,0.1,0,0.1c0.3,0.7,0.4,1.5,0.3,2.2c-0.1,0.4-0.3,0.8-0.5,1.1c0,0,0,0-0.1,0.1
|
||||
c0.2-0.1,0.4-0.1,0.6-0.1l2.5-0.6c0.5-0.1,0.9-0.6,1-1.1c0.1-0.5,0-1-0.1-1.5C5320.8-8124,5320.8-8124.2,5320.7-8124.4z"/>
|
||||
<path id="Path_188" class="st0" d="M5325.5-8127c-2.7,0.5-5.3,1.1-7.9,1.6c0,0.5,0,0.9,0.1,1.4c0.1,0,0.2,0,0.3-0.1
|
||||
c1.2-0.3,2.3-0.5,3.5-0.8c1.2-0.3,2.4-0.5,3.6-0.8c0.1,0,0.3-0.1,0.4-0.1c0,0,0.1,0,0.1-0.1
|
||||
C5325.6-8126.2,5325.5-8126.6,5325.5-8127z"/>
|
||||
<path id="Path_189" class="st0" d="M5328.6-8118.4c-0.2-0.4-0.3-0.7-0.5-1.1c-0.1-0.2-0.2-0.5-0.3-0.7c0-0.1,0-0.1-0.1,0
|
||||
c-1.2,0.3-2.4,0.6-3.6,1c0,0,0,0-0.1,0c0.2,0.7,0.5,1.3,0.7,2C5326-8117.6,5327.3-8118,5328.6-8118.4z"/>
|
||||
<path id="Path_190" class="st0" d="M5319.9-8120.9l-0.6,0.1c-1,0.2-2,0.5-3,0.7c-0.1,0-0.1,0.1-0.1,0.1c-0.3,0.7-0.5,1.5-0.8,2.2
|
||||
c0,0,0,0,0,0.1c0.2,0,0.4-0.1,0.5-0.1c1-0.3,2-0.5,3.1-0.8c0.1,0,0.2-0.1,0.3-0.2C5319.5-8119.5,5319.7-8120.2,5319.9-8120.9z"/>
|
||||
<path id="Path_191" class="st0" d="M5325.1-8125.4c-1.1,0.2-2.2,0.5-3.3,0.7c0.3,0.7,0.4,1.4,0.3,2.2c0.2,0,0.4-0.1,0.5-0.1
|
||||
c0.9-0.2,1.8-0.4,2.7-0.6c0.1,0,0.1,0,0.1-0.1c0.1-0.4,0-0.9-0.1-1.3C5325.3-8124.9,5325.2-8125.1,5325.1-8125.4
|
||||
C5325.1-8125.3,5325.1-8125.4,5325.1-8125.4z"/>
|
||||
<path id="Path_192" class="st0" d="M5325.6-8132c0.2,0,0.4,0,0.5,0c0.2,0,0.4,0,0.6,0c0.3,0,0.6-0.2,0.8-0.4c0.3-0.4,0.7-0.8,1-1.2
|
||||
c-0.1-0.1-0.1-0.1-0.1-0.2c0,0,0,0-0.1,0c-0.7-0.1-1.3-0.5-1.4-1.2c-0.1-0.2-0.1-0.4-0.1-0.6c-0.2,0.1-0.3,0.3-0.5,0.4
|
||||
c-0.1,0.1-0.2,0.1-0.3,0.2c0,0-0.1,0.1-0.2,0c-0.2,0-0.5-0.1-0.7-0.1c0,0,0,0-0.1,0C5325.3-8134.1,5325.4-8133.1,5325.6-8132z"/>
|
||||
<path id="Path_193" class="st0" d="M5328.4-8134.2c0.2-0.3,0.5-0.5,0.8-0.7c0.4-0.4,0.6-0.8,0.7-1.4c0-0.1,0-0.2-0.1-0.3
|
||||
c-0.3-0.5-0.7-1.1-1-1.6c0-0.1-0.1-0.1-0.1,0c-0.4,0.2-0.8,0.5-1.1,0.8c-0.2,0.2-0.4,0.4-0.6,0.6c-0.1,0.1-0.1,0.3,0,0.4
|
||||
c0.5,0.7,1,1.5,1.4,2.2C5328.4-8134.2,5328.4-8134.2,5328.4-8134.2z"/>
|
||||
<path id="Path_194" class="st0" d="M5314.3-8126.1c-0.1-0.1-0.1-0.1-0.2-0.2c-0.1,0-0.1-0.1-0.1-0.2c0-0.1,0-0.3,0-0.4h-0.1
|
||||
c-0.6,0-1.2-0.1-1.7-0.2c0,0-0.1,0-0.1,0c-0.4,0.2-0.7,0.4-1,0.8c-0.4,0.6-0.4,1.4,0.1,1.9c0.2,0.2,0.4,0.4,0.6,0.6
|
||||
c0.1,0.1,0.2,0.2,0.3,0.2c-0.2-0.6,0-1.3,0.5-1.8C5313-8125.9,5313.6-8126.2,5314.3-8126.1z"/>
|
||||
<path id="Path_195" class="st0" d="M5315.7-8114.9c0.5-0.1,0.9-0.3,1.4-0.4c0.8-0.2,1.6-0.4,2.4-0.7c0.1,0,0.1,0,0.1-0.1
|
||||
c0.1-0.4,0.2-0.7,0.4-1.1c0,0,0,0,0-0.1c-0.1,0-0.2,0-0.3,0.1c-1.2,0.3-2.3,0.6-3.5,1c-0.1,0-0.1,0.1-0.1,0.1
|
||||
c-0.1,0.4-0.3,0.7-0.4,1.1C5315.7-8115,5315.7-8115,5315.7-8114.9z"/>
|
||||
<path id="Path_196" class="st0" d="M5315.4-8117.4c0.2,0.3,0.4,0.6,0.6,0.9c0,0,0.1,0,0.1,0c1-0.3,1.9-0.5,2.9-0.8
|
||||
c0.3-0.1,0.6-0.2,0.9-0.2c-0.1-0.1-0.1-0.2-0.2-0.2c-0.2-0.2-0.3-0.4-0.5-0.6c0,0-0.1-0.1-0.1,0c-0.9,0.3-1.9,0.5-2.8,0.8
|
||||
C5316-8117.5,5315.7-8117.5,5315.4-8117.4z"/>
|
||||
<path id="Path_197" class="st0" d="M5321.3-8143.6c0-0.3,0-0.7,0-1c0,0-0.1,0-0.1,0c-0.7,0-1.5,0-2.2,0.1c-0.4,0-0.7,0-1.1,0.1
|
||||
c-0.1,0-0.1,0-0.1,0.1c0,0.3,0,0.6,0,0.8c0,0,0,0.1,0.1,0.1c0.4,0,0.8,0,1.1,0c0.5,0,1.1,0,1.6-0.1
|
||||
C5320.9-8143.5,5321.1-8143.6,5321.3-8143.6z"/>
|
||||
<path id="Path_198" class="st0" d="M5329.2-8134.3c0.1,0,0.2,0,0.2-0.1c0.4-0.2,0.8-0.4,1.1-0.7c0.3-0.2,0.4-0.5,0.6-0.8
|
||||
c0.1-0.3,0.1-0.6-0.1-0.9c-0.4-0.5-0.7-1-1.1-1.6c0,0,0,0-0.1-0.1c-0.2,0.2-0.4,0.4-0.6,0.6c0,0,0,0,0,0c0,0,0,0.1,0,0.1
|
||||
c0.2,0.4,0.5,0.7,0.7,1c0.1,0.2,0.2,0.4,0.1,0.6c0,0.5-0.1,0.9-0.4,1.3c-0.1,0.1-0.2,0.2-0.3,0.3
|
||||
C5329.4-8134.5,5329.3-8134.4,5329.2-8134.3C5329.2-8134.3,5329.2-8134.3,5329.2-8134.3z"/>
|
||||
<path id="Path_199" class="st0" d="M5317.5-8136.7c0,0.2,0,0.3,0,0.5c0,0,0,0.1,0.1,0.1c0.2,0,0.3,0.1,0.5,0.1c0.7,0.1,1.4,0.1,2,0
|
||||
c0.4,0,0.8-0.1,1.2-0.1c0.2,0,0.5-0.1,0.7-0.1c0.1,0,0.1,0,0.1-0.1c0-0.2,0-0.3,0-0.5C5320.5-8136.6,5319-8136.5,5317.5-8136.7z"/>
|
||||
<path id="Path_200" class="st0" d="M5312.5-8123.2c0.1-0.4,0.1-0.8,0.2-1.2c0.1-0.6,0.6-1,1.2-1c0.3,0,0.5,0.1,0.7,0.3
|
||||
c0.2,0.2,0.2,0.4,0.2,0.7c-0.1,0.3-0.2,0.6-0.2,0.9c0,0.1-0.1,0.2-0.1,0.4c0,0,0,0,0,0c0.1-0.1,0.2-0.2,0.3-0.3
|
||||
c0.3-0.4,0.4-0.9,0.4-1.4c0-0.6-0.4-1-0.9-1.1c-0.1,0-0.1,0-0.2,0c-0.5,0-1,0.3-1.4,0.7c-0.3,0.3-0.4,0.6-0.5,1
|
||||
c-0.1,0.3,0,0.7,0.2,1C5312.5-8123.2,5312.5-8123.2,5312.5-8123.2z"/>
|
||||
<path id="Path_201" class="st0" d="M5314.3-8123.2c0.1-0.5,0.3-0.9,0.4-1.4c0.1-0.2,0-0.4-0.2-0.5c-0.4-0.2-0.9-0.1-1.2,0.2
|
||||
c0,0,0,0,0,0.1c0,0.2,0,0.4,0.1,0.6c0,0.1,0.1,0.2,0.2,0.3C5313.7-8123.6,5314-8123.4,5314.3-8123.2
|
||||
C5314.2-8123.2,5314.3-8123.2,5314.3-8123.2z"/>
|
||||
<path id="Path_202" class="st0" d="M5317.4-8124.1c0-0.4,0-0.9-0.1-1.3c-0.1,0-0.1,0-0.2,0c-0.1,0-0.2,0-0.3,0
|
||||
c-0.7-0.3-1.4-0.5-2.1-0.8c0,0,0,0,0,0c0.1,0.1,0.1,0.1,0.2,0.2c0.3,0.2,0.5,0.6,0.6,0.9c0,0,0,0,0,0c0.1,0,0.3,0,0.4,0.1
|
||||
c0.3,0.1,0.6,0.3,0.9,0.5c0,0,0.1,0.1,0.1,0.1C5317.1-8124.2,5317.2-8124.1,5317.4-8124.1z"/>
|
||||
<path id="Path_203" class="st0" d="M5321.6-8124.6c-0.2,0-0.4,0.1-0.6,0.1c0.1,0.2,0.1,0.4,0.2,0.6c0.1,0.4,0.2,0.8,0.1,1.2
|
||||
c0,0.5-0.1,0.9-0.4,1.3c0,0,0,0,0,0c0.3,0,0.6-0.2,0.7-0.5c0.2-0.3,0.3-0.6,0.3-0.9C5321.9-8123.4,5321.8-8124,5321.6-8124.6z"/>
|
||||
<path id="Path_204" class="st0" d="M5315.7-8135.8c0.2,0,0.3,0.1,0.5,0.1c0.5,0.1,1,0.2,1.5,0.2c0.2,0,0.5,0,0.7,0
|
||||
c0.7-0.1,1.4-0.2,2.1-0.2c0.6-0.1,1.2-0.2,1.8-0.2c0.5-0.1,1.1-0.1,1.6-0.2l-1.5-0.2c0,0,0,0,0,0c0,0.2-0.1,0.3-0.2,0.3
|
||||
c0,0,0,0,0,0c-0.3,0.1-0.5,0.1-0.8,0.2c-0.8,0.1-1.6,0.1-2.3,0.1c-0.4,0-0.9,0-1.3-0.1c-0.1,0-0.2-0.1-0.3-0.2c0,0-0.1,0-0.1,0
|
||||
c-0.3,0-0.6,0.1-0.9,0.1L5315.7-8135.8L5315.7-8135.8z"/>
|
||||
<path id="Path_205" class="st0" d="M5327.3-8117.7c-0.3,0.1-0.5,0.2-0.8,0.2c-0.6,0.2-1.1,0.3-1.7,0.5c0,0-0.1,0-0.1,0.1
|
||||
c-0.5,0.2-1,0.5-1.5,0.7c0,0,0,0,0,0c0.3-0.1,0.5-0.1,0.8-0.2c0.5-0.2,1.1-0.3,1.6-0.5c0.1,0,0.2-0.1,0.2-0.1
|
||||
C5326.2-8117.2,5326.8-8117.5,5327.3-8117.7C5327.3-8117.7,5327.3-8117.7,5327.3-8117.7C5327.3-8117.7,5327.3-8117.7,5327.3-8117.7
|
||||
z"/>
|
||||
<path id="Path_206" class="st0" d="M5327-8135.8c0,0.1,0,0.2,0,0.4c0.1,0.5,0.3,0.9,0.7,1.1c0.1,0.1,0.3,0.1,0.4,0.2l0,0
|
||||
C5327.8-8134.7,5327.4-8135.2,5327-8135.8L5327-8135.8z"/>
|
||||
<path id="Path_207" class="st0" d="M5329-8134.4c-0.1,0.1-0.2,0.2-0.3,0.4c0,0,0,0,0,0.1c0,0.1,0,0.1,0.1,0.1c0.1,0,0.2,0,0.3-0.1
|
||||
c0.1,0,0.2-0.1,0.3-0.1c-0.1,0-0.1-0.1-0.2-0.1C5329-8134.2,5329-8134.3,5329-8134.4z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 11 KiB |
@ -4,10 +4,11 @@
|
||||
import { deployCoreAsync, initAsync } from "./deploy";
|
||||
import { FieldPorts } from "./field_ports";
|
||||
import { FieldImages } from "./field_images";
|
||||
import {FieldSpeed} from "./field_speed";
|
||||
import { FieldSpeed } from "./field_speed";
|
||||
import { FieldBrickButtons } from "./field_brickbuttons";
|
||||
import { FieldTurnRatio } from "./field_turnratio";
|
||||
|
||||
pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
||||
pxt.editor.initExtensionsAsync = function(opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
||||
pxt.debug('loading pxt-ev3 target extensions...')
|
||||
updateBlocklyShape();
|
||||
const res: pxt.editor.ExtensionResult = {
|
||||
@ -23,6 +24,9 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
}, {
|
||||
selector: "brickbuttons",
|
||||
editor: FieldBrickButtons
|
||||
}, {
|
||||
selector: "turnratio",
|
||||
editor: FieldTurnRatio
|
||||
}],
|
||||
deployCoreAsync
|
||||
};
|
||||
|
@ -24,6 +24,9 @@ export class FieldPorts extends Blockly.FieldDropdown implements Blockly.FieldCu
|
||||
this.width_ = parseInt(options.width) || 300;
|
||||
}
|
||||
|
||||
trimOptions_() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a dropdown menu under the text.
|
||||
* @private
|
||||
@ -42,7 +45,8 @@ export class FieldPorts extends Blockly.FieldDropdown implements Blockly.FieldCu
|
||||
// Accessibility properties
|
||||
contentDiv.setAttribute('role', 'menu');
|
||||
contentDiv.setAttribute('aria-haspopup', 'true');
|
||||
const options = this.getOptions();
|
||||
let options = this.getOptions();
|
||||
options = options.sort();
|
||||
for (let i = 0, option: any; option = options[i]; i++) {
|
||||
let content = (options[i] as any)[0]; // Human-readable text or image.
|
||||
const value = (options[i] as any)[1]; // Language-neutral value.
|
||||
|
108
editor/field_turnratio.ts
Normal file
108
editor/field_turnratio.ts
Normal file
@ -0,0 +1,108 @@
|
||||
/// <reference path="../node_modules/pxt-core/localtypings/blockly.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
|
||||
|
||||
export interface FieldTurnRatioOptions extends Blockly.FieldCustomOptions {
|
||||
}
|
||||
|
||||
export class FieldTurnRatio extends Blockly.FieldSlider implements Blockly.FieldCustom {
|
||||
public isFieldCustom_ = true;
|
||||
|
||||
private params: any;
|
||||
|
||||
private path_: SVGPathElement;
|
||||
private reporter_: SVGTextElement;
|
||||
|
||||
/**
|
||||
* Class for a color wheel field.
|
||||
* @param {number|string} value The initial content of the field.
|
||||
* @param {Function=} opt_validator An optional function that is called
|
||||
* to validate any constraints on what the user entered. Takes the new
|
||||
* text as an argument and returns either the accepted text, a replacement
|
||||
* text, or null to abort the change.
|
||||
* @extends {Blockly.FieldNumber}
|
||||
* @constructor
|
||||
*/
|
||||
constructor(value_: any, params: FieldTurnRatioOptions, opt_validator?: Function) {
|
||||
super(String(value_), '-100', '100', null, '10', 'TurnRatio', opt_validator);
|
||||
this.params = params;
|
||||
(this as any).sliderColor_ = '#a8aaa8';
|
||||
}
|
||||
|
||||
static HALF = 80;
|
||||
static HANDLE_RADIUS = 30;
|
||||
static RADIUS = FieldTurnRatio.HALF - FieldTurnRatio.HANDLE_RADIUS - 1;
|
||||
|
||||
createLabelDom_(labelText: string) {
|
||||
let labelContainer = document.createElement('div');
|
||||
let svg = Blockly.utils.createSvgElement('svg', {
|
||||
'xmlns': 'http://www.w3.org/2000/svg',
|
||||
'xmlns:html': 'http://www.w3.org/1999/xhtml',
|
||||
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
||||
'version': '1.1',
|
||||
'height': (FieldTurnRatio.HALF + FieldTurnRatio.HANDLE_RADIUS + 10) + 'px',
|
||||
'width': (FieldTurnRatio.HALF * 2) + 'px'
|
||||
}, labelContainer);
|
||||
let defs = Blockly.utils.createSvgElement('defs', {}, svg);
|
||||
let marker = Blockly.utils.createSvgElement('marker', {
|
||||
'id': 'head',
|
||||
'orient': "auto",
|
||||
'markerWidth': '2',
|
||||
'markerHeight': '4',
|
||||
'refX': '0.1', 'refY': '1.5'
|
||||
}, defs);
|
||||
let markerPath = Blockly.utils.createSvgElement('path', {
|
||||
'd': 'M0,0 V3 L1.5,1.5 Z',
|
||||
'fill': '#f12a21'
|
||||
}, marker);
|
||||
this.reporter_ = pxsim.svg.child(svg, "text", {
|
||||
'x': FieldTurnRatio.HALF, 'y': 96,
|
||||
'text-anchor': 'middle', 'alignment-baseline': 'middle',
|
||||
'style': 'font-size: 50px',
|
||||
'class': 'sim-text inverted number'
|
||||
}) as SVGTextElement;
|
||||
this.path_ = Blockly.utils.createSvgElement('path', {
|
||||
'x1': FieldTurnRatio.HALF,
|
||||
'y1': FieldTurnRatio.HALF,
|
||||
'marker-end': 'url(#head)',
|
||||
'style': 'fill: none; stroke: #f12a21; stroke-width: 10'
|
||||
}, svg);
|
||||
this.updateGraph_();
|
||||
let readout = document.createElement('span');
|
||||
readout.setAttribute('class', 'blocklyFieldSliderReadout');
|
||||
return [labelContainer, readout];
|
||||
};
|
||||
|
||||
updateGraph_() {
|
||||
if (!this.path_) {
|
||||
return;
|
||||
}
|
||||
let v = goog.math.clamp(parseFloat(this.getText()), -100, 100);
|
||||
if (isNaN(v)) {
|
||||
v = 0;
|
||||
}
|
||||
|
||||
const x = goog.math.clamp(parseFloat(this.getText()), -100, 100) / 100;
|
||||
const theta = x * Math.PI / 2;
|
||||
const cx = FieldTurnRatio.HALF;
|
||||
const cy = FieldTurnRatio.HALF - 14;
|
||||
const gamma = Math.PI - 2 * theta;
|
||||
const r = FieldTurnRatio.RADIUS;
|
||||
const alpha = 0.2 + Math.abs(x) * 0.5;
|
||||
const x1 = 0;
|
||||
const y1 = r * alpha;
|
||||
const y2 = r * Math.sin(Math.PI / 2 - theta);
|
||||
const x2 = r * Math.cos(Math.PI / 2 - theta);
|
||||
const y3 = y2 - r * alpha * Math.cos(2 * theta);
|
||||
const x3 = x2 - r * alpha * Math.sin(2 * theta);
|
||||
|
||||
|
||||
const d = `M ${cx} ${cy} C ${cx} ${cy - y1} ${cx + x3} ${cy - y3} ${cx + x2} ${cy - y2}`;
|
||||
this.path_.setAttribute('d', d);
|
||||
|
||||
this.reporter_.textContent = `${v}`;
|
||||
}
|
||||
|
||||
setReadout_(readout: Element, value: string) {
|
||||
this.updateGraph_();
|
||||
}
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
{
|
||||
"chassis.Chassis": "A differential drive robot",
|
||||
"chassis.Chassis.drive": "Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)\nusing a unicycle model.",
|
||||
"chassis.Chassis.driveFor": "Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)\nusing a unicycle model.",
|
||||
"chassis.Chassis.driveFor|param|rotationSpeed": "rotation of the robot around the center point, eg: 30",
|
||||
"chassis.Chassis.driveFor|param|speed": "speed of the center point between motors, eg: 10",
|
||||
"chassis.Chassis.driveFor|param|value": "the amount of movement, eg: 2",
|
||||
"chassis.Chassis.drive|param|rotationSpeed": "rotation of the robot around the center point, eg: 30",
|
||||
"chassis.Chassis.drive|param|speed": "speed of the center point between motors, eg: 10",
|
||||
"chassis.Chassis.drive|param|value": "the amount of movement, eg: 2",
|
||||
"chassis.Chassis.setMotors": "Sets the motors used by the chassis, default is B+C",
|
||||
"chassis.Chassis.setProperty": "Sets a property of the robot",
|
||||
"chassis.Chassis.setProperty|param|property": "the property to set",
|
||||
|
@ -1,7 +1,6 @@
|
||||
{
|
||||
"ChassisProperty.BaseLength|block": "base length (cm)",
|
||||
"ChassisProperty.WheelRadius|block": "wheel radius (cm)",
|
||||
"chassis.Chassis.driveFor|block": "drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s|for %value|%unit",
|
||||
"chassis.Chassis.drive|block": "drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s",
|
||||
"chassis.Chassis.setMotors|block": "set %chassis|motors to %motors",
|
||||
"chassis.Chassis.setProperty|block": "set %chassis|%property|to %value",
|
||||
|
@ -24,19 +24,6 @@ namespace chassis {
|
||||
this.baseLength = 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)
|
||||
* using a unicycle model.
|
||||
* @param speed speed of the center point between motors, eg: 10
|
||||
* @param rotationSpeed rotation of the robot around the center point, eg: 30
|
||||
*/
|
||||
//% blockId=motorDrive block="drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s"
|
||||
//% inlineInputMode=inline
|
||||
//% weight=99 blockGap=8
|
||||
drive(speed: number, rotationSpeed: number) {
|
||||
this.driveFor(speed, rotationSpeed, 0, MoveUnit.Degrees);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)
|
||||
* using a unicycle model.
|
||||
@ -45,10 +32,10 @@ namespace chassis {
|
||||
* @param value the amount of movement, eg: 2
|
||||
* @param unit
|
||||
*/
|
||||
//% blockId=motorDriveFor block="drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s|for %value|%unit"
|
||||
//% blockId=motorDrive block="drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s"
|
||||
//% inlineInputMode=inline
|
||||
//% weight=95 blockGap=8
|
||||
driveFor(speed: number, rotationSpeed: number, value: number, unit: MoveUnit) {
|
||||
drive(speed: number, rotationSpeed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
||||
// speed is expressed in %
|
||||
const R = this.wheelRadius; // cm
|
||||
const L = this.baseLength; // cm
|
||||
@ -65,7 +52,7 @@ namespace chassis {
|
||||
const sr = vr / maxw * 100; // %
|
||||
const sl = vl / maxw * 100; // %
|
||||
|
||||
this.motors.tankFor(sr, sl, value, unit)
|
||||
this.motors.tank(sr, sl, value, unit)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,5 +11,8 @@
|
||||
"sensors.ColorSensor.onLightChanged|param|handler": "the code to run when detected",
|
||||
"sensors.ColorSensor.pauseForColor": "Waits for the given color to be detected",
|
||||
"sensors.ColorSensor.pauseForColor|param|color": "the color to detect",
|
||||
"sensors.ColorSensor.pauseForLight": "Waits for the given color to be detected"
|
||||
"sensors.ColorSensor.pauseForLight": "Waits for the given color to be detected",
|
||||
"sensors.ColorSensor.setThreshold": "Sets a threshold value",
|
||||
"sensors.ColorSensor.setThreshold|param|condition": "the dark or bright light condition",
|
||||
"sensors.ColorSensor.setThreshold|param|value": "the value threshold"
|
||||
}
|
@ -19,11 +19,13 @@
|
||||
"sensors.ColorSensor.onLightChanged|block": "on %sensor|%mode|%condition",
|
||||
"sensors.ColorSensor.pauseForColor|block": "pause %sensor|for color %color",
|
||||
"sensors.ColorSensor.pauseForLight|block": "pause %sensor|for %mode|%condition",
|
||||
"sensors.ColorSensor.setThreshold|block": "set %sensor|%condition|to %value",
|
||||
"sensors.color1|block": "color 1",
|
||||
"sensors.color2|block": "color 2",
|
||||
"sensors.color3|block": "color 3",
|
||||
"sensors.color4|block": "color 4",
|
||||
"sensors|block": "sensors",
|
||||
"{id:category}Sensors": "Sensors",
|
||||
"{id:group}Color Sensor": "Color Sensor"
|
||||
"{id:group}Color Sensor": "Color Sensor",
|
||||
"{id:group}Threshold": "Threshold"
|
||||
}
|
@ -152,7 +152,7 @@ namespace sensors {
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% weight=99
|
||||
//% weight=98
|
||||
//% group="Color Sensor"
|
||||
color(): ColorSensorColor {
|
||||
this.setMode(ColorSensorMode.Color)
|
||||
@ -221,6 +221,21 @@ namespace sensors {
|
||||
reflectedLight() {
|
||||
return this.light(LightIntensityMode.Reflected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a threshold value
|
||||
* @param condition the dark or bright light condition
|
||||
* @param value the value threshold
|
||||
*/
|
||||
//% blockId=colorSetThreshold block="set %sensor|%condition|to %value"
|
||||
//% group="Threshold" blockGap=8 weight=90
|
||||
//% value.min=0 value.max=100
|
||||
setThreshold(condition: LightCondition, value: number) {
|
||||
if (condition == LightCondition.Dark)
|
||||
this.thresholdDetector.setLowThreshold(value)
|
||||
else
|
||||
this.thresholdDetector.setHighThreshold(value);
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed block="color 3" weight=90 fixedInstance jres=icons.port3
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"BrickLight": "Patterns for lights under the buttons.",
|
||||
"ButtonEvent": "User interaction on buttons",
|
||||
"Draw": "Drawing modes",
|
||||
"Image.buffer": "Returns the underlaying Buffer object.",
|
||||
@ -6,14 +7,15 @@
|
||||
"Image.draw": "Draw an image on the screen.",
|
||||
"Image.height": "Returns the height of an image.",
|
||||
"Image.width": "Returns the width of an image.",
|
||||
"LightsPattern": "Patterns for lights under the buttons.",
|
||||
"MMap.getNumber": "Read a number in specified format from the buffer.",
|
||||
"MMap.ioctl": "Perform ioctl(2) on the underlaying file",
|
||||
"MMap.length": "Returns the length of a Buffer object.",
|
||||
"MMap.lseek": "Set pointer on the underlaying file.",
|
||||
"MMap.read": "Perform read(2) on the underlaying file",
|
||||
"MMap.setNumber": "Write a number in specified format in the buffer.",
|
||||
"MMap.slice": "Read a range of bytes into a buffer.",
|
||||
"MMap.write": "Perform write(2) on the underlaying file",
|
||||
"SeekWhence": "Mode for lseek()",
|
||||
"brick.Button": "Generic button class, for device buttons and sensors.",
|
||||
"brick.Button.isPressed": "Check if button is currently pressed or not.",
|
||||
"brick.Button.onEvent": "Do something when a button or sensor is clicked, up or down.",
|
||||
@ -28,11 +30,9 @@
|
||||
"brick.buttonRight": "Right button on the EV3 Brick.",
|
||||
"brick.buttonUp": "Up button on the EV3 Brick.",
|
||||
"brick.clearScreen": "Clears the screen",
|
||||
"brick.lightPattern": "Pattern block.",
|
||||
"brick.lightPattern|param|pattern": "the lights pattern to use. eg: LightsPattern.Green",
|
||||
"brick.printPorts": "Prints the port states on the screen",
|
||||
"brick.setLight": "Set lights.",
|
||||
"brick.setLight|param|pattern": "the lights pattern to use.",
|
||||
"brick.setLight|param|pattern": "the lights pattern to use. eg: BrickLight.Orange",
|
||||
"brick.showImage": "Shows an image on screen",
|
||||
"brick.showImage|param|image": "image to draw",
|
||||
"brick.showNumber": "Shows a number on the screen",
|
||||
@ -61,6 +61,8 @@
|
||||
"control.raiseEvent|param|value": "Component specific code indicating the cause of the event.",
|
||||
"motors.Motor.angle": "Gets motor angle.",
|
||||
"motors.Motor.clearCounts": "Clears the motor count",
|
||||
"motors.Motor.setRegulated": "Indicates if the motor speed should be regulated. Default is true.",
|
||||
"motors.Motor.setRegulated|param|value": "true for regulated motor",
|
||||
"motors.Motor.speed": "Gets motor actual speed.",
|
||||
"motors.Motor.tacho": "Gets motor tachometer count.",
|
||||
"motors.Motor.toString": "Returns the status of the motor",
|
||||
@ -71,7 +73,7 @@
|
||||
"motors.MotorBase.setBrake": "Sets the automatic brake on or off when the motor is off",
|
||||
"motors.MotorBase.setBrake|param|brake": "a value indicating if the motor should break when off",
|
||||
"motors.MotorBase.setReversed": "Reverses the motor polarity",
|
||||
"motors.MotorBase.setSpeed": "Sets the motor speed for limited time or distance",
|
||||
"motors.MotorBase.setSpeed": "Sets the motor speed for limited time or distance.",
|
||||
"motors.MotorBase.setSpeed|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50",
|
||||
"motors.MotorBase.setSpeed|param|unit": "(optional) unit of the value",
|
||||
"motors.MotorBase.setSpeed|param|value": "(optional) measured distance or rotation",
|
||||
|
@ -1,17 +1,17 @@
|
||||
{
|
||||
"BrickLight.GreenFlash|block": "green flash",
|
||||
"BrickLight.GreenPulse|block": "green pulse",
|
||||
"BrickLight.Green|block": "green",
|
||||
"BrickLight.Off|block": "off",
|
||||
"BrickLight.OrangeFlash|block": "orange flash",
|
||||
"BrickLight.OrangePulse|block": "orange pulse",
|
||||
"BrickLight.Orange|block": "orange",
|
||||
"BrickLight.RedFlash|block": "red flash",
|
||||
"BrickLight.RedPulse|block": "red pulse",
|
||||
"BrickLight.Red|block": "red",
|
||||
"ButtonEvent.Click|block": "click",
|
||||
"ButtonEvent.Down|block": "down",
|
||||
"ButtonEvent.Up|block": "up",
|
||||
"LightsPattern.GreenFlash|block": "Flashing Green",
|
||||
"LightsPattern.GreenPulse|block": "Pulsing Green",
|
||||
"LightsPattern.Green|block": "Green",
|
||||
"LightsPattern.Off|block": "Off",
|
||||
"LightsPattern.OrangeFlash|block": "Flashing Orange",
|
||||
"LightsPattern.OrangePulse|block": "Pulsing Orange",
|
||||
"LightsPattern.Orange|block": "Orange",
|
||||
"LightsPattern.RedFlash|block": "Flashing Red",
|
||||
"LightsPattern.RedPulse|block": "Pulsing Red",
|
||||
"LightsPattern.Red|block": "Red",
|
||||
"MoveUnit.Degrees|block": "degrees",
|
||||
"MoveUnit.MilliSeconds|block": "milliseconds",
|
||||
"MoveUnit.Rotations|block": "rotations",
|
||||
@ -30,15 +30,14 @@
|
||||
"brick.Button.pauseUntil|block": "pause until %button|%event",
|
||||
"brick.Button.wasPressed|block": "%button|was pressed",
|
||||
"brick.batteryLevel|block": "battery level",
|
||||
"brick.buttonDown|block": "down",
|
||||
"brick.buttonEnter|block": "enter",
|
||||
"brick.buttonLeft|block": "left",
|
||||
"brick.buttonRight|block": "right",
|
||||
"brick.buttonUp|block": "up",
|
||||
"brick.buttonDown|block": "button down",
|
||||
"brick.buttonEnter|block": "button enter",
|
||||
"brick.buttonLeft|block": "button left",
|
||||
"brick.buttonRight|block": "button right",
|
||||
"brick.buttonUp|block": "button up",
|
||||
"brick.clearScreen|block": "clear screen",
|
||||
"brick.lightPattern|block": "%pattern",
|
||||
"brick.printPorts|block": "print ports",
|
||||
"brick.setLight|block": "set light to %pattern=led_pattern",
|
||||
"brick.setLight|block": "set light to %pattern",
|
||||
"brick.showImage|block": "show image %image=screen_image_picker",
|
||||
"brick.showNumber|block": "show number %name|at line %line",
|
||||
"brick.showString|block": "show string %text|at line %line",
|
||||
@ -52,13 +51,16 @@
|
||||
"control|block": "control",
|
||||
"motors.Motor.angle|block": "%motor|angle",
|
||||
"motors.Motor.clearCounts|block": "%motor|clear counts",
|
||||
"motors.Motor.setRegulated|block": "set %motor|regulated %value",
|
||||
"motors.Motor.speed|block": "%motor|speed",
|
||||
"motors.Motor.tacho|block": "%motor|tacho",
|
||||
"motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready",
|
||||
"motors.MotorBase.reset|block": "%motors|reset",
|
||||
"motors.MotorBase.setBrake|block": "set %motor|brake %brake",
|
||||
"motors.MotorBase.setReversed|block": "set %motor|reversed %reversed",
|
||||
"motors.MotorBase.setSpeed|block": "set %motor|speed to %speed=motorSpeedPicker|%",
|
||||
"motors.SynchedMotorPair.steer|block": "steer %chassis|turn ratio %turnRatio|speed %speed=motorSpeedPicker|%",
|
||||
"motors.MotorBase.stop|block": "%motors|stop",
|
||||
"motors.SynchedMotorPair.steer|block": "steer %chassis|turn ratio %turnRatio=motorTurnRatioPicker|speed %speed=motorSpeedPicker|%",
|
||||
"motors.SynchedMotorPair.tank|block": "tank %motors|%speedLeft=motorSpeedPicker|%|%speedRight=motorSpeedPicker|%",
|
||||
"motors.largeAB|block": "large A+B",
|
||||
"motors.largeAD|block": "large A+D",
|
||||
@ -90,7 +92,6 @@
|
||||
"{id:category}Serial": "Serial",
|
||||
"{id:group}Buttons": "Buttons",
|
||||
"{id:group}Counters": "Counters",
|
||||
"{id:group}Light": "Light",
|
||||
"{id:group}More": "More",
|
||||
"{id:group}Move": "Move",
|
||||
"{id:group}Screen": "Screen",
|
||||
|
@ -2,35 +2,35 @@
|
||||
/**
|
||||
* Patterns for lights under the buttons.
|
||||
*/
|
||||
const enum LightsPattern {
|
||||
//% block=Off enumval=0
|
||||
const enum BrickLight {
|
||||
//% block=off enumval=0
|
||||
//% blockIdentity=brick.lightPattern
|
||||
Off = 0,
|
||||
//% block=Green enumval=1
|
||||
//% block=green enumval=1
|
||||
//% blockIdentity=brick.lightPattern
|
||||
Green = 1,
|
||||
//% block=Red enumval=2
|
||||
//% block=red enumval=2
|
||||
//% blockIdentity=brick.lightPattern
|
||||
Red = 2,
|
||||
//% block=Orange enumval=3
|
||||
//% block=orange enumval=3
|
||||
//% blockIdentity=brick.lightPattern
|
||||
Orange = 3,
|
||||
//% block="Flashing Green" enumval=4
|
||||
//% block="green flash" enumval=4
|
||||
//% blockIdentity=brick.lightPattern
|
||||
GreenFlash = 4,
|
||||
//% block="Flashing Red" enumval=5
|
||||
//% block="red flash" enumval=5
|
||||
//% blockIdentity=brick.lightPattern
|
||||
RedFlash = 5,
|
||||
//% block="Flashing Orange" enumval=6
|
||||
//% block="orange flash" enumval=6
|
||||
//% blockIdentity=brick.lightPattern
|
||||
OrangeFlash = 6,
|
||||
//% block="Pulsing Green" enumval=7
|
||||
//% block="green pulse" enumval=7
|
||||
//% blockIdentity=brick.lightPattern
|
||||
GreenPulse = 7,
|
||||
//% block="Pulsing Red" enumval=8
|
||||
//% block="red pulse" enumval=8
|
||||
//% blockIdentity=brick.lightPattern
|
||||
RedPulse = 8,
|
||||
//% block="Pulsing Orange" enumval=9
|
||||
//% block="orange pulse" enumval=9
|
||||
//% blockIdentity=brick.lightPattern
|
||||
OrangePulse = 9,
|
||||
}
|
||||
@ -170,6 +170,7 @@ namespace brick {
|
||||
// this needs to be done in query(), which is run without the main JS execution mutex
|
||||
// otherwise, while(true){} will lock the device
|
||||
if (ret & DAL.BUTTON_ID_ESCAPE) {
|
||||
motors.stopAllMotors(); // ensuring that all motors are off
|
||||
control.reset()
|
||||
}
|
||||
return ret
|
||||
@ -203,31 +204,31 @@ namespace brick {
|
||||
/**
|
||||
* Enter button on the EV3 Brick.
|
||||
*/
|
||||
//% whenUsed block="enter" weight=95 fixedInstance
|
||||
//% whenUsed block="button enter" weight=95 fixedInstance
|
||||
export const buttonEnter: Button = new DevButton(DAL.BUTTON_ID_ENTER)
|
||||
|
||||
/**
|
||||
* Left button on the EV3 Brick.
|
||||
*/
|
||||
//% whenUsed block="left" weight=95 fixedInstance
|
||||
//% whenUsed block="button left" weight=95 fixedInstance
|
||||
export const buttonLeft: Button = new DevButton(DAL.BUTTON_ID_LEFT)
|
||||
|
||||
/**
|
||||
* Right button on the EV3 Brick.
|
||||
*/
|
||||
//% whenUsed block="right" weight=94 fixedInstance
|
||||
//% whenUsed block="button right" weight=94 fixedInstance
|
||||
export const buttonRight: Button = new DevButton(DAL.BUTTON_ID_RIGHT)
|
||||
|
||||
/**
|
||||
* Up button on the EV3 Brick.
|
||||
*/
|
||||
//% whenUsed block="up" weight=95 fixedInstance
|
||||
//% whenUsed block="button up" weight=95 fixedInstance
|
||||
export const buttonUp: Button = new DevButton(DAL.BUTTON_ID_UP)
|
||||
|
||||
/**
|
||||
* Down button on the EV3 Brick.
|
||||
*/
|
||||
//% whenUsed block="down" weight=95 fixedInstance
|
||||
//% whenUsed block="button down" weight=95 fixedInstance
|
||||
export const buttonDown: Button = new DevButton(DAL.BUTTON_ID_DOWN)
|
||||
}
|
||||
|
||||
@ -251,32 +252,21 @@ namespace control {
|
||||
}
|
||||
|
||||
namespace brick {
|
||||
let currPattern: LightsPattern
|
||||
// the brick starts with the red color
|
||||
let currPattern: BrickLight = BrickLight.Red;
|
||||
|
||||
/**
|
||||
* Set lights.
|
||||
* @param pattern the lights pattern to use.
|
||||
* @param pattern the lights pattern to use. eg: BrickLight.Orange
|
||||
*/
|
||||
//% blockId=setLights block="set light to %pattern=led_pattern"
|
||||
//% blockId=setLights block="set light to %pattern"
|
||||
//% weight=100 group="Buttons"
|
||||
export function setLight(pattern: number): void {
|
||||
export function setLight(pattern: BrickLight): void {
|
||||
if (currPattern === pattern)
|
||||
return
|
||||
currPattern = pattern
|
||||
let cmd = output.createBuffer(2)
|
||||
currPattern = pattern;
|
||||
const cmd = output.createBuffer(2)
|
||||
cmd[0] = pattern + 48
|
||||
brick.internal.getBtnsMM().write(cmd)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pattern block.
|
||||
* @param pattern the lights pattern to use. eg: LightsPattern.Green
|
||||
*/
|
||||
//% blockId=led_pattern block="%pattern"
|
||||
//% shim=TD_ID colorSecondary="#6e9a36" group="Light"
|
||||
//% blockHidden=true useEnumVal=1 pattern.fieldOptions.decompileLiterals=1
|
||||
export function lightPattern(pattern: LightsPattern): number {
|
||||
return pattern;
|
||||
}
|
||||
}
|
||||
|
11
libs/core/enums.d.ts
vendored
11
libs/core/enums.d.ts
vendored
@ -1,6 +1,17 @@
|
||||
// Auto-generated. Do not edit.
|
||||
|
||||
|
||||
/**
|
||||
* Mode for lseek()
|
||||
*/
|
||||
|
||||
declare const enum SeekWhence {
|
||||
Set = 0,
|
||||
Current = 1,
|
||||
End = 2,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Drawing modes
|
||||
*/
|
||||
|
@ -114,23 +114,7 @@
|
||||
"progressWaterLevel3": "iVBORw0KGgoAAAANSUhEUgAAALIAAACAAQAAAACHQw5jAAABP0lEQVR42u2VMWrEMBBFRxGsGrNqXYT4CltuFV9lj5EqVlhImyPkKoKFbJcrrHKCKJ2XKFb+BGxsGBdbBRJ/mGHm+VtjJGNT/srQO6cG8cnFKXvKLVdHRFcjfXD3xDyybY9IFVJgbpgHtilEa5E8XJ1m/gJbVwJFXuwRrqSYa9hSCZt/A1/B1VLjqdMG1mu0bgeD4W5Te2r1A6YVJne0qfNP57fWU9AY5dYKd29tDgodldoTqagjGaoc3VAiiibQmlg1ApeIQIjuufDUq+C0Q1z1xaJFi/60iluZ28aJ3Jy9yPU5iFxlmesZvsry+kUz8/z/5qTuZKyizM2F3IYZfnDyuR7kc61fL+P4qYmq0mCZ+tuhfHZjPvhV8iKnMVejuZNXrjnK3O77aeo03hEzNGqyUcbNnJdfPjqLFv2+vgH+JtBJ4nz/SAAAAABJRU5ErkJggg==",
|
||||
"systemAccept1": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQAQAAAAAkX4I4AAAAQElEQVR42mM4wMDMsP//X4b6//+AWI6h/p8dQ/2fOob6H/8YKj/+Y6h4/I+hxvkfQx07UJ4fiOf/A6sF6QHqBQDsYh9jNdETHwAAAABJRU5ErkJggg==",
|
||||
"systemAccept2": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQAQAAAAAkX4I4AAAAQUlEQVR42mM4wMDMsP//X4YEBjYGB4ZHDA6MhxgcmJsYHNiZGNz4mBjcZZgYnPcwMTj+YGJw+ADECUxgtSA9QL0A+IIPxwiZFtwAAAAASUVORK5CYII=",
|
||||
"systemAlert": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAVAQAAAAB0khOLAAAARUlEQVR42iXD0QmAIAAE0IvWCtqmMbLG8MtVhAZwjBvALyE85XzwoE/QO8f5WPsd0K+An6c3Jq8sThIUUVg9qfmDDRn7AD/WMAQEJ+pCAAAAAElFTkSuQmCC",
|
||||
"systemBox": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQAQAAAAAkX4I4AAAAGklEQVR42mM4wMDMsP//X4b6//9IwiA9QL0AlQYkzY8nCoAAAAAASUVORK5CYII=",
|
||||
"systemBusy0": "iVBORw0KGgoAAAANSUhEUgAAABMAAAAPAQAAAAAuP8mBAAAAMElEQVR42mPY/38Bg/x/BgbnHw4Msd8dGKLeA+k4IL0XSGdB6TioOFAepA6kHqgPAJCPFdTsOCPGAAAAAElFTkSuQmCC",
|
||||
"systemBusy1": "iVBORw0KGgoAAAANSUhEUgAAAA8AAAATAQAAAABnuWoHAAAAOUlEQVR42mNoYGKw/8EAJO9/A6GrYQyv1jF8jWP4tY/hbx3D730M3+4xvH/HcO8bw90yhlvbGGDqAdjhGYsKgwC5AAAAAElFTkSuQmCC",
|
||||
"systemDecline1": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQAQAAAAAkX4I4AAAANUlEQVR42mM4wMDMsP//X4b6//8Y6urtGOrt6hjq5/xjqD8JxI+hGMQGiQHlwGqAakF6gHoBybUeX0RcSJEAAAAASUVORK5CYII=",
|
||||
"systemDecline2": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQAQAAAAAkX4I4AAAANUlEQVR42mM4wMDMsP//X4YEBjYGx4ZDDA4HmxgckpkYHMyAWAaKQWyQGFAOpAakFqQHqBcAGz4QyzSHE/gAAAAASUVORK5CYII=",
|
||||
"systemDotEmpty": "iVBORw0KGgoAAAANSUhEUgAAAB8AAAAfAQAAAAA31SuUAAAAYklEQVR42oWOMQ5AQBRE5yZ7FEfSKTmC25CQuILehkahkc12IvgjRqHUTPX/ew+MzsByNlhxGq7ochz90mFL9gmBFjCSGTxZoSUb1OTwTkquP/Md61cU8USWQzZ5VaCWp+oGeLZn9EklJaAAAAAASUVORK5CYII=",
|
||||
"systemDotFull": "iVBORw0KGgoAAAANSUhEUgAAAB8AAAAfAQAAAAA31SuUAAAAX0lEQVR42mP4/0H+H8P//sf/GP7V//nH8PeDfB3D7wPs+xi+MzDeY3jHAER3GBjKGG4wMJgx7GBgsGLYwMAgBSESGBh4CBAIxWC9YFPA5oFNBtsBtg1sL9gFYLeAXAUAPIwyHWLMTS8AAAAASUVORK5CYII=",
|
||||
"systemEv3small": "iVBORw0KGgoAAAANSUhEUgAAACsAAAANAQAAAAAY06pGAAAAPUlEQVR42mNg4LFvYwACFEr+n32fPYiS5/8P5PLLyz8AUXwQqs8eSMn/b7H/D6IO1NmDBA/UgbTzP/gHpwBcwBWO2QYBDwAAAABJRU5ErkJggg==",
|
||||
"systemPlay": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQAAAAA3iMLMAAAAMElEQVR42mP4Y8/wsZ/h+XOG858Z5v5k2POXwcaGoUYOhIAMIBcoCJQCKgAq+2MPAAFKFVmziLfGAAAAAElFTkSuQmCC",
|
||||
"systemSlider0": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAEklEQVR42mM4YMBwfwPV0AEDAHmKKNims3dJAAAAAElFTkSuQmCC",
|
||||
"systemSlider1": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAGklEQVR42mM4YMBwfwNFCAKuGjCc2sBwwAAAT7olG9TpXdAAAAAASUVORK5CYII=",
|
||||
"systemSlider2": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAG0lEQVR42mM4YMBwfwM5CAJObWC4aoAgDxgAACpUJGftPg+WAAAAAElFTkSuQmCC",
|
||||
"systemSlider3": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAG0lEQVR42mM4YMBwfwMJCAKuGjCc2oCFPGAAAPSIIz417p4OAAAAAElFTkSuQmCC",
|
||||
"systemSlider4": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAG0lEQVR42mM4YMBwfwNhBAGnNjBcNcBHHjAAAMJ6IooqNLP/AAAAAElFTkSuQmCC",
|
||||
"systemSlider5": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAG0lEQVR42mM4YMBwfwNOBAFXDRhObSCKPGAAAHfbIWHuFKlNAAAAAElFTkSuQmCC",
|
||||
"systemSlider6": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAG0lEQVR42mM4YMBwfwM6goBTGxiuGpBGHjAAADklIK1PooVQAAAAAElFTkSuQmCC",
|
||||
"systemSlider7": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAG0lEQVR42mM4YMBwfwMUQcBVA4ZTG8gkDxgAANmVH4SOiUHMAAAAAElFTkSuQmCC",
|
||||
"systemSlider8": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAbAQAAAABg3VNpAAAAFElEQVR42mM4YMBwagPDVSqRBwwASoohT92wVBIAAAAASUVORK5CYII="
|
||||
"systemDecline2": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQAQAAAAAkX4I4AAAANUlEQVR42mM4wMDMsP//X4YEBjYGx4ZDDA4HmxgckpkYHMyAWAaKQWyQGFAOpAakFqQHqBcAGz4QyzSHE/gAAAAASUVORK5CYII="
|
||||
}
|
@ -220,41 +220,10 @@ namespace images {
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemAccept2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemAlert = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemBox = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemBusy0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemBusy1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemDecline1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemDecline2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemDotEmpty = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemDotFull = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemEv3small = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemPlay = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider3 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider4 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider5 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider6 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider7 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres blockIdentity=brick.__imagePicker
|
||||
export const systemSlider8 = screen.unpackPNG(hex``);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ namespace sensors.internal {
|
||||
init();
|
||||
return {
|
||||
temp: analogMM.getNumber(NumberFormat.Int16LE, AnalogOff.BatteryTemp),
|
||||
current: analogMM.getNumber(NumberFormat.Int16LE, AnalogOff.BatteryCurrent)
|
||||
current: Math.round(analogMM.getNumber(NumberFormat.Int16LE, AnalogOff.BatteryCurrent) / 10)
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ namespace sensors.internal {
|
||||
return getUartNumber(fmt, off, this._port)
|
||||
}
|
||||
|
||||
protected reset() {
|
||||
reset() {
|
||||
if (this.isActive()) uartReset(this._port);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,16 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/**
|
||||
* Mode for lseek()
|
||||
*/
|
||||
enum class SeekWhence {
|
||||
Set = 0,
|
||||
Current = 1,
|
||||
End = 2,
|
||||
};
|
||||
|
||||
|
||||
namespace pxt {
|
||||
PXT_VTABLE_CTOR(MMap) {
|
||||
length = 0;
|
||||
@ -111,4 +121,10 @@ int read(MMap *mmap, Buffer data) {
|
||||
return ::read(mmap->fd, data->data, data->length);
|
||||
}
|
||||
|
||||
/** Set pointer on the underlaying file. */
|
||||
//%
|
||||
int lseek(MMap *mmap, int offset, SeekWhence whence) {
|
||||
return ::lseek(mmap->fd, offset, (int)whence);
|
||||
}
|
||||
|
||||
}
|
@ -11,4 +11,15 @@ namespace motors {
|
||||
export function __speedPicker(speed: number): number {
|
||||
return speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* A turn ratio picker
|
||||
* @param turnratio the turn ratio, eg: 0
|
||||
*/
|
||||
//% blockId=motorTurnRatioPicker block="%turnratio" shim=TD_ID
|
||||
//% turnratio.fieldEditor="turnratio" colorSecondary="#FFFFFF"
|
||||
//% weight=0 blockHidden=1 turnRatio.fieldOptions.decompileLiterals=1
|
||||
export function __turnRatioPicker(turnratio: number): number {
|
||||
return turnratio;
|
||||
}
|
||||
}
|
@ -111,7 +111,7 @@ namespace motors {
|
||||
* Stops all motors
|
||||
*/
|
||||
//% blockId=motorStopAll block="stop all motors"
|
||||
//% weight=5
|
||||
//% weight=1
|
||||
//% group="Move"
|
||||
export function stopAllMotors() {
|
||||
const b = mkCmd(Output.ALL, DAL.opOutputStop, 0)
|
||||
@ -175,7 +175,7 @@ namespace motors {
|
||||
*/
|
||||
//% blockId=motorSetReversed block="set %motor|reversed %reversed"
|
||||
//% reversed.fieldEditor=toggleonoff
|
||||
//% weight=59
|
||||
//% weight=59 blockGap=8
|
||||
//% group="Move"
|
||||
setReversed(reversed: boolean) {
|
||||
this.init();
|
||||
@ -187,7 +187,9 @@ namespace motors {
|
||||
/**
|
||||
* Stops the motor(s).
|
||||
*/
|
||||
//%
|
||||
//% weight=6 blockGap=8
|
||||
//% group="Move"
|
||||
//% blockId=motorStop block="%motors|stop"
|
||||
stop() {
|
||||
this.init();
|
||||
stop(this._port, this._brake);
|
||||
@ -196,14 +198,16 @@ namespace motors {
|
||||
/**
|
||||
* Resets the motor(s).
|
||||
*/
|
||||
//%
|
||||
//% weight=5
|
||||
//% group="Move"
|
||||
//% blockId=motorReset block="%motors|reset"
|
||||
reset() {
|
||||
this.init();
|
||||
reset(this._port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the motor speed for limited time or distance
|
||||
* Sets the motor speed for limited time or distance.
|
||||
* @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50
|
||||
* @param value (optional) measured distance or rotation
|
||||
* @param unit (optional) unit of the value
|
||||
@ -214,10 +218,17 @@ namespace motors {
|
||||
setSpeed(speed: number, value: number = 0, unit: MoveUnit = MoveUnit.MilliSeconds) {
|
||||
this.init();
|
||||
speed = Math.clamp(-100, 100, speed >> 0);
|
||||
// stop if speed is 0
|
||||
if (!speed) {
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
// special: 0 is infinity
|
||||
if (value == 0) {
|
||||
this._setSpeed(speed);
|
||||
return;
|
||||
}
|
||||
// timed motor moves
|
||||
let useSteps: boolean;
|
||||
let stepsOrTime: number;
|
||||
switch (unit) {
|
||||
@ -240,6 +251,8 @@ namespace motors {
|
||||
}
|
||||
|
||||
this._move(useSteps, stepsOrTime, speed);
|
||||
// wait till motor is done with this work
|
||||
this.pauseUntilReady();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -269,10 +282,12 @@ namespace motors {
|
||||
//% fixedInstances
|
||||
export class Motor extends MotorBase {
|
||||
private _large: boolean;
|
||||
private _regulated: boolean;
|
||||
|
||||
constructor(port: Output, large: boolean) {
|
||||
super(port, () => this.__init(), (speed) => this.__setSpeed(speed), (steps, stepsOrTime, speed) => this.__move(steps, stepsOrTime, speed));
|
||||
this._large = large;
|
||||
this._regulated = true;
|
||||
this.markUsed();
|
||||
}
|
||||
|
||||
@ -288,7 +303,7 @@ namespace motors {
|
||||
}
|
||||
|
||||
private __setSpeed(speed: number) {
|
||||
const b = mkCmd(this._port, DAL.opOutputSpeed, 1)
|
||||
const b = mkCmd(this._port, this._regulated ? DAL.opOutputPower : DAL.opOutputSpeed, 1)
|
||||
b.setNumber(NumberFormat.Int8LE, 2, speed)
|
||||
writePWM(b)
|
||||
if (speed) {
|
||||
@ -302,11 +317,24 @@ namespace motors {
|
||||
step1: 0,
|
||||
step2: stepsOrTime,
|
||||
step3: 0,
|
||||
speed: speed,
|
||||
speed: this._regulated ? speed : undefined,
|
||||
power: this._regulated ? undefined : speed,
|
||||
useBrake: this._brake
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the motor speed should be regulated. Default is true.
|
||||
* @param value true for regulated motor
|
||||
*/
|
||||
//% blockId=outputMotorSetRegulated block="set %motor|regulated %value"
|
||||
//% value.fieldEditor=toggleonoff
|
||||
//% weight=58
|
||||
//% group="Move"
|
||||
setRegulated(value: boolean) {
|
||||
this._regulated = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets motor actual speed.
|
||||
* @param motor the port which connects to the motor
|
||||
@ -474,7 +502,7 @@ namespace motors {
|
||||
* @param value (optional) move duration or rotation
|
||||
* @param unit (optional) unit of the value
|
||||
*/
|
||||
//% blockId=motorPairSteer block="steer %chassis|turn ratio %turnRatio|speed %speed=motorSpeedPicker|%"
|
||||
//% blockId=motorPairSteer block="steer %chassis|turn ratio %turnRatio=motorTurnRatioPicker|speed %speed=motorSpeedPicker|%"
|
||||
//% weight=95
|
||||
//% turnRatio.min=-200 turnRatio=200
|
||||
//% inlineInputMode=inline
|
||||
|
4
libs/core/shims.d.ts
vendored
4
libs/core/shims.d.ts
vendored
@ -41,6 +41,10 @@ declare interface MMap {
|
||||
/** Perform read(2) on the underlaying file */
|
||||
//% shim=MMapMethods::read
|
||||
read(data: Buffer): int32;
|
||||
|
||||
/** Set pointer on the underlaying file. */
|
||||
//% shim=MMapMethods::lseek
|
||||
lseek(offset: int32, whence: SeekWhence): int32;
|
||||
}
|
||||
declare namespace control {
|
||||
|
||||
|
@ -2,7 +2,7 @@ screen.clear()
|
||||
brick.print("PXT!", 10, 30, Draw.Quad)
|
||||
|
||||
brick.drawRect(40, 40, 20, 10, Draw.Fill)
|
||||
brick.setLight(LightsPattern.Orange)
|
||||
brick.setLight(BrickLight.Orange)
|
||||
|
||||
brick.heart.doubled().draw(100, 50, Draw.Double | Draw.Transparent)
|
||||
|
||||
@ -12,7 +12,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Click, () => {
|
||||
|
||||
brick.buttonLeft.onEvent(ButtonEvent.Click, () => {
|
||||
brick.drawRect(10, 70, 20, 10, Draw.Fill)
|
||||
brick.setLight(LightsPattern.Red)
|
||||
brick.setLight(BrickLight.Red)
|
||||
brick.setFont(brick.microbitFont())
|
||||
})
|
||||
|
||||
|
3
libs/datalog/README.md
Normal file
3
libs/datalog/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Datalog
|
||||
|
||||
A tiny libraty to create CSV datalog files.
|
8
libs/datalog/_locales/datalog-jsdoc-strings.json
Normal file
8
libs/datalog/_locales/datalog-jsdoc-strings.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"datalog.addRow": "Starts a row of data",
|
||||
"datalog.addValue": "Adds a cell to the row of data",
|
||||
"datalog.addValue|param|name": "name of the cell, eg: \"x\"",
|
||||
"datalog.addValue|param|value": "value of the cell, eg: 0",
|
||||
"datalog.setFile": "Starts a new data logger for the given file",
|
||||
"datalog.setStorage": "* @param storage custom storage solution"
|
||||
}
|
6
libs/datalog/_locales/datalog-strings.json
Normal file
6
libs/datalog/_locales/datalog-strings.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"datalog.addRow|block": "datalog add row",
|
||||
"datalog.addValue|block": "datalog add %name|=%value",
|
||||
"datalog|block": "datalog",
|
||||
"{id:category}Datalog": "Datalog"
|
||||
}
|
90
libs/datalog/datalog.ts
Normal file
90
libs/datalog/datalog.ts
Normal file
@ -0,0 +1,90 @@
|
||||
//% weight=100 color=#0fbc11 icon=""
|
||||
namespace datalog {
|
||||
let _headers: string[] = undefined;
|
||||
let _headersLength: number;
|
||||
let _values: number[];
|
||||
let _start: number;
|
||||
let _filename = "data.csv";
|
||||
let _storage: storage.Storage = storage.temporary;
|
||||
|
||||
function clear() {
|
||||
_headers = undefined;
|
||||
_values = undefined;
|
||||
}
|
||||
|
||||
function init() {
|
||||
if (!_headers) {
|
||||
_headers = [];
|
||||
_headersLength = 0;
|
||||
_start = control.millis();
|
||||
_storage.remove(_filename);
|
||||
}
|
||||
_values = [];
|
||||
}
|
||||
|
||||
function commit() {
|
||||
// write row if any data
|
||||
if (_values && _values.length > 0) {
|
||||
// write headers for the first row
|
||||
if (!_headersLength) {
|
||||
_storage.appendCSVHeaders(_filename, _headers);
|
||||
_headersLength = _storage.size(_filename);
|
||||
}
|
||||
// commit row data
|
||||
_storage.appendCSV(_filename, _values);
|
||||
}
|
||||
|
||||
// clear values
|
||||
_values = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a row of data
|
||||
*/
|
||||
//% weight=100
|
||||
//% blockId=datalogAddRow block="datalog add row"
|
||||
export function addRow(): void {
|
||||
commit();
|
||||
init();
|
||||
const s = (control.millis() - _start) / 1000;
|
||||
addValue("time (s)", s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a cell to the row of data
|
||||
* @param name name of the cell, eg: "x"
|
||||
* @param value value of the cell, eg: 0
|
||||
*/
|
||||
//% weight=99
|
||||
//% blockId=datalogAddValue block="datalog add %name|=%value"
|
||||
export function addValue(name: string, value: number) {
|
||||
if (!_values) return;
|
||||
let i = _headers.indexOf(name);
|
||||
if (i < 0) {
|
||||
_headers.push(name);
|
||||
i = _headers.length - 1;
|
||||
}
|
||||
_values[i] = value;
|
||||
if (i > 0) // 0 is time
|
||||
console.logValue(name, value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new data logger for the given file
|
||||
*/
|
||||
//%
|
||||
export function setFile(fn: string) {
|
||||
_filename = fn;
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param storage custom storage solution
|
||||
*/
|
||||
//%
|
||||
export function setStorage(storage: storage.Storage) {
|
||||
_storage = storage;
|
||||
clear();
|
||||
}
|
||||
}
|
16
libs/datalog/pxt.json
Normal file
16
libs/datalog/pxt.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "datalog",
|
||||
"description": "Tiny data logging framework",
|
||||
"files": [
|
||||
"README.md",
|
||||
"datalog.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
"core": "file:../core",
|
||||
"storage": "file:../storage"
|
||||
}
|
||||
}
|
6
libs/datalog/test.ts
Normal file
6
libs/datalog/test.ts
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
loops.forever(function () {
|
||||
datalog.addRow()
|
||||
datalog.addValue("x", Math.random())
|
||||
datalog.addValue("y", Math.random())
|
||||
})
|
@ -8,7 +8,7 @@ namespace brick {
|
||||
|
||||
//% color="#C8509B" weight=95 icon="\uf10f"
|
||||
//% labelLineWidth=0
|
||||
//% groups='["Ultrasonic Sensor", "Touch Sensor", "Color Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Gyro Sensor"]'
|
||||
//% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Gyro Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Threshold"]'
|
||||
//% groupIcons='["\uf101","\uf103","\uf102","","","\uf104"]'
|
||||
namespace sensors {
|
||||
}
|
||||
@ -56,4 +56,9 @@ namespace loops {
|
||||
//% color="#1E5AA8"
|
||||
namespace light {
|
||||
|
||||
}
|
||||
|
||||
//% color="#b0b0b0" advanced=true weight=5
|
||||
namespace storage {
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"sensors.GyroSensor.angle": "Get the current angle from the gyroscope.",
|
||||
"sensors.GyroSensor.calibrate": "Forces a calibration of the gyro. Must be called when the sensor is completely still.",
|
||||
"sensors.GyroSensor.rotationRate": "Get the current rotation rate from the gyroscope."
|
||||
"sensors.GyroSensor.rate": "Get the current rotation rate from the gyroscope.",
|
||||
"sensors.GyroSensor.reset": "Forces a calibration of the gyro. Must be called when the sensor is completely still."
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"sensors.GyroSensor.angle|block": "%sensor|angle",
|
||||
"sensors.GyroSensor.calibrate|block": "%sensor|calibrate",
|
||||
"sensors.GyroSensor.rotationRate|block": "%sensor|rotation rate",
|
||||
"sensors.GyroSensor.rate|block": "%sensor|rate",
|
||||
"sensors.GyroSensor.reset|block": "%sensor|reset",
|
||||
"sensors.gyro1|block": "gyro 1",
|
||||
"sensors.gyro2|block": "gyro 2",
|
||||
"sensors.gyro3|block": "gyro 3",
|
||||
|
@ -31,7 +31,7 @@ namespace sensors {
|
||||
//% parts="gyroscope"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% weight=65 blockGap=8
|
||||
//% weight=64 blockGap=8
|
||||
//% group="Gyro Sensor"
|
||||
angle(): number {
|
||||
if (this.calibrating)
|
||||
@ -45,15 +45,15 @@ namespace sensors {
|
||||
* Get the current rotation rate from the gyroscope.
|
||||
* @param sensor the gyroscope to query the request
|
||||
*/
|
||||
//% help=input/gyro/rotation-rate
|
||||
//% block="%sensor|rotation rate"
|
||||
//% help=input/gyro/rate
|
||||
//% block="%sensor|rate"
|
||||
//% blockId=gyroGetRate
|
||||
//% parts="gyroscope"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Gyro Sensor"
|
||||
rotationRate(): number {
|
||||
rate(): number {
|
||||
if (this.calibrating)
|
||||
pauseUntil(() => !this.calibrating, 2000);
|
||||
|
||||
@ -65,21 +65,21 @@ namespace sensors {
|
||||
* Forces a calibration of the gyro. Must be called when the sensor is completely still.
|
||||
*/
|
||||
//% help=input/gyro/calibrate
|
||||
//% block="%sensor|calibrate"
|
||||
//% blockId=gyroCalibrate
|
||||
//% block="%sensor|reset"
|
||||
//% blockId=gyroReset
|
||||
//% parts="gyroscope"
|
||||
//% blockNamespace=sensors
|
||||
//% sensor.fieldEditor="ports"
|
||||
//% weight=65 blockGap=8
|
||||
//% weight=50 blockGap=8
|
||||
//% group="Gyro Sensor"
|
||||
calibrate(): void {
|
||||
reset(): void {
|
||||
if (this.calibrating) return; // already in calibration mode
|
||||
|
||||
this.calibrating = true;
|
||||
// may be triggered by a button click, give time to settle
|
||||
loops.pause(500);
|
||||
// send a reset command
|
||||
this.reset();
|
||||
super.reset();
|
||||
// we need to switch mode twice to perform a calibration
|
||||
if (this.mode == GyroSensorMode.Rate)
|
||||
this.setMode(GyroSensorMode.Angle);
|
||||
@ -90,7 +90,9 @@ namespace sensors {
|
||||
this.setMode(GyroSensorMode.Angle);
|
||||
else
|
||||
this.setMode(GyroSensorMode.Rate);
|
||||
this.calibrating = false;
|
||||
// give it more time to settle
|
||||
loops.pause(500);
|
||||
this.calibrating = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,9 @@
|
||||
"sensors.InfraredSensor.pauseUntil": "Waits for the event to occur",
|
||||
"sensors.InfraredSensor.proximity": "Get the promixity measured by the infrared sensor, from ``0`` (close) to ``100`` (far)",
|
||||
"sensors.InfraredSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.",
|
||||
"sensors.InfraredSensor.setThreshold": "Sets a threshold value",
|
||||
"sensors.InfraredSensor.setThreshold|param|condition": "the dark or bright light condition",
|
||||
"sensors.InfraredSensor.setThreshold|param|value": "the value threshold",
|
||||
"sensors.RemoteInfraredBeaconButton.isPressed": "Check if a remote button is currently pressed or not.",
|
||||
"sensors.RemoteInfraredBeaconButton.onEvent": "Do something when a button or sensor is clicked, up or down",
|
||||
"sensors.RemoteInfraredBeaconButton.onEvent|param|body": "code to run when the event is raised",
|
||||
|
@ -5,6 +5,7 @@
|
||||
"sensors.InfraredSensor.pauseUntil|block": "pause until %sensor| %event",
|
||||
"sensors.InfraredSensor.proximity|block": "%sensor|proximity",
|
||||
"sensors.InfraredSensor.remoteCommand|block": "%sensor|remote command",
|
||||
"sensors.InfraredSensor.setThreshold|block": "set %sensor|%condition|to %value",
|
||||
"sensors.RemoteInfraredBeaconButton.isPressed|block": "%button|is pressed",
|
||||
"sensors.RemoteInfraredBeaconButton.onEvent|block": "on %button|%event",
|
||||
"sensors.RemoteInfraredBeaconButton.wasPressed|block": "%button|was pressed",
|
||||
@ -20,5 +21,6 @@
|
||||
"sensors|block": "sensors",
|
||||
"{id:category}Sensors": "Sensors",
|
||||
"{id:group}Infrared Sensor": "Infrared Sensor",
|
||||
"{id:group}Remote Infrared Beacon": "Remote Infrared Beacon"
|
||||
"{id:group}Remote Infrared Beacon": "Remote Infrared Beacon",
|
||||
"{id:group}Threshold": "Threshold"
|
||||
}
|
@ -250,6 +250,22 @@ namespace sensors {
|
||||
this._setMode(IrSensorMode.Seek)
|
||||
return this.getNumber(NumberFormat.UInt16LE, this.channel * 2)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a threshold value
|
||||
* @param condition the dark or bright light condition
|
||||
* @param value the value threshold
|
||||
*/
|
||||
//% blockId=irSetThreshold block="set %sensor|%condition|to %value"
|
||||
//% group="Threshold" blockGap=8
|
||||
//% value.min=0 value.max=100
|
||||
setThreshold(condition: InfraredSensorEvent, value: number) {
|
||||
if (condition == InfraredSensorEvent.ObjectNear)
|
||||
this.proximityThreshold.setLowThreshold(value)
|
||||
else
|
||||
this.proximityThreshold.setHighThreshold(value);
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstance whenUsed block="infrared 1" jres=icons.port1
|
||||
|
@ -33,34 +33,34 @@
|
||||
"music.stopAllSounds|block": "stop all sounds",
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "music",
|
||||
"sounds.animalsCatPurr|block": "Animals cat purr",
|
||||
"sounds.animalsDogBark1|block": "Animals dog bark 1",
|
||||
"sounds.animalsDogBark2|block": "Animals dog bark 2",
|
||||
"sounds.animalsDogGrowl|block": "Animals dog growl",
|
||||
"sounds.animalsDogSniff|block": "Animals dog sniff",
|
||||
"sounds.animalsDogWhine|block": "Animals dog whine",
|
||||
"sounds.animalsElephantCall|block": "Animals elephant call",
|
||||
"sounds.animalsInsectBuzz1|block": "Animals insect buzz1",
|
||||
"sounds.animalsInsectBuzz2|block": "Animals insect buzz2",
|
||||
"sounds.animalsInsectChirp|block": "Animals insect chirp",
|
||||
"sounds.animalsSnakeHiss|block": "Animals snake hiss",
|
||||
"sounds.animalsSnakeRattle|block": "Animals snake rattle",
|
||||
"sounds.animalsTRexRoar|block": "Animals trex roar",
|
||||
"sounds.colorsBlack|block": "Colors black",
|
||||
"sounds.colorsBlue|block": "Colors blue",
|
||||
"sounds.colorsBrown|block": "Colors brown",
|
||||
"sounds.colorsGreen|block": "Colors green",
|
||||
"sounds.colorsRed|block": "Colors red",
|
||||
"sounds.colorsWhite|block": "Colors white",
|
||||
"sounds.colorsYellow|block": "Colors yellow",
|
||||
"sounds.communicationBravo|block": "Communication bravo",
|
||||
"sounds.communicationEv3|block": "Communication ev3",
|
||||
"sounds.communicationFantastic|block": "Communication fantastic",
|
||||
"sounds.communicationGameOver|block": "Communication game over",
|
||||
"sounds.animalsCatPurr|block": "animals cat purr",
|
||||
"sounds.animalsDogBark1|block": "animals dog bark 1",
|
||||
"sounds.animalsDogBark2|block": "animals dog bark 2",
|
||||
"sounds.animalsDogGrowl|block": "animals dog growl",
|
||||
"sounds.animalsDogSniff|block": "animals dog sniff",
|
||||
"sounds.animalsDogWhine|block": "animals dog whine",
|
||||
"sounds.animalsElephantCall|block": "animals elephant call",
|
||||
"sounds.animalsInsectBuzz1|block": "animals insect buzz1",
|
||||
"sounds.animalsInsectBuzz2|block": "animals insect buzz2",
|
||||
"sounds.animalsInsectChirp|block": "animals insect chirp",
|
||||
"sounds.animalsSnakeHiss|block": "animals snake hiss",
|
||||
"sounds.animalsSnakeRattle|block": "animals snake rattle",
|
||||
"sounds.animalsTRexRoar|block": "animals trex roar",
|
||||
"sounds.colorsBlack|block": "colors black",
|
||||
"sounds.colorsBlue|block": "colors blue",
|
||||
"sounds.colorsBrown|block": "colors brown",
|
||||
"sounds.colorsGreen|block": "colors green",
|
||||
"sounds.colorsRed|block": "colors red",
|
||||
"sounds.colorsWhite|block": "colors white",
|
||||
"sounds.colorsYellow|block": "colors yellow",
|
||||
"sounds.communicationBravo|block": "communication bravo",
|
||||
"sounds.communicationEv3|block": "communication ev3",
|
||||
"sounds.communicationFantastic|block": "communication fantastic",
|
||||
"sounds.communicationGameOver|block": "communication game over",
|
||||
"sounds.communicationGoodJob|block": "communicationGoodJob",
|
||||
"sounds.communicationGoodbye|block": "communication goodbye",
|
||||
"sounds.communicationGood|block": "communication good",
|
||||
"sounds.communicationGo|block": "Communication go",
|
||||
"sounds.communicationGo|block": "communication go",
|
||||
"sounds.communicationHello|block": "communication hello",
|
||||
"sounds.communicationHi|block": "communication hi",
|
||||
"sounds.communicationLego|block": "communication lego",
|
||||
@ -159,7 +159,7 @@
|
||||
"sounds.systemOverpower|block": "system overpower",
|
||||
"sounds.systemPowerDown|block": "system power down",
|
||||
"sounds.systemReady|block": "system ready",
|
||||
"sounds.systemStartUp|block": "S",
|
||||
"sounds.systemStartUp|block": "system start up",
|
||||
"{id:category}Music": "Music",
|
||||
"{id:category}Sound": "Sound",
|
||||
"{id:category}Sounds": "Sounds"
|
||||
|
@ -1,53 +1,53 @@
|
||||
namespace sounds {
|
||||
//% fixedInstance jres block="Animals cat purr"
|
||||
//% fixedInstance jres block="animals cat purr"
|
||||
export const animalsCatPurr = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals dog bark 1"
|
||||
//% fixedInstance jres block="animals dog bark 1"
|
||||
export const animalsDogBark1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals dog bark 2"
|
||||
//% fixedInstance jres block="animals dog bark 2"
|
||||
export const animalsDogBark2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals dog growl"
|
||||
//% fixedInstance jres block="animals dog growl"
|
||||
export const animalsDogGrowl = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals dog sniff"
|
||||
//% fixedInstance jres block="animals dog sniff"
|
||||
export const animalsDogSniff = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals dog whine"
|
||||
//% fixedInstance jres block="animals dog whine"
|
||||
export const animalsDogWhine = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals elephant call"
|
||||
//% fixedInstance jres block="animals elephant call"
|
||||
export const animalsElephantCall = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals insect buzz1"
|
||||
//% fixedInstance jres block="animals insect buzz1"
|
||||
export const animalsInsectBuzz1 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals insect buzz2"
|
||||
//% fixedInstance jres block="animals insect buzz2"
|
||||
export const animalsInsectBuzz2 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals insect chirp"
|
||||
//% fixedInstance jres block="animals insect chirp"
|
||||
export const animalsInsectChirp = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals snake hiss"
|
||||
//% fixedInstance jres block="animals snake hiss"
|
||||
export const animalsSnakeHiss = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals snake rattle"
|
||||
//% fixedInstance jres block="animals snake rattle"
|
||||
export const animalsSnakeRattle = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Animals trex roar"
|
||||
//% fixedInstance jres block="animals trex roar"
|
||||
export const animalsTRexRoar = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Colors black"
|
||||
//% fixedInstance jres block="colors black"
|
||||
export const colorsBlack = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Colors blue"
|
||||
//% fixedInstance jres block="colors blue"
|
||||
export const colorsBlue = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Colors brown"
|
||||
//% fixedInstance jres block="colors brown"
|
||||
export const colorsBrown = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Colors green"
|
||||
//% fixedInstance jres block="colors green"
|
||||
export const colorsGreen = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Colors red"
|
||||
//% fixedInstance jres block="colors red"
|
||||
export const colorsRed = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Colors white"
|
||||
//% fixedInstance jres block="colors white"
|
||||
export const colorsWhite = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Colors yellow"
|
||||
//% fixedInstance jres block="colors yellow"
|
||||
export const colorsYellow = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Communication bravo"
|
||||
//% fixedInstance jres block="communication bravo"
|
||||
export const communicationBravo = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Communication ev3"
|
||||
//% fixedInstance jres block="communication ev3"
|
||||
export const communicationEv3 = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Communication fantastic"
|
||||
//% fixedInstance jres block="communication fantastic"
|
||||
export const communicationFantastic = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Communication game over"
|
||||
//% fixedInstance jres block="communication game over"
|
||||
export const communicationGameOver = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="Communication go"
|
||||
//% fixedInstance jres block="communication go"
|
||||
export const communicationGo = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="communicationGoodJob"
|
||||
export const communicationGoodJob = music.fromWAV(hex``);
|
||||
@ -251,7 +251,7 @@ namespace sounds {
|
||||
export const systemPowerDown = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block="system ready"
|
||||
export const systemReady = music.fromWAV(hex``);
|
||||
//% fixedInstance jres block=S
|
||||
//% fixedInstance jres block="system start up"
|
||||
export const systemStartUp = music.fromWAV(hex``);
|
||||
}
|
||||
|
||||
|
29
libs/storage/_locales/storage-jsdoc-strings.json
Normal file
29
libs/storage/_locales/storage-jsdoc-strings.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"storage.Storage.append": "Append string data to a new or existing file.",
|
||||
"storage.Storage.appendBuffer": "Append a buffer to a new or existing file.",
|
||||
"storage.Storage.appendCSV": "Append a row of CSV data",
|
||||
"storage.Storage.appendCSVHeaders": "Append a row of CSV headers",
|
||||
"storage.Storage.appendCSVHeaders|param|filename": "the file name to append data, eg: \"data.csv\"",
|
||||
"storage.Storage.appendCSVHeaders|param|headers": "the data to append",
|
||||
"storage.Storage.appendCSV|param|data": "the data to append",
|
||||
"storage.Storage.appendCSV|param|filename": "the file name to append data, eg: \"data.csv\"",
|
||||
"storage.Storage.appendLine": "Appends a new line of data in the file",
|
||||
"storage.Storage.appendLine|param|data": "the data to append",
|
||||
"storage.Storage.appendLine|param|filename": "the file name to append data, eg: \"data.txt\"",
|
||||
"storage.Storage.append|param|data": "the data to append",
|
||||
"storage.Storage.append|param|filename": "the file name to append data, eg: \"data.txt\"",
|
||||
"storage.Storage.exists": "Tests if a file exists",
|
||||
"storage.Storage.exists|param|filename": "the file name to append data, eg: \"data.txt\"",
|
||||
"storage.Storage.limit": "Resizing the size of a file to stay under the limit",
|
||||
"storage.Storage.limit|param|filename": "name of the file to drop",
|
||||
"storage.Storage.limit|param|size": "maximum length",
|
||||
"storage.Storage.overwrite": "Overwrite file with string data.",
|
||||
"storage.Storage.overwriteWithBuffer": "Overwrite file with a buffer.",
|
||||
"storage.Storage.overwrite|param|data": "the data to append",
|
||||
"storage.Storage.overwrite|param|filename": "the file name to append data, eg: \"data.txt\"",
|
||||
"storage.Storage.read": "Read contents of file as a string.",
|
||||
"storage.Storage.readAsBuffer": "Read contents of file as a buffer.",
|
||||
"storage.Storage.remove": "Delete a file, or do nothing if it doesn't exist.",
|
||||
"storage.Storage.size": "Return the size of the file, or -1 if it doesn't exists.",
|
||||
"storage.temporary": "Temporary storage in memory, deleted when the device restarts."
|
||||
}
|
15
libs/storage/_locales/storage-strings.json
Normal file
15
libs/storage/_locales/storage-strings.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"storage.Storage.appendCSVHeaders|block": "storage %source|%filename|append CSV headers %headers",
|
||||
"storage.Storage.appendCSV|block": "storage %source|%filename|append CSV %data",
|
||||
"storage.Storage.appendLine|block": "storage %source|%filename|append line %data",
|
||||
"storage.Storage.append|block": "storage %source|%filename|append %data",
|
||||
"storage.Storage.exists|block": "storage %source|%filename|exists",
|
||||
"storage.Storage.limit|block": "storage %source|limit %filename|to %size|bytes",
|
||||
"storage.Storage.overwrite|block": "storage %source|%filename|overwrite with|%data",
|
||||
"storage.Storage.read|block": "storage %source|read %filename|as string",
|
||||
"storage.Storage.remove|block": "storage %source|remove %filename",
|
||||
"storage.Storage.size|block": "storage %source|%filename|size",
|
||||
"storage.temporary|block": "temporary",
|
||||
"storage|block": "storage",
|
||||
"{id:category}Storage": "Storage"
|
||||
}
|
14
libs/storage/pxt.json
Normal file
14
libs/storage/pxt.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "storage",
|
||||
"description": "USB Pen-drive support and flash storage",
|
||||
"files": [
|
||||
"storage.cpp",
|
||||
"storage-core.ts",
|
||||
"storage.ts",
|
||||
"shims.d.ts"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
"core": "file:../core"
|
||||
}
|
||||
}
|
17
libs/storage/shims.d.ts
vendored
Normal file
17
libs/storage/shims.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Auto-generated. Do not edit.
|
||||
declare namespace storage {
|
||||
|
||||
/** Will be moved. */
|
||||
//% shim=storage::__stringToBuffer
|
||||
function __stringToBuffer(s: string): Buffer;
|
||||
|
||||
/** Will be moved. */
|
||||
//% shim=storage::__bufferToString
|
||||
function __bufferToString(s: Buffer): string;
|
||||
|
||||
/** Create named directory. */
|
||||
//% shim=storage::__mkdir
|
||||
function __mkdir(filename: string): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
197
libs/storage/storage-core.ts
Normal file
197
libs/storage/storage-core.ts
Normal file
@ -0,0 +1,197 @@
|
||||
namespace storage {
|
||||
//% shim=storage::__unlink
|
||||
function __unlink(filename: string): void { }
|
||||
//% shim=storage::__truncate
|
||||
function __truncate(filename: string): void { }
|
||||
|
||||
//% fixedInstances
|
||||
export class Storage {
|
||||
csvSeparator: string;
|
||||
constructor() {
|
||||
this.csvSeparator = ",";
|
||||
}
|
||||
|
||||
protected mapFilename(filename: string) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
private getFile(filename: string): MMap {
|
||||
filename = this.mapFilename(filename)
|
||||
let r = control.mmap(filename, 0, 0)
|
||||
if (!r) {
|
||||
__mkdir(this.dirname(filename))
|
||||
__truncate(filename)
|
||||
r = control.mmap(filename, 0, 0)
|
||||
}
|
||||
if (!r)
|
||||
control.panic(906)
|
||||
return r
|
||||
}
|
||||
|
||||
dirname(filename: string) {
|
||||
let last = 0
|
||||
for (let i = 0; i < filename.length; ++i)
|
||||
if (filename[i] == "/")
|
||||
last = i
|
||||
return filename.substr(0, last)
|
||||
}
|
||||
|
||||
/**
|
||||
* Append string data to a new or existing file.
|
||||
* @param filename the file name to append data, eg: "data.txt"
|
||||
* @param data the data to append
|
||||
*/
|
||||
//% blockId=storageAppend block="storage %source|%filename|append %data"
|
||||
append(filename: string, data: string): void {
|
||||
this.appendBuffer(filename, __stringToBuffer(data))
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a new line of data in the file
|
||||
* @param filename the file name to append data, eg: "data.txt"
|
||||
* @param data the data to append
|
||||
*/
|
||||
//% blockId=storageAppendLine block="storage %source|%filename|append line %data"
|
||||
appendLine(filename: string, data: string): void {
|
||||
this.append(filename, data + "\r\n");
|
||||
}
|
||||
|
||||
/** Append a buffer to a new or existing file. */
|
||||
appendBuffer(filename: string, data: Buffer): void {
|
||||
let f = this.getFile(filename);
|
||||
f.lseek(0, SeekWhence.End)
|
||||
f.write(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a row of CSV headers
|
||||
* @param filename the file name to append data, eg: "data.csv"
|
||||
* @param headers the data to append
|
||||
*/
|
||||
//% blockId=storageAppendCSVHeaders block="storage %source|%filename|append CSV headers %headers"
|
||||
appendCSVHeaders(filename: string, headers: string[]) {
|
||||
let s = ""
|
||||
for (const d of headers) {
|
||||
if (s) s += this.csvSeparator;
|
||||
s = s + d;
|
||||
}
|
||||
s += "\r\n"
|
||||
this.append(filename, s)
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a row of CSV data
|
||||
* @param filename the file name to append data, eg: "data.csv"
|
||||
* @param data the data to append
|
||||
*/
|
||||
//% blockId=storageAppendCSV block="storage %source|%filename|append CSV %data"
|
||||
appendCSV(filename: string, data: number[]) {
|
||||
let s = ""
|
||||
for (const d of data) {
|
||||
if (s) s += this.csvSeparator;
|
||||
s = s + d;
|
||||
}
|
||||
s += "\r\n"
|
||||
this.append(filename, s)
|
||||
}
|
||||
|
||||
/** Overwrite file with string data.
|
||||
* @param filename the file name to append data, eg: "data.txt"
|
||||
* @param data the data to append
|
||||
*/
|
||||
//% blockId=storageOverwrite block="storage %source|%filename|overwrite with|%data"
|
||||
overwrite(filename: string, data: string): void {
|
||||
this.overwriteWithBuffer(filename, __stringToBuffer(data))
|
||||
}
|
||||
|
||||
/** Overwrite file with a buffer. */
|
||||
overwriteWithBuffer(filename: string, data: Buffer): void {
|
||||
__truncate(this.mapFilename(filename))
|
||||
this.appendBuffer(filename, data)
|
||||
}
|
||||
|
||||
/** Tests if a file exists
|
||||
* @param filename the file name to append data, eg: "data.txt"
|
||||
*/
|
||||
//% blockId=storageExists block="storage %source|%filename|exists"
|
||||
exists(filename: string): boolean {
|
||||
return !!control.mmap(this.mapFilename(filename), 0, 0);
|
||||
}
|
||||
|
||||
/** Delete a file, or do nothing if it doesn't exist. */
|
||||
//% blockId=storageRemove block="storage %source|remove %filename"
|
||||
remove(filename: string): void {
|
||||
__unlink(this.mapFilename(filename))
|
||||
}
|
||||
|
||||
/** Return the size of the file, or -1 if it doesn't exists. */
|
||||
//% blockId=storageSize block="storage %source|%filename|size"
|
||||
size(filename: string): int32 {
|
||||
let f = control.mmap(this.mapFilename(filename), 0, 0)
|
||||
if (!f) return -1;
|
||||
return f.lseek(0, SeekWhence.End)
|
||||
}
|
||||
|
||||
/** Read contents of file as a string. */
|
||||
//% blockId=storageRead block="storage %source|read %filename|as string"
|
||||
read(filename: string): string {
|
||||
return __bufferToString(this.readAsBuffer(filename))
|
||||
}
|
||||
|
||||
/** Read contents of file as a buffer. */
|
||||
//%
|
||||
readAsBuffer(filename: string): Buffer {
|
||||
let f = this.getFile(filename)
|
||||
let sz = f.lseek(0, SeekWhence.End)
|
||||
let b = output.createBuffer(sz)
|
||||
f.lseek(0, SeekWhence.Set);
|
||||
f.read(b)
|
||||
return b
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizing the size of a file to stay under the limit
|
||||
* @param filename name of the file to drop
|
||||
* @param size maximum length
|
||||
*/
|
||||
//% blockId=storageLimit block="storage %source|limit %filename|to %size|bytes"
|
||||
limit(filename: string, size: number) {
|
||||
if (!this.exists(filename) || size < 0) return;
|
||||
|
||||
const sz = storage.temporary.size(filename);
|
||||
if (sz > size) {
|
||||
let buf = storage.temporary.readAsBuffer(filename)
|
||||
buf = buf.slice(buf.length / 2);
|
||||
storage.temporary.overwriteWithBuffer(filename, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TemporaryStorage extends Storage {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected mapFilename(filename: string) {
|
||||
if (filename[0] == '/') filename = filename.substr(1);
|
||||
return '/tmp/logs/' + filename;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary storage in memory, deleted when the device restarts.
|
||||
*/
|
||||
//% whenUsed fixedInstance block="temporary"
|
||||
export const temporary: Storage = new TemporaryStorage();
|
||||
|
||||
class PermanentStorage extends Storage {
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
protected mapFilename(filename: string) {
|
||||
if (filename[0] == '/') return filename;
|
||||
return '/' + filename;
|
||||
}
|
||||
}
|
||||
}
|
44
libs/storage/storage.cpp
Normal file
44
libs/storage/storage.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "pxt.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
namespace storage {
|
||||
|
||||
/** Will be moved. */
|
||||
//%
|
||||
Buffer __stringToBuffer(String s) {
|
||||
return mkBuffer((uint8_t *)s->data, s->length);
|
||||
}
|
||||
|
||||
/** Will be moved. */
|
||||
//%
|
||||
String __bufferToString(Buffer s) {
|
||||
return mkString((char*)s->data, s->length);
|
||||
}
|
||||
|
||||
//%
|
||||
void __init() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
//%
|
||||
void __unlink(String filename) {
|
||||
::unlink(filename->data);
|
||||
}
|
||||
|
||||
//%
|
||||
void __truncate(String filename) {
|
||||
int fd = open(filename->data, O_CREAT | O_TRUNC | O_WRONLY, 0777);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/** Create named directory. */
|
||||
//%
|
||||
void __mkdir(String filename) {
|
||||
::mkdir(filename->data, 0777);
|
||||
}
|
||||
|
||||
} // namespace storage
|
11
libs/storage/storage.ts
Normal file
11
libs/storage/storage.ts
Normal file
@ -0,0 +1,11 @@
|
||||
namespace storage {
|
||||
// automatically send console output to temp storage
|
||||
storage.temporary.remove("console.txt");
|
||||
console.addListener(function(line) {
|
||||
const fn = "console.txt";
|
||||
const mxs = 65536;
|
||||
const t = control.millis();
|
||||
storage.temporary.appendLine(fn, `${t}> ${line}`);
|
||||
storage.temporary.limit(fn, 65536);
|
||||
})
|
||||
}
|
@ -2,5 +2,8 @@
|
||||
"sensors.UltraSonicSensor.distance": "Gets the distance from the sonar in centimeters",
|
||||
"sensors.UltraSonicSensor.onEvent": "Registers code to run when the given color is close",
|
||||
"sensors.UltraSonicSensor.onEvent|param|handler": "the code to run when detected",
|
||||
"sensors.UltraSonicSensor.pauseUntil": "Waits for the event to occur"
|
||||
"sensors.UltraSonicSensor.pauseUntil": "Waits for the event to occur",
|
||||
"sensors.UltraSonicSensor.setThreshold": "Sets a threshold value",
|
||||
"sensors.UltraSonicSensor.setThreshold|param|condition": "the dark or bright light condition",
|
||||
"sensors.UltraSonicSensor.setThreshold|param|value": "the value threshold"
|
||||
}
|
@ -5,10 +5,12 @@
|
||||
"sensors.UltraSonicSensor.distance|block": "%sensor|distance",
|
||||
"sensors.UltraSonicSensor.onEvent|block": "on %sensor|%event",
|
||||
"sensors.UltraSonicSensor.pauseUntil|block": "pause until %sensor| %event",
|
||||
"sensors.UltraSonicSensor.setThreshold|block": "set %sensor|%condition|to %value",
|
||||
"sensors.ultrasonic1|block": "ultrasonic 1",
|
||||
"sensors.ultrasonic2|block": "ultrasonic 2",
|
||||
"sensors.ultrasonic3|block": "ultrasonic 3",
|
||||
"sensors.ultrasonic4|block": "ultrasonic 4",
|
||||
"{id:category}Sensors": "Sensors",
|
||||
"{id:group}Threshold": "Threshold",
|
||||
"{id:group}Ultrasonic Sensor": "Ultrasonic Sensor"
|
||||
}
|
@ -85,6 +85,23 @@ namespace sensors {
|
||||
this._setMode(0)
|
||||
return this._query();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a threshold value
|
||||
* @param condition the dark or bright light condition
|
||||
* @param value the value threshold
|
||||
*/
|
||||
//% blockId=ultrasonicSetThreshold block="set %sensor|%condition|to %value"
|
||||
//% group="Threshold" blockGap=8
|
||||
//% value.min=0 value.max=255
|
||||
setThreshold(condition: UltrasonicSensorEvent, value: number) {
|
||||
switch(condition) {
|
||||
case UltrasonicSensorEvent.ObjectNear: this.promixityThreshold.setLowThreshold(value); break;
|
||||
case UltrasonicSensorEvent.ObjectFar: this.promixityThreshold.setHighThreshold(value); break;
|
||||
case UltrasonicSensorEvent.ObjectDetected: this.movementThreshold = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstance whenUsed block="ultrasonic 4" jres=icons.port4
|
||||
|
87
package-lock.json
generated
87
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.0.51",
|
||||
"version": "0.0.59",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -399,7 +399,7 @@
|
||||
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
|
||||
"requires": {
|
||||
"bn.js": "4.11.8",
|
||||
"randombytes": "2.0.5"
|
||||
"randombytes": "2.0.6"
|
||||
}
|
||||
},
|
||||
"browserify-sign": {
|
||||
@ -792,7 +792,7 @@
|
||||
"inherits": "2.0.3",
|
||||
"pbkdf2": "3.0.14",
|
||||
"public-encrypt": "4.0.0",
|
||||
"randombytes": "2.0.5",
|
||||
"randombytes": "2.0.6",
|
||||
"randomfill": "1.0.3"
|
||||
}
|
||||
},
|
||||
@ -956,7 +956,7 @@
|
||||
"requires": {
|
||||
"bn.js": "4.11.8",
|
||||
"miller-rabin": "4.0.1",
|
||||
"randombytes": "2.0.5"
|
||||
"randombytes": "2.0.6"
|
||||
}
|
||||
},
|
||||
"domain-browser": {
|
||||
@ -1009,9 +1009,9 @@
|
||||
}
|
||||
},
|
||||
"end-of-stream": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz",
|
||||
"integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=",
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
|
||||
"integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
|
||||
"requires": {
|
||||
"once": "1.4.0"
|
||||
}
|
||||
@ -1562,6 +1562,15 @@
|
||||
"verror": "1.10.0"
|
||||
}
|
||||
},
|
||||
"keytar": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/keytar/-/keytar-3.0.2.tgz",
|
||||
"integrity": "sha1-TcFd01I/4wYx+dOIV4pAFRpgWG8=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"nan": "2.3.2"
|
||||
}
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
|
||||
@ -1833,9 +1842,9 @@
|
||||
"integrity": "sha1-WQTcU3w57G2+/q6QIycTX6hRHxI="
|
||||
},
|
||||
"marked": {
|
||||
"version": "0.3.9",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.9.tgz",
|
||||
"integrity": "sha512-nW5u0dxpXxHfkHzzrveY45gCbi+R4PaO4WRZYqZNl+vB0hVGeqlFn0aOg1c8AKL63TrNFn9Bm2UP4AdiZ9TPLw=="
|
||||
"version": "0.3.12",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.12.tgz",
|
||||
"integrity": "sha512-k4NaW+vS7ytQn6MgJn3fYpQt20/mOgYM5Ft9BYMfQJDz2QT6yEeS9XJ8k2Nw8JTeWK/znPPW2n3UJGzyYEiMoA=="
|
||||
},
|
||||
"math-expression-evaluator": {
|
||||
"version": "1.2.17",
|
||||
@ -1966,8 +1975,7 @@
|
||||
"nan": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.3.2.tgz",
|
||||
"integrity": "sha1-TU7PF+HaTpie+08nPY0AIBytCH4=",
|
||||
"dev": true
|
||||
"integrity": "sha1-TU7PF+HaTpie+08nPY0AIBytCH4="
|
||||
},
|
||||
"neatequal": {
|
||||
"version": "1.0.0",
|
||||
@ -2510,7 +2518,7 @@
|
||||
"npmlog": "4.1.2",
|
||||
"os-homedir": "1.0.2",
|
||||
"pump": "1.0.3",
|
||||
"rc": "1.2.2",
|
||||
"rc": "1.2.3",
|
||||
"simple-get": "1.4.3",
|
||||
"tar-fs": "1.16.0",
|
||||
"tunnel-agent": "0.6.0",
|
||||
@ -2558,7 +2566,7 @@
|
||||
"browserify-rsa": "4.0.1",
|
||||
"create-hash": "1.1.3",
|
||||
"parse-asn1": "5.1.0",
|
||||
"randombytes": "2.0.5"
|
||||
"randombytes": "2.0.6"
|
||||
}
|
||||
},
|
||||
"pump": {
|
||||
@ -2566,7 +2574,7 @@
|
||||
"resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz",
|
||||
"integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==",
|
||||
"requires": {
|
||||
"end-of-stream": "1.4.0",
|
||||
"end-of-stream": "1.4.1",
|
||||
"once": "1.4.0"
|
||||
}
|
||||
},
|
||||
@ -2576,19 +2584,19 @@
|
||||
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
|
||||
},
|
||||
"pxt-common-packages": {
|
||||
"version": "0.14.13",
|
||||
"resolved": "https://registry.npmjs.org/pxt-common-packages/-/pxt-common-packages-0.14.13.tgz",
|
||||
"integrity": "sha1-L/axrdv7I1g6xjGC8JXNx/Bv0Ss=",
|
||||
"version": "0.15.4",
|
||||
"resolved": "https://registry.npmjs.org/pxt-common-packages/-/pxt-common-packages-0.15.4.tgz",
|
||||
"integrity": "sha1-hI1q5+UQ7vIuBqlOrIy66PmiePo=",
|
||||
"requires": {
|
||||
"autoprefixer": "6.7.7",
|
||||
"pxt-core": "3.0.2",
|
||||
"pxt-core": "3.0.8",
|
||||
"rtlcss": "2.2.1"
|
||||
}
|
||||
},
|
||||
"pxt-core": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.0.2.tgz",
|
||||
"integrity": "sha1-q7aCkAXRwvsmhPaeHR1S9osLK98=",
|
||||
"version": "3.0.8",
|
||||
"resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.0.8.tgz",
|
||||
"integrity": "sha1-wmvgLvyX1lV5ZB6EM9APj22/gIo=",
|
||||
"requires": {
|
||||
"bluebird": "3.5.1",
|
||||
"browserify": "13.3.0",
|
||||
@ -2596,15 +2604,16 @@
|
||||
"faye-websocket": "0.11.1",
|
||||
"fuse.js": "2.6.1",
|
||||
"highlight.js": "9.12.0",
|
||||
"keytar": "3.0.2",
|
||||
"lzma": "2.3.2",
|
||||
"marked": "0.3.9",
|
||||
"marked": "0.3.12",
|
||||
"node-hid": "0.5.7",
|
||||
"postcss": "6.0.15",
|
||||
"postcss": "6.0.16",
|
||||
"request": "2.83.0",
|
||||
"rimraf": "2.5.4",
|
||||
"rtlcss": "2.2.1",
|
||||
"serialport": "4.0.7",
|
||||
"uglify-js": "3.3.4"
|
||||
"uglify-js": "3.3.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-styles": {
|
||||
@ -2641,9 +2650,9 @@
|
||||
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE="
|
||||
},
|
||||
"postcss": {
|
||||
"version": "6.0.15",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.15.tgz",
|
||||
"integrity": "sha512-v/SpyMzLbtkmh45zUdaqLAaqXqzPdSrw8p4cQVO0/w6YiYfpj4k+Wkzhn68qk9br+H+0qfddhdPEVnbmBPfXVQ==",
|
||||
"version": "6.0.16",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.16.tgz",
|
||||
"integrity": "sha512-m758RWPmSjFH/2MyyG3UOW1fgYbR9rtdzz5UNJnlm7OLtu4B2h9C6gi+bE4qFKghsBRFfZT8NzoQBs6JhLotoA==",
|
||||
"requires": {
|
||||
"chalk": "2.3.0",
|
||||
"source-map": "0.6.1",
|
||||
@ -2695,9 +2704,9 @@
|
||||
"integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM="
|
||||
},
|
||||
"randombytes": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz",
|
||||
"integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==",
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
|
||||
"integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
|
||||
"requires": {
|
||||
"safe-buffer": "5.1.1"
|
||||
}
|
||||
@ -2707,14 +2716,14 @@
|
||||
"resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.3.tgz",
|
||||
"integrity": "sha512-YL6GrhrWoic0Eq8rXVbMptH7dAxCs0J+mh5Y0euNekPPYaxEmdVGim6GdoxoRzKW2yJoU8tueifS7mYxvcFDEQ==",
|
||||
"requires": {
|
||||
"randombytes": "2.0.5",
|
||||
"randombytes": "2.0.6",
|
||||
"safe-buffer": "5.1.1"
|
||||
}
|
||||
},
|
||||
"rc": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.2.tgz",
|
||||
"integrity": "sha1-2M6ctX6NZNnHut2YdsfDTL48cHc=",
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.3.tgz",
|
||||
"integrity": "sha1-UVdakA+N1oOBxxC0cSwhVMPiA1s=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"deep-extend": "0.4.2",
|
||||
@ -4310,7 +4319,7 @@
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"bl": "1.2.1",
|
||||
"end-of-stream": "1.4.0",
|
||||
"end-of-stream": "1.4.1",
|
||||
"readable-stream": "2.3.3",
|
||||
"xtend": "4.0.1"
|
||||
}
|
||||
@ -4422,9 +4431,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.4.tgz",
|
||||
"integrity": "sha512-hfIwuAQI5dlXP30UtdmWoYF9k+ypVqBXIdmd6ZKBiaNHHvA8ty7ZloMe3+7S5AEKVkxHbjByl4DfRHQ7QpZquw==",
|
||||
"version": "3.3.5",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.5.tgz",
|
||||
"integrity": "sha512-ZebM2kgBL/UI9rKeAbsS2J0UPPv7SBy5hJNZml/YxB1zC6JK8IztcPs+cxilE4pu0li6vadVSFqiO7xFTKuSrg==",
|
||||
"requires": {
|
||||
"commander": "2.12.2",
|
||||
"source-map": "0.6.1"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.0.57",
|
||||
"version": "0.0.62",
|
||||
"description": "LEGO Mindstorms EV3 for Microsoft MakeCode",
|
||||
"private": true,
|
||||
"keywords": [
|
||||
@ -45,7 +45,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-common-packages": "0.15.4",
|
||||
"pxt-core": "3.0.5"
|
||||
"pxt-core": "3.0.11"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||
|
@ -17,6 +17,8 @@
|
||||
"libs/gyro-sensor",
|
||||
"libs/chassis",
|
||||
"libs/ev3",
|
||||
"libs/storage",
|
||||
"libs/datalog",
|
||||
"libs/tests",
|
||||
"libs/behaviors"
|
||||
],
|
||||
|
@ -30,8 +30,8 @@ namespace pxsim {
|
||||
data,
|
||||
beforeMemRead: () => {
|
||||
//console.log("analog before read");
|
||||
data[AnalogOff.BatteryTemp] = 21; // TODO simulate this
|
||||
data[AnalogOff.BatteryCurrent] = 100; // TODO simulate this
|
||||
util.map16Bit(data, AnalogOff.BatteryTemp, 21);
|
||||
util.map16Bit(data, AnalogOff.BatteryCurrent, 900);
|
||||
const inputNodes = ev3board().getInputNodes();
|
||||
for (let port = 0; port < DAL.NUM_INPUTS; port++) {
|
||||
const node = inputNodes[port];
|
||||
|
@ -8,6 +8,7 @@ namespace pxsim.MMapMethods {
|
||||
read?: (d: Buffer) => number;
|
||||
write?: (d: Buffer) => number;
|
||||
ioctl?: (id: number, d: Buffer) => number;
|
||||
lseek?: (offset: number, whence: number) => number;
|
||||
}
|
||||
|
||||
import BM = pxsim.BufferMethods
|
||||
@ -23,6 +24,7 @@ namespace pxsim.MMapMethods {
|
||||
if (!impl.read) impl.read = () => 0
|
||||
if (!impl.write) impl.write = () => 0
|
||||
if (!impl.ioctl) impl.ioctl = () => -1
|
||||
if (!impl.lseek) impl.lseek = (offset, whence) => -1
|
||||
}
|
||||
destroy() {
|
||||
}
|
||||
@ -68,6 +70,10 @@ namespace pxsim.MMapMethods {
|
||||
export function read(m: MMap, data: Buffer): number {
|
||||
return m.impl.read(data)
|
||||
}
|
||||
|
||||
export function lseek(m: MMap, offset: number, whence: number): number {
|
||||
return m.impl.lseek(offset, whence);
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.control {
|
||||
|
@ -40,6 +40,10 @@ namespace pxsim {
|
||||
}
|
||||
|
||||
setSpeedCmd(cmd: DAL, values: number[]) {
|
||||
if (this.speedCmd != cmd ||
|
||||
JSON.stringify(this.speedCmdValues) != JSON.stringify(values))
|
||||
this.setChangedState();
|
||||
// new command TODO: values
|
||||
this.speedCmd = cmd;
|
||||
this.speedCmdValues = values;
|
||||
this.speedCmdTacho = this.angle;
|
||||
|
23
sim/state/storage.ts
Normal file
23
sim/state/storage.ts
Normal file
@ -0,0 +1,23 @@
|
||||
namespace pxsim.storage {
|
||||
export function __stringToBuffer(s: string): RefBuffer {
|
||||
// TODO
|
||||
return new RefBuffer(new Uint8Array([]));
|
||||
}
|
||||
|
||||
export function __bufferToString(b: RefBuffer): string {
|
||||
// TODO
|
||||
return "";
|
||||
}
|
||||
|
||||
export function __mkdir(fn: string) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
export function __unlink(filename: string): void {
|
||||
// TODO
|
||||
}
|
||||
|
||||
export function __truncate(filename: string): void {
|
||||
// TODO
|
||||
}
|
||||
}
|
@ -50,6 +50,15 @@ namespace pxsim.visuals {
|
||||
fill:#5A5A5A;
|
||||
}
|
||||
|
||||
.no-drag, .sim-text, .sim-text-pin {
|
||||
user-drag: none;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
}
|
||||
|
||||
/* Color Grid */
|
||||
.sim-color-grid-circle:hover {
|
||||
stroke-width: 0.4;
|
||||
|
@ -173,15 +173,15 @@ namespace pxsim.visuals {
|
||||
}
|
||||
|
||||
// Inject all ports
|
||||
this.setInput(0, new PortView(0, 'A'));
|
||||
this.setInput(1, new PortView(1, 'B'));
|
||||
this.setInput(2, new PortView(2, 'C'));
|
||||
this.setInput(3, new PortView(3, 'D'));
|
||||
this.setInput(0, new PortView(0, '1'));
|
||||
this.setInput(1, new PortView(1, '2'));
|
||||
this.setInput(2, new PortView(2, '3'));
|
||||
this.setInput(3, new PortView(3, '4'));
|
||||
|
||||
this.setOutput(0, new PortView(0, '1'));
|
||||
this.setOutput(1, new PortView(1, '2'));
|
||||
this.setOutput(2, new PortView(2, '3'));
|
||||
this.setOutput(3, new PortView(3, '4'));
|
||||
this.setOutput(0, new PortView(0, 'A'));
|
||||
this.setOutput(1, new PortView(1, 'B'));
|
||||
this.setOutput(2, new PortView(2, 'C'));
|
||||
this.setOutput(3, new PortView(3, 'D'));
|
||||
|
||||
return this.contentGroup;
|
||||
}
|
||||
|
@ -34,14 +34,14 @@ namespace pxsim.visuals {
|
||||
this.syncedLabelG = pxsim.svg.child(this.element, 'g', {'transform': 'scale(0.5)'}) as SVGGElement;
|
||||
pxsim.svg.child(this.syncedLabelG, 'rect', {'rx': 15, 'ry': 15, 'x': 0, 'y': 0, 'width': 84, 'height': 34, 'fill': '#A8A9A8'});
|
||||
pxsim.svg.child(this.syncedLabelG, 'circle', {'cx': 17, 'cy': 17, 'r': 15, 'fill': 'white'});
|
||||
const leftLabel = pxsim.svg.child(this.syncedLabelG, 'text', {'transform': 'translate(11, 22)', 'style': 'isolation: isolate;font-size: 16px;fill: #A8A9A8;font-family: ArialMT, Arial'});
|
||||
const leftLabel = pxsim.svg.child(this.syncedLabelG, 'text', {'transform': 'translate(11, 22)', 'class': 'no-drag', 'style': 'isolation: isolate;font-size: 16px;fill: #A8A9A8;font-family: ArialMT, Arial'});
|
||||
leftLabel.textContent = a;
|
||||
|
||||
pxsim.svg.child(this.syncedLabelG, 'rect', {'rx': 0, 'ry': 0, 'x': 37, 'y': 12, 'width': 10, 'height': 3, 'fill': '#ffffff'});
|
||||
pxsim.svg.child(this.syncedLabelG, 'rect', {'rx': 0, 'ry': 0, 'x': 37, 'y': 18, 'width': 10, 'height': 3, 'fill': '#ffffff'});
|
||||
|
||||
pxsim.svg.child(this.syncedLabelG, 'circle', {'cx': 67, 'cy': 17, 'r': 15, 'fill': 'white'});
|
||||
const rightLabel = pxsim.svg.child(this.syncedLabelG, 'text', {'transform': 'translate(61, 22)', 'style': 'isolation: isolate;font-size: 16px;fill: #A8A9A8;font-family: ArialMT, Arial'});
|
||||
const rightLabel = pxsim.svg.child(this.syncedLabelG, 'text', {'transform': 'translate(61, 22)', 'class': 'no-drag', 'style': 'isolation: isolate;font-size: 16px;fill: #A8A9A8;font-family: ArialMT, Arial'});
|
||||
rightLabel.textContent = b;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
}
|
||||
|
||||
.blocklyFlyoutLabel .blocklyFlyoutLabelIcon {
|
||||
font-family: 'legoIcons';
|
||||
font-family: 'legoIcons' !important;
|
||||
}
|
||||
|
||||
span.blocklyTreeIcon {
|
||||
|
Reference in New Issue
Block a user