Compare commits
100 Commits
Author | SHA1 | Date | |
---|---|---|---|
e07d6e3a31 | |||
763ad3f763 | |||
919a03951c | |||
9e427898ae | |||
60bf3a17d3 | |||
0529759a80 | |||
b07f157181 | |||
2f5f7d4133 | |||
e6e1dce59f | |||
43a9d03231 | |||
c0f6cd3651 | |||
f1445c6e89 | |||
04275ee35c | |||
f8d0594eca | |||
5be3b31e00 | |||
84c1079e50 | |||
6320379d02 | |||
b166f6034e | |||
d07f672b28 | |||
363e076f36 | |||
8bf6f265f7 | |||
217958aec3 | |||
367b1b0d1a | |||
6836852122 | |||
944098b9f9 | |||
539cf3d73e | |||
4b3e7cfb7d | |||
b144744509 | |||
e591bed6ad | |||
6a4e64eac0 | |||
f7dd14ff7b | |||
bfd34cedd6 | |||
8e1c075911 | |||
a02f364a4c | |||
48fee2c215 | |||
5780d1982c | |||
6fb08f0f7b | |||
13f8659b98 | |||
edc9d17a8c | |||
c7a3f5bbd0 | |||
41d5052583 | |||
07ddec343a | |||
5a9a5e997a | |||
55b6549999 | |||
fcdc350e40 | |||
9dedbeae1b | |||
124d8a0fd8 | |||
81fcbb6916 | |||
d436bd1227 | |||
cb648019bb | |||
11a88a9d94 | |||
92178f3371 | |||
3c86ae286f | |||
1b6d84a9b8 | |||
2d81be3b24 | |||
14f57f54bf | |||
e7c697c24d | |||
7ac63f038c | |||
557926d631 | |||
da62d51615 | |||
3918857fcc | |||
f1dcebdd88 | |||
1d35c78737 | |||
d17326ad7a | |||
4948a88833 | |||
b73b924ec4 | |||
641d292c33 | |||
223275fd65 | |||
6e42e816d3 | |||
5678cf5df9 | |||
67ec4accb9 | |||
fa867c3a34 | |||
7865876e64 | |||
113b42656c | |||
7557380722 | |||
3e2a1ec9e1 | |||
09db613620 | |||
bacb4673c9 | |||
e649a167cd | |||
997e8efb20 | |||
1f380ce959 | |||
8cbf601131 | |||
bdbb2a8c2f | |||
5e90cb4434 | |||
1bf1eb16f0 | |||
fbc6fc30a7 | |||
fee2329ca7 | |||
5656031e2d | |||
e87e1767b5 | |||
2d7a108e79 | |||
193f66fd2d | |||
5768fcaf35 | |||
2c22ea925f | |||
4e4aa266d5 | |||
05bdbd7b40 | |||
085ab0844b | |||
064d6f9411 | |||
330aff8082 | |||
0886a5d4e1 | |||
aa636aef96 |
@ -1,4 +1,3 @@
|
||||
/// <reference path="../node_modules/pxt-core/typings/globals/node/index.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
||||
|
||||
import * as fs from 'fs';
|
||||
|
@ -1,4 +1,3 @@
|
||||
/// <reference path="../node_modules/pxt-core/typings/globals/node/index.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
||||
|
||||
import * as path from "path";
|
||||
|
@ -8,6 +8,7 @@
|
||||
"module": "commonjs",
|
||||
"rootDir": ".",
|
||||
"newLine": "LF",
|
||||
"sourceMap": false
|
||||
"sourceMap": false,
|
||||
"types": ["node"]
|
||||
}
|
||||
}
|
||||
|
BIN
docs/static/MC-LEGO-loader-eyes.gif
vendored
Normal file
After Width: | Height: | Size: 69 KiB |
30
docs/static/fonts/icons/iconfont.css
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
@font-face {
|
||||
font-family: "iconfont";
|
||||
src: url("iconfont.eot?e05611aaee246c1da118a83eaf515de9?#iefix") format("embedded-opentype"),
|
||||
url("iconfont.woff2?e05611aaee246c1da118a83eaf515de9") format("woff2"),
|
||||
url("iconfont.woff?e05611aaee246c1da118a83eaf515de9") format("woff");
|
||||
}
|
||||
|
||||
.icon {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.icon:before {
|
||||
font-family: iconfont !important;
|
||||
font-style: normal;
|
||||
font-weight: normal !important;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.icon-ultrasonic:before {
|
||||
content: "\f101";
|
||||
}
|
||||
.icon-color:before {
|
||||
content: "\f102";
|
||||
}
|
||||
.icon-touch:before {
|
||||
content: "\f103";
|
||||
}
|
||||
.icon-gyro:before {
|
||||
content: "\f104";
|
||||
}
|
BIN
docs/static/fonts/icons/iconfont.eot
vendored
Normal file
24
docs/static/fonts/icons/iconfont.svg
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<font id="iconfont" horiz-adv-x="40">
|
||||
<font-face font-family="iconfont"
|
||||
units-per-em="40" ascent="40"
|
||||
descent="0" />
|
||||
<missing-glyph horiz-adv-x="0" />
|
||||
<glyph glyph-name="ultrasonic"
|
||||
unicode=""
|
||||
horiz-adv-x="40" d=" M26.8 13H13.1C15.6 14.6 17 17.3 17 20.2C17 21.8 16.6 23.3 15.8 24.7S13.8 27 12.4 27.8H27.6C26.2 27 25.1 26.1 24.2 24.7S23 21.8 23 20.2C22.9 17.3 24.3 14.6 26.8 13L26.8 13L26.8 13z M8.6 12C4.1 12 0.4 15.7 0.4 20.2S4.1 28.4 8.6 28.4S16.8 24.7 16.8 20.2C16.7 15.7 13.1 12 8.6 12zM8.6 23.4C6.8 23.4 5.4 22 5.4 20.2S6.8 16.9 8.6 16.9S11.9 18.4 11.9 20.2S10.4 23.4 8.6 23.4z M31.4 12C26.9 12 23.2 15.7 23.2 20.2S26.9 28.4 31.4 28.4S39.6 24.7 39.6 20.2C39.5 15.7 35.9 12 31.4 12zM31.4 23.4C29.6 23.4 28.1 22 28.1 20.2S29.6 16.9 31.4 16.9S34.6 18.4 34.6 20.2S33.2 23.4 31.4 23.4z" />
|
||||
<glyph glyph-name="color"
|
||||
unicode=""
|
||||
horiz-adv-x="43.35195530726257" d=" M38.7 -0.1H4.7C3.4 -0.1 2.5 0.6 2.5 1.5V6.8H0.9A0.9608938547486034 0.9608938547486034 0 0 0 0 7.7V31.5A0.9608938547486034 0.9608938547486034 0 0 0 0.9 32.4H2.5V38.4C2.5 39.3 3.6 40 4.7 40H38.7C40 40 40.9 39.3 40.9 38.4V32.4H42.5A0.9608938547486034 0.9608938547486034 0 0 0 43.4 31.5V7.8A0.9608938547486034 0.9608938547486034 0 0 0 42.5 6.9H40.9V1.6C41.1 0.7 40 -0.1 38.7 -0.1zM21.7 35.1A11.374301675977657 11.374301675977657 0 0 1 13.6 15.5A4.916201117318437 4.916201117318437 0 0 1 13.4 13.7A8.268156424581006 8.268156424581006 0 0 1 29.9 13.7A4.916201117318437 4.916201117318437 0 0 1 29.7 15.5A12.379888268156424 12.379888268156424 0 0 1 33.1 23.6A11.1731843575419 11.1731843575419 0 0 1 21.7 35.1zM41.6 18.3V10.9H42.5V18.3zM1.1 18.3V10.9H2V18.3zM41.6 28.6V21.2H42.5V28.6zM1.1 28.6V21.2H2V28.6z M21.9 7.4A6.480446927374302 6.480446927374302 0 0 0 15.4 13.9A9.497206703910615 9.497206703910615 0 0 0 15.9 16.3A9.87709497206704 9.87709497206704 0 0 0 12.3 23.9A9.608938547486035 9.608938547486035 0 0 0 31.5 23.9A9.87709497206704 9.87709497206704 0 0 0 27.9 16.3A8.022346368715086 8.022346368715086 0 0 0 28.4 13.9A6.703910614525141 6.703910614525141 0 0 0 21.9 7.4zM21.9 16.3A2.4581005586592184 2.4581005586592184 0 1 1 24.4 13.9A2.837988826815643 2.837988826815643 0 0 1 21.9 16.3zM21.9 27.7A4.46927374301676 4.46927374301676 0 1 1 26.4 23.2A4.804469273743018 4.804469273743018 0 0 1 21.9 27.7z" />
|
||||
<glyph glyph-name="touch"
|
||||
unicode=""
|
||||
horiz-adv-x="40" d=" M34.3 3.3H4.9C3.8 3.3 2.8 3.9 2.8 4.8V9.3H1.5C1.1 9.3 0.7 9.7 0.7 10.1V30.5C0.7 30.9 1.1 31.3 1.5 31.3H2.8V36.6C2.8 37.4 3.7 38.1 4.9 38.1H16V36.6H22.7V38.1H34.2C35.3 38.1 36.3 37.5 36.3 36.6V31.3H37.6C37.9 31.3 38.3 30.9 38.3 30.5V10.1C38.3 9.7 37.9 9.3 37.6 9.3H36.3V4.8C36.3 3.9 35.3 3.3 34.3 3.3L34.3 3.3zM14.1 16.2C14.7 15.3 15.4 14.7 16.2 14.1V5.6H22.6V14.1C23.5 14.7 24.1 15.4 24.7 16.2H33.4V22.6H24.9C24.3 23.5 23.6 24.3 22.6 24.9V33.6H16.2V24.9C15.3 24.3 14.5 23.6 13.9 22.6H5.4V16.2H14.1L14.1 16.2zM36.6 19.2V13H37.4V19.2H36.6zM1.8 19.2V13H2.6V19.2H1.8zM36.6 28.1V21.9H37.4V28.1H36.6zM1.8 28.1V21.9H2.6V28.1H1.8zM19.4 15.4C18.8 15.4 18.5 15.4 18.1 15.6V17.1C18.1 17.5 17.9 17.7 17.5 17.7L17.5 17.7H16C15.8 18.1 15.6 18.6 15.6 19.2C15.6 19.8 15.6 20.3 16 20.7H17.3C18.1 20.7 18.1 21.6 18.1 21.6L18.1 21.6C18.1 21.8 18.1 22.4 18.1 22.9C18.5 23.1 19 23.1 19.4 23.1C20 23.1 20.5 23.1 21.1 22.9C21.1 22.5 21.1 22 21.1 21.6L21.1 21.6V21.4C21.1 21 21.3 20.8 21.7 20.8C21.7 20.8 21.7 20.8 21.9 20.8L21.9 20.8H23.4C23.8 20.4 23.8 19.9 23.8 19.3S23.6 18.2 23.4 17.8L23.4 17.8C23 17.8 22.5 17.6 22.1 17.6C21.7 17.6 21.3 17.4 21.3 17V15.5C20.7 15.3 20.4 15.3 19.8 15.3C19.4 15.4 19.4 15.4 19.4 15.4z" />
|
||||
<glyph glyph-name="gyro"
|
||||
unicode=""
|
||||
horiz-adv-x="23.578015492438215" d=" M17 0H6.4A5.901881224640355 5.901881224640355 0 0 0 5.1 0.3H2.3A1.283659166359277 1.283659166359277 0 0 0 1 1.6V4.5H0.5A0.5016599040944301 0.5016599040944301 0 0 0 0 5V35.4A0.5016599040944301 0.5016599040944301 0 0 0 0.5 35.9H1V38.7A1.283659166359277 1.283659166359277 0 0 0 2.3 40H10.6V39.6H12.8V40H21.2A1.283659166359277 1.283659166359277 0 0 0 22.5 38.7V35.9H23.1A0.5016599040944301 0.5016599040944301 0 0 0 23.6 35.4V5.1A0.5016599040944301 0.5016599040944301 0 0 0 23.1 4.6H22.5V1.6A1.283659166359277 1.283659166359277 0 0 0 21.2 0.4H18.5C18.4 0.1 17.2 0 17 0zM6.2 34.5L3.7 33.8A1.0033198081888601 1.0033198081888601 0 0 1 3.4 33.7A0.2360752489856142 0.2360752489856142 0 0 1 3.3 33.5A0.20656584286241245 0.20656584286241245 0 0 1 3.4 33.3L4.1 32.8A7.657690888970861 7.657690888970861 0 0 1 3.1 30A8.51346366654371 8.51346366654371 0 0 1 4.8 23.5C5.8 24.2 6.5 24.7 6.5 24.7A7.377351530800443 7.377351530800443 0 0 0 5.4 26.9A6.300258207303577 6.300258207303577 0 0 0 6 31.8L6.5 31.5H6.5L6.6 31.5A0.3541128734784213 0.3541128734784213 0 0 1 6.8 31.4A0.17705643673921065 0.17705643673921065 0 0 1 7 31.5A0.6344522316488379 0.6344522316488379 0 0 1 7 32L6.2 34.5zM17.5 31.8H17.5A6.300258207303577 6.300258207303577 0 0 0 18 26.9A7.510143858354851 7.510143858354851 0 0 0 17 24.7L17.1 24.6L18.6 23.5A8.631501291036518 8.631501291036518 0 0 1 20.3 30A7.657690888970861 7.657690888970861 0 0 1 19.3 32.8L19.8 33.1L20 33.2A0.22132054592401326 0.22132054592401326 0 0 1 20.1 33.4A0.26558465510881596 0.26558465510881596 0 0 1 20 33.6A1.0033198081888601 1.0033198081888601 0 0 1 19.7 33.7L17.2 34.5S17.1 34.1 17 33.6S16.6 32.3 16.5 32A0.619697528587237 0.619697528587237 0 0 1 16.5 31.5A0.17705643673921065 0.17705643673921065 0 0 1 16.6 31.4A0.48690520103282936 0.48690520103282936 0 0 1 16.8 31.4L16.8 31.4L17.4 31.7zM11.7 30.6A1.9918849133161198 1.9918849133161198 0 1 1 13.7 28.6A1.9918849133161198 1.9918849133161198 0 0 1 11.7 30.6H11.7z" />
|
||||
</font>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 5.7 KiB |
BIN
docs/static/fonts/icons/iconfont.ttf
vendored
Normal file
BIN
docs/static/fonts/icons/iconfont.woff
vendored
Normal file
BIN
docs/static/fonts/icons/iconfont.woff2
vendored
Normal file
47
docs/tests/motors.md
Normal file
@ -0,0 +1,47 @@
|
||||
```typescript
|
||||
tests.test("lgB set speed 10", () => {
|
||||
motors.largeB.setSpeed(10);
|
||||
loops.pause(100)
|
||||
tests.assertClose("speedB", 10, motors.largeB.speed(), 2)
|
||||
});
|
||||
tests.test("lgB set speed 25 (reversed)", () => {
|
||||
motors.largeB.setReversed(true)
|
||||
motors.largeB.setSpeed(25)
|
||||
loops.pause(100)
|
||||
tests.assertClose("speedB", -25, motors.largeB.speed(), 2)
|
||||
});
|
||||
tests.test("lgBC set speed 5", () => {
|
||||
motors.largeBC.setSpeed(5)
|
||||
loops.pause(100)
|
||||
tests.assertClose("speedB", 5, motors.largeB.speed(), 1);
|
||||
tests.assertClose("speedC", 5, motors.largeC.speed(), 1);
|
||||
});
|
||||
tests.test("lgBC steer 50% 2x", () => {
|
||||
motors.largeBC.setBrake(true)
|
||||
motors.largeBC.steer(50, 50, 1, MoveUnit.Rotations)
|
||||
loops.pause(1000)
|
||||
tests.assertClose("largeB", 360, motors.largeB.angle(), 5)
|
||||
motors.largeBC.setBrake(false)
|
||||
})
|
||||
tests.test("lgBC steer 50% 500deg", () => {
|
||||
motors.largeBC.setBrake(true)
|
||||
motors.largeBC.steer(50, 50, 135, MoveUnit.Degrees)
|
||||
loops.pause(1000)
|
||||
tests.assertClose("largeB", 135, motors.largeB.angle(), 5)
|
||||
});
|
||||
tests.test("lgBC steer 50% 2s", () => {
|
||||
motors.largeBC.setBrake(true)
|
||||
motors.largeBC.steer(50, 50, 500, MoveUnit.MilliSeconds)
|
||||
loops.pause(1000)
|
||||
})
|
||||
tests.test("lgBC tank 50% 720deg", () => {
|
||||
motors.largeBC.setBrake(true)
|
||||
motors.largeBC.tank(50, 50, 180, MoveUnit.Degrees)
|
||||
loops.pause(1000)
|
||||
tests.assertClose("largeB", 180, motors.largeB.angle(), 5)
|
||||
});
|
||||
```
|
||||
|
||||
```package
|
||||
tests
|
||||
```
|
BIN
legoresources/Block icns/Blockcolor-icns.pdf
Normal file
193
legoresources/Block icns/icn_block_Large_motor.svg
Normal file
@ -0,0 +1,193 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1344 8191 55 41">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: #a8a9a8;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
clip-path: url(#clip-path);
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
clip-path: url(#clip-path-2);
|
||||
}
|
||||
|
||||
.cls-5 {
|
||||
fill: #919191;
|
||||
}
|
||||
|
||||
.cls-6 {
|
||||
clip-path: url(#clip-path-3);
|
||||
}
|
||||
|
||||
.cls-7 {
|
||||
fill: #f2f2f2;
|
||||
}
|
||||
|
||||
.cls-8 {
|
||||
clip-path: url(#clip-path-4);
|
||||
}
|
||||
|
||||
.cls-9 {
|
||||
fill: #6a6a6a;
|
||||
}
|
||||
|
||||
.cls-10 {
|
||||
fill: #9a9a9a;
|
||||
}
|
||||
|
||||
.cls-11 {
|
||||
fill: #d02e26;
|
||||
}
|
||||
|
||||
.cls-12 {
|
||||
fill: #242424;
|
||||
}
|
||||
|
||||
.cls-13 {
|
||||
filter: url(#rød);
|
||||
}
|
||||
|
||||
.cls-14 {
|
||||
filter: url(#Path_4);
|
||||
}
|
||||
|
||||
.cls-15 {
|
||||
filter: url(#Path_1-2);
|
||||
}
|
||||
|
||||
.cls-16 {
|
||||
filter: url(#Path_2);
|
||||
}
|
||||
|
||||
.cls-17 {
|
||||
filter: url(#Path_1);
|
||||
}
|
||||
|
||||
.cls-18 {
|
||||
filter: url(#Path_34);
|
||||
}
|
||||
</style>
|
||||
<clipPath id="clip-path">
|
||||
<rect id="Rectangle_119" data-name="Rectangle 119" class="cls-1" width="55" height="41" transform="translate(-10.923 65.26)"/>
|
||||
</clipPath>
|
||||
<clipPath id="clip-path-2">
|
||||
<path id="Union_6" data-name="Union 6" class="cls-2" d="M0,88.889A11.109,11.109,0,0,1,9.191,77.947L8.954,77.7,8.947,54.41c0-.273.093-.261.255-.438l7.1-6.846V40.6l-.488-.5v-.516H11.39a2.6,2.6,0,0,1-2.6-2.6V20.163a2.6,2.6,0,0,1,2.6-2.6h4.421V12.236a3.765,3.765,0,0,1,3.766-3.765h4.241c0-.059-.005-.117-.005-.176V3.941a3,3,0,0,1,1.882-2.785V.4a.4.4,0,0,1,.4-.4H43.183a.394.394,0,0,1,.394.4v1a3,3,0,0,1,1.412,2.546V8.294c0,.059,0,.118-.005.176h2.359a3.765,3.765,0,0,1,3.765,3.765V31.528c-6.749,9.152-11.8,15.533-11.8,15.533h-.387s-4.616-.035-8.906-.062l.022,7.681h4.479a2.6,2.6,0,0,1,2.6,2.6V74.093a2.6,2.6,0,0,1-2.6,2.6H30.1l.022,7.664c0,.545-.1.545-.3.74l-6.78,6.569-.139.124a.989.989,0,0,1-1.036-.154A11.108,11.108,0,0,1,0,88.889Z"/>
|
||||
</clipPath>
|
||||
<filter id="Path_34" x="1375.234" y="8125.181" width="24.177" height="13.354" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="0.5" result="blur"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
<filter id="Path_1" x="1360.37" y="8169.796" width="24.177" height="49.327" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="0.5" result="blur-2"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur-2"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
<filter id="Path_2" x="1367.722" y="8164.375" width="16.687" height="17.582" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="0.5" result="blur-3"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur-3"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
<filter id="Path_1-2" x="1367.234" y="8132.71" width="38.296" height="41.59" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="0.5" result="blur-4"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur-4"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
<clipPath id="clip-path-3">
|
||||
<path id="Path_9" data-name="Path 9" class="cls-2" d="M3.765,0H31.531A3.765,3.765,0,0,1,35.3,3.765V23.057C28.547,32.209,23.5,38.59,23.5,38.59h-.387s-12.667-.1-15.533-.1a1.484,1.484,0,0,1-1.548-.641L0,31.62V3.765A3.765,3.765,0,0,1,3.765,0Z"/>
|
||||
</clipPath>
|
||||
<filter id="Path_4" x="1370.999" y="8136.004" width="30.766" height="34.531" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="0.5" result="blur-5"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur-5"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
<clipPath id="clip-path-4">
|
||||
<path id="Path_10" data-name="Path 10" class="cls-2" d="M3.765,0H24a3.765,3.765,0,0,1,3.765,3.765v14.48c-5.628,7.331-10.127,13.286-10.127,13.286H3.765A3.765,3.765,0,0,1,0,27.766v-24A3.765,3.765,0,0,1,3.765,0Z"/>
|
||||
</clipPath>
|
||||
<filter id="rød" x="1351.423" y="8202.021" width="25.213" height="25.214" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="0.5" result="blur-6"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur-6"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<g id="icn_block_Large_motor" transform="translate(666.315 8209.204)">
|
||||
<g id="Symbol_13_1" data-name="Symbol 13 – 1" transform="translate(688.608 -83.464)">
|
||||
<g id="Mask_Group_12" data-name="Mask Group 12" class="cls-3">
|
||||
<g id="Mask_Group_6" data-name="Mask Group 6" class="cls-4" transform="translate(-2)">
|
||||
<g id="Large_motor" data-name="Large motor" transform="translate(-1.056 0)">
|
||||
<g id="Group_23" data-name="Group 23">
|
||||
<path id="Subtraction_1" data-name="Subtraction 1" class="cls-5" d="M-2806.659-5548.724h-3.653a3.558,3.558,0,0,1-3.554-3.554v-14.908a3.558,3.558,0,0,1,3.554-3.555h3.653a3.558,3.558,0,0,1,3.554,3.555v14.908A3.558,3.558,0,0,1-2806.659-5548.724Zm.1-5.923a2.47,2.47,0,0,0-2.468,2.467,2.471,2.471,0,0,0,2.468,2.469,2.471,2.471,0,0,0,2.468-2.469A2.47,2.47,0,0,0-2806.56-5554.647Zm.062-.99h.01a2.859,2.859,0,0,1,1.425.37c.112.054.238.116.378.176a.67.67,0,0,0,.267.063c.364,0,.427-.425.428-.429v-1.145s-.111-.449-.454-.449a.556.556,0,0,0-.241.063l-.211.1a2.988,2.988,0,0,1-1.591.4h-.023a4.281,4.281,0,0,1-1.831-.5.642.642,0,0,0-.262-.059c-.167,0-.392.077-.517.444,0,0-.011.628,0,1.145.007.32.3.388.537.388a1.414,1.414,0,0,0,.239-.021A4.678,4.678,0,0,1-2806.5-5555.637Zm-1.218-3.3h.006c.048,0,.469.012.469.422v.844s.136.2.639.2c.039,0,.079,0,.123,0a2.375,2.375,0,0,0,.914-.2v-.844a.437.437,0,0,1,.429-.422c.145,0,.287,0,.394,0,.22,0,.391,0,.42,0,.005,0,.168-.134.19-.861.021-.7-.165-.883-.186-.9h-.818c-.022,0-.524-.049-.532-.5-.006-.386,0-1.306,0-1.684v-.022a.326.326,0,0,1,.048-.21.1.1,0,0,1,.076-.033.219.219,0,0,1,.093.025l.79.379a.668.668,0,0,0,.256.062.255.255,0,0,0,.189-.07.4.4,0,0,0,.084-.292c-.008-.485,0-1.013,0-1.163v-.008a.214.214,0,0,0-.215-.179.654.654,0,0,0-.315.111,2.7,2.7,0,0,1-1.524.458c-.075.006-.151.009-.224.009a3.3,3.3,0,0,1-1.72-.468,1.044,1.044,0,0,0-.545-.253.225.225,0,0,0-.167.065.4.4,0,0,0-.087.255v1.171a.423.423,0,0,0,.451.4.709.709,0,0,0,.349-.1c.357-.2.564-.326.633-.366l.022-.013a.216.216,0,0,1,.088-.021c.067,0,.147.042.147.238v1.706a.578.578,0,0,1-.138.378.427.427,0,0,1-.319.121h-.018c-.136,0-.288,0-.449,0-.219,0-.384,0-.445,0,0,0-.2.165-.2.9,0,.717.184.855.192.861Zm1.156-10.815a2.471,2.471,0,0,0-2.468,2.469,2.47,2.47,0,0,0,2.468,2.467,2.47,2.47,0,0,0,2.468-2.467A2.471,2.471,0,0,0-2806.56-5569.753Z" transform="translate(2841.282 5625.42)"/>
|
||||
</g>
|
||||
<path id="Path_36" data-name="Path 36" class="cls-2" d="M.395,0H17.488a.4.4,0,0,1,.395.395V3.841a.4.4,0,0,1-.395.395H.395A.4.4,0,0,1,0,3.841V.395A.4.4,0,0,1,.395,0Z" transform="translate(26.751 0)"/>
|
||||
<g class="cls-18" transform="matrix(1, 0, 0, 1, -1351.87, -8125.74)">
|
||||
<path id="Path_34-2" data-name="Path 34" class="cls-2" d="M.395,0H20.782a.4.4,0,0,1,.395.395V9.958a.4.4,0,0,1-.395.395H.395A.4.4,0,0,1,0,9.958V.395A.4.4,0,0,1,.395,0Z" transform="translate(1376.73 8126.68)"/>
|
||||
</g>
|
||||
<g class="cls-17" transform="matrix(1, 0, 0, 1, -1351.87, -8125.74)">
|
||||
<path id="Path_1-3" data-name="Path 1" class="cls-5" d="M-.121,4,8.6-4.416,20.69-3.98,20.8,34.388c0,.545-.1.545-.3.74l-6.78,6.57-.138.124c-.38.26-1.293-.075-1.293-.62L-.368,27.722-.375,4.438C-.375,4.165-.283,4.176-.121,4Z" transform="translate(1362.25 8175.71)"/>
|
||||
</g>
|
||||
<g class="cls-16" transform="matrix(1, 0, 0, 1, -1351.87, -8125.74)">
|
||||
<path id="Path_2-2" data-name="Path 2" class="cls-2" d="M1484.037,521.285v11.229s.012.55.2.729,2.289,2.36,2.289,2.36a1.019,1.019,0,0,0,.753.262c.493-.016,7.567,0,7.567,0l2.883-3.057v-5.183l-6.94-.369Z" transform="translate(-114.81 7644.59)"/>
|
||||
</g>
|
||||
<g id="Group_4" data-name="Group 4" transform="translate(9.843 17.559)">
|
||||
<path id="Path_44" data-name="Path 44" class="cls-2" d="M3.554,0H7.207a3.554,3.554,0,0,1,3.554,3.554V18.462a3.554,3.554,0,0,1-3.554,3.554H3.554A3.554,3.554,0,0,1,0,18.462V3.554A3.554,3.554,0,0,1,3.554,0Z" transform="translate(0 0)"/>
|
||||
<ellipse id="Ellipse_3" data-name="Ellipse 3" class="cls-1" cx="2.468" cy="2.468" rx="2.468" ry="2.468" transform="translate(0.691 0.987)"/>
|
||||
<ellipse id="Ellipse_4" data-name="Ellipse 4" class="cls-1" cx="2.468" cy="2.468" rx="2.468" ry="2.468" transform="translate(0.691 16.092)"/>
|
||||
<path id="Path_5" data-name="Path 5" class="cls-1" d="M5607.868,939.1a2.7,2.7,0,0,1-1.524.459,3.338,3.338,0,0,1-1.945-.459c-.818-.606-.8.067-.8.067v1.172c0,.293.36.55.8.3s.654-.378.654-.378.235-.12.235.218v1.705s.013.512-.475.5-.9,0-.9,0-.191.161-.191.9.191.86.191.86h.9s.475-.016.475.422v.844s.147.234.761.2a2.341,2.341,0,0,0,.914-.2v-.844a.436.436,0,0,1,.43-.422c.41-.006.818,0,.818,0s.164-.124.187-.86-.187-.9-.187-.9h-.818s-.524-.034-.533-.5,0-1.705,0-1.705-.03-.335.216-.218l.791.378s.541.265.53-.3,0-1.172,0-1.172S5608.345,938.813,5607.868,939.1Z" transform="translate(-5602.81 -932.641)"/>
|
||||
<path id="Path_6" data-name="Path 6" class="cls-1" d="M5601.894,1015.1a.54.54,0,0,1,.778-.386,4.241,4.241,0,0,0,1.854.5,3.287,3.287,0,0,0,1.8-.5c.54-.263.695.386.695.386v1.145a.462.462,0,0,1-.695.365,3.768,3.768,0,0,0-1.8-.545,4.6,4.6,0,0,0-1.854.545s-.767.155-.778-.365S5601.894,1015.1,5601.894,1015.1Z" transform="translate(-5601.296 -1000.958)"/>
|
||||
</g>
|
||||
<g class="cls-15" transform="matrix(1, 0, 0, 1, -1351.87, -8125.74)">
|
||||
<path id="Path_1-4" data-name="Path 1" class="cls-2" d="M3.765,0H31.531A3.765,3.765,0,0,1,35.3,3.765V23.057C28.547,32.209,23.5,38.59,23.5,38.59h-.387s-12.667-.1-15.533-.1a1.484,1.484,0,0,1-1.548-.641L0,31.62V3.765A3.765,3.765,0,0,1,3.765,0Z" transform="translate(1368.73 8134.21)"/>
|
||||
</g>
|
||||
<g id="hvid" transform="translate(16.868 8.471)">
|
||||
<g id="Mask_Group_1" data-name="Mask Group 1" class="cls-6">
|
||||
<path id="hvid-2" data-name="hvid" class="cls-7" d="M1498.578,448.445l4.657,4.8,15.484,20.229v9.67l8.5-10.5V452.321l-.646-5.006Z" transform="translate(-1491.247 -448.708)"/>
|
||||
</g>
|
||||
</g>
|
||||
<g class="cls-14" transform="matrix(1, 0, 0, 1, -1351.87, -8125.74)">
|
||||
<path id="Path_4-2" data-name="Path 4" class="cls-2" d="M3.765,0H24a3.765,3.765,0,0,1,3.765,3.765v14.48c-5.628,7.331-10.127,13.286-10.127,13.286H3.765A3.765,3.765,0,0,1,0,27.766v-24A3.765,3.765,0,0,1,3.765,0Z" transform="translate(1372.5 8137.51)"/>
|
||||
</g>
|
||||
<g id="Group_3" data-name="Group 3" transform="translate(20.633 11.963)">
|
||||
<g id="Mask_Group_2" data-name="Mask Group 2" class="cls-8" transform="translate(0 0)">
|
||||
<path id="Union_1" data-name="Union 1" class="cls-9" d="M9.412,18.589V.706a.706.706,0,1,1,1.412,0V18.589a.706.706,0,1,1-1.412,0Zm-2.353,0V.706a.706.706,0,1,1,1.412,0V18.589a.706.706,0,1,1-1.412,0Zm-2.353,0V.706a.706.706,0,1,1,1.412,0V18.589a.706.706,0,1,1-1.412,0Zm-2.353,0V.706a.706.706,0,1,1,1.412,0V18.589a.706.706,0,1,1-1.412,0ZM0,18.589V.706a.706.706,0,1,1,1.412,0V18.589a.706.706,0,1,1-1.412,0Z" transform="translate(10.353 -3.492)"/>
|
||||
</g>
|
||||
</g>
|
||||
<ellipse id="Ellipse_1" data-name="Ellipse 1" class="cls-10" cx="1.461" cy="1.461" rx="1.461" ry="1.461" transform="translate(18.925 10.528)"/>
|
||||
<ellipse id="Ellipse_2" data-name="Ellipse 2" class="cls-10" cx="1.461" cy="1.461" rx="1.461" ry="1.461" transform="translate(37.584 43.404)"/>
|
||||
<g class="cls-13" transform="matrix(1, 0, 0, 1, -1351.87, -8125.74)">
|
||||
<ellipse id="rød-2" data-name="rød" class="cls-11" cx="11.107" cy="11.107" rx="11.107" ry="11.107" transform="translate(1352.92 8203.52)"/>
|
||||
</g>
|
||||
<g id="Group_2" data-name="Group 2" transform="matrix(0.966, 0.259, -0.259, 0.966, 5.162, 76.726)">
|
||||
<ellipse id="Ellipse_4-2" data-name="Ellipse 4" cx="2.468" cy="2.468" rx="2.468" ry="2.468" transform="translate(7.503 0)"/>
|
||||
<ellipse id="Ellipse_7" data-name="Ellipse 7" cx="2.468" cy="2.468" rx="2.468" ry="2.468" transform="translate(15.006 7.503)"/>
|
||||
<ellipse id="Ellipse_5" data-name="Ellipse 5" cx="2.468" cy="2.468" rx="2.468" ry="2.468" transform="translate(7.503 15.006)"/>
|
||||
<ellipse id="Ellipse_6" data-name="Ellipse 6" cx="2.468" cy="2.468" rx="2.468" ry="2.468" transform="translate(0 7.503)"/>
|
||||
<path id="Path_4-3" data-name="Path 4" class="cls-12" d="M1.564,1.019s.014.512-.475.5-.9,0-.9,0S0,1.68,0,2.421s.191.86.191.86h.9s.475-.016.475.422,0,.844,0,.844.147.234.761.2a2.339,2.339,0,0,0,.914-.2V3.7a.436.436,0,0,1,.43-.422c.41-.006.818,0,.818,0s.164-.124.187-.86-.187-.9-.187-.9H3.669s-.524-.034-.532-.5A8.122,8.122,0,0,1,3.179.2,1.884,1.884,0,0,0,1.646.138C1.595.533,1.564,1.019,1.564,1.019Z" transform="translate(7.602 12.277) rotate(-90)"/>
|
||||
<path id="Path_5-2" data-name="Path 5" d="M.3.1,1.312,0,2.369.1a.3.3,0,0,1,.3.3V1.779a.3.3,0,0,1-.3.3L1.36,1.939.3,2.075a.3.3,0,0,1-.3-.3V.4A.3.3,0,0,1,.3.1Z" transform="translate(8.618 5.261)"/>
|
||||
<path id="Path_7" data-name="Path 7" d="M.3.1,1.312,0,2.369.1a.3.3,0,0,1,.3.3V1.779a.3.3,0,0,1-.3.3L1.36,1.939.3,2.075a.3.3,0,0,1-.3-.3V.4A.3.3,0,0,1,.3.1Z" transform="translate(5.26 11.285) rotate(-90)"/>
|
||||
<path id="Path_6-2" data-name="Path 6" d="M.3.1,1.312,0,2.369.1a.3.3,0,0,1,.3.3V1.779a.3.3,0,0,1-.3.3L1.36,1.939.3,2.075a.3.3,0,0,1-.3-.3V.4A.3.3,0,0,1,.3.1Z" transform="translate(11.284 14.642) rotate(180)"/>
|
||||
<path id="Path_8" data-name="Path 8" d="M.3.1,1.312,0,2.369.1a.3.3,0,0,1,.3.3V1.779a.3.3,0,0,1-.3.3L1.36,1.939.3,2.075a.3.3,0,0,1-.3-.3V.4A.3.3,0,0,1,.3.1Z" transform="translate(14.641 8.619) rotate(90)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 14 KiB |
35
legoresources/Block icns/icn_block_buttons_green.svg
Normal file
@ -0,0 +1,35 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1321.124 9006.084 42.65 31.79">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #6a6a6a;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: url(#linear-gradient);
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: #a8a9a8;
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
fill: #3c3c3c;
|
||||
}
|
||||
</style>
|
||||
<linearGradient id="linear-gradient" x1="0.5" y1="0.948" x2="0.5" y2="0.059" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#6a6a6a"/>
|
||||
<stop offset="0.522" stop-color="#8ce300"/>
|
||||
<stop offset="1" stop-color="#6a6a6a"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="icn_block_buttons_green" transform="translate(666.315 8209.204)">
|
||||
<path id="Union_4" data-name="Union 4" class="cls-1" d="M16.882,31.79c-3.635-3.509-9.28-9.28-9.28-9.28V21.325H5.38a5.381,5.381,0,0,1,0-10.761H7.6V9.379L16.783,0h9.182c4.158,4.237,9.182,9.182,9.182,9.182v1.382h2.122a5.381,5.381,0,1,1,0,10.761H35.147V22.51c-4.891,5.031-9.083,9.28-9.083,9.28Z" transform="translate(654.809 796.881)"/>
|
||||
<path id="light" class="cls-2" d="M16.882,31.79c-3.635-3.509-9.28-9.28-9.28-9.28V21.325H5.38a5.381,5.381,0,0,1,0-10.761H7.6V9.379L16.783,0h9.182c4.158,4.237,9.182,9.182,9.182,9.182v1.382h2.122a5.381,5.381,0,1,1,0,10.761H35.147V22.51c-4.891,5.031-9.083,9.28-9.083,9.28Z" transform="translate(654.809 796.881)"/>
|
||||
<path id="Rectangle_23" data-name="Rectangle 23" class="cls-3" d="M4,0h6.763a0,0,0,0,1,0,0V8a0,0,0,0,1,0,0H4A4,4,0,0,1,0,4V4A4,4,0,0,1,4,0Z" transform="translate(656.092 808.729)"/>
|
||||
<path id="Rectangle_24" data-name="Rectangle 24" class="cls-3" d="M4,0h6.763a0,0,0,0,1,0,0V8a0,0,0,0,1,0,0H4A4,4,0,0,1,0,4V4A4,4,0,0,1,4,0Z" transform="translate(696.077 816.725) rotate(180)"/>
|
||||
<path id="Path_42" data-name="Path 42" class="cls-4" d="M.3,0H8.1a.3.3,0,0,1,.3.3V7.7a.3.3,0,0,1-.3.3H.3A.3.3,0,0,1,0,7.7V.3A.3.3,0,0,1,.3,0Z" transform="translate(671.889 808.729)"/>
|
||||
<path id="Path_15" data-name="Path 15" class="cls-3" d="M-102.228-1598.9l8.293-.1,6.22,6.417-2.567,2.567v4.64h-2.369v-2.666a1.99,1.99,0,0,0-1.975-1.974c-1.927-.031-7.207,0-7.207,0a1.606,1.606,0,0,0-1.678,1.678v2.962h-2.369v-4.64l-2.567-2.567Z" transform="translate(774.216 2397.264)"/>
|
||||
<path id="Path_16" data-name="Path 16" class="cls-3" d="M6.264.062,14.505,0l6.236,6.412L18.135,8.954v4.667H15.79V10.945a2,2,0,0,0-1.969-1.99c-1.927-.031-7.166,0-7.166,0A1.689,1.689,0,0,0,4.93,10.679v2.942H2.543V8.954L0,6.412Z" transform="translate(686.509 827.175) rotate(180)"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.5 KiB |
35
legoresources/Block icns/icn_block_buttons_red.svg
Normal file
@ -0,0 +1,35 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1321.124 8957.084 42.65 31.79">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #6a6a6a;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: url(#linear-gradient);
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: #a8a9a8;
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
fill: #3c3c3c;
|
||||
}
|
||||
</style>
|
||||
<linearGradient id="linear-gradient" x1="0.5" y1="0.948" x2="0.5" y2="0.059" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#6a6a6a"/>
|
||||
<stop offset="0.522" stop-color="#e5352c"/>
|
||||
<stop offset="1" stop-color="#6a6a6a"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="icn_block_buttons_red" transform="translate(666.315 8209.204)">
|
||||
<path id="Union_4" data-name="Union 4" class="cls-1" d="M16.882,31.79c-3.635-3.509-9.28-9.28-9.28-9.28V21.325H5.38a5.381,5.381,0,0,1,0-10.761H7.6V9.379L16.783,0h9.182c4.158,4.237,9.182,9.182,9.182,9.182v1.382h2.122a5.381,5.381,0,1,1,0,10.761H35.147V22.51c-4.891,5.031-9.083,9.28-9.083,9.28Z" transform="translate(654.809 747.881)"/>
|
||||
<path id="light" class="cls-2" d="M16.882,31.79c-3.635-3.509-9.28-9.28-9.28-9.28V21.325H5.38a5.381,5.381,0,0,1,0-10.761H7.6V9.379L16.783,0h9.182c4.158,4.237,9.182,9.182,9.182,9.182v1.382h2.122a5.381,5.381,0,1,1,0,10.761H35.147V22.51c-4.891,5.031-9.083,9.28-9.083,9.28Z" transform="translate(654.809 747.881)"/>
|
||||
<path id="Rectangle_23" data-name="Rectangle 23" class="cls-3" d="M4,0h6.763a0,0,0,0,1,0,0V8a0,0,0,0,1,0,0H4A4,4,0,0,1,0,4V4A4,4,0,0,1,4,0Z" transform="translate(656.092 759.729)"/>
|
||||
<path id="Rectangle_24" data-name="Rectangle 24" class="cls-3" d="M4,0h6.763a0,0,0,0,1,0,0V8a0,0,0,0,1,0,0H4A4,4,0,0,1,0,4V4A4,4,0,0,1,4,0Z" transform="translate(696.077 767.725) rotate(180)"/>
|
||||
<path id="Path_42" data-name="Path 42" class="cls-4" d="M.3,0H8.1a.3.3,0,0,1,.3.3V7.7a.3.3,0,0,1-.3.3H.3A.3.3,0,0,1,0,7.7V.3A.3.3,0,0,1,.3,0Z" transform="translate(671.889 759.729)"/>
|
||||
<path id="Path_15" data-name="Path 15" class="cls-3" d="M-102.228-1598.9l8.293-.1,6.22,6.417-2.567,2.567v4.64h-2.369v-2.666a1.99,1.99,0,0,0-1.975-1.974c-1.927-.031-7.207,0-7.207,0a1.606,1.606,0,0,0-1.678,1.678v2.962h-2.369v-4.64l-2.567-2.567Z" transform="translate(774.216 2348.264)"/>
|
||||
<path id="Path_16" data-name="Path 16" class="cls-3" d="M6.264.062,14.505,0l6.236,6.412L18.135,8.954v4.667H15.79V10.945a2,2,0,0,0-1.969-1.99c-1.927-.031-7.166,0-7.166,0A1.689,1.689,0,0,0,4.93,10.679v2.942H2.543V8.954L0,6.412Z" transform="translate(686.509 778.175) rotate(180)"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.5 KiB |
35
legoresources/Block icns/icn_block_buttons_yellow.svg
Normal file
@ -0,0 +1,35 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1393.124 8957.084 42.65 31.79">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #6a6a6a;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: url(#linear-gradient);
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: #a8a9a8;
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
fill: #3c3c3c;
|
||||
}
|
||||
</style>
|
||||
<linearGradient id="linear-gradient" x1="0.5" y1="0.948" x2="0.5" y2="0.059" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#6a6a6a"/>
|
||||
<stop offset="0.522" stop-color="#ffeb00"/>
|
||||
<stop offset="1" stop-color="#838383"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="icn_block_buttons_yellow" transform="translate(666.315 8209.204)">
|
||||
<path id="Union_4" data-name="Union 4" class="cls-1" d="M16.882,31.79c-3.635-3.509-9.28-9.28-9.28-9.28V21.325H5.38a5.381,5.381,0,0,1,0-10.761H7.6V9.379L16.783,0h9.182c4.158,4.237,9.182,9.182,9.182,9.182v1.382h2.122a5.381,5.381,0,1,1,0,10.761H35.147V22.51c-4.891,5.031-9.083,9.28-9.083,9.28Z" transform="translate(726.809 747.881)"/>
|
||||
<path id="light" class="cls-2" d="M16.882,31.79c-3.635-3.509-9.28-9.28-9.28-9.28V21.325H5.38a5.381,5.381,0,0,1,0-10.761H7.6V9.379L16.783,0h9.182c4.158,4.237,9.182,9.182,9.182,9.182v1.382h2.122a5.381,5.381,0,1,1,0,10.761H35.147V22.51c-4.891,5.031-9.083,9.28-9.083,9.28Z" transform="translate(726.809 747.881)"/>
|
||||
<path id="Rectangle_23" data-name="Rectangle 23" class="cls-3" d="M4,0h6.763a0,0,0,0,1,0,0V8a0,0,0,0,1,0,0H4A4,4,0,0,1,0,4V4A4,4,0,0,1,4,0Z" transform="translate(728.092 759.729)"/>
|
||||
<path id="Rectangle_24" data-name="Rectangle 24" class="cls-3" d="M4,0h6.763a0,0,0,0,1,0,0V8a0,0,0,0,1,0,0H4A4,4,0,0,1,0,4V4A4,4,0,0,1,4,0Z" transform="translate(768.077 767.725) rotate(180)"/>
|
||||
<path id="Path_42" data-name="Path 42" class="cls-4" d="M.3,0H8.1a.3.3,0,0,1,.3.3V7.7a.3.3,0,0,1-.3.3H.3A.3.3,0,0,1,0,7.7V.3A.3.3,0,0,1,.3,0Z" transform="translate(743.889 759.729)"/>
|
||||
<path id="Path_15" data-name="Path 15" class="cls-3" d="M-102.228-1598.9l8.293-.1,6.22,6.417-2.567,2.567v4.64h-2.369v-2.666a1.99,1.99,0,0,0-1.975-1.974c-1.927-.031-7.207,0-7.207,0a1.606,1.606,0,0,0-1.678,1.678v2.962h-2.369v-4.64l-2.567-2.567Z" transform="translate(846.216 2348.264)"/>
|
||||
<path id="Path_16" data-name="Path 16" class="cls-3" d="M6.264.062,14.505,0l6.236,6.412L18.135,8.954v4.667H15.79V10.945a2,2,0,0,0-1.969-1.99c-1.927-.031-7.166,0-7.166,0A1.689,1.689,0,0,0,4.93,10.679v2.942H2.543V8.954L0,6.412Z" transform="translate(758.509 778.175) rotate(180)"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.5 KiB |
65
legoresources/Block icns/icn_block_color_sensor.svg
Normal file
@ -0,0 +1,65 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1327.274 8333.921 23.497 21.72">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #a8a9a8;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
clip-path: url(#clip-path);
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: url(#linear-gradient);
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
fill: #b72b1c;
|
||||
}
|
||||
|
||||
.cls-5 {
|
||||
fill: #f2f2f2;
|
||||
}
|
||||
|
||||
.cls-6 {
|
||||
filter: url(#Path_1);
|
||||
}
|
||||
</style>
|
||||
<clipPath id="clip-path">
|
||||
<path id="Union_5" data-name="Union 5" class="cls-1" d="M2.543,21.72c-.7,0-1.26-.4-1.26-.9V17.968H.494A.494.494,0,0,1,0,17.475V4.64a.494.494,0,0,1,.494-.494h.79V.9c0-.5.564-.9,1.26-.9H20.954c.7,0,1.26.4,1.26.9v3.25H23a.494.494,0,0,1,.494.494V17.475a.494.494,0,0,1-.494.494h-.79v2.855c0,.5-.564.9-1.26.9Z"/>
|
||||
</clipPath>
|
||||
<linearGradient id="linear-gradient" x1="0.5" y1="0.901" x2="0.5" y2="1.068" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#a8a9a8"/>
|
||||
<stop offset="1" stop-color="#545554"/>
|
||||
</linearGradient>
|
||||
<filter id="Path_1" x="1319.557" y="8327.921" width="38.93" height="39.72" filterUnits="userSpaceOnUse">
|
||||
<feOffset dy="3" input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="3" result="blur"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<g id="icn_block_color_sensor" transform="translate(666.315 8209.204)">
|
||||
<g id="Mask_Group_5" data-name="Mask Group 5" class="cls-2" transform="translate(660.959 124.718)">
|
||||
<g id="Group_4" data-name="Group 4" transform="translate(0)">
|
||||
<g id="Group_2" data-name="Group 2">
|
||||
<path id="Path_28" data-name="Path 28" class="cls-1" d="M.494,0H23A.494.494,0,0,1,23.5.494V13.328a.494.494,0,0,1-.494.494H.494A.494.494,0,0,1,0,13.328V.494A.494.494,0,0,1,.494,0Z" transform="translate(0 4.147)"/>
|
||||
<g class="cls-6" transform="matrix(1, 0, 0, 1, -1327.27, -8333.92)">
|
||||
<path id="Path_1-2" data-name="Path 1" class="cls-3" d="M1.26,0H19.67c.7,0,1.26.4,1.26.9V20.823c0,.5-.564.9-1.26.9H1.26c-.7,0-1.26-.4-1.26-.9V.9C0,.4.564,0,1.26,0Z" transform="translate(1328.56 8333.92)"/>
|
||||
</g>
|
||||
<rect id="Rectangle_2" data-name="Rectangle 2" width="0.494" height="3.949" transform="translate(22.51 6.121)"/>
|
||||
<rect id="Rectangle_5" data-name="Rectangle 5" width="0.494" height="3.949" transform="translate(0.592 6.121)"/>
|
||||
<rect id="Rectangle_3" data-name="Rectangle 3" width="0.494" height="3.949" transform="translate(22.51 11.748)"/>
|
||||
<rect id="Rectangle_4" data-name="Rectangle 4" width="0.494" height="3.949" transform="translate(0.592 11.748)"/>
|
||||
</g>
|
||||
<path id="Union_1" data-name="Union 1" class="cls-4" d="M1.678,11.551a4.557,4.557,0,0,1,.1-.973,6.22,6.22,0,1,1,8.874,0,4.542,4.542,0,1,1-8.979.973Z" transform="translate(5.529 2.666)"/>
|
||||
<path id="Union_2" data-name="Union 2" d="M1.738,10.614A3.5,3.5,0,0,1,1.98,9.332,5.233,5.233,0,1,1,8.5,9.317a3.507,3.507,0,1,1-6.765,1.3Z" transform="translate(6.516 3.602)"/>
|
||||
<g id="Group_3" data-name="Group 3" transform="translate(9.379 6.615)">
|
||||
<ellipse id="Ellipse_5" data-name="Ellipse 5" class="cls-5" cx="2.369" cy="2.369" rx="2.369" ry="2.369"/>
|
||||
<ellipse id="Ellipse_6" data-name="Ellipse 6" class="cls-5" cx="1.283" cy="1.283" rx="1.283" ry="1.283" transform="translate(1.086 6.22)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
26
legoresources/Block icns/icn_block_display.svg
Normal file
@ -0,0 +1,26 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1299.627 9145.076 41.445 32.779">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: url(#linear-gradient);
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: #3c3c3c;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: #a0b5a6;
|
||||
}
|
||||
</style>
|
||||
<linearGradient id="linear-gradient" x1="0.5" y1="0.924" x2="0.5" y2="0.948" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#a8a9a8"/>
|
||||
<stop offset="1" stop-color="gray"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="icn_block_display" transform="translate(666.315 8209.204)">
|
||||
<path id="Path_91" data-name="Path 91" class="cls-1" d="M.816,0H40.629a.816.816,0,0,1,.816.816V31.963a.816.816,0,0,1-.816.816H.816A.816.816,0,0,1,0,31.963V.816A.816.816,0,0,1,.816,0Z" transform="translate(633.313 935.874)"/>
|
||||
<path id="Path_92" data-name="Path 92" class="cls-2" d="M1.57,0H32.4a1.57,1.57,0,0,1,1.57,1.57V18.9a1.57,1.57,0,0,1-1.57,1.57H1.57A1.57,1.57,0,0,1,0,18.9V1.57A1.57,1.57,0,0,1,1.57,0Z" transform="translate(637.08 940.207)"/>
|
||||
<path id="Path_93" data-name="Path 93" class="cls-3" d="M1.13,0H27.316a1.13,1.13,0,0,1,1.13,1.13v16.7a1.13,1.13,0,0,1-1.13,1.13H1.13A1.13,1.13,0,0,1,0,17.834V1.13A1.13,1.13,0,0,1,1.13,0Z" transform="translate(639.906 941.023)"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
101
legoresources/Block icns/icn_block_gyro.svg
Normal file
@ -0,0 +1,101 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1306.936 8729.215 61.393 44.083">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #d5277e;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: #a8a9a8;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
clip-path: url(#clip-path);
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
clip-path: url(#clip-path-2);
|
||||
}
|
||||
|
||||
.cls-11, .cls-5 {
|
||||
fill: #9a9a9a;
|
||||
}
|
||||
|
||||
.cls-6 {
|
||||
fill: #f2f2f2;
|
||||
}
|
||||
|
||||
.cls-7 {
|
||||
opacity: 0.6;
|
||||
fill: url(#linear-gradient);
|
||||
}
|
||||
|
||||
.cls-8 {
|
||||
fill: url(#linear-gradient-2);
|
||||
}
|
||||
|
||||
.cls-9 {
|
||||
fill: #b72b1c;
|
||||
}
|
||||
|
||||
.cls-10, .cls-11 {
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.cls-12 {
|
||||
filter: url(#Path_12);
|
||||
}
|
||||
</style>
|
||||
<clipPath id="clip-path">
|
||||
<path id="Path_88" data-name="Path 88" class="cls-1" d="M1162.538,3051.215l1.79,38.862h-31.593l-5.221,5.221h-11.692l-5.221-5.221h-7.666l1.729-38.862Z" transform="translate(-1124.637 -3056.569)"/>
|
||||
</clipPath>
|
||||
<clipPath id="clip-path-2">
|
||||
<path id="Union_7" data-name="Union 7" class="cls-2" d="M6.318,39.688a6.076,6.076,0,0,1-1.291-.3H2.271A1.283,1.283,0,0,1,.987,38.108V35.147H.494A.494.494,0,0,1,0,34.653V4.542a.494.494,0,0,1,.494-.494H.987V1.284A1.283,1.283,0,0,1,2.271,0h8.237V.395h2.226V0h8.3a1.284,1.284,0,0,1,1.284,1.284V4.048H22.9a.494.494,0,0,1,.494.494V34.653a.494.494,0,0,1-.494.493h-.592v2.962a1.284,1.284,0,0,1-1.284,1.283h-2.7c-.111.2-1.244.3-1.451.3Z"/>
|
||||
</clipPath>
|
||||
<filter id="Path_12" x="1328.499" y="8733.444" width="23.575" height="33.349" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="0.375" result="blur"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
<linearGradient id="linear-gradient" x1="0.5" x2="0.5" y2="1" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#fff" stop-opacity="0"/>
|
||||
<stop offset="1" stop-color="#404040"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="linear-gradient-2" x1="0.5" x2="0.5" y2="1" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#fff"/>
|
||||
<stop offset="1" stop-color="gray"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="icn_block_gyro" transform="translate(666.315 8209.204)">
|
||||
<g id="Mask_Group_11" data-name="Mask Group 11" class="cls-3" transform="translate(662.322 525.366)">
|
||||
<g id="Group_16" data-name="Group 16">
|
||||
<g id="Mask_Group_7" data-name="Mask Group 7" class="cls-4" transform="translate(0 0)">
|
||||
<g id="Group_9" data-name="Group 9" transform="translate(0 0)">
|
||||
<path id="Path_29" data-name="Path 29" class="cls-2" d="M.494,0H22.9A.494.494,0,0,1,23.4.494V30.605a.494.494,0,0,1-.494.494H.494A.494.494,0,0,1,0,30.605V.494A.494.494,0,0,1,.494,0Z" transform="translate(0 4.048)"/>
|
||||
<rect id="Rectangle_11" data-name="Rectangle 11" class="cls-5" width="3.752" height="10.268" transform="translate(9.774 0.395)"/>
|
||||
<g class="cls-12" transform="matrix(1, 0, 0, 1, -1328.64, -8734.57)">
|
||||
<path id="Path_12-2" data-name="Path 12" class="cls-2" d="M1.283,0H9.52V10.424l2.226-.163V0h8.3a1.283,1.283,0,0,1,1.283,1.283V29.815A1.283,1.283,0,0,1,20.041,31.1H1.283A1.283,1.283,0,0,1,0,29.815V1.283A1.283,1.283,0,0,1,1.283,0Z" transform="translate(1329.62 8734.57)"/>
|
||||
</g>
|
||||
<g id="hvid" transform="translate(0.987 19.252)">
|
||||
<g id="hvid-2" data-name="hvid" transform="translate(0)">
|
||||
<path id="Path_57" data-name="Path 57" class="cls-6" d="M.79,0H20.535a.79.79,0,0,1,.79.79V18.857a1.283,1.283,0,0,1-1.283,1.283H1.283A1.283,1.283,0,0,1,0,18.857V.79A.79.79,0,0,1,.79,0Z" transform="translate(0)"/>
|
||||
<path id="Path_59" data-name="Path 59" class="cls-7" d="M0,0H21.325V1.975a1.283,1.283,0,0,1-1.283,1.283H1.283A1.283,1.283,0,0,1,0,1.975Z" transform="translate(0 16.882)"/>
|
||||
</g>
|
||||
<g id="Path_1" data-name="Path 1" class="cls-8" transform="translate(15.935 18.955)">
|
||||
<path class="cls-10" d="M -0.03972615301609039 1.355897426605225 L -10.6034460067749 1.355897426605225 C -10.8238697052002 1.355897426605225 -11.76168155670166 1.143560767173767 -12.02564239501953 0.9932262897491455 L -11.25642585754395 0.3544974625110626 C -11.06739616394043 0.1967574656009674 -10.78548622131348 0.1249974593520164 -10.6034460067749 0.1249974593520164 L -0.03972615301609039 0.1249974593520164 C 0.08689384907484055 0.1249974593520164 0.1953838467597961 0.221777468919754 0.3209938406944275 0.3338374495506287 C 0.3559758961200714 0.3650458753108978 0.3912657201290131 0.3964739441871643 0.4275123476982117 0.4264010488986969 L 1.240363001823425 1.159494996070862 C 0.997438907623291 1.265054941177368 0.2347392439842224 1.355897426605225 -0.03972615301609039 1.355897426605225 Z"/>
|
||||
<path class="cls-11" d="M -0.03972615301609039 1.230897426605225 C 0.1518102586269379 1.230897426605225 0.6746260523796082 1.174463033676147 0.9910745024681091 1.102993011474609 L 0.3458296954631805 0.5210594534873962 C 0.3090922832489014 0.490643322467804 0.2732802927494049 0.4587787985801697 0.2377838492393494 0.4271174669265747 C 0.1312438398599625 0.3320774734020233 0.03924384713172913 0.249997466802597 -0.03972615301609039 0.249997466802597 L -10.6034460067749 0.249997466802597 C -10.76875591278076 0.249997466802597 -11.01853656768799 0.3187874555587769 -11.1765661239624 0.4506674706935883 L -11.78844928741455 0.9587525725364685 C -11.43126487731934 1.086030006408691 -10.7613353729248 1.230897426605225 -10.6034460067749 1.230897426605225 L -0.03972615301609039 1.230897426605225 M -0.03972615301609039 1.480897426605225 L -10.6034460067749 1.480897426605225 C -10.82154655456543 1.480897426605225 -12.20312595367432 1.196227431297302 -12.20312595367432 0.9781274795532227 L -11.33627605438232 0.258327454328537 C -11.12889575958252 0.08526746183633804 -10.82154655456543 -2.538394937801058e-06 -10.6034460067749 -2.538394937801058e-06 L -0.03972615301609039 -2.538394937801058e-06 C 0.1783738434314728 -2.538394937801058e-06 0.3312638401985168 0.1853174567222595 0.5091438293457031 0.3316974639892578 L 1.42017388343811 1.153337478637695 C 1.42017388343811 1.371437430381775 0.1783738434314728 1.480897426605225 -0.03972615301609039 1.480897426605225 Z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="red_things" data-name="red things" transform="translate(2.962 5.529)">
|
||||
<ellipse id="red_dot" data-name="red dot" class="cls-9" cx="1.975" cy="1.975" rx="1.975" ry="1.975" transform="translate(6.713 3.85)"/>
|
||||
<path id="red_arrow_1" data-name="red arrow 1" class="cls-9" d="M3121.088-1937.325a6.718,6.718,0,0,1-.494-7.01c.151.093.443.226.592.3.42.239.482-.2.4-.494l-.79-2.468-2.468.691a.939.939,0,0,0-.3.1c-.129.082-.24.258,0,.395l.691.395a8.146,8.146,0,0,0,.691,9.28C3120.449-1936.882,3121.088-1937.325,3121.088-1937.325Z" transform="translate(-3117.592 1947)"/>
|
||||
<path id="red_arrow_2" data-name="red arrow 2" class="cls-9" d="M3118.12-1937.325a6.718,6.718,0,0,0,.493-7.01c-.151.093-.443.226-.592.3-.42.239-.482-.2-.395-.494l.79-2.468,2.468.691a.943.943,0,0,1,.3.1c.128.082.24.258,0,.395l-.691.395a8.147,8.147,0,0,1-.691,9.28C3118.758-1936.882,3118.12-1937.325,3118.12-1937.325Z" transform="translate(-3104.259 1947)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 7.3 KiB |
65
legoresources/Block icns/icn_block_medium_motor.svg
Normal file
@ -0,0 +1,65 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1323.372 8463.761 30.979 30.979">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: url(#linear-gradient);
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: #a8a9a8;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: #3c3c3c;
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
fill: #b72b1c;
|
||||
stroke: #8b1104;
|
||||
stroke-width: 0.25px;
|
||||
}
|
||||
|
||||
.cls-5 {
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.cls-6 {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.cls-7 {
|
||||
filter: url(#Union_1);
|
||||
}
|
||||
</style>
|
||||
<linearGradient id="linear-gradient" x1="0.5" y1="0.919" x2="0.5" y2="1.077" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#a8a9a8"/>
|
||||
<stop offset="1" stop-color="#545554"/>
|
||||
</linearGradient>
|
||||
<filter id="Union_1" x="1323.372" y="8463.761" width="30.979" height="30.979" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="0.375" result="blur"/>
|
||||
<feFlood flood-opacity="0.322"/>
|
||||
<feComposite operator="in" in2="blur"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<g id="icn_block_medium_motor" transform="translate(666.315 8209.204)">
|
||||
<g id="Group_4" data-name="Group 4" transform="translate(658.182 255.683)">
|
||||
<path id="Path_1" data-name="Path 1" class="cls-1" d="M2.383-.287H27.768A1.534,1.534,0,0,1,29.44,1V27.258c0,.654-.714,1.185-1.673,1.185H2.383c-.959,0-1.673-.531-1.673-1.185V1A1.534,1.534,0,0,1,2.383-.287Z" transform="translate(-0.711 0.287)"/>
|
||||
</g>
|
||||
<g id="Group_7" data-name="Group 7" transform="translate(686.912 255.683) rotate(90)">
|
||||
<g class="cls-7" transform="matrix(0, -1, 1, 0, -8464.89, 1353.23)">
|
||||
<path id="Union_1-2" data-name="Union 1" class="cls-2" d="M13.822,28.729a4.048,4.048,0,0,1-4.048-4.048V18.955H4.048A4.048,4.048,0,0,1,0,14.908V13.822A4.048,4.048,0,0,1,4.048,9.774H9.774V4.048A4.048,4.048,0,0,1,13.822,0h1.086a4.048,4.048,0,0,1,4.048,4.048V9.774h5.726a4.048,4.048,0,0,1,4.048,4.048v1.086a4.048,4.048,0,0,1-4.048,4.048H18.955v5.726a4.048,4.048,0,0,1-4.048,4.048Z" transform="translate(1353.23 8464.89) rotate(90)"/>
|
||||
</g>
|
||||
<ellipse id="Ellipse_1" data-name="Ellipse 1" class="cls-3" cx="3.159" cy="3.159" rx="3.159" ry="3.159" transform="translate(11.255 0.987)"/>
|
||||
<ellipse id="Ellipse_2" data-name="Ellipse 2" class="cls-3" cx="3.159" cy="3.159" rx="3.159" ry="3.159" transform="translate(11.255 21.424)"/>
|
||||
<ellipse id="Ellipse_1-2" data-name="Ellipse 1" class="cls-3" cx="3.159" cy="3.159" rx="3.159" ry="3.159" transform="translate(0.987 17.475) rotate(-90)"/>
|
||||
<ellipse id="Ellipse_2-2" data-name="Ellipse 2" class="cls-3" cx="3.159" cy="3.159" rx="3.159" ry="3.159" transform="translate(21.424 17.475) rotate(-90)"/>
|
||||
</g>
|
||||
<g id="Ellipse_4" data-name="Ellipse 4" class="cls-4" transform="translate(668.3 265.702)">
|
||||
<ellipse class="cls-5" cx="4.395" cy="4.395" rx="4.395" ry="4.395"/>
|
||||
<ellipse class="cls-6" cx="4.395" cy="4.395" rx="4.27" ry="4.27"/>
|
||||
</g>
|
||||
<path id="Hole" d="M5605.5,961.821s-.035.664-.5.67-.952,0-.952,0a1.541,1.541,0,0,0-.3,1.1c0,.824.232,1.045.232,1.045h1.06a.42.42,0,0,1,.454.454v1.085a2.528,2.528,0,0,0,1.149.187,4.2,4.2,0,0,0,1.091-.187v-1.085a.475.475,0,0,1,.478-.454,6.978,6.978,0,0,0,.94-.091s.257-.243.282-1.062-.23-1.07-.23-1.07h-1.1a.417.417,0,0,1-.5-.441,7.426,7.426,0,0,1,0-1.07,3.135,3.135,0,0,0-2.113,0C5605.488,961.354,5605.5,961.821,5605.5,961.821Z" transform="translate(-4933.915 -693.478)"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.5 KiB |
84
legoresources/Block icns/icn_block_touch_sensor.svg
Normal file
@ -0,0 +1,84 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1327.51 8602.067 23.497 21.72">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #a8a9a8;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
clip-path: url(#clip-path);
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: url(#linear-gradient);
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
fill: url(#linear-gradient-2);
|
||||
}
|
||||
|
||||
.cls-5 {
|
||||
fill: #b72b1c;
|
||||
stroke: #8b1104;
|
||||
stroke-width: 0.25px;
|
||||
}
|
||||
|
||||
.cls-6 {
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.cls-7 {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.cls-8 {
|
||||
filter: url(#Path_1);
|
||||
}
|
||||
</style>
|
||||
<clipPath id="clip-path">
|
||||
<path id="Union_3" data-name="Union 3" class="cls-1" d="M2.567,21.72c-.7,0-1.283-.393-1.283-.889V17.968H.651A.651.651,0,0,1,0,17.317V4.8a.651.651,0,0,1,.651-.651h.633V.889C1.283.394,1.871,0,2.567,0H9.576V.889h4.147V0H20.93c.7,0,1.283.394,1.283.889V4.147h.633A.65.65,0,0,1,23.5,4.8v12.52a.651.651,0,0,1-.651.651h-.633v2.863c0,.5-.588.889-1.283.889Z"/>
|
||||
</clipPath>
|
||||
<linearGradient id="linear-gradient" x1="0.5" y1="0.91" x2="0.5" y2="1.046" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#a8a9a8"/>
|
||||
<stop offset="1" stop-color="#545554"/>
|
||||
</linearGradient>
|
||||
<filter id="Path_1" x="1325.794" y="8599.067" width="26.93" height="27.72" filterUnits="userSpaceOnUse">
|
||||
<feOffset input="SourceAlpha"/>
|
||||
<feGaussianBlur stdDeviation="1" result="blur"/>
|
||||
<feFlood flood-opacity="0.502"/>
|
||||
<feComposite operator="in" in2="blur"/>
|
||||
<feComposite in="SourceGraphic"/>
|
||||
</filter>
|
||||
<linearGradient id="linear-gradient-2" x1="0.949" y1="0.5" x2="0.056" y2="0.5" gradientUnits="objectBoundingBox">
|
||||
<stop offset="0" stop-color="#b72b1c"/>
|
||||
<stop offset="1" stop-color="#8b1104"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="icn_block_touch_sensor" transform="translate(666.315 8209.204)">
|
||||
<g id="Group_8" data-name="Group 8" transform="translate(661.196 392.864)">
|
||||
<g id="Mask_Group_3" data-name="Mask Group 3" class="cls-2">
|
||||
<g id="Group_2" data-name="Group 2" transform="translate(0 0)">
|
||||
<path id="Path_27" data-name="Path 27" class="cls-1" d="M.494,0H23A.494.494,0,0,1,23.5.494V13.328a.494.494,0,0,1-.494.494H.494A.494.494,0,0,1,0,13.328V.494A.494.494,0,0,1,.494,0Z" transform="translate(0 4.147)"/>
|
||||
<g class="cls-8" transform="matrix(1, 0, 0, 1, -1327.51, -8602.07)">
|
||||
<path id="Path_1-2" data-name="Path 1" class="cls-3" d="M1.283,0h7.01V.889H12.44V0h7.207c.7,0,1.283.393,1.283.889V20.831c0,.5-.588.889-1.283.889H1.283c-.7,0-1.283-.393-1.283-.889V.889C0,.393.588,0,1.283,0Z" transform="translate(1328.79 8602.07)"/>
|
||||
</g>
|
||||
<rect id="Rectangle_2" data-name="Rectangle 2" width="0.494" height="3.949" transform="translate(22.51 6.121)"/>
|
||||
<rect id="Rectangle_5" data-name="Rectangle 5" width="0.494" height="3.949" transform="translate(0.592 6.121)"/>
|
||||
<rect id="Rectangle_3" data-name="Rectangle 3" width="0.494" height="3.949" transform="translate(22.51 11.748)"/>
|
||||
<rect id="Rectangle_4" data-name="Rectangle 4" width="0.494" height="3.949" transform="translate(0.592 11.748)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Group_5" data-name="Group 5" transform="translate(664.158 395.579)">
|
||||
<rect id="Rectangle_6" data-name="Rectangle 6" class="cls-4" width="6.22" height="4.048" transform="translate(0 6.861)"/>
|
||||
<rect id="Rectangle_9" data-name="Rectangle 9" class="cls-4" width="6.22" height="4.048" transform="translate(10.811) rotate(90)"/>
|
||||
<rect id="Rectangle_7" data-name="Rectangle 7" class="cls-4" width="6.22" height="4.048" transform="translate(17.573 10.909) rotate(180)"/>
|
||||
<rect id="Rectangle_8" data-name="Rectangle 8" class="cls-4" width="6.22" height="4.048" transform="translate(6.763 17.573) rotate(-90)"/>
|
||||
<g id="Ellipse_1" data-name="Ellipse 1" class="cls-5" transform="translate(4.838 4.887)">
|
||||
<ellipse class="cls-6" cx="3.949" cy="3.949" rx="3.949" ry="3.949"/>
|
||||
<ellipse class="cls-7" cx="3.949" cy="3.949" rx="3.824" ry="3.824"/>
|
||||
</g>
|
||||
<path id="Hole" d="M5605.323,961.71s-.032.6-.45.6-.854,0-.854,0a1.382,1.382,0,0,0-.266.989c0,.74.208.939.208.939h.953a.378.378,0,0,1,.409.408v.975a2.269,2.269,0,0,0,1.033.168,3.77,3.77,0,0,0,.98-.168v-.975a.426.426,0,0,1,.43-.408,6.239,6.239,0,0,0,.845-.082s.231-.219.253-.955-.207-.961-.207-.961h-.99a.375.375,0,0,1-.446-.4,6.76,6.76,0,0,1,0-.961,2.814,2.814,0,0,0-1.9,0C5605.313,961.289,5605.323,961.71,5605.323,961.71Z" transform="translate(-5597.534 -954.45)"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.5 KiB |
103
legoresources/Block icns/icn_block_ultra_sonic.svg
Normal file
@ -0,0 +1,103 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="1324.724 8870.247 54.201 22.707">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #f2f2f2;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: #292929;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
stroke: rgba(242,242,242,0.5);
|
||||
stroke-width: 0.15px;
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
fill: #931f1f;
|
||||
}
|
||||
|
||||
.cls-5 {
|
||||
fill: #9d761f;
|
||||
}
|
||||
|
||||
.cls-6 {
|
||||
clip-path: url(#clip-path);
|
||||
}
|
||||
|
||||
.cls-7 {
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.cls-8 {
|
||||
fill: none;
|
||||
}
|
||||
</style>
|
||||
<clipPath id="clip-path">
|
||||
<ellipse id="guld" class="cls-1" cx="4.541" cy="4.541" rx="4.541" ry="4.541"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g id="icn_block_ultra_sonic" transform="translate(666.315 8209.204)">
|
||||
<rect id="Rectangle_1" data-name="Rectangle 1" class="cls-2" width="28.236" height="20.338" transform="translate(673.021 661.932)"/>
|
||||
<rect id="Rectangle_2" data-name="Rectangle 2" width="16.487" height="11.452" transform="translate(677.958 666.474)"/>
|
||||
<g id="eye1" transform="translate(658.41 661.044)">
|
||||
<g id="sort" class="cls-3" transform="translate(0 0)">
|
||||
<ellipse class="cls-7" cx="11.354" cy="11.354" rx="11.354" ry="11.354"/>
|
||||
<ellipse class="cls-8" cx="11.354" cy="11.354" rx="11.279" ry="11.279"/>
|
||||
</g>
|
||||
<ellipse id="rød" class="cls-4" cx="7.01" cy="7.01" rx="7.01" ry="7.01" transform="translate(4.344 4.344)"/>
|
||||
<ellipse id="guld-3" data-name="guld" class="cls-5" cx="5.232" cy="5.232" rx="5.232" ry="5.232" transform="translate(6.121 6.121)"/>
|
||||
<ellipse id="guld-4" data-name="guld" class="cls-1" cx="4.541" cy="4.541" rx="4.541" ry="4.541" transform="translate(6.812 6.812)"/>
|
||||
<g id="Group_5" data-name="Group 5" transform="translate(6.812 6.812)">
|
||||
<g id="Mask_Group_8" data-name="Mask Group 8" class="cls-6">
|
||||
<g id="Group_17" data-name="Group 17" transform="translate(-4.652 2.089) rotate(-30)">
|
||||
<rect id="Rectangle_84" data-name="Rectangle 84" class="cls-5" width="0.395" height="14.834" transform="translate(1.333 0)"/>
|
||||
<rect id="Rectangle_91" data-name="Rectangle 91" class="cls-5" width="0.395" height="14.649" transform="translate(0 13.081) rotate(-90)"/>
|
||||
<rect id="Rectangle_85" data-name="Rectangle 85" class="cls-5" width="0.395" height="14.834" transform="translate(3.209 0)"/>
|
||||
<rect id="Rectangle_97" data-name="Rectangle 97" class="cls-5" width="0.395" height="14.649" transform="translate(0 11.205) rotate(-90)"/>
|
||||
<rect id="Rectangle_86" data-name="Rectangle 86" class="cls-5" width="0.395" height="14.834" transform="translate(5.084 0)"/>
|
||||
<rect id="Rectangle_96" data-name="Rectangle 96" class="cls-5" width="0.395" height="14.649" transform="translate(0 9.33) rotate(-90)"/>
|
||||
<rect id="Rectangle_87" data-name="Rectangle 87" class="cls-5" width="0.395" height="14.834" transform="translate(6.96 0)"/>
|
||||
<rect id="Rectangle_95" data-name="Rectangle 95" class="cls-5" width="0.395" height="14.649" transform="translate(0 7.454) rotate(-90)"/>
|
||||
<rect id="Rectangle_88" data-name="Rectangle 88" class="cls-5" width="0.395" height="14.834" transform="translate(8.836 0)"/>
|
||||
<rect id="Rectangle_94" data-name="Rectangle 94" class="cls-5" width="0.395" height="14.649" transform="translate(0 5.578) rotate(-90)"/>
|
||||
<rect id="Rectangle_89" data-name="Rectangle 89" class="cls-5" width="0.395" height="14.834" transform="translate(10.712 0)"/>
|
||||
<rect id="Rectangle_93" data-name="Rectangle 93" class="cls-5" width="0.395" height="14.649" transform="translate(0 3.702) rotate(-90)"/>
|
||||
<rect id="Rectangle_90" data-name="Rectangle 90" class="cls-5" width="0.395" height="14.834" transform="translate(12.588 0)"/>
|
||||
<rect id="Rectangle_92" data-name="Rectangle 92" class="cls-5" width="0.395" height="14.649" transform="translate(0 1.826) rotate(-90)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="eye2" transform="translate(689.903 661.044)">
|
||||
<g id="sort-2" data-name="sort" class="cls-3" transform="translate(0 0)">
|
||||
<ellipse class="cls-7" cx="11.354" cy="11.354" rx="11.354" ry="11.354"/>
|
||||
<ellipse class="cls-8" cx="11.354" cy="11.354" rx="11.279" ry="11.279"/>
|
||||
</g>
|
||||
<ellipse id="rød-2" data-name="rød" class="cls-4" cx="7.01" cy="7.01" rx="7.01" ry="7.01" transform="translate(4.344 4.344)"/>
|
||||
<ellipse id="guld-5" data-name="guld" class="cls-5" cx="5.232" cy="5.232" rx="5.232" ry="5.232" transform="translate(6.121 6.121)"/>
|
||||
<ellipse id="guld-6" data-name="guld" class="cls-1" cx="4.541" cy="4.541" rx="4.541" ry="4.541" transform="translate(6.812 6.812)"/>
|
||||
<g id="Group_18" data-name="Group 18" transform="translate(6.812 6.812)">
|
||||
<g id="Mask_Group_8-2" data-name="Mask Group 8" class="cls-6">
|
||||
<g id="Group_17-2" data-name="Group 17" transform="translate(-4.652 2.089) rotate(-30)">
|
||||
<rect id="Rectangle_84-2" data-name="Rectangle 84" class="cls-5" width="0.395" height="14.834" transform="translate(1.333 0)"/>
|
||||
<rect id="Rectangle_91-2" data-name="Rectangle 91" class="cls-5" width="0.395" height="14.649" transform="translate(0 13.081) rotate(-90)"/>
|
||||
<rect id="Rectangle_85-2" data-name="Rectangle 85" class="cls-5" width="0.395" height="14.834" transform="translate(3.209 0)"/>
|
||||
<rect id="Rectangle_97-2" data-name="Rectangle 97" class="cls-5" width="0.395" height="14.649" transform="translate(0 11.205) rotate(-90)"/>
|
||||
<rect id="Rectangle_86-2" data-name="Rectangle 86" class="cls-5" width="0.395" height="14.834" transform="translate(5.084 0)"/>
|
||||
<rect id="Rectangle_96-2" data-name="Rectangle 96" class="cls-5" width="0.395" height="14.649" transform="translate(0 9.33) rotate(-90)"/>
|
||||
<rect id="Rectangle_87-2" data-name="Rectangle 87" class="cls-5" width="0.395" height="14.834" transform="translate(6.96 0)"/>
|
||||
<rect id="Rectangle_95-2" data-name="Rectangle 95" class="cls-5" width="0.395" height="14.649" transform="translate(0 7.454) rotate(-90)"/>
|
||||
<rect id="Rectangle_88-2" data-name="Rectangle 88" class="cls-5" width="0.395" height="14.834" transform="translate(8.836 0)"/>
|
||||
<rect id="Rectangle_94-2" data-name="Rectangle 94" class="cls-5" width="0.395" height="14.649" transform="translate(0 5.578) rotate(-90)"/>
|
||||
<rect id="Rectangle_89-2" data-name="Rectangle 89" class="cls-5" width="0.395" height="14.834" transform="translate(10.712 0)"/>
|
||||
<rect id="Rectangle_93-2" data-name="Rectangle 93" class="cls-5" width="0.395" height="14.649" transform="translate(0 3.702) rotate(-90)"/>
|
||||
<rect id="Rectangle_90-2" data-name="Rectangle 90" class="cls-5" width="0.395" height="14.834" transform="translate(12.588 0)"/>
|
||||
<rect id="Rectangle_92-2" data-name="Rectangle 92" class="cls-5" width="0.395" height="14.649" transform="translate(0 1.826) rotate(-90)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 7.0 KiB |
BIN
legoresources/SVGassets/.DS_Store
vendored
@ -92,7 +92,7 @@
|
||||
"Math.pow|param|x": "The base value of the expression.",
|
||||
"Math.pow|param|y": "The exponent value of the expression.",
|
||||
"Math.random": "Returns a pseudorandom number between 0 and 1.",
|
||||
"Math.randomRange": "Returns a pseudorandom number between min and max included. \nIf both numbers are integral, the result is integral.",
|
||||
"Math.randomRange": "Returns a pseudorandom number between min and max included.\nIf both numbers are integral, the result is integral.",
|
||||
"Math.randomRange|param|max": "the upper inclusive bound, eg: 10",
|
||||
"Math.randomRange|param|min": "the lower inclusive bound, eg: 0",
|
||||
"Math.round": "Returns a supplied numeric expression rounded to the nearest number.",
|
||||
@ -142,15 +142,10 @@
|
||||
"loops.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
|
||||
"loops.pause": "Pause for the specified time in milliseconds",
|
||||
"loops.pause|param|ms": "how long to pause for, eg: 100, 200, 500, 1000, 2000",
|
||||
"loops.timePicker": "Get the time field editor",
|
||||
"loops.timePicker|param|ms": "time duration in milliseconds, eg: 500, 1000",
|
||||
"loops.waitUntil": "Busy wait for a condition to be true",
|
||||
"loops.waitUntil|param|condition": "condition to test for",
|
||||
"loops.waitUntil|param|timeOut": "if positive, maximum duration to wait for in milliseconds",
|
||||
"loops.when": "Runs code when the condition becomes true",
|
||||
"loops.when|param|condition": "condition to test",
|
||||
"loops.when|param|handler": "code to run",
|
||||
"parseInt": "Convert a string to an integer.",
|
||||
"pauseUntil": "Busy wait for a condition to be true",
|
||||
"pauseUntil|param|condition": "condition to test for",
|
||||
"pauseUntil|param|timeOut": "if positive, maximum duration to wait for in milliseconds",
|
||||
"serial": "Reading and writing data over a serial connection.",
|
||||
"serial.writeBuffer": "Send a buffer across the serial connection.",
|
||||
"serial.writeLine": "Write a line of text to the serial port.",
|
||||
|
@ -31,7 +31,6 @@
|
||||
"control|block": "control",
|
||||
"loops.forever|block": "forever",
|
||||
"loops.pause|block": "pause %pause=timePicker|ms",
|
||||
"loops.timePicker|block": "%ms",
|
||||
"loops|block": "loops",
|
||||
"parseInt|block": "parse to integer %text",
|
||||
"serial.writeBuffer|block": "serial|write buffer %buffer",
|
||||
|
@ -17,8 +17,7 @@
|
||||
"control.cpp",
|
||||
"control.ts",
|
||||
"serial.cpp",
|
||||
"serial.ts",
|
||||
"loops.ts"
|
||||
"serial.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
|
@ -8,5 +8,8 @@
|
||||
"sensors.ColorSensor.onColorDetected|param|handler": "the code to run when detected",
|
||||
"sensors.ColorSensor.onLightChanged": "Registers code to run when the ambient light changes.",
|
||||
"sensors.ColorSensor.onLightChanged|param|condition": "the light condition",
|
||||
"sensors.ColorSensor.onLightChanged|param|handler": "the code to run when detected"
|
||||
"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"
|
||||
}
|
@ -13,14 +13,16 @@
|
||||
"LightCondition.Dark|block": "dark",
|
||||
"LightIntensityMode.Ambient|block": "ambient light",
|
||||
"LightIntensityMode.Reflected|block": "reflected light",
|
||||
"sensors.ColorSensor.color|block": "`icons.colorSensor` %sensor| color",
|
||||
"sensors.ColorSensor.light|block": "`icons.colorSensor` %sensor|%mode",
|
||||
"sensors.ColorSensor.onColorDetected|block": "on `icons.colorSensor` %sensor|detected color %color",
|
||||
"sensors.ColorSensor.onLightChanged|block": "on `icons.colorSensor` %sensor|%mode|%condition",
|
||||
"sensors.color1|block": "1",
|
||||
"sensors.color2|block": "2",
|
||||
"sensors.color3|block": "3",
|
||||
"sensors.color4|block": "4",
|
||||
"sensors.ColorSensor.color|block": "%sensor| color",
|
||||
"sensors.ColorSensor.light|block": "%sensor|%mode",
|
||||
"sensors.ColorSensor.onColorDetected|block": "on %sensor|detected color %color",
|
||||
"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|light %condition",
|
||||
"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"
|
||||
|
@ -74,12 +74,14 @@ namespace sensors {
|
||||
/**
|
||||
* Gets the current color mode
|
||||
*/
|
||||
colorMode() {
|
||||
colorMode() {
|
||||
return <ColorSensorMode>this.mode;
|
||||
}
|
||||
|
||||
_query() {
|
||||
if (this.mode == ColorSensorMode.Color)
|
||||
if (this.mode == ColorSensorMode.Color
|
||||
|| this.mode == ColorSensorMode.AmbientLightIntensity
|
||||
|| this.mode == ColorSensorMode.ReflectedLightIntensity)
|
||||
return this.getNumber(NumberFormat.UInt8LE, 0)
|
||||
return 0
|
||||
}
|
||||
@ -97,32 +99,47 @@ namespace sensors {
|
||||
* @param handler the code to run when detected
|
||||
*/
|
||||
//% help=sensors/color-sensor/on-color-detected
|
||||
//% block="on `icons.colorSensor` %sensor|detected color %color"
|
||||
//% block="on %sensor|detected color %color"
|
||||
//% blockId=colorOnColorDetected
|
||||
//% parts="colorsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=100 blockGap=8
|
||||
//% group="Color Sensor"
|
||||
onColorDetected(color: ColorSensorColor, handler: () => void) {
|
||||
this.setMode(ColorSensorMode.Color)
|
||||
const v = this._colorEventValue(<number>color);
|
||||
control.onEvent(this._id, v, handler);
|
||||
this.setMode(ColorSensorMode.Color)
|
||||
if (this.color() == color)
|
||||
control.raiseEvent(this._id, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the given color to be detected
|
||||
* @param color the color to detect
|
||||
*/
|
||||
//% help=sensors/color-sensor/pause-for-color
|
||||
//% block="pause %sensor|for color %color"
|
||||
//% blockId=colorPauseForColorDetected
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% weight=99 blockGap=8
|
||||
//% group="Color Sensor"
|
||||
pauseForColor(color: ColorSensorColor) {
|
||||
this.setMode(ColorSensorMode.Color);
|
||||
if (this.color() != color) {
|
||||
const v = this._colorEventValue(<number>color);
|
||||
control.waitForEvent(this._id, v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current color from the color sensor.
|
||||
* @param sensor the color sensor to query the request
|
||||
*/
|
||||
//% help=sensors/color-sensor/color
|
||||
//% block="`icons.colorSensor` %sensor| color"
|
||||
//% block="%sensor| color"
|
||||
//% blockId=colorGetColor
|
||||
//% parts="colorsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=99
|
||||
//% group="Color Sensor"
|
||||
@ -137,17 +154,32 @@ namespace sensors {
|
||||
* @param handler the code to run when detected
|
||||
*/
|
||||
//% help=sensors/color-sensor/on-light-changed
|
||||
//% block="on `icons.colorSensor` %sensor|%mode|%condition"
|
||||
//% block="on %sensor|%mode|%condition"
|
||||
//% blockId=colorOnLightChanged
|
||||
//% parts="colorsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=89 blockGap=8
|
||||
//% group="Color Sensor"
|
||||
onLightChanged(mode: LightIntensityMode, condition: LightCondition, handler: () => void) {
|
||||
control.onEvent(this._id, <number>condition, handler);
|
||||
this.setMode(<ColorSensorMode><number>mode)
|
||||
control.onEvent(this._id, <number>condition, handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the given color to be detected
|
||||
* @param color the color to detect
|
||||
*/
|
||||
//% help=sensors/color-sensor/pause-for-light
|
||||
//% block="pause %sensor|for %mode|light %condition"
|
||||
//% blockId=colorPauseForLight
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=sensors
|
||||
//% weight=88 blockGap=8
|
||||
//% group="Color Sensor"
|
||||
pauseForLight(mode: LightIntensityMode, condition: LightCondition) {
|
||||
this.setMode(<ColorSensorMode><number>mode)
|
||||
if (this.thresholdDetector.state != <number>condition)
|
||||
control.waitForEvent(this._id, <number>condition)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,13 +187,11 @@ namespace sensors {
|
||||
* @param sensor the color sensor port
|
||||
*/
|
||||
//% help=sensors/color-sensor/light
|
||||
//% block="`icons.colorSensor` %sensor|%mode"
|
||||
//% block="%sensor|%mode"
|
||||
//% blockId=colorLight
|
||||
//% parts="colorsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=88
|
||||
//% weight=87
|
||||
//% group="Color Sensor"
|
||||
light(mode: LightIntensityMode) {
|
||||
this.setMode(<ColorSensorMode><number>mode)
|
||||
@ -179,15 +209,15 @@ namespace sensors {
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed block="1" weight=95 fixedInstance jres=icons.port1
|
||||
//% whenUsed block="color 1" weight=95 fixedInstance jres=icons.port1
|
||||
export const color1: ColorSensor = new ColorSensor(1)
|
||||
|
||||
//% whenUsed block="3" weight=90 fixedInstance jres=icons.port3
|
||||
export const color3: ColorSensor = new ColorSensor(3)
|
||||
|
||||
//% whenUsed block="2" weight=90 fixedInstance jres=icons.port2
|
||||
|
||||
//% whenUsed block="color 2" weight=90 fixedInstance jres=icons.port2
|
||||
export const color2: ColorSensor = new ColorSensor(2)
|
||||
|
||||
//% whenUsed block="4" weight=90 fixedInstance jres=icons.port4
|
||||
//% whenUsed block="color 3" weight=90 fixedInstance jres=icons.port3
|
||||
export const color3: ColorSensor = new ColorSensor(3)
|
||||
|
||||
//% whenUsed block="color 4" weight=90 fixedInstance jres=icons.port4
|
||||
export const color4: ColorSensor = new ColorSensor(4)
|
||||
}
|
||||
|
@ -18,8 +18,8 @@
|
||||
"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.",
|
||||
"brick.Button.onEvent|param|body": "code to run when the event is raised",
|
||||
"brick.Button.waitUntil": "Waits until the event is raised",
|
||||
"brick.Button.waitUntil|param|ev": "the event to wait for",
|
||||
"brick.Button.pauseUntil": "Waits until the event is raised",
|
||||
"brick.Button.pauseUntil|param|ev": "the event to wait for",
|
||||
"brick.Button.wasPressed": "See if the button was pressed again since the last time you checked.",
|
||||
"brick._imagePicker": "An image",
|
||||
"brick._imagePicker|param|image": "the image",
|
||||
@ -28,6 +28,7 @@
|
||||
"brick.buttonLeft": "Left button on the EV3 Brick.",
|
||||
"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.print": "Show text on the screen.",
|
||||
@ -42,6 +43,13 @@
|
||||
"brick.setStatusLight|param|pattern": "the lights pattern to use.",
|
||||
"brick.showImage": "Shows an image on screen",
|
||||
"brick.showImage|param|image": "image to draw",
|
||||
"console": "Reading and writing data to the console output.\n\nReading and writing data to the console output.",
|
||||
"console.addListener": "Adds a listener for the log messages",
|
||||
"console.log": "Write a line of text to the console output.",
|
||||
"console.logValue": "Write a name:value pair as a line of text to the console output.",
|
||||
"console.logValue|param|name": "name of the value stream, eg: \"x\"",
|
||||
"console.logValue|param|value": "to write",
|
||||
"console.sendToScreen": "Sends the log messages to the brick screen and uses the brick up and down buttons to scroll.",
|
||||
"control": "Program controls and events.",
|
||||
"control.allocateNotifyEvent": "Allocates the next user notification event",
|
||||
"control.deviceFirmwareVersion": "Determine the version of system software currently running.",
|
||||
@ -50,21 +58,44 @@
|
||||
"control.raiseEvent": "Announce that an event happened to registered handlers.",
|
||||
"control.raiseEvent|param|src": "ID of the Component that generated the event",
|
||||
"control.raiseEvent|param|value": "Component specific code indicating the cause of the event.",
|
||||
"motors.Motor.angle": "Gets motor ration angle.",
|
||||
"motors.Motor.clearCount": "Clears the motor count",
|
||||
"motors.Motor.count": "Gets motor step count.",
|
||||
"motors.Motor.move": "Moves the motor by a number of degrees",
|
||||
"motors.Motor.move|param|angle": "the degrees to rotate, eg: 360",
|
||||
"motors.Motor.move|param|power": "the power from ``100`` full forward to ``-100`` full backward, eg: 50",
|
||||
"motors.Motor.power": "Sets the motor power level from ``-100`` to ``100``.",
|
||||
"motors.Motor.power|param|power": "the power from ``100`` full forward to ``-100`` full backward, eg: 50",
|
||||
"motors.Motor.reset": "Resets the motor.",
|
||||
"motors.Motor.setBrake": "Sets the automatic brake on or off when the motor is off",
|
||||
"motors.Motor.setBrake|param|brake": "a value indicating if the motor should break when off",
|
||||
"motors.Motor.setReversed": "Reverses the motor polarity",
|
||||
"motors.Motor.speed": "Gets motor actual speed.",
|
||||
"motors.Motor.stop": "Stops the motor",
|
||||
"motors.Motor.tachoCount": "Gets motor tacho count.",
|
||||
"motors.Motor.toString": "Returns the status of the motor",
|
||||
"motors.MotorBase.isReady": "Returns a value indicating if the motor is still running a previous command.",
|
||||
"motors.MotorBase.move": "Moves the motor by a number of rotations, degress or seconds",
|
||||
"motors.MotorBase.move|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50",
|
||||
"motors.MotorBase.move|param|unit": "the meaning of the value",
|
||||
"motors.MotorBase.move|param|value": "the move quantity, eg: 2",
|
||||
"motors.MotorBase.pauseUntilReady": "Pauses the execution until the previous command finished.",
|
||||
"motors.MotorBase.pauseUntilReady|param|timeOut": "optional maximum pausing time in milliseconds",
|
||||
"motors.MotorBase.reset": "Resets the motor(s).",
|
||||
"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 speed of the motor.",
|
||||
"motors.MotorBase.setSpeed|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50",
|
||||
"motors.MotorBase.stop": "Stops the motor(s).",
|
||||
"motors.SynchedMotorPair.steer": "Turns the motor and the follower motor by a number of rotations",
|
||||
"motors.SynchedMotorPair.steer|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50",
|
||||
"motors.SynchedMotorPair.steer|param|steering": "the ratio of power sent to the follower motor, from ``-100`` to ``100``",
|
||||
"motors.SynchedMotorPair.steer|param|unit": "the meaning of the value",
|
||||
"motors.SynchedMotorPair.steer|param|value": "the move quantity, eg: 2",
|
||||
"motors.SynchedMotorPair.tank": "The Move Tank block can make a robot drive forward, backward, turn, or stop. \nUse the Move Tank block for robot vehicles that have two Large Motors, \nwith one motor driving the left side of the vehicle and the other the right side. \nYou can make the two motors go at different speeds or in different directions \nto make your robot turn.",
|
||||
"motors.SynchedMotorPair.tank|param|speedRight": "the speed on the right motor, eg: 50",
|
||||
"motors.SynchedMotorPair.tank|param|unit": "@param speedLeft the speed on the left motor, eg: 50",
|
||||
"motors.SynchedMotorPair.tank|param|value": "the amount of movement, eg: 2",
|
||||
"motors.SynchedMotorPair.toString": "Returns the name(s) of the motor",
|
||||
"motors.mkCmd": "Allocates a message buffer",
|
||||
"motors.mkCmd|param|addSize": "required additional bytes",
|
||||
"motors.mkCmd|param|cmd": "command id",
|
||||
"motors.mkCmd|param|out": "ports",
|
||||
"motors.readPWM": "Sends and receives a message from the motors device",
|
||||
"motors.readPWM|param|buf": "message buffer",
|
||||
"motors.resetAllMotors": "Resets all motors",
|
||||
"motors.stopAllMotors": "Stops all motors",
|
||||
"motors.writePWM": "Sends a command to the motors device",
|
||||
"motors.writePWM|param|buf": "the command buffer",
|
||||
"output.createBuffer": "Create a new zero-initialized buffer.",
|
||||
"output.createBuffer|param|size": "number of bytes in the buffer",
|
||||
"screen.clear": "Clear screen and reset font to normal.",
|
||||
|
@ -12,14 +12,21 @@
|
||||
"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",
|
||||
"Output.AB|block": "A+B",
|
||||
"Output.AD|block": "A+D",
|
||||
"Output.ALL|block": "All",
|
||||
"Output.A|block": "A",
|
||||
"Output.BC|block": "B+C",
|
||||
"Output.B|block": "B",
|
||||
"Output.CD|block": "C+D",
|
||||
"Output.C|block": "C",
|
||||
"Output.D|block": "D",
|
||||
"brick.Button.isPressed|block": "`icons.brickButtons` %button|is pressed",
|
||||
"brick.Button.onEvent|block": "on `icons.brickButtons` %button|%event",
|
||||
"brick.Button.waitUntil|block": "wait until `icons.brickButtons` %button|%event",
|
||||
"brick.Button.pauseUntil|block": "pause until `icons.brickButtons` %button|%event",
|
||||
"brick.Button.wasPressed|block": "`icons.brickButtons` %button|was pressed",
|
||||
"brick._imagePicker|block": "%image",
|
||||
"brick.buttonDown|block": "down",
|
||||
@ -27,36 +34,48 @@
|
||||
"brick.buttonLeft|block": "left",
|
||||
"brick.buttonRight|block": "right",
|
||||
"brick.buttonUp|block": "up",
|
||||
"brick.clearScreen|block": "`icons.brickDisplay` clear screen",
|
||||
"brick.lightPattern|block": "%pattern",
|
||||
"brick.print|block": "`icons.brickDisplay` print %text| at x: %x| y: %y",
|
||||
"brick.setPixel|block": "`icons.brickDisplay` set pixel %on| at x: %x| y: %y",
|
||||
"brick.setStatusLight|block": "set `icons.brickButtons` to %pattern=led_pattern",
|
||||
"brick.showImage|block": "`icons.brickDisplay` show image %image=scren_image_picker",
|
||||
"brick.showImage|block": "`icons.brickDisplay` show image %image=screen_image_picker",
|
||||
"brick|block": "brick",
|
||||
"console.logValue|block": "console|log value %name|= %value",
|
||||
"console.log|block": "console|log %text",
|
||||
"console.sendToScreen|block": "send console to screen",
|
||||
"console|block": "console",
|
||||
"control.raiseEvent|block": "raise event|from %src|with value %value",
|
||||
"control|block": "control",
|
||||
"motors.Motor.count|block": "`icons.motorLarge` %motor|count",
|
||||
"motors.Motor.move|block": "move `icons.motorLarge` %motor|by %angle|degrees at %power|%",
|
||||
"motors.Motor.power|block": "power `icons.motorLarge` %motor|to %power|%",
|
||||
"motors.Motor.setBrake|block": "set `icons.motorLarge` %motor|brake %brake",
|
||||
"motors.Motor.setReversed|block": "set `icons.motorLarge` %motor|reversed %reversed",
|
||||
"motors.Motor.speed|block": "`icons.motorLarge` %motor|speed",
|
||||
"motors.Motor.stop|block": "stop `icons.motorLarge` %motor",
|
||||
"motors.Motor.tachoCount|block": "`icons.motorLarge` %motor|tacho count",
|
||||
"motors.largeMotorA|block": "large A",
|
||||
"motors.largeMotorB|block": "large B",
|
||||
"motors.largeMotorC|block": "large C",
|
||||
"motors.largeMotorD|block": "large D",
|
||||
"motors.mediumMotorA|block": "medium A",
|
||||
"motors.mediumMotorB|block": "medium B",
|
||||
"motors.mediumMotorC|block": "medium C",
|
||||
"motors.mediumMotorD|block": "medium D",
|
||||
"motors.stopAllMotors|block": "stop all `icons.motorLarge`",
|
||||
"motors.Motor.angle|block": "%motor|angle",
|
||||
"motors.Motor.speed|block": "%motor|speed",
|
||||
"motors.MotorBase.move|block": "move %motor|for %value|%unit|at %speed|%",
|
||||
"motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready",
|
||||
"motors.MotorBase.setBrake|block": "set %motor|brake %brake",
|
||||
"motors.MotorBase.setReversed|block": "set %motor|reversed %reversed",
|
||||
"motors.MotorBase.setSpeed|block": "set speed of %motor|to %speed|%",
|
||||
"motors.SynchedMotorPair.steer|block": "steer %chassis|%steering|%|at speed %speed|%|by %value|%unit",
|
||||
"motors.SynchedMotorPair.tank|block": "tank %chassis|left %speedLeft|%|right %speedRight|%|by %value|%unit",
|
||||
"motors.largeAB|block": "large A+B",
|
||||
"motors.largeAD|block": "large A+D",
|
||||
"motors.largeA|block": "large A",
|
||||
"motors.largeBC|block": "large B+C",
|
||||
"motors.largeB|block": "large B",
|
||||
"motors.largeCD|block": "large C+D",
|
||||
"motors.largeC|block": "large C",
|
||||
"motors.largeD|block": "large D",
|
||||
"motors.mediumA|block": "medium A",
|
||||
"motors.mediumB|block": "medium B",
|
||||
"motors.mediumC|block": "medium C",
|
||||
"motors.mediumD|block": "medium D",
|
||||
"motors.stopAllMotors|block": "stop all motors",
|
||||
"motors|block": "motors",
|
||||
"output|block": "output",
|
||||
"screen|block": "screen",
|
||||
"sensors|block": "sensors",
|
||||
"serial|block": "serial",
|
||||
"{id:category}Brick": "Brick",
|
||||
"{id:category}Console": "Console",
|
||||
"{id:category}Control": "Control",
|
||||
"{id:category}Image": "Image",
|
||||
"{id:category}Images": "Images",
|
||||
@ -66,7 +85,9 @@
|
||||
"{id:category}Screen": "Screen",
|
||||
"{id:category}Serial": "Serial",
|
||||
"{id:group}Buttons": "Buttons",
|
||||
"{id:group}Chassis": "Chassis",
|
||||
"{id:group}Light": "Light",
|
||||
"{id:group}Motors": "Motors",
|
||||
"{id:group}Screen": "Screen"
|
||||
"{id:group}Motion": "Motion",
|
||||
"{id:group}Screen": "Screen",
|
||||
"{id:group}Sensors": "Sensors"
|
||||
}
|
@ -132,13 +132,13 @@ namespace brick {
|
||||
* Waits until the event is raised
|
||||
* @param ev the event to wait for
|
||||
*/
|
||||
//% help=input/button/wait-until
|
||||
//% blockId=buttonWaitUntil block="wait until `icons.brickButtons` %button|%event"
|
||||
//% help=input/button/pause-until
|
||||
//% blockId=buttonWaitUntil block="pause until `icons.brickButtons` %button|%event"
|
||||
//% parts="brick"
|
||||
//% blockNamespace=brick
|
||||
//% weight=98 blockGap=8
|
||||
//% group="Buttons"
|
||||
waitUntil(ev: ButtonEvent) {
|
||||
pauseUntil(ev: ButtonEvent) {
|
||||
control.waitForEvent(this._id, ev);
|
||||
}
|
||||
}
|
||||
|
107
libs/core/console.ts
Normal file
@ -0,0 +1,107 @@
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/**
|
||||
* Reading and writing data to the console output.
|
||||
*/
|
||||
//% weight=12 color=#002050 icon="\uf120"
|
||||
//% advanced=true
|
||||
namespace console {
|
||||
type Listener = (text: string) => void;
|
||||
|
||||
const listeners: Listener[] = [
|
||||
(text: string) => serial.writeLine(text)
|
||||
];
|
||||
|
||||
/**
|
||||
* Write a line of text to the console output.
|
||||
* @param value to send
|
||||
*/
|
||||
//% weight=90
|
||||
//% help=console/log blockGap=8
|
||||
//% blockId=console_log block="console|log %text"
|
||||
export function log(text: string): void {
|
||||
for (let i = 0; i < listeners.length; ++i)
|
||||
listeners[i](text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a name:value pair as a line of text to the console output.
|
||||
* @param name name of the value stream, eg: "x"
|
||||
* @param value to write
|
||||
*/
|
||||
//% weight=88 blockGap=8
|
||||
//% help=console/log-value
|
||||
//% blockId=console_log_value block="console|log value %name|= %value"
|
||||
export function logValue(name: string, value: number): void {
|
||||
log(`${name}: ${value}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener for the log messages
|
||||
* @param listener
|
||||
*/
|
||||
//%
|
||||
export function addListener(listener: (text: string) => void) {
|
||||
if (!listener) return;
|
||||
listeners.push(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the log messages to the brick screen and uses the brick up and down buttons to scroll.
|
||||
*/
|
||||
//% blockId=logsendtostreen block="send console to screen"
|
||||
//% weight=1
|
||||
export function sendToScreen(): void {
|
||||
console.screen.attach();
|
||||
}
|
||||
}
|
||||
|
||||
namespace console.screen {
|
||||
const maxLines = 100;
|
||||
const screenLines = 8;
|
||||
const lineHeight = 12;
|
||||
let lines: string[];
|
||||
let scrollPosition = 0;
|
||||
|
||||
export function attach() {
|
||||
if (!lines) {
|
||||
lines = [];
|
||||
console.addListener(log);
|
||||
brick.buttonUp.onEvent(ButtonEvent.Click, () => scroll(1))
|
||||
brick.buttonDown.onEvent(ButtonEvent.Click, () => scroll(-1))
|
||||
}
|
||||
}
|
||||
|
||||
function printLog() {
|
||||
brick.clearScreen()
|
||||
if (!lines) return;
|
||||
for (let i = 0; i < screenLines; ++i) {
|
||||
const line = lines[i + scrollPosition];
|
||||
if (line)
|
||||
brick.print(line, 0, 4 + i * lineHeight)
|
||||
}
|
||||
}
|
||||
|
||||
function scroll(pos: number) {
|
||||
if (!pos) return;
|
||||
|
||||
scrollPosition += pos >> 0;
|
||||
if (scrollPosition >= lines.length) scrollPosition = lines.length - 1;
|
||||
if (scrollPosition < 0) scrollPosition = 0;
|
||||
printLog();
|
||||
}
|
||||
|
||||
function log(msg: string): void {
|
||||
lines.push(msg);
|
||||
if (lines.length + 5 > maxLines) {
|
||||
lines.splice(0, maxLines - lines.length);
|
||||
scrollPosition = Math.min(scrollPosition, lines.length - 1)
|
||||
}
|
||||
// move down scroll once it gets large than the screen
|
||||
if (lines.length > screenLines
|
||||
&& lines.length >= scrollPosition + screenLines) {
|
||||
scrollPosition++;
|
||||
}
|
||||
printLog();
|
||||
}
|
||||
}
|
@ -1,260 +1,260 @@
|
||||
namespace images {
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsBigSmile = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsHeartLarge = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsHeartSmall = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsMouth1open = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsMouth1shut = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsMouth2open = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsMouth2shut = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsSad = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsSick = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsSmile = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsSwearing = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsTalking = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsWink = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const expressionsZzz = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesAngry = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesAwake = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesBlackEye = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesBottomLeft = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesBottomRight = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesCrazy1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesCrazy2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesDisappointed = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesDizzy = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesDown = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesEvil = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesHurt = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesKnockedOut = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesLove = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesMiddleLeft = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesMiddleRight = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesNeutral = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesNuclear = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesPinchLeft = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesPinchMiddle = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesPinchRight = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesSleeping = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesTear = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesTiredLeft = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesTiredMiddle = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesTiredRight = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesToxic = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesUp = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const eyesWinking = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationAccept = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationBackward = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationDecline = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationForward = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationLeft = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationNoGo = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationQuestionMark = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationRight = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationStop1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationStop2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationThumbsDown = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationThumbsUp = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const informationWarning = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoColorSensor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoEv3icon = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoEv3 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoGyroSensor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoIrBeacon = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoIrSensor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoLego = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoLargeMotor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoMindstorms = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoMediumMotor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoSoundSensor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoTempSensor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoTouchSensor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const legoUsSensor = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsBomb = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsBoom = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsFire = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsFlowers = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsForest = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsLightOff = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsLightOn = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsLightning = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsNight = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsPirate = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsSnow = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const objectsTarget = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressBar0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressBar1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressBar2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressBar3 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressBar4 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDial0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDial1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDial2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDial3 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDial4 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDots0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDots1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDots2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressDots3 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressHourglass0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressHourglass1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressHourglass2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressTimer0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressTimer1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressTimer2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressTimer3 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressTimer4 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressWaterLevel0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressWaterLevel1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressWaterLevel2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const progressWaterLevel3 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemAccept1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemAccept2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemAlert = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemBox = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemBusy0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemBusy1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemDecline1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemDecline2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemDotEmpty = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemDotFull = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemEv3small = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemPlay = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider0 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider1 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider2 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider3 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider4 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider5 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider6 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider7 = screen.unpackPNG(hex``);
|
||||
//% fixedInstance jres
|
||||
//% fixedInstance jres blockIdentity=brick._imagePicker
|
||||
export const systemSlider8 = screen.unpackPNG(hex``);
|
||||
}
|
||||
|
11
libs/core/input.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "pxt.h"
|
||||
|
||||
namespace sensors {
|
||||
|
||||
/**
|
||||
* Mark a sensor as used
|
||||
*/
|
||||
//%
|
||||
void __sensorUsed(int port, int type) {
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ namespace sensors.internal {
|
||||
|
||||
control.runInBackground(() => {
|
||||
let prev = query()
|
||||
changeHandler(prev, prev)
|
||||
while (true) {
|
||||
loops.pause(periodMs)
|
||||
let curr = query()
|
||||
@ -141,6 +142,11 @@ namespace sensors.internal {
|
||||
this._port = port_ - 1
|
||||
init()
|
||||
sensorInfos[this._port].sensors.push(this)
|
||||
this.markUsed();
|
||||
}
|
||||
|
||||
markUsed() {
|
||||
sensors.__sensorUsed(this._port, this._deviceType());
|
||||
}
|
||||
|
||||
_activated() { }
|
||||
@ -183,14 +189,14 @@ namespace sensors.internal {
|
||||
Low = 3,
|
||||
}
|
||||
|
||||
export class ThresholdDetector {
|
||||
export class ThresholdDetector {
|
||||
public id: number;
|
||||
private min: number;
|
||||
private max: number;
|
||||
private lowThreshold: number;
|
||||
private highThreshold: number;
|
||||
private level: number;
|
||||
private state: ThresholdState;
|
||||
public state: ThresholdState;
|
||||
|
||||
constructor(id: number, min = 0, max = 100, lowThreshold = 20, highThreshold = 80) {
|
||||
this.id = id;
|
||||
|
@ -13,14 +13,35 @@
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#define THREAD_DBG(...)
|
||||
|
||||
#define MALLOC_LIMIT (8 * 1024 * 1024)
|
||||
#define MALLOC_CHECK_PERIOD (1024 * 1024)
|
||||
|
||||
void *xmalloc(size_t sz) {
|
||||
static size_t allocBytes = 0;
|
||||
allocBytes += sz;
|
||||
if (allocBytes >= MALLOC_CHECK_PERIOD) {
|
||||
allocBytes = 0;
|
||||
auto info = mallinfo();
|
||||
DMESG("malloc used: %d kb", info.uordblks / 1024);
|
||||
if (info.uordblks > MALLOC_LIMIT) {
|
||||
target_panic(904);
|
||||
}
|
||||
}
|
||||
auto r = malloc(sz);
|
||||
if (r == NULL)
|
||||
target_panic(905); // shouldn't happen
|
||||
return r;
|
||||
}
|
||||
|
||||
void *operator new(size_t size) {
|
||||
return malloc(size);
|
||||
return xmalloc(size);
|
||||
}
|
||||
void *operator new[](size_t size) {
|
||||
return malloc(size);
|
||||
return xmalloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void *p) {
|
||||
@ -200,10 +221,6 @@ int current_time_ms() {
|
||||
return currTime() - startTime;
|
||||
}
|
||||
|
||||
int getSerialNumber() {
|
||||
return 42; // TODO
|
||||
}
|
||||
|
||||
void disposeThread(Thread *t) {
|
||||
if (allThreads == t) {
|
||||
allThreads = t->next;
|
||||
@ -376,6 +393,10 @@ static void runPoller(Thread *thr) {
|
||||
// note that this is run without the user mutex held - it should not modify any state!
|
||||
TValue prev = pxt::runAction0(query);
|
||||
|
||||
startUser();
|
||||
pxt::runAction2(thr->act, prev, prev);
|
||||
stopUser();
|
||||
|
||||
while (true) {
|
||||
sleep_core_us(us);
|
||||
if (paniced)
|
||||
|
@ -1,9 +1 @@
|
||||
//% weight=100
|
||||
namespace brick {
|
||||
|
||||
}
|
||||
|
||||
//% color="#B4009E" weight=98 icon="\uf192"
|
||||
//% groups='["Ultrasonic Sensor", "Touch Sensor", "Color Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Gyro Sensor"]'
|
||||
namespace sensors {
|
||||
}
|
||||
|
@ -20,3 +20,13 @@ void target_init() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace motors {
|
||||
|
||||
/**
|
||||
* Mark a motor as used
|
||||
*/
|
||||
//%
|
||||
void __motorUsed(int port, bool large) {
|
||||
}
|
||||
}
|
@ -7,6 +7,14 @@ enum Output {
|
||||
C = 0x04,
|
||||
//% block="D"
|
||||
D = 0x08,
|
||||
//% block="B+C"
|
||||
BC = Output.B | Output.C,
|
||||
//% block="A+B"
|
||||
AB = Output.A | Output.B,
|
||||
//% block="C+D"
|
||||
CD = Output.C | Output.D,
|
||||
//% block="A+D"
|
||||
AD = Output.B | Output.C,
|
||||
//% block="All"
|
||||
ALL = 0x0f
|
||||
}
|
||||
@ -17,6 +25,15 @@ enum OutputType {
|
||||
MiniTacho = 8,
|
||||
}
|
||||
|
||||
enum MoveUnit {
|
||||
//% block="rotations"
|
||||
Rotations,
|
||||
//% block="degrees"
|
||||
Degrees,
|
||||
//% block="milliseconds"
|
||||
MilliSeconds
|
||||
}
|
||||
|
||||
namespace motors {
|
||||
let pwmMM: MMap
|
||||
let motorMM: MMap
|
||||
@ -34,212 +51,482 @@ namespace motors {
|
||||
pwmMM = control.mmap("/dev/lms_pwm", 0, 0)
|
||||
if (!pwmMM) control.fail("no PWM file")
|
||||
motorMM = control.mmap("/dev/lms_motor", MotorDataOff.Size * DAL.NUM_OUTPUTS, 0)
|
||||
if (!motorMM) control.fail("no motor file")
|
||||
|
||||
resetMotors()
|
||||
resetAllMotors()
|
||||
|
||||
let buf = output.createBuffer(1)
|
||||
const buf = output.createBuffer(1)
|
||||
buf[0] = DAL.opProgramStart
|
||||
writePWM(buf)
|
||||
}
|
||||
|
||||
function writePWM(buf: Buffer): void {
|
||||
/**
|
||||
* Sends a command to the motors device
|
||||
* @param buf the command buffer
|
||||
*/
|
||||
//%
|
||||
export function writePWM(buf: Buffer): void {
|
||||
init()
|
||||
pwmMM.write(buf)
|
||||
}
|
||||
|
||||
function readPWM(buf: Buffer): void {
|
||||
/**
|
||||
* Sends and receives a message from the motors device
|
||||
* @param buf message buffer
|
||||
*/
|
||||
//%
|
||||
export function readPWM(buf: Buffer): number {
|
||||
init()
|
||||
pwmMM.read(buf);
|
||||
return pwmMM.read(buf);
|
||||
}
|
||||
|
||||
function mkCmd(out: Output, cmd: number, addSize: number) {
|
||||
/**
|
||||
* Allocates a message buffer
|
||||
* @param out ports
|
||||
* @param cmd command id
|
||||
* @param addSize required additional bytes
|
||||
*/
|
||||
//%
|
||||
export function mkCmd(out: Output, cmd: number, addSize: number) {
|
||||
const b = output.createBuffer(2 + addSize)
|
||||
b.setNumber(NumberFormat.UInt8LE, 0, cmd)
|
||||
b.setNumber(NumberFormat.UInt8LE, 1, out)
|
||||
return b
|
||||
}
|
||||
|
||||
function resetMotors() {
|
||||
reset(Output.ALL)
|
||||
function outputToName(out: Output): string {
|
||||
let r = "";
|
||||
for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
|
||||
if (out & (1 << i)) {
|
||||
if (r.length > 0) r += "+";
|
||||
r += "ABCD"[i];
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops all motors
|
||||
*/
|
||||
//% blockId=motorStopAll block="stop all `icons.motorLarge`"
|
||||
//% weight=10 group="Motors" blockGap=8
|
||||
//% blockId=motorStopAll block="stop all motors"
|
||||
//% weight=97
|
||||
//% group="Motion"
|
||||
export function stopAllMotors() {
|
||||
const b = mkCmd(Output.ALL, DAL.opOutputStop, 0)
|
||||
writePWM(b)
|
||||
}
|
||||
|
||||
//% fixedInstances
|
||||
export class Motor extends control.Component {
|
||||
private port: Output;
|
||||
private large: boolean;
|
||||
private brake: boolean;
|
||||
/**
|
||||
* Resets all motors
|
||||
*/
|
||||
//% group="Motion"
|
||||
export function resetAllMotors() {
|
||||
reset(Output.ALL)
|
||||
}
|
||||
|
||||
constructor(port: Output, large: boolean) {
|
||||
//% fixedInstances
|
||||
export class MotorBase extends control.Component {
|
||||
protected _port: Output;
|
||||
protected _portName: string;
|
||||
protected _brake: boolean;
|
||||
private _initialized: boolean;
|
||||
private _init: () => void;
|
||||
private _setSpeed: (speed: number) => void;
|
||||
private _move: (steps: boolean, stepsOrTime: number, speed: number) => void;
|
||||
|
||||
constructor(port: Output, init: () => void, setSpeed: (speed: number) => void, move: (steps: boolean, stepsOrTime: number, speed: number) => void) {
|
||||
super();
|
||||
this.port = port;
|
||||
this.large = large;
|
||||
this.brake = false;
|
||||
this._port = port;
|
||||
this._portName = outputToName(this._port);
|
||||
this._brake = false;
|
||||
this._initialized = false;
|
||||
this._init = init;
|
||||
this._setSpeed = setSpeed;
|
||||
this._move = move;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the motor power level from ``-100`` to ``100``.
|
||||
* @param motor the output connection that the motor is connected to
|
||||
* @param power the power from ``100`` full forward to ``-100`` full backward, eg: 50
|
||||
* Lazy initialization code
|
||||
*/
|
||||
//% blockId=motorSetPower block="power `icons.motorLarge` %motor|to %power|%"
|
||||
//% weight=99 group="Motors" blockGap=8
|
||||
//% power.min=-100 power.max=100
|
||||
power(power: number) {
|
||||
power = Math.clamp(-100, 100, power >> 0);
|
||||
|
||||
// per LEGO: call it power, use speed
|
||||
const b = mkCmd(this.port, DAL.opOutputSpeed, 1)
|
||||
b.setNumber(NumberFormat.Int8LE, 2, power)
|
||||
writePWM(b)
|
||||
if (power) {
|
||||
const b = mkCmd(this.port, DAL.opOutputStart, 0)
|
||||
writePWM(b);
|
||||
} else {
|
||||
this.stop();
|
||||
protected init() {
|
||||
if (!this._initialized) {
|
||||
this._initialized = true;
|
||||
this._init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the motor by a number of degrees
|
||||
* @param degrees the angle to turn the motor
|
||||
* @param angle the degrees to rotate, eg: 360
|
||||
* @param power the power from ``100`` full forward to ``-100`` full backward, eg: 50
|
||||
*/
|
||||
//% blockId=motorMove block="move `icons.motorLarge` %motor|by %angle|degrees at %power|%"
|
||||
//% weight=98 group="Motors" blockGap=8
|
||||
//% power.min=-100 power.max=100
|
||||
move(angle: number, power: number) {
|
||||
angle = angle >> 0;
|
||||
power = Math.clamp(-100, 100, power >> 0);
|
||||
|
||||
step(this.port, {
|
||||
speed: power,
|
||||
step1: 0,
|
||||
step2: angle,
|
||||
step3: 0,
|
||||
useSteps: true,
|
||||
useBrake: this.brake
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the motor
|
||||
*/
|
||||
//% blockId=motorStop block="stop `icons.motorLarge` %motor"
|
||||
//% weight=97 group="Motors"
|
||||
stop() {
|
||||
const b = mkCmd(this.port, DAL.opOutputStop, 1)
|
||||
b.setNumber(NumberFormat.UInt8LE, 2, this.brake ? 1 : 0)
|
||||
writePWM(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the automatic brake on or off when the motor is off
|
||||
* @param brake a value indicating if the motor should break when off
|
||||
*/
|
||||
//% blockId=outputMotorSetBrakeMode block="set `icons.motorLarge` %motor|brake %brake"
|
||||
//% blockId=outputMotorSetBrakeMode block="set %motor|brake %brake"
|
||||
//% brake.fieldEditor=toggleonoff
|
||||
//% weight=60 group="Motors" blockGap=8
|
||||
//% weight=60 blockGap=8
|
||||
//% group="Motion"
|
||||
setBrake(brake: boolean) {
|
||||
this.brake = brake;
|
||||
this.init();
|
||||
this._brake = brake;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses the motor polarity
|
||||
*/
|
||||
//% blockId=motorSetReversed block="set `icons.motorLarge` %motor|reversed %reversed"
|
||||
//% blockId=motorSetReversed block="set %motor|reversed %reversed"
|
||||
//% reversed.fieldEditor=toggleonoff
|
||||
//% weight=59 group="Motors"
|
||||
//% weight=59
|
||||
//% group="Motion"
|
||||
setReversed(reversed: boolean) {
|
||||
const b = mkCmd(this.port, DAL.opOutputPolarity, 1)
|
||||
b.setNumber(NumberFormat.Int8LE, 2, reversed ? -1 : 1);
|
||||
this.init();
|
||||
const b = mkCmd(this._port, DAL.opOutputPolarity, 1)
|
||||
b.setNumber(NumberFormat.Int8LE, 2, reversed ? 0 : 1);
|
||||
writePWM(b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the motor(s).
|
||||
*/
|
||||
//%
|
||||
stop() {
|
||||
this.init();
|
||||
stop(this._port, this._brake);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the motor(s).
|
||||
*/
|
||||
//%
|
||||
reset() {
|
||||
this.init();
|
||||
reset(this._port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the speed of the motor.
|
||||
* @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50
|
||||
*/
|
||||
//% blockId=motorSetSpeed block="set speed of %motor|to %speed|%"
|
||||
//% on.fieldEditor=toggleonoff
|
||||
//% weight=99 blockGap=8
|
||||
//% speed.min=-100 speed.max=100
|
||||
//% group="Motion"
|
||||
setSpeed(speed: number) {
|
||||
this.init();
|
||||
speed = Math.clamp(-100, 100, speed >> 0);
|
||||
if (!speed) // always stop
|
||||
this.stop();
|
||||
else
|
||||
this._setSpeed(speed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the motor by a number of rotations, degress or seconds
|
||||
* @param value the move quantity, eg: 2
|
||||
* @param unit the meaning of the value
|
||||
* @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50
|
||||
*/
|
||||
//% blockId=motorMove block="move %motor|for %value|%unit|at %speed|%"
|
||||
//% weight=98 blockGap=8
|
||||
//% speed.min=-100 speed.max=100
|
||||
//% group="Motion"
|
||||
move(value: number, unit: MoveUnit, speed: number) {
|
||||
this.init();
|
||||
speed = Math.clamp(-100, 100, speed >> 0);
|
||||
if (!speed) {
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
let useSteps: boolean;
|
||||
let stepsOrTime: number;
|
||||
switch (unit) {
|
||||
case MoveUnit.Rotations:
|
||||
stepsOrTime = (value * 360) >> 0;
|
||||
useSteps = true;
|
||||
break;
|
||||
case MoveUnit.Degrees:
|
||||
stepsOrTime = value >> 0;
|
||||
useSteps = true;
|
||||
break;
|
||||
default:
|
||||
stepsOrTime = value;
|
||||
useSteps = false;
|
||||
break;
|
||||
}
|
||||
|
||||
this._move(useSteps, stepsOrTime, speed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value indicating if the motor is still running a previous command.
|
||||
*/
|
||||
//%
|
||||
isReady(): boolean {
|
||||
this.init();
|
||||
const r = readPWM(mkCmd(this._port, DAL.opOutputTest, 0))
|
||||
// 0 = ready, 1 = busy
|
||||
return r == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pauses the execution until the previous command finished.
|
||||
* @param timeOut optional maximum pausing time in milliseconds
|
||||
*/
|
||||
//% blockId=motorPauseUntilRead block="%motor|pause until ready"
|
||||
//% group="Motion"
|
||||
pauseUntilReady(timeOut?: number) {
|
||||
pauseUntil(() => this.isReady(), timeOut);
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstances
|
||||
export class Motor extends MotorBase {
|
||||
private _large: 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.markUsed();
|
||||
}
|
||||
|
||||
markUsed() {
|
||||
motors.__motorUsed(this._port, this._large);
|
||||
}
|
||||
|
||||
private __init() {
|
||||
// specify motor size on this port
|
||||
const b = mkCmd(outOffset(this._port), DAL.opOutputSetType, 1)
|
||||
b.setNumber(NumberFormat.Int8LE, 2, this._large ? 0x07 : 0x08)
|
||||
writePWM(b)
|
||||
}
|
||||
|
||||
private __setSpeed(speed: number) {
|
||||
const b = mkCmd(this._port, DAL.opOutputSpeed, 1)
|
||||
b.setNumber(NumberFormat.Int8LE, 2, speed)
|
||||
writePWM(b)
|
||||
if (speed) {
|
||||
writePWM(mkCmd(this._port, DAL.opOutputStart, 0))
|
||||
}
|
||||
}
|
||||
|
||||
private __move(steps: boolean, stepsOrTime: number, speed: number) {
|
||||
step(this._port, {
|
||||
useSteps: steps,
|
||||
step1: 0,
|
||||
step2: stepsOrTime,
|
||||
step3: 0,
|
||||
speed: speed,
|
||||
useBrake: this._brake
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets motor actual speed.
|
||||
* @param motor the port which connects to the motor
|
||||
*/
|
||||
//% blockId=motorSpeed block="`icons.motorLarge` %motor|speed"
|
||||
//% weight=72 group="Motors" blockGap=8
|
||||
//% blockId=motorSpeed block="%motor|speed"
|
||||
//% weight=72 blockGap=8
|
||||
//% group="Sensors"
|
||||
speed(): number {
|
||||
return getMotorData(this.port).actualSpeed;
|
||||
this.init();
|
||||
return getMotorData(this._port).actualSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets motor step count.
|
||||
* Gets motor ration angle.
|
||||
* @param motor the port which connects to the motor
|
||||
*/
|
||||
//% blockId=motorCount block="`icons.motorLarge` %motor|count"
|
||||
//% weight=71 group="Motors" blockGap=8
|
||||
count(): number {
|
||||
return getMotorData(this.port).count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets motor tacho count.
|
||||
* @param motor the port which connects to the motor
|
||||
*/
|
||||
//% blockId=motorTachoCount block="`icons.motorLarge` %motor|tacho count"
|
||||
//% weight=70 group="Motors"
|
||||
tachoCount(): number {
|
||||
return getMotorData(this.port).tachoCount;
|
||||
//% blockId=motorTachoCount block="%motor|angle"
|
||||
//% weight=70
|
||||
//% group="Sensors"
|
||||
angle(): number {
|
||||
this.init();
|
||||
return getMotorData(this._port).count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the motor count
|
||||
*/
|
||||
//% group="Motion"
|
||||
clearCount() {
|
||||
const b = mkCmd(this.port, DAL.opOutputClearCount, 0)
|
||||
this.init();
|
||||
const b = mkCmd(this._port, DAL.opOutputClearCount, 0)
|
||||
writePWM(b)
|
||||
for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
|
||||
if (this.port & (1 << i)) {
|
||||
if (this._port & (1 << i)) {
|
||||
motorMM.setNumber(NumberFormat.Int32LE, i * MotorDataOff.Size + MotorDataOff.TachoSensor, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the motor.
|
||||
* Returns the status of the motor
|
||||
*/
|
||||
reset() {
|
||||
reset(this.port);
|
||||
//%
|
||||
toString(): string {
|
||||
return `${this._large ? "" : "M"}${this._portName} ${this.speed()}% ${this.angle()}>`;
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed fixedInstance block="large A"
|
||||
export const largeMotorA = new Motor(Output.A, true);
|
||||
export const largeA = new Motor(Output.A, true);
|
||||
|
||||
//% whenUsed fixedInstance block="large B"
|
||||
export const largeMotorB = new Motor(Output.B, true);
|
||||
export const largeB = new Motor(Output.B, true);
|
||||
|
||||
//% whenUsed fixedInstance block="large C"
|
||||
export const largeMotorC = new Motor(Output.C, true);
|
||||
export const largeC = new Motor(Output.C, true);
|
||||
|
||||
//% whenUsed fixedInstance block="large D"
|
||||
export const largeMotorD = new Motor(Output.D, true);
|
||||
export const largeD = new Motor(Output.D, true);
|
||||
|
||||
//% whenUsed fixedInstance block="medium A"
|
||||
export const mediumMotorA = new Motor(Output.A, false);
|
||||
export const mediumA = new Motor(Output.A, false);
|
||||
|
||||
//% whenUsed fixedInstance block="medium B"
|
||||
export const mediumMotorB = new Motor(Output.B, false);
|
||||
export const mediumB = new Motor(Output.B, false);
|
||||
|
||||
//% whenUsed fixedInstance block="medium C"
|
||||
export const mediumMotorC = new Motor(Output.C, false);
|
||||
export const mediumC = new Motor(Output.C, false);
|
||||
|
||||
//% whenUsed fixedInstance block="medium D"
|
||||
export const mediumMotorD = new Motor(Output.D, false);
|
||||
export const mediumD = new Motor(Output.D, false);
|
||||
|
||||
//% fixedInstances
|
||||
export class SynchedMotorPair extends MotorBase {
|
||||
|
||||
constructor(ports: Output) {
|
||||
super(ports, () => this.__init(), (speed) => this.__setSpeed(speed), (steps, stepsOrTime, speed) => this.__move(steps, stepsOrTime, speed));
|
||||
this.markUsed();
|
||||
}
|
||||
|
||||
markUsed() {
|
||||
motors.__motorUsed(this._port, true);
|
||||
}
|
||||
|
||||
private __init() {
|
||||
for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
|
||||
if (this._port & (1 << i)) {
|
||||
const b = mkCmd(outOffset(1 << i), DAL.opOutputSetType, 1)
|
||||
b.setNumber(NumberFormat.Int8LE, 2, 0x07) // large motor
|
||||
writePWM(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private __setSpeed(speed: number) {
|
||||
syncMotors(this._port, {
|
||||
speed: speed,
|
||||
turnRatio: 0,
|
||||
useBrake: !!this._brake
|
||||
})
|
||||
}
|
||||
|
||||
private __move(steps: boolean, stepsOrTime: number, speed: number) {
|
||||
syncMotors(this._port, {
|
||||
useSteps: steps,
|
||||
speed: speed,
|
||||
turnRatio: 100, // same speed
|
||||
stepsOrTime: stepsOrTime,
|
||||
useBrake: this._brake
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns the motor and the follower motor by a number of rotations
|
||||
* @param value the move quantity, eg: 2
|
||||
* @param unit the meaning of the value
|
||||
* @param steering the ratio of power sent to the follower motor, from ``-100`` to ``100``
|
||||
* @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50
|
||||
*/
|
||||
//% blockId=motorPairTurn block="steer %chassis|%steering|%|at speed %speed|%|by %value|%unit"
|
||||
//% weight=9 blockGap=8
|
||||
//% steering.min=-100 steering=100
|
||||
//% inlineInputMode=inline
|
||||
//% group="Chassis"
|
||||
steer(steering: number, speed: number, value: number, unit: MoveUnit) {
|
||||
this.init();
|
||||
speed = Math.clamp(-100, 100, speed >> 0);
|
||||
if (!speed) {
|
||||
stop(this._port, this._brake);
|
||||
return;
|
||||
}
|
||||
|
||||
const turnRatio = Math.clamp(-200, 200, steering + 100 >> 0);
|
||||
let useSteps: boolean;
|
||||
let stepsOrTime: number;
|
||||
switch (unit) {
|
||||
case MoveUnit.Rotations:
|
||||
stepsOrTime = (value * 360) >> 0;
|
||||
useSteps = true;
|
||||
break;
|
||||
case MoveUnit.Degrees:
|
||||
stepsOrTime = value >> 0;
|
||||
useSteps = true;
|
||||
break;
|
||||
default:
|
||||
stepsOrTime = value;
|
||||
useSteps = false;
|
||||
break;
|
||||
}
|
||||
|
||||
syncMotors(this._port, {
|
||||
useSteps: useSteps,
|
||||
speed: speed,
|
||||
turnRatio: turnRatio,
|
||||
stepsOrTime: stepsOrTime,
|
||||
useBrake: this._brake
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The Move Tank block can make a robot drive forward, backward, turn, or stop.
|
||||
* Use the Move Tank block for robot vehicles that have two Large Motors,
|
||||
* with one motor driving the left side of the vehicle and the other the right side.
|
||||
* You can make the two motors go at different speeds or in different directions
|
||||
* to make your robot turn.
|
||||
* @param value the amount of movement, eg: 2
|
||||
* @param unit
|
||||
* @param speedLeft the speed on the left motor, eg: 50
|
||||
* @param speedRight the speed on the right motor, eg: 50
|
||||
*/
|
||||
//% blockId=motorPairTank block="tank %chassis|left %speedLeft|%|right %speedRight|%|by %value|%unit"
|
||||
//% weight=9 blockGap=8
|
||||
//% speedLeft.min=-100 speedLeft=100
|
||||
//% speedRight.min=-100 speedRight=100
|
||||
//% inlineInputMode=inline
|
||||
//% group="Chassis"
|
||||
tank(speedLeft: number, speedRight: number, value: number, unit: MoveUnit) {
|
||||
speedLeft = Math.clamp(speedLeft >> 0, -100, 100);
|
||||
speedRight = Math.clamp(speedRight >> 0, -100, 100);
|
||||
const steering = (speedRight * 100 / speedLeft) >> 0;
|
||||
this.steer(speedLeft, steering, value, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name(s) of the motor
|
||||
*/
|
||||
//%
|
||||
toString(): string {
|
||||
let r = outputToName(this._port);
|
||||
for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
|
||||
if (this._port & (1 << i)) {
|
||||
r += ` ${getMotorData(1 << i).actualSpeed}%`
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed fixedInstance block="large B+C"
|
||||
export const largeBC = new SynchedMotorPair(Output.BC);
|
||||
|
||||
//% whenUsed fixedInstance block="large A+D"
|
||||
export const largeAD = new SynchedMotorPair(Output.AD);
|
||||
|
||||
//% whenUsed fixedInstance block="large A+B"
|
||||
export const largeAB = new SynchedMotorPair(Output.AB);
|
||||
|
||||
//% whenUsed fixedInstance block="large C+D"
|
||||
export const largeCD = new SynchedMotorPair(Output.CD);
|
||||
|
||||
function reset(out: Output) {
|
||||
let b = mkCmd(out, DAL.opOutputReset, 0)
|
||||
@ -262,6 +549,7 @@ namespace motors {
|
||||
|
||||
// only a single output at a time
|
||||
function getMotorData(out: Output): MotorData {
|
||||
init()
|
||||
let buf = motorMM.slice(outOffset(out), MotorDataOff.Size)
|
||||
return {
|
||||
actualSpeed: buf.getNumber(NumberFormat.Int8LE, MotorDataOff.Speed),
|
||||
@ -270,6 +558,29 @@ namespace motors {
|
||||
}
|
||||
}
|
||||
|
||||
interface SyncOptions {
|
||||
useSteps?: boolean;
|
||||
speed: number;
|
||||
turnRatio: number;
|
||||
stepsOrTime?: number;
|
||||
useBrake?: boolean;
|
||||
}
|
||||
|
||||
function syncMotors(out: Output, opts: SyncOptions) {
|
||||
const cmd = opts.useSteps ? DAL.opOutputStepSync : DAL.opOutputTimeSync;
|
||||
const b = mkCmd(out, cmd, 11);
|
||||
const speed = Math.clamp(-100, 100, opts.speed);
|
||||
const turnRatio = Math.clamp(-200, 200, opts.turnRatio);
|
||||
|
||||
b.setNumber(NumberFormat.Int8LE, 2, speed)
|
||||
// note that b[3] is padding
|
||||
b.setNumber(NumberFormat.Int16LE, 4 + 4 * 0, turnRatio)
|
||||
// b[6], b[7] is padding
|
||||
b.setNumber(NumberFormat.Int32LE, 4 + 4 * 1, opts.stepsOrTime || 0)
|
||||
b.setNumber(NumberFormat.Int8LE, 4 + 4 * 2, opts.useBrake ? 1 : 0)
|
||||
writePWM(b)
|
||||
}
|
||||
|
||||
interface StepOptions {
|
||||
power?: number;
|
||||
speed?: number; // either speed or power has to be present
|
||||
@ -280,6 +591,17 @@ namespace motors {
|
||||
useBrake?: boolean;
|
||||
}
|
||||
|
||||
function start(out: Output) {
|
||||
const b = mkCmd(out, DAL.opOutputStart, 0)
|
||||
writePWM(b);
|
||||
}
|
||||
|
||||
function stop(out: Output, brake: boolean) {
|
||||
const b = mkCmd(out, DAL.opOutputStop, 1)
|
||||
b.setNumber(NumberFormat.UInt8LE, 2, brake ? 1 : 0)
|
||||
writePWM(b);
|
||||
}
|
||||
|
||||
function step(out: Output, opts: StepOptions) {
|
||||
let op = opts.useSteps ? DAL.opOutputStepSpeed : DAL.opOutputTimeSpeed
|
||||
let speed = opts.speed
|
||||
|
@ -88,7 +88,7 @@ Image unpackPNG(Buffer png) {
|
||||
uint32_t byteW = (hd.width + 7) >> 3;
|
||||
uint32_t expSize = (byteW + 1) * hd.height;
|
||||
unsigned long sz = expSize;
|
||||
uint8_t *tmp = (uint8_t *)malloc(sz);
|
||||
uint8_t *tmp = (uint8_t *)xmalloc(sz);
|
||||
int code = uncompress(tmp, &sz, png->data + sizeof(hd), hd.lenIDAT);
|
||||
if (code != 0) {
|
||||
DMESG("PNG: zlib failed: %d", code);
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "pxtbase.h"
|
||||
|
||||
void *xmalloc(size_t sz);
|
||||
|
||||
namespace pxt {
|
||||
void raiseEvent(int id, int event);
|
||||
int allocateNotifyEvent();
|
||||
|
@ -10,6 +10,8 @@
|
||||
"linux.cpp",
|
||||
"mmap.cpp",
|
||||
"control.cpp",
|
||||
"console.ts",
|
||||
"serialnumber.cpp",
|
||||
"buttons.ts",
|
||||
"png.cpp",
|
||||
"screen.cpp",
|
||||
@ -17,6 +19,7 @@
|
||||
"output.cpp",
|
||||
"output.ts",
|
||||
"core.ts",
|
||||
"input.cpp",
|
||||
"input.ts",
|
||||
"shims.d.ts",
|
||||
"enums.d.ts",
|
||||
|
@ -63,16 +63,16 @@ namespace brick {
|
||||
firstChar: 32,
|
||||
// source https://github.com/lancaster-university/microbit-dal/blob/master/source/core/MicroBitFont.cpp
|
||||
data: hex`
|
||||
0000000000 0202020002 0a0a000000 0a1f0a1f0a 0e130e190e 1309041219 0609060916 0202000000 0402020204
|
||||
0204040402 000a040a00 00040e0400 0000000402 00000e0000 0000000200 1008040201 0609090906 040604040e
|
||||
070806010f 0f08040906 0c0a091f08 1f010f100f 08040e110e 1f08040201 0e110e110e 0e110e0402 0002000200
|
||||
0004000402 0804020408 000e000e00 0204080402 0e110c0004 0e11151906 06090f0909 0709070907 0e0101010e
|
||||
0709090907 0f0107010f 0f01070101 0e0119110e 09090f0909 0702020207 1f08080906 0905030509 010101010f
|
||||
111b151111 1113151911 0609090906 0709070101 060909060c 0709070911 0e01060807 1f04040404 0909090906
|
||||
1111110a04 1111151b11 0909060909 110a040404 0f0402010f 0e0202020e 0102040810 0e0808080e 040a000000
|
||||
000000001f 0204000000 000e09091e 0101070907 000e01010e 08080e090e 060907010e 0c02070202 0e090e0806
|
||||
0101070909 0200020202 0800080806 0105030509 020202020c 001b151111 0007090909 0006090906 0007090701
|
||||
000e090e08 000e010101 000c020403 02020e021c 000909091e 0011110a04 001111151b 0009060609 00110a0403
|
||||
0000000000 0202020002 0a0a000000 0a1f0a1f0a 0e130e190e 1309041219 0609060916 0202000000 0402020204
|
||||
0204040402 000a040a00 00040e0400 0000000402 00000e0000 0000000200 1008040201 0609090906 040604040e
|
||||
070806010f 0f08040906 0c0a091f08 1f010f100f 08040e110e 1f08040201 0e110e110e 0e110e0402 0002000200
|
||||
0004000402 0804020408 000e000e00 0204080402 0e110c0004 0e11151906 06090f0909 0709070907 0e0101010e
|
||||
0709090907 0f0107010f 0f01070101 0e0119110e 09090f0909 0702020207 1f08080906 0905030509 010101010f
|
||||
111b151111 1113151911 0609090906 0709070101 060909060c 0709070911 0e01060807 1f04040404 0909090906
|
||||
1111110a04 1111151b11 0909060909 110a040404 0f0402010f 0e0202020e 0102040810 0e0808080e 040a000000
|
||||
000000001f 0204000000 000e09091e 0101070907 000e01010e 08080e090e 060907010e 0c02070202 0e090e0806
|
||||
0101070909 0200020202 0800080806 0105030509 020202020c 001b151111 0007090909 0006090906 0007090701
|
||||
000e090e08 000e010101 000c020403 02020e021c 000909091e 0011110a04 001111151b 0009060609 00110a0403
|
||||
000f04020f 0c0406040c 0202020202 0302060203 0000061800
|
||||
`
|
||||
}
|
||||
@ -137,7 +137,7 @@ namespace brick {
|
||||
* Shows an image on screen
|
||||
* @param image image to draw
|
||||
*/
|
||||
//% blockId=screen_show_image block="`icons.brickDisplay` show image %image=scren_image_picker"
|
||||
//% blockId=screen_show_image block="`icons.brickDisplay` show image %image=screen_image_picker"
|
||||
//% weight=95 group="Screen" blockGap=8
|
||||
export function showImage(image: Image, delay: number = 400) {
|
||||
if (!image) return;
|
||||
@ -151,7 +151,7 @@ namespace brick {
|
||||
* An image
|
||||
* @param image the image
|
||||
*/
|
||||
//% blockId=scren_image_picker block="%image" shim=TD_ID
|
||||
//% blockId=screen_image_picker block="%image" shim=TD_ID
|
||||
//% image.fieldEditor="imagedropdown"
|
||||
//% image.fieldOptions.columns=6
|
||||
//% image.fieldOptions.hasSearchBar=true
|
||||
@ -159,7 +159,16 @@ namespace brick {
|
||||
export function _imagePicker(image: Image): Image {
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the screen
|
||||
*/
|
||||
//% blockId=screen_clear_screen block="`icons.brickDisplay` clear screen"
|
||||
//% weight=94 group="Screen" blockGap=8
|
||||
export function clearScreen() {
|
||||
screen.clear();
|
||||
}
|
||||
|
||||
export function drawRect(x: number, y: number, w: number, h: number, mode = Draw.Normal) {
|
||||
x |= 0;
|
||||
y |= 0;
|
||||
|
77
libs/core/serialnumber.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#include "pxt.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define BTPROTO_HCI 1
|
||||
#define HCIGETDEVLIST _IOR('H', 210, int)
|
||||
#define HCIGETDEVINFO _IOR('H', 211, int)
|
||||
|
||||
struct hci_dev_info {
|
||||
uint16_t dev_id;
|
||||
char name[8];
|
||||
uint8_t bdaddr[6];
|
||||
uint32_t padding[32];
|
||||
};
|
||||
|
||||
struct hci_dev_req {
|
||||
uint16_t dev_id;
|
||||
uint32_t dev_opt;
|
||||
};
|
||||
|
||||
struct hci_dev_list_req {
|
||||
uint16_t dev_num;
|
||||
hci_dev_req dev_req[2];
|
||||
};
|
||||
|
||||
static uint32_t bt_addr() {
|
||||
uint32_t res = -1;
|
||||
|
||||
int fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
|
||||
if (fd < 0) {
|
||||
DMESG("BT_ADDR: can't open HCI socket");
|
||||
return res;
|
||||
}
|
||||
|
||||
hci_dev_list_req dl;
|
||||
dl.dev_num = 1;
|
||||
|
||||
if (ioctl(fd, HCIGETDEVLIST, (void *)&dl) < 0) {
|
||||
DMESG("BT_ADDR: can't get HCI device list");
|
||||
goto done;
|
||||
}
|
||||
|
||||
hci_dev_info di;
|
||||
di.dev_id = dl.dev_req[0].dev_id;
|
||||
|
||||
if (ioctl(fd, HCIGETDEVINFO, (void *)&di) < 0) {
|
||||
DMESG("BT_ADDR: can't get HCI device info");
|
||||
goto done;
|
||||
}
|
||||
|
||||
memcpy(&res, di.bdaddr, 4);
|
||||
res *= 0x1000193;
|
||||
res += di.bdaddr[4];
|
||||
res *= 0x1000193;
|
||||
res += di.bdaddr[5];
|
||||
|
||||
done:
|
||||
close(fd);
|
||||
return res;
|
||||
}
|
||||
|
||||
namespace pxt {
|
||||
|
||||
int getSerialNumber() {
|
||||
static int serial;
|
||||
|
||||
if (serial != 0)
|
||||
return serial;
|
||||
|
||||
serial = bt_addr() & 0x7fffffff;
|
||||
|
||||
return serial;
|
||||
}
|
||||
|
||||
} // namespace pxt
|
16
libs/core/shims.d.ts
vendored
@ -120,5 +120,21 @@ declare namespace output {
|
||||
//% shim=output::createBuffer
|
||||
function createBuffer(size: int32): Buffer;
|
||||
}
|
||||
declare namespace motors {
|
||||
|
||||
/**
|
||||
* Mark a motor as used
|
||||
*/
|
||||
//% shim=motors::__motorUsed
|
||||
function __motorUsed(port: int32, large: boolean): void;
|
||||
}
|
||||
declare namespace sensors {
|
||||
|
||||
/**
|
||||
* Mark a sensor as used
|
||||
*/
|
||||
//% shim=sensors::__sensorUsed
|
||||
function __sensorUsed(port: int32, type: int32): void;
|
||||
}
|
||||
|
||||
// Auto-generated. Do not edit. Really.
|
||||
|
@ -1,81 +0,0 @@
|
||||
namespace pxsim {
|
||||
enum ThresholdState {
|
||||
High,
|
||||
Low,
|
||||
Normal
|
||||
}
|
||||
|
||||
export class AnalogSensorState {
|
||||
public sensorUsed: boolean = false;
|
||||
|
||||
private level: number;
|
||||
private state = ThresholdState.Normal;
|
||||
|
||||
constructor(public id: number, private min = 0, private max = 255, private lowThreshold = 64, private highThreshold = 192) {
|
||||
this.level = Math.ceil((max - min) / 2);
|
||||
}
|
||||
|
||||
public setUsed() {
|
||||
if (!this.sensorUsed) {
|
||||
this.sensorUsed = true;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public setLevel(level: number) {
|
||||
this.level = this.clampValue(level);
|
||||
|
||||
if (this.level >= this.highThreshold) {
|
||||
this.setState(ThresholdState.High);
|
||||
}
|
||||
else if (this.level <= this.lowThreshold) {
|
||||
this.setState(ThresholdState.Low);
|
||||
}
|
||||
else {
|
||||
this.setState(ThresholdState.Normal);
|
||||
}
|
||||
}
|
||||
|
||||
public getLevel(): number {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public setLowThreshold(value: number) {
|
||||
this.lowThreshold = this.clampValue(value);
|
||||
this.highThreshold = Math.max(this.lowThreshold + 1, this.highThreshold);
|
||||
}
|
||||
|
||||
public setHighThreshold(value: number) {
|
||||
this.highThreshold = this.clampValue(value);
|
||||
this.lowThreshold = Math.min(this.highThreshold - 1, this.lowThreshold);
|
||||
}
|
||||
|
||||
private clampValue(value: number) {
|
||||
if (value < this.min) {
|
||||
return this.min;
|
||||
}
|
||||
else if (value > this.max) {
|
||||
return this.max;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private setState(state: ThresholdState) {
|
||||
if (this.state === state) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.state = state;
|
||||
switch (state) {
|
||||
case ThresholdState.High:
|
||||
board().bus.queue(this.id, DAL.ANALOG_THRESHOLD_HIGH);
|
||||
break;
|
||||
case ThresholdState.Low:
|
||||
board().bus.queue(this.id, DAL.ANALOG_THRESHOLD_LOW);
|
||||
break;
|
||||
case ThresholdState.Normal:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
|
||||
namespace pxsim.pins {
|
||||
export class CommonPin extends Pin {
|
||||
used: boolean;
|
||||
}
|
||||
|
||||
export class DigitalPin extends CommonPin {
|
||||
}
|
||||
|
||||
export class AnalogPin extends CommonPin {
|
||||
|
||||
}
|
||||
|
||||
export function markUsed(name: CommonPin) {
|
||||
if (!name.used) {
|
||||
name.used = true;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.DigitalPinMethods {
|
||||
export function digitalRead(name: pins.DigitalPin): number {
|
||||
return name.digitalReadPin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a pin or connector value to either 0 or 1.
|
||||
* @param value value to set on the pin, 1 eg,0
|
||||
*/
|
||||
export function digitalWrite(name: pins.DigitalPin, value: number): void {
|
||||
name.digitalWritePin(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures this pin to a digital input, and generates events where the timestamp is the duration
|
||||
* that this pin was either ``high`` or ``low``.
|
||||
*/
|
||||
export function onPulsed(name: pins.DigitalPin, pulse: number, body: RefAction): void {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the duration of a pulse in microseconds
|
||||
* @param value the value of the pulse (default high)
|
||||
* @param maximum duration in micro-seconds
|
||||
*/
|
||||
export function pulseIn(name: pins.DigitalPin, pulse: number, maxDuration = 2000000): number {
|
||||
// TODO
|
||||
return 500;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the pull of this pin.
|
||||
* @param pull one of the mbed pull configurations: PullUp, PullDown, PullNone
|
||||
*/
|
||||
export function setPull(name: pins.DigitalPin, pull: number): void {
|
||||
name.setPull(pull);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something when a pin is pressed.
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
export function onPressed(name: pins.DigitalPin, body: RefAction): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something when a pin is released.
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
export function onReleased(name: pins.DigitalPin, body: RefAction): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
*/
|
||||
export function isPressed(name: pins.DigitalPin): boolean {
|
||||
return name.isTouched();
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.AnalogPinMethods {
|
||||
/**
|
||||
* Read the connector value as analog, that is, as a value comprised between 0 and 1023.
|
||||
*/
|
||||
export function analogRead(name: pins.AnalogPin): number {
|
||||
pins.markUsed(name);
|
||||
return name.analogReadPin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the connector value as analog. Value must be comprised between 0 and 1023.
|
||||
* @param value value to write to the pin between ``0`` and ``1023``. eg:1023,0
|
||||
*/
|
||||
export function analogWrite(name: pins.AnalogPin, value: number): void {
|
||||
pins.markUsed(name);
|
||||
name.analogWritePin(value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the Pulse-width modulation (PWM) of the analog output to the given value in
|
||||
* **microseconds** or `1/1000` milliseconds.
|
||||
* If this pin is not configured as an analog output (using `analog write pin`), the operation has
|
||||
* no effect.
|
||||
* @param micros period in micro seconds. eg:20000
|
||||
*/
|
||||
export function analogSetPeriod(name: pins.AnalogPin, micros: number): void {
|
||||
pins.markUsed(name);
|
||||
name.analogSetPeriod(micros);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will
|
||||
* set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous
|
||||
* rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one
|
||||
* direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
|
||||
* @param value angle or rotation speed, eg:180,90,0
|
||||
*/
|
||||
export function servoWrite(name: pins.AnalogPin, value: number): void {
|
||||
pins.markUsed(name);
|
||||
name.servoWritePin(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the
|
||||
* pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.
|
||||
* @param micros pulse duration in micro seconds, eg:1500
|
||||
*/
|
||||
export function servoSetPulse(name: pins.AnalogPin, micros: number): void {
|
||||
pins.markUsed(name);
|
||||
// TODO fix pxt
|
||||
// name.servoSetPulse(micros);
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.PwmPinMethods {
|
||||
export function analogSetPeriod(name: pins.AnalogPin, micros: number): void {
|
||||
name.analogSetPeriod(micros);
|
||||
}
|
||||
|
||||
export function servoWrite(name: pins.AnalogPin, value: number): void {
|
||||
name.servoWritePin(value);
|
||||
}
|
||||
|
||||
export function servoSetPulse(name: pins.AnalogPin, micros: number): void {
|
||||
name.servoSetPulse(name.id, micros);
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.pins {
|
||||
export function pulseDuration(): number {
|
||||
// bus last event timestamp
|
||||
return 500;
|
||||
}
|
||||
|
||||
export function createBuffer(sz: number) {
|
||||
return pxsim.BufferMethods.createBuffer(sz)
|
||||
}
|
||||
|
||||
export function spiWrite(value: number): number {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function i2cReadBuffer(address: number, size: number, repeat?: boolean): RefBuffer {
|
||||
// fake reading zeros
|
||||
return createBuffer(size)
|
||||
}
|
||||
|
||||
export function i2cWriteBuffer(address: number, buf: RefBuffer, repeat?: boolean): void {
|
||||
// fake - noop
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,36 @@
|
||||
screen.clear()
|
||||
screen.print("PXT!", 10, 30, Draw.Quad)
|
||||
brick.print("PXT!", 10, 30, Draw.Quad)
|
||||
|
||||
screen.drawRect(40, 40, 20, 10, Draw.Fill)
|
||||
motors.setStatusLight(LightsPattern.Orange)
|
||||
brick.drawRect(40, 40, 20, 10, Draw.Fill)
|
||||
brick.setStatusLight(LightsPattern.Orange)
|
||||
|
||||
screen.heart.doubled().draw(100, 50, Draw.Double | Draw.Transparent)
|
||||
brick.heart.doubled().draw(100, 50, Draw.Double | Draw.Transparent)
|
||||
|
||||
sensors.buttonEnter.onEvent(ButtonEvent.Click, () => {
|
||||
brick.buttonEnter.onEvent(ButtonEvent.Click, () => {
|
||||
screen.clear()
|
||||
})
|
||||
|
||||
sensors.buttonLeft.onEvent(ButtonEvent.Click, () => {
|
||||
screen.drawRect(10, 70, 20, 10, Draw.Fill)
|
||||
motors.setStatusLight(LightsPattern.Red)
|
||||
screen.setFont(screen.microbitFont())
|
||||
brick.buttonLeft.onEvent(ButtonEvent.Click, () => {
|
||||
brick.drawRect(10, 70, 20, 10, Draw.Fill)
|
||||
brick.setStatusLight(LightsPattern.Red)
|
||||
brick.setFont(brick.microbitFont())
|
||||
})
|
||||
|
||||
sensors.buttonRight.onEvent(ButtonEvent.Click, () => {
|
||||
screen.print("Right!", 10, 60)
|
||||
brick.buttonRight.onEvent(ButtonEvent.Click, () => {
|
||||
brick.print("Right!", 10, 60)
|
||||
})
|
||||
|
||||
sensors.buttonDown.onEvent(ButtonEvent.Click, () => {
|
||||
screen.print("Down! ", 10, 60)
|
||||
brick.buttonDown.onEvent(ButtonEvent.Click, () => {
|
||||
brick.print("Down! ", 10, 60)
|
||||
})
|
||||
|
||||
sensors.buttonUp.onEvent(ButtonEvent.Click, () => {
|
||||
screen.print("Up! ", 10, 60)
|
||||
brick.buttonUp.onEvent(ButtonEvent.Click, () => {
|
||||
brick.print("Up! ", 10, 60)
|
||||
})
|
||||
|
||||
|
||||
let num = 0
|
||||
|
||||
sensors.touchSensor1.onEvent(TouchSensorEvent.Bumped, () => {
|
||||
screen.print("Click! " + num, 10, 60)
|
||||
num++
|
||||
})
|
||||
|
||||
sensors.remoteButtonTopLeft.onEvent(ButtonEvent.Click, () => {
|
||||
screen.print("TOPLEFT " + num, 10, 60)
|
||||
num++
|
||||
})
|
||||
|
||||
sensors.remoteButtonTopRight.onEvent(ButtonEvent.Down, () => {
|
||||
screen.print("TOPRIGH " + num, 10, 60)
|
||||
num++
|
||||
})
|
||||
|
||||
loops.forever(() => {
|
||||
serial.writeDmesg()
|
||||
loops.pause(100)
|
||||
|
@ -1,19 +1,25 @@
|
||||
|
||||
//% color="#00A5C8" weight=100
|
||||
//% color="#68C3E2" weight=100
|
||||
//% groups='["Light", "Buttons", "Screen"]'
|
||||
//% labelLineWidth=0
|
||||
namespace brick {
|
||||
}
|
||||
|
||||
|
||||
//% color="#D42878" weight=95
|
||||
//% color="#C8509B" weight=95 icon="\uf192"
|
||||
//% labelLineWidth=0
|
||||
//% groups='["Ultrasonic Sensor", "Touch Sensor", "Color Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Gyro Sensor"]'
|
||||
//% groupIcons='["\uf101","\uf103","\uf102","","","\uf104"]'
|
||||
namespace sensors {
|
||||
}
|
||||
|
||||
//% color="#8AC044" weight=90 icon="\uf185"
|
||||
//% color="#A5CA18" weight=90 icon="\uf185"
|
||||
//% groups='["Motion", "Sensors", "Chassis"]'
|
||||
//% labelLineWidth=0
|
||||
namespace motors {
|
||||
}
|
||||
|
||||
//% color="#DF5014" weight=80
|
||||
//% color="#D67923" weight=80
|
||||
namespace music {
|
||||
|
||||
}
|
||||
@ -33,12 +39,12 @@ namespace serial {
|
||||
|
||||
}
|
||||
|
||||
//% color="#0F841C"
|
||||
//% color="#58AB41"
|
||||
namespace loops {
|
||||
|
||||
}
|
||||
|
||||
//% color="#4c97ff"
|
||||
//% color="#1E5AA8"
|
||||
namespace light {
|
||||
|
||||
}
|
@ -3,7 +3,8 @@
|
||||
"description": "The EV3 library",
|
||||
"files": [
|
||||
"README.md",
|
||||
"ns.ts"
|
||||
"ns.ts",
|
||||
"startup.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"base": "file:../base",
|
||||
|
4
libs/ev3/startup.ts
Normal file
@ -0,0 +1,4 @@
|
||||
// This is the last thing executed before user code
|
||||
|
||||
// We pause for 100ms to give time to read sensor values, so they work in on_start block
|
||||
loops.pause(100)
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"sensors.GyroSensor.angle|block": "`icons.gyroSensor` %sensor|angle",
|
||||
"sensors.GyroSensor.rate|block": "`icons.gyroSensor` %sensor|rotation rate",
|
||||
"sensors.gyro1|block": "1",
|
||||
"sensors.gyro2|block": "2",
|
||||
"sensors.gyro3|block": "3",
|
||||
"sensors.gyro4|block": "4",
|
||||
"sensors.GyroSensor.angle|block": "%sensor|angle",
|
||||
"sensors.GyroSensor.rate|block": "%sensor|rotation rate",
|
||||
"sensors.gyro1|block": "gyro 1",
|
||||
"sensors.gyro2|block": "gyro 2",
|
||||
"sensors.gyro3|block": "gyro 3",
|
||||
"sensors.gyro4|block": "gyro 4",
|
||||
"{id:category}Sensors": "Sensors",
|
||||
"{id:group}Gyro Sensor": "Gyro Sensor"
|
||||
}
|
@ -24,11 +24,9 @@ namespace sensors {
|
||||
* @param sensor the gyroscope to query the request
|
||||
*/
|
||||
//% help=input/gyro/angle
|
||||
//% block="`icons.gyroSensor` %sensor|angle"
|
||||
//% block="%sensor|angle"
|
||||
//% blockId=gyroGetAngle
|
||||
//% parts="gyroscope"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Gyro Sensor"
|
||||
@ -42,11 +40,9 @@ namespace sensors {
|
||||
* @param sensor the gyroscope to query the request
|
||||
*/
|
||||
//% help=input/gyro/rate
|
||||
//% block="`icons.gyroSensor` %sensor|rotation rate"
|
||||
//% block="%sensor|rotation rate"
|
||||
//% blockId=gyroGetRate
|
||||
//% parts="gyroscope"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Gyro Sensor"
|
||||
@ -56,15 +52,15 @@ namespace sensors {
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstance whenUsed block="1" jres=icons.port1
|
||||
//% fixedInstance whenUsed block="gyro 1" jres=icons.port1
|
||||
export const gyro1: GyroSensor = new GyroSensor(1)
|
||||
|
||||
//% fixedInstance whenUsed block="2" weight=95 jres=icons.port2
|
||||
//% fixedInstance whenUsed block="gyro 2" weight=95 jres=icons.port2
|
||||
export const gyro2: GyroSensor = new GyroSensor(2)
|
||||
|
||||
//% fixedInstance whenUsed block="3" jres=icons.port3
|
||||
//% fixedInstance whenUsed block="gyro 3" jres=icons.port3
|
||||
export const gyro3: GyroSensor = new GyroSensor(3)
|
||||
|
||||
//% fixedInstance whenUsed block="4" jres=icons.port4
|
||||
//% fixedInstance whenUsed block="gyro 4" jres=icons.port4
|
||||
export const gyro4: GyroSensor = new GyroSensor(4)
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"sensors.InfraredSensor.onEvent": "Registers code to run when an object is getting near.",
|
||||
"sensors.InfraredSensor.onEvent|param|handler": "the code to run when detected",
|
||||
"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.waitUntil": "Waits for the event to occur",
|
||||
"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",
|
||||
|
@ -1,17 +1,17 @@
|
||||
{
|
||||
"InfraredSensorEvent.ObjectDetected|block": "object detected",
|
||||
"InfraredSensorEvent.ObjectNear|block": "object near",
|
||||
"sensors.InfraredSensor.onEvent|block": "on `icons.infraredSensor` %sensor|%event",
|
||||
"sensors.InfraredSensor.proximity|block": "`icons.infraredSensor` %sensor|proximity",
|
||||
"sensors.InfraredSensor.remoteCommand|block": "`icons.infraredSensor` %sensor|remote command",
|
||||
"sensors.InfraredSensor.waitUntil|block": "wait until `icons.infraredSensor` %sensor| %event",
|
||||
"sensors.RemoteInfraredBeaconButton.isPressed|block": "`icons.infraredSensor` %button|is pressed",
|
||||
"sensors.RemoteInfraredBeaconButton.onEvent|block": "on `icons.infraredSensor` %button|%event",
|
||||
"sensors.RemoteInfraredBeaconButton.wasPressed|block": "`icons.infraredSensor` %button|was pressed",
|
||||
"sensors.infraredSensor1|block": "1",
|
||||
"sensors.infraredSensor2|block": "2",
|
||||
"sensors.infraredSensor3|block": "3",
|
||||
"sensors.infraredSensor4|block": "4",
|
||||
"sensors.InfraredSensor.onEvent|block": "on %sensor|%event",
|
||||
"sensors.InfraredSensor.pauseUntil|block": "pause until %sensor| %event",
|
||||
"sensors.InfraredSensor.proximity|block": "%sensor|proximity",
|
||||
"sensors.InfraredSensor.remoteCommand|block": "%sensor|remote command",
|
||||
"sensors.RemoteInfraredBeaconButton.isPressed|block": "%button|is pressed",
|
||||
"sensors.RemoteInfraredBeaconButton.onEvent|block": "on %button|%event",
|
||||
"sensors.RemoteInfraredBeaconButton.wasPressed|block": "%button|was pressed",
|
||||
"sensors.infraredSensor1|block": "infrared 1",
|
||||
"sensors.infraredSensor2|block": "infrared 2",
|
||||
"sensors.infraredSensor3|block": "infrared 3",
|
||||
"sensors.infraredSensor4|block": "infrared 4",
|
||||
"sensors.remoteButtonBottomLeft|block": "bottom-left",
|
||||
"sensors.remoteButtonBottomRight|block": "bottom-right",
|
||||
"sensors.remoteButtonCenter|block": "center",
|
||||
|
@ -93,7 +93,7 @@ namespace sensors {
|
||||
* @param button the remote button to query the request
|
||||
*/
|
||||
//% help=input/remote-infrared-beacon/is-pressed
|
||||
//% block="`icons.infraredSensor` %button|is pressed"
|
||||
//% block="%button|is pressed"
|
||||
//% blockId=remoteButtonIsPressed
|
||||
//% parts="remote"
|
||||
//% blockNamespace=sensors
|
||||
@ -108,7 +108,7 @@ namespace sensors {
|
||||
* @param button the remote button to query the request
|
||||
*/
|
||||
//% help=input/remote-infrared-beacon/was-pressed
|
||||
//% block="`icons.infraredSensor` %button|was pressed"
|
||||
//% block="%button|was pressed"
|
||||
//% blockId=remotebuttonWasPressed
|
||||
//% parts="remote"
|
||||
//% blockNamespace=sensors
|
||||
@ -125,7 +125,7 @@ namespace sensors {
|
||||
* @param body code to run when the event is raised
|
||||
*/
|
||||
//% help=input/remote-infrared-beacon/on-event
|
||||
//% blockId=remotebuttonEvent block="on `icons.infraredSensor` %button|%event"
|
||||
//% blockId=remotebuttonEvent block="on %button|%event"
|
||||
//% parts="remote"
|
||||
//% blockNamespace=sensors
|
||||
//% weight=99 blockGap=8
|
||||
@ -189,11 +189,9 @@ namespace sensors {
|
||||
* @param handler the code to run when detected
|
||||
*/
|
||||
//% help=input/infrared/on
|
||||
//% block="on `icons.infraredSensor` %sensor|%event"
|
||||
//% block="on %sensor|%event"
|
||||
//% blockId=infraredOn
|
||||
//% parts="infraredsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=100 blockGap=8
|
||||
//% group="Infrared Sensor"
|
||||
@ -205,15 +203,13 @@ namespace sensors {
|
||||
* Waits for the event to occur
|
||||
*/
|
||||
//% help=input/ultrasonic/wait
|
||||
//% block="wait until `icons.infraredSensor` %sensor| %event"
|
||||
//% block="pause until %sensor| %event"
|
||||
//% blockId=infraredwait
|
||||
//% parts="infraredsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=99 blockGap=8
|
||||
//% group="Infrared Sensor"
|
||||
waitUntil(event: InfraredSensorEvent) {
|
||||
pauseUntil(event: InfraredSensorEvent) {
|
||||
control.waitForEvent(this._id, event);
|
||||
}
|
||||
|
||||
@ -222,11 +218,9 @@ namespace sensors {
|
||||
* @param sensor the infrared sensor
|
||||
*/
|
||||
//% help=input/infrared/proximity
|
||||
//% block="`icons.infraredSensor` %sensor|proximity"
|
||||
//% block="%sensor|proximity"
|
||||
//% blockId=infraredGetProximity
|
||||
//% parts="infrared"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Infrared Sensor"
|
||||
@ -240,11 +234,9 @@ namespace sensors {
|
||||
* @param sensor the infrared sensor
|
||||
*/
|
||||
//% help=input/infrared/remote-command
|
||||
//% block="`icons.infraredSensor` %sensor|remote command"
|
||||
//% block="%sensor|remote command"
|
||||
//% blockId=infraredGetRemoteCommand
|
||||
//% parts="infrared"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Infrared Sensor"
|
||||
@ -260,16 +252,16 @@ namespace sensors {
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstance whenUsed block="1" jres=icons.port1
|
||||
//% fixedInstance whenUsed block="infrared 1" jres=icons.port1
|
||||
export const infraredSensor1: InfraredSensor = new InfraredSensor(1)
|
||||
|
||||
//% fixedInstance whenUsed block="2" jres=icons.port2
|
||||
//% fixedInstance whenUsed block="infrared 2" jres=icons.port2
|
||||
export const infraredSensor2: InfraredSensor = new InfraredSensor(2)
|
||||
|
||||
//% fixedInstance whenUsed block="3" jres=icons.port3
|
||||
//% fixedInstance whenUsed block="infrared 3" jres=icons.port3
|
||||
export const infraredSensor3: InfraredSensor = new InfraredSensor(3)
|
||||
|
||||
//% fixedInstance whenUsed block="4" jres=icons.port4
|
||||
//% fixedInstance whenUsed block="infrared 4" jres=icons.port4
|
||||
export const infraredSensor4: InfraredSensor = new InfraredSensor(4)
|
||||
|
||||
|
||||
|
@ -11,12 +11,10 @@
|
||||
"music.fromWAV": "Makes a sound bound to a buffer in WAV format.",
|
||||
"music.noteFrequency": "Get the frequency of a note.",
|
||||
"music.noteFrequency|param|name": "the note name, eg: Note.C",
|
||||
"music.playSound": "Start playing a sound and don't wait for it to finish.\nNotes are expressed as a string of characters with this format: NOTE[octave][:duration]",
|
||||
"music.playSoundEffect": "Plays a sound",
|
||||
"music.playSoundEffect": "Start playing a sound and don't wait for it to finish.",
|
||||
"music.playSoundEffectUntilDone": "Plays a sound",
|
||||
"music.playSoundEffectUntilDone|param|sound": "the sound to play",
|
||||
"music.playSoundEffect|param|sound": "the sound to play",
|
||||
"music.playSoundUntilDone": "Play a sound and wait until the sound is done.\nNotes are expressed as a string of characters with this format: NOTE[octave][:duration]",
|
||||
"music.playSoundUntilDone|param|sound": "the melody to play, eg: music.sounds(Sounds.PowerUp)",
|
||||
"music.playSound|param|sound": "the melody to play, eg: music.sounds(Sounds.PowerUp)",
|
||||
"music.playTone": "Play a tone through the speaker for some amount of time.",
|
||||
"music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||
"music.playTone|param|ms": "tone duration in milliseconds (ms)",
|
||||
@ -28,8 +26,6 @@
|
||||
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
||||
"music.setVolume": "Set the output volume of the sound synthesizer.",
|
||||
"music.setVolume|param|volume": "the volume 0...256, eg: 128",
|
||||
"music.sounds": "Get the melody string for a built-in melody.",
|
||||
"music.sounds|param|name": "the note name, eg: Note.C",
|
||||
"music.stopAllSounds": "Stop all sounds from playing.",
|
||||
"music.stopAllSounds": "Play a tone through the speaker for some amount of time.",
|
||||
"music.tempo": "Return the tempo in beats per minute (bpm).\nTempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play."
|
||||
}
|
@ -20,27 +20,17 @@
|
||||
"Note.GSharp|block": "G#",
|
||||
"SoundOutputDestination.Pin|block": "pin",
|
||||
"SoundOutputDestination.Speaker|block": "speaker",
|
||||
"Sounds.BaDing|block": "ba ding",
|
||||
"Sounds.JumpDown|block": "jump down",
|
||||
"Sounds.JumpUp|block": "jump up",
|
||||
"Sounds.MagicWand|block": "magic wand",
|
||||
"Sounds.PowerDown|block": "power down",
|
||||
"Sounds.PowerUp|block": "power up",
|
||||
"Sounds.Siren|block": "siren",
|
||||
"Sounds.Wawawawaa|block": "wawawawaa",
|
||||
"music._soundPicker|block": "%sound",
|
||||
"music.beat|block": "%fraction|beat",
|
||||
"music.changeTempoBy|block": "change tempo by %value|(bpm)",
|
||||
"music.noteFrequency|block": "%note",
|
||||
"music.playSoundEffect|block": "play %sound",
|
||||
"music.playSoundUntilDone|block": "play sound %sound=music_sounds|until done",
|
||||
"music.playSound|block": "play sound %sound=music_sounds",
|
||||
"music.playSoundEffectUntilDone|block": "play sound effect %sound|until done",
|
||||
"music.playSoundEffect|block": "play sound effect %sound",
|
||||
"music.playTone|block": "play tone|at %note=device_note|for %duration=device_beat",
|
||||
"music.rest|block": "rest|for %duration=device_beat",
|
||||
"music.ringTone|block": "ring tone|at %note=device_note",
|
||||
"music.setTempo|block": "set tempo to %value|(bpm)",
|
||||
"music.setVolume|block": "set volume %volume",
|
||||
"music.sounds|block": "%name",
|
||||
"music.stopAllSounds|block": "stop all sounds",
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "music",
|
||||
|
1
libs/music/melodies.ts
Normal file
@ -0,0 +1 @@
|
||||
namespace music {}
|
@ -163,6 +163,21 @@ void playTone(int frequency, int ms) {
|
||||
sleep_ms(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Play a tone through the speaker for some amount of time.
|
||||
*/
|
||||
//% help=music/stop-all-sounds
|
||||
//% blockId=music_stop_all_sounds block="stop all sounds"
|
||||
//% parts="headphone"
|
||||
//% blockNamespace=music
|
||||
//% weight=76 blockGap=8
|
||||
void stopAllSounds() {
|
||||
if (currentSample) {
|
||||
samplePtr = currentSample->length;
|
||||
}
|
||||
_stopSound();
|
||||
}
|
||||
|
||||
/** Makes a sound bound to a buffer in WAV format. */
|
||||
//%
|
||||
Sound fromWAV(Buffer buf) {
|
||||
|
10
libs/music/shims.d.ts
vendored
@ -25,6 +25,16 @@ declare namespace music {
|
||||
//% weight=76 blockGap=8 shim=music::playTone
|
||||
function playTone(frequency: int32, ms: int32): void;
|
||||
|
||||
/**
|
||||
* Play a tone through the speaker for some amount of time.
|
||||
*/
|
||||
//% help=music/stop-all-sounds
|
||||
//% blockId=music_stop_all_sounds block="stop all sounds"
|
||||
//% parts="headphone"
|
||||
//% blockNamespace=music
|
||||
//% weight=76 blockGap=8 shim=music::stopAllSounds
|
||||
function stopAllSounds(): void;
|
||||
|
||||
/** Makes a sound bound to a buffer in WAV format. */
|
||||
//% shim=music::fromWAV
|
||||
function fromWAV(buf: Buffer): Sound;
|
||||
|
@ -256,15 +256,17 @@ namespace sounds {
|
||||
}
|
||||
|
||||
namespace music {
|
||||
let numSoundsPlaying = 0;
|
||||
const soundsLimit = 1;
|
||||
|
||||
/**
|
||||
* Plays a sound
|
||||
* @param sound the sound to play
|
||||
*/
|
||||
//% blockId=music_play_sound_effect block="play %sound"
|
||||
//% blockId=music_play_sound_effect_until_done block="play sound effect %sound|until done"
|
||||
//% weight=98
|
||||
export function playSoundEffect(sound: Sound) {
|
||||
export function playSoundEffectUntilDone(sound: Sound) {
|
||||
if (!sound) return;
|
||||
|
||||
sound.play();
|
||||
}
|
||||
|
||||
@ -277,4 +279,16 @@ namespace music {
|
||||
export function _soundPicker(sound: Sound): Sound {
|
||||
return sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start playing a sound and don't wait for it to finish.
|
||||
* @param sound the sound to play
|
||||
*/
|
||||
//% blockId=music_play_sound_effect block="play sound effect %sound"
|
||||
//% weight=99
|
||||
export function playSoundEffect(sound: Sound) {
|
||||
if (!sound || numSoundsPlaying >= soundsLimit) return;
|
||||
numSoundsPlaying++;
|
||||
control.runInBackground(() => {sound.play(); numSoundsPlaying--;});
|
||||
}
|
||||
}
|
||||
|
35
libs/tests/README.md
Normal file
@ -0,0 +1,35 @@
|
||||
# tests
|
||||
|
||||
A unit test framework
|
||||
|
||||
## Defining tests
|
||||
|
||||
Tests are registered as event handlers. They will automatically run once ``on start`` is finished.
|
||||
|
||||
```blocks
|
||||
tests.test("lgB set speed 10", () => {
|
||||
motors.largeB.setSpeed(10);
|
||||
loops.pause(100)
|
||||
tests.assertClose("speedB", 10, motors.largeB.speed(), 2)
|
||||
});
|
||||
```
|
||||
|
||||
## Assertions
|
||||
|
||||
The library has various asserts that will register fault. Note that since exceptions are not available, assertion failure **do not** stop the program execution.
|
||||
|
||||
* **assert** checks a boolean condition
|
||||
|
||||
```blocks
|
||||
tests.assert("speed positive", motors.largeB.speed() > 0)
|
||||
```
|
||||
|
||||
* **assert close** checks that a numberical value is within a particular range
|
||||
|
||||
```blocks
|
||||
tests.assertClose("speed", motors.largeB.speed(), 10, 2)
|
||||
```
|
||||
|
||||
```package
|
||||
tests
|
||||
```
|
9
libs/tests/_locales/tests-jsdoc-strings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"tests": "Unit tests framework",
|
||||
"tests.assert": "Checks a boolean condition",
|
||||
"tests.assertClose": "Checks that 2 values are close to each other",
|
||||
"tests.assertClose|param|actual": "what the value was",
|
||||
"tests.assertClose|param|expected": "what the value should be",
|
||||
"tests.assertClose|param|tolerance": "the acceptable error margin",
|
||||
"tests.test": "Registers a test to run"
|
||||
}
|
6
libs/tests/_locales/tests-strings.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"tests.assert|block": "assert %message|%condition",
|
||||
"tests.test|block": "test %name",
|
||||
"tests|block": "tests",
|
||||
"{id:category}Tests": "Tests"
|
||||
}
|
14
libs/tests/pxt.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "tests",
|
||||
"description": "A unit test library",
|
||||
"files": [
|
||||
"README.md",
|
||||
"tests.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
"core": "file:../core"
|
||||
}
|
||||
}
|
89
libs/tests/tests.ts
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Unit tests framework
|
||||
*/
|
||||
//% weight=100 color=#0fbc11 icon=""
|
||||
namespace tests {
|
||||
class Test {
|
||||
name: string;
|
||||
handler: () => void;
|
||||
errors: string[];
|
||||
|
||||
constructor(name: string, handler: () => void) {
|
||||
this.name = name;
|
||||
this.handler = handler;
|
||||
this.errors = [];
|
||||
}
|
||||
|
||||
reset() {
|
||||
motors.stopAllMotors();
|
||||
motors.resetAllMotors();
|
||||
}
|
||||
|
||||
run() {
|
||||
// clear state
|
||||
this.reset();
|
||||
|
||||
console.log(`# ${this.name}`)
|
||||
this.handler()
|
||||
|
||||
// ensure clean state after test
|
||||
this.reset();
|
||||
}
|
||||
}
|
||||
|
||||
let _tests: Test[] = undefined;
|
||||
let _currentTest: Test = undefined;
|
||||
|
||||
function run() {
|
||||
if (!_tests) return;
|
||||
|
||||
const start = control.millis();
|
||||
console.sendToScreen();
|
||||
console.log(`${_tests.length} tests`)
|
||||
for (let i = 0; i < _tests.length; ++i) {
|
||||
const t = _currentTest = _tests[i];
|
||||
t.run();
|
||||
_currentTest = undefined;
|
||||
}
|
||||
console.log(`${_tests.map(t => t.errors.length).reduce((p, c) => p + c, 0)} X, ${Math.ceil((control.millis() - start) / 1000)}s`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a test to run
|
||||
*/
|
||||
//% blockId=testtest block="test %name"
|
||||
export function test(name: string, handler: () => void): void {
|
||||
if (!name || !handler) return;
|
||||
if (!_tests) {
|
||||
_tests = [];
|
||||
control.runInBackground(function () {
|
||||
// should run after on start
|
||||
loops.pause(100)
|
||||
run()
|
||||
})
|
||||
}
|
||||
_tests.push(new Test(name, handler));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a boolean condition
|
||||
*/
|
||||
//% blockId=testAssert block="assert %message|%condition"
|
||||
export function assert(message: string, condition: boolean) {
|
||||
if (!condition) {
|
||||
console.log(` X ${message || ''}`)
|
||||
if (_currentTest)
|
||||
_currentTest.errors.push(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that 2 values are close to each other
|
||||
* @param expected what the value should be
|
||||
* @param actual what the value was
|
||||
* @param tolerance the acceptable error margin
|
||||
*/
|
||||
export function assertClose(name: string, expected: number, actual: number, tolerance: number) {
|
||||
assert(`${name} ${expected} != ${actual} +-${tolerance}`, Math.abs(expected - actual) <= tolerance);
|
||||
}
|
||||
}
|
@ -3,6 +3,6 @@
|
||||
"sensors.TouchSensor.isPressed": "Check if touch sensor is touched.",
|
||||
"sensors.TouchSensor.onEvent": "Do something when a touch sensor is touched...",
|
||||
"sensors.TouchSensor.onEvent|param|body": "code to run when the event is raised",
|
||||
"sensors.TouchSensor.waitUntil": "Wait until the touch sensor is touched",
|
||||
"sensors.TouchSensor.pauseUntil": "Wait until the touch sensor is touched",
|
||||
"sensors.TouchSensor.wasPressed": "Check if touch sensor is touched since it was last checked."
|
||||
}
|
@ -2,14 +2,14 @@
|
||||
"TouchSensorEvent.Bumped|block": "bumped",
|
||||
"TouchSensorEvent.Pressed|block": "pressed",
|
||||
"TouchSensorEvent.Released|block": "released",
|
||||
"sensors.TouchSensor.isPressed|block": "`icons.touchSensor` %sensor|is pressed",
|
||||
"sensors.TouchSensor.onEvent|block": "on `icons.touchSensor` %sensor|%event",
|
||||
"sensors.TouchSensor.waitUntil|block": "wait until `icons.touchSensor` %sensor|%event",
|
||||
"sensors.TouchSensor.wasPressed|block": "`icons.touchSensor` %sensor|was pressed",
|
||||
"sensors.touchSensor1|block": "1",
|
||||
"sensors.touchSensor2|block": "2",
|
||||
"sensors.touchSensor3|block": "3",
|
||||
"sensors.touchSensor4|block": "4",
|
||||
"sensors.TouchSensor.isPressed|block": "%sensor|is pressed",
|
||||
"sensors.TouchSensor.onEvent|block": "on %sensor|%event",
|
||||
"sensors.TouchSensor.pauseUntil|block": "pause until %sensor|%event",
|
||||
"sensors.TouchSensor.wasPressed|block": "%sensor|was pressed",
|
||||
"sensors.touchSensor1|block": "touch 1",
|
||||
"sensors.touchSensor2|block": "touch 2",
|
||||
"sensors.touchSensor3|block": "touch 3",
|
||||
"sensors.touchSensor4|block": "touch 4",
|
||||
"{id:category}Sensors": "Sensors",
|
||||
"{id:group}Touch Sensor": "Touch Sensor"
|
||||
}
|
@ -42,10 +42,8 @@ namespace sensors {
|
||||
* @param body code to run when the event is raised
|
||||
*/
|
||||
//% help=input/touch-sensor/on-event
|
||||
//% blockId=touchEvent block="on `icons.touchSensor` %sensor|%event"
|
||||
//% blockId=touchEvent block="on %sensor|%event"
|
||||
//% parts="touch"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=99 blockGap=8
|
||||
//% group="Touch Sensor"
|
||||
@ -58,16 +56,14 @@ namespace sensors {
|
||||
* @param sensor the touch sensor that needs to be clicked or used
|
||||
* @param event the kind of button gesture that needs to be detected
|
||||
*/
|
||||
//% help=input/touch-sensor/wait-until
|
||||
//% blockId=touchWaitUntil block="wait until `icons.touchSensor` %sensor|%event"
|
||||
//% help=input/touch-sensor/pause-until
|
||||
//% blockId=touchWaitUntil block="pause until %sensor|%event"
|
||||
//% parts="touch"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=98 blockGap=8
|
||||
//% group="Touch Sensor"
|
||||
waitUntil(ev: TouchSensorEvent) {
|
||||
this.button.waitUntil(<ButtonEvent><number>ev);
|
||||
pauseUntil(ev: TouchSensorEvent) {
|
||||
this.button.pauseUntil(<ButtonEvent><number>ev);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,11 +71,9 @@ namespace sensors {
|
||||
* @param sensor the port to query the request
|
||||
*/
|
||||
//% help=input/touch-sensor/is-pressed
|
||||
//% block="`icons.touchSensor` %sensor|is pressed"
|
||||
//% block="%sensor|is pressed"
|
||||
//% blockId=touchIsPressed
|
||||
//% parts="touch"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=81 blockGap=8
|
||||
//% group="Touch Sensor"
|
||||
@ -92,11 +86,9 @@ namespace sensors {
|
||||
* @param sensor the port to query the request
|
||||
*/
|
||||
//% help=input/touch-sensor/was-pressed
|
||||
//% block="`icons.touchSensor` %sensor|was pressed"
|
||||
//% block="%sensor|was pressed"
|
||||
//% blockId=touchWasPressed
|
||||
//% parts="touch"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=81 blockGap=8
|
||||
//% group="Touch Sensor"
|
||||
@ -105,12 +97,12 @@ namespace sensors {
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed block="1" weight=95 fixedInstance jres=icons.port1
|
||||
//% whenUsed block="touch 1" weight=95 fixedInstance jres=icons.port1
|
||||
export const touchSensor1: TouchSensor = new TouchSensor(1)
|
||||
//% whenUsed block="2" weight=95 fixedInstance jres=icons.port2
|
||||
//% whenUsed block="touch 2" weight=95 fixedInstance jres=icons.port2
|
||||
export const touchSensor2: TouchSensor = new TouchSensor(2)
|
||||
//% whenUsed block="3" weight=95 fixedInstance jres=icons.port3
|
||||
//% whenUsed block="touch 3" weight=95 fixedInstance jres=icons.port3
|
||||
export const touchSensor3: TouchSensor = new TouchSensor(3)
|
||||
//% whenUsed block="4" weight=95 fixedInstance jres=icons.port4
|
||||
//% whenUsed block="touch 4" weight=95 fixedInstance jres=icons.port4
|
||||
export const touchSensor4: TouchSensor = new TouchSensor(4)
|
||||
}
|
||||
|
11
libs/tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"rootDir": ".",
|
||||
"newLine": "LF",
|
||||
"sourceMap": false,
|
||||
"types": []
|
||||
}
|
||||
}
|
@ -2,5 +2,5 @@
|
||||
"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.waitUntil": "Waits for the event to occur"
|
||||
"sensors.UltraSonicSensor.pauseUntil": "Waits for the event to occur"
|
||||
}
|
@ -2,13 +2,13 @@
|
||||
"UltrasonicSensorEvent.ObjectDetected|block": "object detected",
|
||||
"UltrasonicSensorEvent.ObjectFar|block": "object far",
|
||||
"UltrasonicSensorEvent.ObjectNear|block": "object near",
|
||||
"sensors.UltraSonicSensor.distance|block": "`icons.ultrasonicSensor` %sensor|distance",
|
||||
"sensors.UltraSonicSensor.onEvent|block": "on `icons.ultrasonicSensor` %sensor|%event",
|
||||
"sensors.UltraSonicSensor.waitUntil|block": "wait until `icons.ultrasonicSensor` %sensor| %event",
|
||||
"sensors.ultrasonic1|block": "1",
|
||||
"sensors.ultrasonic2|block": "2",
|
||||
"sensors.ultrasonic3|block": "3",
|
||||
"sensors.ultrasonic4|block": "4",
|
||||
"sensors.UltraSonicSensor.distance|block": "%sensor|distance",
|
||||
"sensors.UltraSonicSensor.onEvent|block": "on %sensor|%event",
|
||||
"sensors.UltraSonicSensor.pauseUntil|block": "pause until %sensor| %event",
|
||||
"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}Ultrasonic Sensor": "Ultrasonic Sensor"
|
||||
}
|
@ -25,7 +25,7 @@ namespace sensors {
|
||||
}
|
||||
|
||||
_query(): number {
|
||||
return this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff;
|
||||
return (this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff) * 0.1; // range is 0..2550, in 0.1 cm increments.
|
||||
}
|
||||
|
||||
_update(prev: number, curr: number) {
|
||||
@ -43,10 +43,8 @@ namespace sensors {
|
||||
*/
|
||||
//% help=input/ultrasonic/on
|
||||
//% blockId=ultrasonicOn
|
||||
//% block="on `icons.ultrasonicSensor` %sensor|%event"
|
||||
//% block="on %sensor|%event"
|
||||
//% parts="ultrasonicsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=100 blockGap=8
|
||||
//% group="Ultrasonic Sensor"
|
||||
@ -58,15 +56,13 @@ namespace sensors {
|
||||
* Waits for the event to occur
|
||||
*/
|
||||
//% help=input/ultrasonic/wait
|
||||
//% block="wait until `icons.ultrasonicSensor` %sensor| %event"
|
||||
//% block="pause until %sensor| %event"
|
||||
//% blockId=ultrasonicWait
|
||||
//% parts="ultrasonicsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=99 blockGap=8
|
||||
//% group="Ultrasonic Sensor"
|
||||
waitUntil(event: UltrasonicSensorEvent) {
|
||||
pauseUntil(event: UltrasonicSensorEvent) {
|
||||
control.waitForEvent(this._id, event);
|
||||
}
|
||||
|
||||
@ -75,30 +71,28 @@ namespace sensors {
|
||||
* @param sensor the ultrasonic sensor port
|
||||
*/
|
||||
//% help=input/ultrasonic/distance
|
||||
//% block="`icons.ultrasonicSensor` %sensor|distance"
|
||||
//% block="%sensor|distance"
|
||||
//% blockId=sonarGetDistance
|
||||
//% parts="ultrasonicsensor"
|
||||
//% sensor.fieldEditor="imagedropdown"
|
||||
//% sensor.fieldOptions.columns=4
|
||||
//% blockNamespace=sensors
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Ultrasonic Sensor"
|
||||
distance(): number {
|
||||
// it supposedly also has an inch mode, but we stick to cm
|
||||
this._setMode(0)
|
||||
return this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff; // range is 0..255
|
||||
return (this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff) * 0.1; // range is 0..2550, in 0.1 cm increments.
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstance whenUsed block="1" jres=icons.port1
|
||||
//% fixedInstance whenUsed block="ultrasonic 1" jres=icons.port1
|
||||
export const ultrasonic1: UltraSonicSensor = new UltraSonicSensor(1)
|
||||
|
||||
//% fixedInstance whenUsed block="4" jres=icons.port4
|
||||
export const ultrasonic4: UltraSonicSensor = new UltraSonicSensor(4)
|
||||
|
||||
//% fixedInstance whenUsed block="2" jres=icons.port2
|
||||
//% fixedInstance whenUsed block="ultrasonic 2" jres=icons.port2
|
||||
export const ultrasonic2: UltraSonicSensor = new UltraSonicSensor(2)
|
||||
|
||||
//% fixedInstance whenUsed block="3" jres=icons.port3
|
||||
//% fixedInstance whenUsed block="ultrasonic 3" jres=icons.port3
|
||||
export const ultrasonic3: UltraSonicSensor = new UltraSonicSensor(3)
|
||||
|
||||
//% fixedInstance whenUsed block="ultrasonic 4" jres=icons.port4
|
||||
export const ultrasonic4: UltraSonicSensor = new UltraSonicSensor(4)
|
||||
}
|
||||
|
15
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.0.37",
|
||||
"version": "0.0.44",
|
||||
"description": "LEGO Mindstorms EV3 for Microsoft MakeCode",
|
||||
"private": true,
|
||||
"keywords": [
|
||||
@ -32,15 +32,20 @@
|
||||
"main": "built/pxtrequire.js",
|
||||
"typings": "built/pxtrequire.d.ts",
|
||||
"devDependencies": {
|
||||
"typescript": "^1.8.7",
|
||||
"typescript": "2.6.1",
|
||||
"less": "^2.6.0",
|
||||
"rtlcss": "^2.1.2",
|
||||
"autoprefixer": "^6.7.6",
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
"semantic-ui-less": "^2.2.4",
|
||||
"@types/bluebird": "2.0.33",
|
||||
"@types/jquery": "3.2.16",
|
||||
"@types/marked": "0.3.0",
|
||||
"@types/node": "8.0.53",
|
||||
"webfonts-generator": "^0.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-common-packages": "0.14.5",
|
||||
"pxt-core": "2.3.37"
|
||||
"pxt-common-packages": "0.14.13",
|
||||
"pxt-core": "3.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||
|
@ -15,12 +15,13 @@
|
||||
"libs/ultrasonic-sensor",
|
||||
"libs/infrared-sensor",
|
||||
"libs/gyro-sensor",
|
||||
"libs/ev3"
|
||||
"libs/ev3",
|
||||
"libs/tests"
|
||||
],
|
||||
"simulator": {
|
||||
"autoRun": true,
|
||||
"streams": true,
|
||||
"aspectRatio": 0.67,
|
||||
"aspectRatio": 0.5,
|
||||
"parts": false,
|
||||
"enableTrace": true,
|
||||
"boardDefinition": {
|
||||
@ -52,8 +53,10 @@
|
||||
"serial": {
|
||||
"vendorId": "0x0694",
|
||||
"productId": "0x0005",
|
||||
"rawHID": true
|
||||
},
|
||||
"rawHID": true,
|
||||
"useEditor": true,
|
||||
"log": true
|
||||
},
|
||||
"runtime": {
|
||||
"mathBlocks": true,
|
||||
"loopsBlocks": true,
|
||||
@ -63,7 +66,10 @@
|
||||
"listsBlocks": true,
|
||||
"functionBlocks": true,
|
||||
"onStartNamespace": "loops",
|
||||
"onStartColor": "#0F841C"
|
||||
"onStartColor": "#58AB41",
|
||||
"pauseUntilBlock": {
|
||||
"category": "loops"
|
||||
}
|
||||
},
|
||||
"compileService": {
|
||||
"buildEngine": "dockermake",
|
||||
@ -122,17 +128,20 @@
|
||||
"blocklyOptions": {
|
||||
},
|
||||
"blockColors": {
|
||||
"loops": "#0F841C",
|
||||
"logic": "#3979B9",
|
||||
"math": "#8A83BA",
|
||||
"variables": "#D4000D",
|
||||
"loops": "#58AB41",
|
||||
"logic": "#1E5AA8",
|
||||
"math": "#9DC3F7",
|
||||
"variables": "#B40000",
|
||||
"text": "#F0890A",
|
||||
"advanced": "#7A8284",
|
||||
"advanced": "#969696",
|
||||
"functions": "#064597",
|
||||
"arrays": "#890058"
|
||||
},
|
||||
"monacoColors": {
|
||||
"editor.background": "#ecf6ff"
|
||||
}
|
||||
}
|
||||
},
|
||||
"simAnimationEnter": "horizontal flip in",
|
||||
"simAnimationExit": "horizontal flip out"
|
||||
},
|
||||
"ignoreDocsErrors": true
|
||||
}
|
||||
|
140
sim/dalboard.ts
@ -22,17 +22,7 @@ namespace pxsim {
|
||||
D13
|
||||
}
|
||||
|
||||
export class DalBoard extends CoreBoard implements
|
||||
AccelerometerBoard,
|
||||
CommonBoard,
|
||||
// LightBoard,
|
||||
LightSensorBoard,
|
||||
MicrophoneBoard,
|
||||
MusicBoard,
|
||||
SlideSwitchBoard,
|
||||
TemperatureBoard,
|
||||
InfraredBoard,
|
||||
CapTouchBoard {
|
||||
export class EV3Board extends CoreBoard {
|
||||
// state & update logic for component services
|
||||
// neopixelState: CommonNeoPixelState;
|
||||
buttonState: EV3ButtonState;
|
||||
@ -44,80 +34,42 @@ namespace pxsim {
|
||||
edgeConnectorState: EdgeConnectorState;
|
||||
capacitiveSensorState: CapacitiveSensorState;
|
||||
accelerometerState: AccelerometerState;
|
||||
audioState: AudioState;
|
||||
touchButtonState: TouchButtonState;
|
||||
irState: InfraredState;
|
||||
lightState: EV3LightState;
|
||||
screenState: EV3ScreenState;
|
||||
|
||||
view: SVGSVGElement;
|
||||
|
||||
outputState: EV3OutputState;
|
||||
analogState: EV3AnalogState;
|
||||
uartState: EV3UArtState;
|
||||
motorState: EV3MotorState;
|
||||
screenState: EV3ScreenState;
|
||||
audioState: AudioState;
|
||||
|
||||
inputNodes: SensorNode[] = [];
|
||||
brickNode: BrickNode;
|
||||
outputNodes: MotorNode[] = [];
|
||||
|
||||
private motorMap: pxt.Map<number> = {
|
||||
0x01: 0,
|
||||
0x02: 1,
|
||||
0x04: 2,
|
||||
0x08: 3
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
this.bus.setNotify(DAL.DEVICE_ID_NOTIFY, DAL.DEVICE_ID_NOTIFY_ONE);
|
||||
|
||||
//components
|
||||
this.brickNode = new BrickNode();
|
||||
|
||||
this.builtinParts["buttons"] = this.buttonState = new EV3ButtonState();
|
||||
this.builtinParts["light"] = this.lightState = new EV3LightState();
|
||||
this.builtinParts["screen"] = this.screenState = new EV3ScreenState();
|
||||
this.builtinParts["audio"] = this.audioState = new AudioState();
|
||||
|
||||
/*this.builtinParts["neopixel"] = this.neopixelState = new CommonNeoPixelState();
|
||||
this.builtinParts["buttonpair"] = this.buttonState = new CommonButtonState();
|
||||
|
||||
this.builtinParts["switch"] = this.slideSwitchState = new SlideSwitchState();
|
||||
this.builtinParts["lightsensor"] = this.lightSensorState = new AnalogSensorState(DAL.DEVICE_ID_LIGHT_SENSOR, 0, 255);
|
||||
this.builtinParts["thermometer"] = this.thermometerState = new AnalogSensorState(DAL.DEVICE_ID_THERMOMETER, -5, 50);
|
||||
this.builtinParts["soundsensor"] = this.microphoneState = new AnalogSensorState(DAL.DEVICE_ID_TOUCH_SENSOR + 1, 0, 255);
|
||||
this.builtinParts["capacitivesensor"] = this.capacitiveSensorState = new CapacitiveSensorState({
|
||||
0: 0,
|
||||
1: 1,
|
||||
2: 2,
|
||||
3: 3,
|
||||
6: 4,
|
||||
9: 5,
|
||||
10: 6,
|
||||
12: 7
|
||||
});
|
||||
|
||||
this.builtinParts["accelerometer"] = this.accelerometerState = new AccelerometerState(runtime);
|
||||
this.builtinParts["edgeconnector"] = this.edgeConnectorState = new EdgeConnectorState({
|
||||
pins: [
|
||||
pxsim.CPlayPinName.A0,
|
||||
pxsim.CPlayPinName.A1,
|
||||
pxsim.CPlayPinName.A2,
|
||||
pxsim.CPlayPinName.A3,
|
||||
pxsim.CPlayPinName.A4,
|
||||
pxsim.CPlayPinName.A5,
|
||||
pxsim.CPlayPinName.A6,
|
||||
pxsim.CPlayPinName.A7,
|
||||
pxsim.CPlayPinName.A8,
|
||||
pxsim.CPlayPinName.A9,
|
||||
pxsim.CPlayPinName.D4,
|
||||
pxsim.CPlayPinName.D5,
|
||||
pxsim.CPlayPinName.D6,
|
||||
pxsim.CPlayPinName.D7,
|
||||
pxsim.CPlayPinName.D8,
|
||||
pxsim.CPlayPinName.D13
|
||||
]
|
||||
});
|
||||
this.builtinParts["microservo"] = this.edgeConnectorState;
|
||||
|
||||
this.builtinVisuals["microservo"] = () => new visuals.MicroServoView();
|
||||
this.builtinPartVisuals["microservo"] = (xy: visuals.Coord) => visuals.mkMicroServoPart(xy);
|
||||
this.touchButtonState = new TouchButtonState([
|
||||
pxsim.CPlayPinName.A1,
|
||||
pxsim.CPlayPinName.A2,
|
||||
pxsim.CPlayPinName.A3,
|
||||
pxsim.CPlayPinName.A4,
|
||||
pxsim.CPlayPinName.A5,
|
||||
pxsim.CPlayPinName.A6,
|
||||
pxsim.CPlayPinName.A7
|
||||
]);
|
||||
|
||||
this.builtinParts["ir"] = this.irState = new InfraredState();*/
|
||||
this.outputState = new EV3OutputState();
|
||||
this.analogState = new EV3AnalogState();
|
||||
this.uartState = new EV3UArtState();
|
||||
this.motorState = new EV3MotorState();
|
||||
this.screenState = new EV3ScreenState();
|
||||
this.audioState = new AudioState();
|
||||
}
|
||||
|
||||
receiveMessage(msg: SimulatorMessage) {
|
||||
@ -182,11 +134,45 @@ namespace pxsim {
|
||||
getDefaultPitchPin() {
|
||||
return this.edgeConnectorState.getPin(CPlayPinName.D6);
|
||||
}
|
||||
|
||||
getBrickNode() {
|
||||
return this.brickNode;
|
||||
}
|
||||
|
||||
getMotor(port: number, large?: boolean): MotorNode[] {
|
||||
if (port == 0xFF) return this.getMotors(); // Return all motors
|
||||
const motorPort = this.motorMap[port];
|
||||
if (this.outputNodes[motorPort] == undefined) {
|
||||
this.outputNodes[motorPort] = large ?
|
||||
new LargeMotorNode(motorPort) : new MediumMotorNode(motorPort);
|
||||
}
|
||||
return [this.outputNodes[motorPort]];
|
||||
}
|
||||
|
||||
getMotors() {
|
||||
return this.outputNodes;
|
||||
}
|
||||
|
||||
getSensor(port: number, type: number): SensorNode {
|
||||
if (this.inputNodes[port] == undefined) {
|
||||
switch (type) {
|
||||
case DAL.DEVICE_TYPE_GYRO: this.inputNodes[port] = new GyroSensorNode(port); break;
|
||||
case DAL.DEVICE_TYPE_COLOR: this.inputNodes[port] = new ColorSensorNode(port); break;
|
||||
case DAL.DEVICE_TYPE_TOUCH: this.inputNodes[port] = new TouchSensorNode(port); break;
|
||||
case DAL.DEVICE_TYPE_ULTRASONIC: this.inputNodes[port] = new UltrasonicSensorNode(port); break;
|
||||
}
|
||||
}
|
||||
return this.inputNodes[port];
|
||||
}
|
||||
|
||||
getInputNodes() {
|
||||
return this.inputNodes;
|
||||
}
|
||||
}
|
||||
|
||||
export function initRuntimeWithDalBoard() {
|
||||
U.assert(!runtime.board);
|
||||
let b = new DalBoard();
|
||||
let b = new EV3Board();
|
||||
runtime.board = b;
|
||||
runtime.postError = (e) => {
|
||||
// TODO
|
||||
@ -194,6 +180,10 @@ namespace pxsim {
|
||||
}
|
||||
}
|
||||
|
||||
export function ev3board(): EV3Board {
|
||||
return runtime.board as EV3Board;
|
||||
}
|
||||
|
||||
if (!pxsim.initCurrentRuntime) {
|
||||
pxsim.initCurrentRuntime = initRuntimeWithDalBoard;
|
||||
}
|
||||
|
@ -1,92 +0,0 @@
|
||||
/// <reference path="../node_modules/pxt-core/typings/globals/bluebird/index.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtrunner.d.ts"/>
|
||||
|
||||
//HACK: allows instructions.html to access pxtblocks without requiring simulator.html to import blocks as well
|
||||
if (!(<any>window).pxt) (<any>window).pxt = {};
|
||||
import pxtrunner = pxt.runner;
|
||||
import pxtdocs = pxt.docs;
|
||||
|
||||
namespace pxsim.instructions {
|
||||
export function drawInstructions() {
|
||||
pxsim.visuals.mkBoardView = (opts: pxsim.visuals.BoardViewOptions): pxsim.visuals.BoardView => {
|
||||
return new visuals.EV3BoardSvg({
|
||||
runtime: runtime,
|
||||
theme: visuals.randomTheme(),
|
||||
disableTilt: false,
|
||||
wireframe: opts.wireframe,
|
||||
});
|
||||
}
|
||||
|
||||
let getQsVal = parseQueryString();
|
||||
|
||||
//project name
|
||||
let name = getQsVal("name") || "Untitled";
|
||||
|
||||
// board def
|
||||
const boardDef = JSON.parse(getQsVal("board")) as pxsim.BoardDefinition;
|
||||
|
||||
//parts list
|
||||
let parts = (getQsVal("parts") || "").split(" ");
|
||||
parts.sort();
|
||||
|
||||
// parts definitions
|
||||
let partDefinitions = JSON.parse(getQsVal("partdefs") || "{}") as pxsim.Map<PartDefinition>
|
||||
|
||||
//fn args
|
||||
let fnArgs = JSON.parse((getQsVal("fnArgs") || "{}"));
|
||||
|
||||
//project code
|
||||
let tsCode = getQsVal("code");
|
||||
let tsPackage = getQsVal("package") || "";
|
||||
let codeSpinnerDiv = document.getElementById("proj-code-spinner");
|
||||
let codeContainerDiv = document.getElementById("proj-code-container");
|
||||
if (tsCode) {
|
||||
//we use the docs renderer to decompile the code to blocks and render it
|
||||
//TODO: render the blocks code directly
|
||||
let md =
|
||||
`\`\`\`blocks
|
||||
${tsCode}
|
||||
\`\`\`
|
||||
\`\`\`package
|
||||
${tsPackage}
|
||||
\`\`\`
|
||||
`
|
||||
|
||||
pxtdocs.requireMarked = function () { return (<any>window).marked; }
|
||||
pxtrunner.renderMarkdownAsync(codeContainerDiv, md)
|
||||
.done(function () {
|
||||
let codeSvg = $("#proj-code-container svg");
|
||||
if (codeSvg.length > 0) {
|
||||
//code rendered successfully as blocks
|
||||
codeSvg.css("width", "inherit");
|
||||
codeSvg.css("height", "inherit");
|
||||
//takes the svg out of the wrapper markdown
|
||||
codeContainerDiv.innerHTML = "";
|
||||
codeContainerDiv.appendChild(codeSvg[0]);
|
||||
} else {
|
||||
//code failed to convert to blocks, display as typescript instead
|
||||
codeContainerDiv.innerText = tsCode;
|
||||
}
|
||||
$(codeContainerDiv).show();
|
||||
$(codeSpinnerDiv).hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (name)
|
||||
$("#proj-title").text(name);
|
||||
|
||||
//init runtime
|
||||
if (!pxsim.initCurrentRuntime)
|
||||
pxsim.initCurrentRuntime = initRuntimeWithDalBoard;
|
||||
|
||||
renderParts({
|
||||
name,
|
||||
boardDef,
|
||||
parts,
|
||||
partDefinitions,
|
||||
fnArgs
|
||||
})
|
||||
}
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en" data-framework="typescript">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Assembly Instructions</title>
|
||||
<style>
|
||||
|
||||
svg {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.blocklyText, .ace_editor {
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace !important;
|
||||
}
|
||||
|
||||
.blocklyText, .ace_editor {
|
||||
font-size: 1rem !important;
|
||||
}
|
||||
|
||||
.blocklyTreeLabel {
|
||||
font-size: 1.25rem !important;
|
||||
}
|
||||
|
||||
.blocklyCheckbox {
|
||||
fill: #ff3030 !important;
|
||||
text-shadow: 0px 0px 6px #f00;
|
||||
font-size: 17pt !important;
|
||||
}
|
||||
|
||||
.ui.card .blocklyPreview {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: calc(100% - 1em);
|
||||
max-height: calc(100% - 1em);
|
||||
}
|
||||
|
||||
code {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
code.lang-config, code.lang-package { display:none; }
|
||||
|
||||
code.lang-blocks::before,
|
||||
code.lang-sig::before,
|
||||
code.lang-block::before,
|
||||
code.lang-shuffle::before,
|
||||
code.lang-sim::before,
|
||||
code.lang-cards::before,
|
||||
code.lang-namespaces::before,
|
||||
code.lang-codecard::before {
|
||||
content: "...";
|
||||
position: absolute;
|
||||
top: calc(50% - 0.5em);
|
||||
left: calc(50% - 5em);
|
||||
}
|
||||
|
||||
code.lang-blocks,
|
||||
code.lang-sig,
|
||||
code.lang-block,
|
||||
code.lang-shuffle,
|
||||
code.lang-sim,
|
||||
code.lang-cards,
|
||||
code.lang-namespaces,
|
||||
code.lang-codecard {
|
||||
color: transparent;
|
||||
}
|
||||
</style>
|
||||
<style type="text/css">
|
||||
@import "/cdn/semantic.css";
|
||||
@import "/cdn/icons.css";
|
||||
</style>
|
||||
<style>
|
||||
html {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: "Lucida Console", Monaco, monospace;
|
||||
}
|
||||
|
||||
div {
|
||||
/*undo semantic UI*/
|
||||
box-sizing: content-box;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
/*TODO: Share CSS with main webpage*/
|
||||
|
||||
.organization {
|
||||
position: absolute;
|
||||
bottom: 2rem;
|
||||
right: 2rem;
|
||||
height: 4rem;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
font-weight: normal;
|
||||
color: rgba(0, 0, 0, 0.87);
|
||||
font-family: 'Segoe UI', 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#front-panel .board-svg {
|
||||
position: absolute;
|
||||
left: 2rem;
|
||||
width: 300px;
|
||||
top: 16rem;
|
||||
}
|
||||
|
||||
#proj-title {
|
||||
width: 100%;
|
||||
font-size: 70px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#proj-code {
|
||||
width: 300px;
|
||||
height: 400px;
|
||||
position: absolute;
|
||||
right: 2rem;
|
||||
top: 16rem;
|
||||
}
|
||||
#proj-code-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 4px;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
}
|
||||
#proj-code-spinner {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.back-panel svg {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
left: inherit;
|
||||
bottom: -7px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='loading' class="ui active inverted dimmer">
|
||||
<div class="ui large loader"></div>
|
||||
</div>
|
||||
<script>
|
||||
// This line gets patched up by the cloud
|
||||
var pxtConfig = null;
|
||||
</script>
|
||||
<script type="text/javascript" src="/cdn/lzma/lzma_worker-min.js"></script>
|
||||
<script type="text/javascript" src="/cdn/marked/marked.min.js"></script>
|
||||
<script type="text/javascript" src="/cdn/jquery.js"></script>
|
||||
<script type="text/javascript" src="/cdn/typescript.js"></script>
|
||||
<script type="text/javascript" src="/cdn/blockly/blockly_compressed.js"></script>
|
||||
<script type="text/javascript" src="/cdn/blockly/blocks_compressed.js"></script>
|
||||
<script type="text/javascript" src="/cdn/blockly/msg/js/en.js"></script>
|
||||
<script type="text/javascript" src="/cdn/pxtlib.js"></script>
|
||||
<script type="text/javascript" src="/cdn/pxtblocks.js"></script>
|
||||
<script type="text/javascript" src="/cdn/pxtsim.js"></script>
|
||||
<script type="text/javascript" src="/cdn/pxtrunner.js"></script>
|
||||
<script type="text/javascript" src="/cdn/semantic.js"></script>
|
||||
<script type="text/javascript" src="/embed.js"></script>
|
||||
<script type="text/javascript" src="/sim/common-sim.js"></script>
|
||||
<script type="text/javascript" src="/sim/sim.js"></script>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
ksRunnerReady(function() {
|
||||
var orgLogo = pxt.appTarget.appTheme.organizationLogo;
|
||||
if (orgLogo)
|
||||
$('#front-panel').append(
|
||||
$('<img/>').attr('class', 'organization').attr('src', orgLogo)
|
||||
);
|
||||
var loading = document.getElementById('loading');
|
||||
pxsim.instructions.drawInstructions();
|
||||
$(loading).hide();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
<div id="front-panel" class="instr-panel">
|
||||
<h1 id="proj-title"></h1>
|
||||
|
||||
<!--TODO: extract real code snapshot from PXT -->
|
||||
<div id="proj-code">
|
||||
<i id="proj-code-spinner" class="spinner loading icon"></i>
|
||||
<div id="proj-code-container">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
68
sim/state/analog.ts
Normal file
@ -0,0 +1,68 @@
|
||||
namespace pxsim {
|
||||
|
||||
enum AnalogOff {
|
||||
InPin1 = 0, // int16[4]
|
||||
InPin6 = 8, // int16[4]
|
||||
OutPin5 = 16, // int16[4]
|
||||
BatteryTemp = 24, // int16
|
||||
MotorCurrent = 26, // int16
|
||||
BatteryCurrent = 28, // int16
|
||||
Cell123456 = 30, // int16
|
||||
Pin1 = 32, // int16[300][4]
|
||||
Pin6 = 2432, // int16[300][4]
|
||||
Actual = 4832, // uint16[4]
|
||||
LogIn = 4840, // uint16[4]
|
||||
LogOut = 4848, // uint16[4]
|
||||
NxtCol = 4856, // uint16[36][4] - NxtColor*4
|
||||
OutPin5Low = 5144, // int16[4]
|
||||
Updated = 5152, // int8[4]
|
||||
InDcm = 5156, // int8[4]
|
||||
InConn = 5160, // int8[4]
|
||||
OutDcm = 5164, // int8[4]
|
||||
OutConn = 5168, // int8[4]
|
||||
Size = 5172
|
||||
}
|
||||
|
||||
export class EV3AnalogState {
|
||||
|
||||
constructor() {
|
||||
let data = new Uint8Array(5172)
|
||||
MMapMethods.register("/dev/lms_analog", {
|
||||
data,
|
||||
beforeMemRead: () => {
|
||||
//console.log("analog before read");
|
||||
const inputNodes = ev3board().getInputNodes();
|
||||
for (let port = 0; port < DAL.NUM_INPUTS; port++) {
|
||||
const node = inputNodes[port];
|
||||
if (node) {
|
||||
data[AnalogOff.InConn + port] = node.isUart() ? DAL.CONN_INPUT_UART : DAL.CONN_INPUT_DUMB;
|
||||
if (node.isAnalog() && node.hasData()) {
|
||||
//data[AnalogOff.InPin6 + 2 * port] = node.getValue();
|
||||
util.map16Bit(data, AnalogOff.InPin6 + 2 * port, Math.floor(node.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
read: buf => {
|
||||
let v = "vSIM"
|
||||
for (let i = 0; i < buf.data.length; ++i)
|
||||
buf.data[i] = v.charCodeAt(i) || 0
|
||||
console.log("analog read");
|
||||
console.log(buf.data);
|
||||
return buf.data.length
|
||||
},
|
||||
write: buf => {
|
||||
console.log("analog write");
|
||||
console.log(buf);
|
||||
return 2
|
||||
},
|
||||
ioctl: (id, buf) => {
|
||||
console.log("analog ioctl");
|
||||
console.log(id);
|
||||
console.log(buf);
|
||||
return 2;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
27
sim/state/brick.ts
Normal file
@ -0,0 +1,27 @@
|
||||
/// <reference path="./nodeTypes.ts"/>
|
||||
|
||||
namespace pxsim {
|
||||
|
||||
export class PortNode extends BaseNode {
|
||||
id = NodeType.Port;
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BrickNode extends BaseNode {
|
||||
id = NodeType.Brick;
|
||||
|
||||
buttonState: EV3ButtonState;
|
||||
lightState: EV3LightState;
|
||||
|
||||
constructor() {
|
||||
super(-1);
|
||||
|
||||
this.buttonState = new EV3ButtonState();
|
||||
this.lightState = new EV3LightState();
|
||||
}
|
||||
}
|
||||
}
|
46
sim/state/color.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/// <reference path="./sensor.ts"/>
|
||||
|
||||
namespace pxsim {
|
||||
|
||||
export enum ColorSensorMode {
|
||||
Reflected = 0,
|
||||
Ambient = 1,
|
||||
Colors = 2,
|
||||
RefRaw = 3,
|
||||
RgbRaw = 4,
|
||||
ColorCal = 5
|
||||
}
|
||||
|
||||
export enum ThresholdState {
|
||||
Normal = 1,
|
||||
High = 2,
|
||||
Low = 3,
|
||||
}
|
||||
|
||||
export class ColorSensorNode extends UartSensorNode {
|
||||
id = NodeType.ColorSensor;
|
||||
|
||||
private color: number;
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
getDeviceType() {
|
||||
return DAL.DEVICE_TYPE_COLOR;
|
||||
}
|
||||
|
||||
setColor(color: number) {
|
||||
this.color = color;
|
||||
this.changed = true;
|
||||
this.valueChanged = true;
|
||||
|
||||
runtime.queueDisplayUpdate();
|
||||
|
||||
}
|
||||
|
||||
getValue() {
|
||||
return this.color;
|
||||
}
|
||||
}
|
||||
}
|
@ -63,7 +63,6 @@ namespace pxsim.MMapMethods {
|
||||
|
||||
export function write(m: MMap, data: Buffer): number {
|
||||
return m.impl.write(data)
|
||||
|
||||
}
|
||||
|
||||
export function read(m: MMap, data: Buffer): number {
|
||||
|
47
sim/state/gyro.ts
Normal file
@ -0,0 +1,47 @@
|
||||
namespace pxsim {
|
||||
const enum GyroSensorMode {
|
||||
None = -1,
|
||||
Angle = 0,
|
||||
Rate = 1,
|
||||
}
|
||||
|
||||
export class GyroSensorNode extends UartSensorNode {
|
||||
id = NodeType.GyroSensor;
|
||||
|
||||
private angle: number = 0;
|
||||
private rate: number = 0;
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
getDeviceType() {
|
||||
return DAL.DEVICE_TYPE_GYRO;
|
||||
}
|
||||
|
||||
setAngle(angle: number) {
|
||||
if (this.angle != angle) {
|
||||
this.angle = angle;
|
||||
this.changed = true;
|
||||
this.valueChanged = true;
|
||||
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
setRate(rate: number) {
|
||||
if (this.rate != rate) {
|
||||
this.rate = rate;
|
||||
this.changed = true;
|
||||
this.valueChanged = true;
|
||||
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
getValue() {
|
||||
return this.mode == GyroSensorMode.Angle ? this.angle :
|
||||
this.mode == GyroSensorMode.Rate ? this.rate : 0;
|
||||
}
|
||||
}
|
||||
}
|
18
sim/state/input.ts
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
namespace pxsim.motors {
|
||||
|
||||
export function __motorUsed(port: number, large: boolean) {
|
||||
console.log("MOTOR INIT " + port);
|
||||
const motors = ev3board().getMotor(port, large);
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.sensors {
|
||||
|
||||
export function __sensorUsed(port: number, type: number) {
|
||||
console.log("SENSOR INIT " + port + ", type: " + type);
|
||||
const sensor = ev3board().getSensor(port, type);
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ namespace pxsim {
|
||||
namespace pxsim.output {
|
||||
|
||||
export function setLights(pattern: number) {
|
||||
const lightState = (board() as DalBoard).lightState;
|
||||
const lightState = ev3board().getBrickNode().lightState;
|
||||
lightState.lightPattern = pattern;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
|
49
sim/state/motor.ts
Normal file
@ -0,0 +1,49 @@
|
||||
namespace pxsim {
|
||||
|
||||
enum MotorDataOff {
|
||||
TachoCounts = 0, // int32
|
||||
Speed = 4, // int8
|
||||
Padding = 5, // int8[3]
|
||||
TachoSensor = 8, // int32
|
||||
Size = 12
|
||||
}
|
||||
|
||||
export class EV3MotorState {
|
||||
|
||||
constructor() {
|
||||
let data = new Uint8Array(12 * DAL.NUM_OUTPUTS)
|
||||
MMapMethods.register("/dev/lms_motor", {
|
||||
data,
|
||||
beforeMemRead: () => {
|
||||
console.log("motor before read");
|
||||
for (let port = 0; port < DAL.NUM_OUTPUTS; ++port) {
|
||||
data[MotorDataOff.TachoCounts * port] = 0; // Tacho count
|
||||
data[MotorDataOff.Speed * port] = 50; // Speed
|
||||
data[MotorDataOff.TachoSensor * port] = 0; // Count
|
||||
}
|
||||
},
|
||||
read: buf => {
|
||||
let v = "vSIM"
|
||||
for (let i = 0; i < buf.data.length; ++i)
|
||||
buf.data[i] = v.charCodeAt(i) || 0
|
||||
console.log("motor read");
|
||||
console.log(buf.data);
|
||||
return buf.data.length
|
||||
},
|
||||
write: buf => {
|
||||
if (buf.data.length == 0) return 2;
|
||||
const cmd = buf.data[0];
|
||||
console.log("motor write");
|
||||
console.log(buf);
|
||||
return 2
|
||||
},
|
||||
ioctl: (id, buf) => {
|
||||
console.log("motor ioctl");
|
||||
console.log(id);
|
||||
console.log(buf);
|
||||
return 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
73
sim/state/motors.ts
Normal file
@ -0,0 +1,73 @@
|
||||
namespace pxsim {
|
||||
|
||||
export class MotorNode extends BaseNode {
|
||||
isOutput = true;
|
||||
|
||||
public angle: number = 0;
|
||||
|
||||
private speed: number;
|
||||
private large: boolean;
|
||||
private rotation: number;
|
||||
private polarity: boolean;
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
setSpeed(speed: number) {
|
||||
if (this.speed != speed) {
|
||||
this.speed = speed;
|
||||
this.changed = true;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
setLarge(large: boolean) {
|
||||
this.large = large;
|
||||
}
|
||||
|
||||
getSpeed() {
|
||||
return this.speed;
|
||||
}
|
||||
|
||||
stepSpeed(speed: number, angle: number, brake: boolean) {
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
setPolarity(polarity: number) {
|
||||
// Either 1 or 255 (reverse)
|
||||
this.polarity = polarity === 255;
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
reset() {
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
stop() {
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
start() {
|
||||
// TODO: implement
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
export class MediumMotorNode extends MotorNode {
|
||||
id = NodeType.MediumMotor;
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
}
|
||||
|
||||
export class LargeMotorNode extends MotorNode {
|
||||
id = NodeType.LargeMotor;
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
36
sim/state/nodeTypes.ts
Normal file
@ -0,0 +1,36 @@
|
||||
namespace pxsim {
|
||||
export enum NodeType {
|
||||
Port = 0,
|
||||
Brick = 1,
|
||||
TouchSensor = 2,
|
||||
MediumMotor = 3,
|
||||
LargeMotor = 4,
|
||||
GyroSensor = 5,
|
||||
ColorSensor = 6,
|
||||
UltrasonicSensor = 7
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
id: number;
|
||||
didChange(): boolean;
|
||||
}
|
||||
|
||||
export class BaseNode implements Node {
|
||||
public id: number;
|
||||
public port: number;
|
||||
public isOutput = false;
|
||||
|
||||
private used = false;
|
||||
protected changed = true;
|
||||
|
||||
constructor(port: number) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
didChange() {
|
||||
const res = this.changed;
|
||||
this.changed = false;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
104
sim/state/output.ts
Normal file
@ -0,0 +1,104 @@
|
||||
namespace pxsim {
|
||||
|
||||
export class EV3OutputState {
|
||||
|
||||
constructor() {
|
||||
let data = new Uint8Array(10)
|
||||
MMapMethods.register("/dev/lms_pwm", {
|
||||
data,
|
||||
beforeMemRead: () => {
|
||||
//console.log("pwm before read");
|
||||
for (let i = 0; i < 10; ++i)
|
||||
data[i] = 0
|
||||
},
|
||||
read: buf => {
|
||||
let v = "vSIM"
|
||||
for (let i = 0; i < buf.data.length; ++i)
|
||||
buf.data[i] = v.charCodeAt(i) || 0
|
||||
console.log("pwm read");
|
||||
return buf.data.length
|
||||
},
|
||||
write: buf => {
|
||||
if (buf.data.length == 0) return 2;
|
||||
const cmd = buf.data[0];
|
||||
switch (cmd) {
|
||||
case DAL.opProgramStart: {
|
||||
// init
|
||||
console.log('init');
|
||||
return 2;
|
||||
}
|
||||
case DAL.opOutputReset: {
|
||||
// reset
|
||||
const port = buf.data[1];
|
||||
const motors = ev3board().getMotor(port);
|
||||
motors.forEach(motor => motor.reset());
|
||||
return 2;
|
||||
}
|
||||
case DAL.opOutputStepSpeed: {
|
||||
// step speed
|
||||
const port = buf.data[1];
|
||||
const speed = buf.data[2];
|
||||
// note that b[3] is padding
|
||||
const step1 = buf.data[4];
|
||||
const step2 = buf.data[5]; // angle
|
||||
const step3 = buf.data[6];
|
||||
const brake = buf.data[7];
|
||||
//console.log(buf);
|
||||
const motors = ev3board().getMotor(port);
|
||||
motors.forEach(motor => motor.stepSpeed(speed, step2, brake === 1));
|
||||
return 2;
|
||||
}
|
||||
case DAL.opOutputStop: {
|
||||
// stop
|
||||
const port = buf.data[1];
|
||||
const brake = buf.data[2];
|
||||
const motors = ev3board().getMotor(port);
|
||||
motors.forEach(motor => motor.stop());
|
||||
return 2;
|
||||
}
|
||||
case DAL.opOutputSpeed: {
|
||||
// setSpeed
|
||||
const port = buf.data[1];
|
||||
const speed = buf.data[2];
|
||||
const motors = ev3board().getMotor(port);
|
||||
motors.forEach(motor => motor.setSpeed(speed));
|
||||
return 2;
|
||||
}
|
||||
case DAL.opOutputStart: {
|
||||
// start
|
||||
const port = buf.data[1];
|
||||
const motors = ev3board().getMotor(port);
|
||||
motors.forEach(motor => motor.start());
|
||||
return 2;
|
||||
}
|
||||
case DAL.opOutputPolarity: {
|
||||
// reverse
|
||||
const port = buf.data[1];
|
||||
const polarity = buf.data[2];
|
||||
const motors = ev3board().getMotor(port);
|
||||
motors.forEach(motor => motor.setPolarity(polarity));
|
||||
return 2;
|
||||
}
|
||||
case DAL.opOutputSetType: {
|
||||
const port = buf.data[1];
|
||||
const large = buf.data[2] == 0x07;
|
||||
const motors = ev3board().getMotor(port);
|
||||
motors.forEach(motor => motor.setLarge(large));
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
console.log("pwm write");
|
||||
console.log(buf);
|
||||
return 2
|
||||
},
|
||||
ioctl: (id, buf) => {
|
||||
console.log("pwm ioctl");
|
||||
console.log(id);
|
||||
console.log(buf);
|
||||
return 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ namespace pxsim {
|
||||
|
||||
|
||||
export class EV3ScreenState {
|
||||
shouldUpdate: boolean;
|
||||
points: Uint8Array;
|
||||
constructor() {
|
||||
this.points = new Uint8Array(visuals.SCREEN_WIDTH * visuals.SCREEN_HEIGHT)
|
||||
@ -24,12 +23,13 @@ namespace pxsim {
|
||||
|
||||
setPixel(x: number, y: number, v: number) {
|
||||
this.applyMode(OFF(x, y), v)
|
||||
this.shouldUpdate = true;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
|
||||
clear() {
|
||||
for (let i = 0; i < this.points.length; ++i)
|
||||
this.points[i] = 0;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
|
||||
blitLineCore(x: number, y: number, w: number, buf: RefBuffer, mode: Draw, offset = 0) {
|
||||
@ -58,7 +58,7 @@ namespace pxsim {
|
||||
}
|
||||
}
|
||||
|
||||
this.shouldUpdate = true;
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
|
||||
clearLine(x: number, y: number, w: number) {
|
||||
@ -81,12 +81,12 @@ namespace pxsim.screen {
|
||||
function YY(v: number) { return v >> 16 }
|
||||
|
||||
export function _setPixel(x: number, y: number, mode: Draw) {
|
||||
const screenState = (board() as DalBoard).screenState;
|
||||
const screenState = ev3board().screenState;
|
||||
screenState.setPixel(x, y, mode);
|
||||
}
|
||||
|
||||
export function _blitLine(xw: number, y: number, buf: RefBuffer, mode: Draw) {
|
||||
const screenState = (board() as DalBoard).screenState;
|
||||
const screenState = ev3board().screenState;
|
||||
screenState.blitLineCore(XX(xw), y, YY(xw), buf, mode)
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ namespace pxsim.screen {
|
||||
return ((x + 7) >> 3)
|
||||
}
|
||||
export function clear(): void {
|
||||
const screenState = (board() as DalBoard).screenState;
|
||||
const screenState = ev3board().screenState;
|
||||
screenState.clear()
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ namespace pxsim.ImageMethods {
|
||||
}
|
||||
|
||||
export function draw(buf: RefBuffer, x: number, y: number, mode: Draw): void {
|
||||
const screenState = (board() as DalBoard).screenState;
|
||||
const screenState = ev3board().screenState;
|
||||
|
||||
if (!screen.isValidImage(buf))
|
||||
return;
|
||||
|
73
sim/state/sensor.ts
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
namespace pxsim {
|
||||
|
||||
export class SensorNode extends BaseNode {
|
||||
|
||||
protected mode: number;
|
||||
protected valueChanged: boolean;
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
public isUart() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public isAnalog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getValue() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
setMode(mode: number) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
getMode() {
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
getDeviceType() {
|
||||
return DAL.DEVICE_TYPE_NONE;
|
||||
}
|
||||
|
||||
public hasData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
valueChange() {
|
||||
const res = this.valueChanged;
|
||||
this.valueChanged = false;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
export class AnalogSensorNode extends SensorNode {
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
public isUart() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public isAnalog() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class UartSensorNode extends SensorNode {
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
hasChanged() {
|
||||
return this.changed;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,9 +3,16 @@ namespace pxsim.music {
|
||||
export function fromWAV(buf: RefBuffer) {
|
||||
return incr(buf)
|
||||
}
|
||||
|
||||
export function stopAllSounds() {
|
||||
SoundMethods.stop()
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.SoundMethods {
|
||||
let numSoundsPlaying = 0;
|
||||
const soundsLimit = 1;
|
||||
let audio: HTMLAudioElement;
|
||||
|
||||
export function buffer(buf: RefBuffer) {
|
||||
return incr(buf)
|
||||
@ -20,14 +27,29 @@ namespace pxsim.SoundMethods {
|
||||
}
|
||||
|
||||
export function play(buf: RefBuffer, volume: number) {
|
||||
if (!buf || numSoundsPlaying >= soundsLimit) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return new Promise<void>(resolve => {
|
||||
let url = "data:audio/wav;base64," + btoa(uint8ArrayToString(buf.data))
|
||||
let audio = new Audio(url)
|
||||
audio = new Audio(url)
|
||||
audio.onended = () => {
|
||||
resolve()
|
||||
resolve();
|
||||
numSoundsPlaying--;
|
||||
}
|
||||
numSoundsPlaying++;
|
||||
audio.play()
|
||||
})
|
||||
}
|
||||
|
||||
export function stop() {
|
||||
return new Promise<void>(resolve => {
|
||||
if (audio) {
|
||||
audio.pause();
|
||||
numSoundsPlaying--;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
42
sim/state/touch.ts
Normal file
@ -0,0 +1,42 @@
|
||||
namespace pxsim {
|
||||
|
||||
export const TOUCH_SENSOR_ANALOG_PRESSED = 2600;
|
||||
|
||||
export class TouchSensorNode extends AnalogSensorNode {
|
||||
id = NodeType.TouchSensor;
|
||||
|
||||
private pressed: boolean[];
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
this.pressed = [];
|
||||
}
|
||||
|
||||
public setPressed(pressed: boolean) {
|
||||
this.pressed.push(pressed);
|
||||
this.changed = true;
|
||||
this.valueChanged = true;
|
||||
}
|
||||
|
||||
public isPressed() {
|
||||
return this.pressed;
|
||||
}
|
||||
|
||||
public getValue() {
|
||||
if (this.pressed.length) {
|
||||
if (this.pressed.pop())
|
||||
return TOUCH_SENSOR_ANALOG_PRESSED;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
getDeviceType() {
|
||||
return DAL.DEVICE_TYPE_TOUCH;
|
||||
}
|
||||
|
||||
public hasData() {
|
||||
return this.pressed.length > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
156
sim/state/uart.ts
Normal file
@ -0,0 +1,156 @@
|
||||
namespace pxsim {
|
||||
|
||||
enum UartOff {
|
||||
TypeData = 0, // Types[8][4]
|
||||
Repeat = 1792, // uint16[300][4]
|
||||
Raw = 4192, // int8[32][300][4]
|
||||
Actual = 42592, // uint16[4]
|
||||
LogIn = 42600, // uint16[4]
|
||||
Status = 42608, // int8[4]
|
||||
Output = 42612, // int8[32][4]
|
||||
OutputLength = 42740, // int8[4]
|
||||
Size = 42744
|
||||
}
|
||||
|
||||
enum UartStatus {
|
||||
UART_PORT_CHANGED = 1,
|
||||
UART_DATA_READY = 8
|
||||
}
|
||||
|
||||
enum IO {
|
||||
UART_SET_CONN = 0xc00c7500,
|
||||
UART_READ_MODE_INFO = 0xc03c7501,
|
||||
UART_NACK_MODE_INFO = 0xc03c7502,
|
||||
UART_CLEAR_CHANGED = 0xc03c7503,
|
||||
IIC_SET_CONN = 0xc00c6902,
|
||||
IIC_READ_TYPE_INFO = 0xc03c6903,
|
||||
IIC_SETUP = 0xc04c6905,
|
||||
IIC_SET = 0xc02c6906,
|
||||
TST_PIN_ON = 0xc00b7401,
|
||||
TST_PIN_OFF = 0xc00b7402,
|
||||
TST_PIN_READ = 0xc00b7403,
|
||||
TST_PIN_WRITE = 0xc00b7404,
|
||||
TST_UART_ON = 0xc0487405,
|
||||
TST_UART_OFF = 0xc0487406,
|
||||
TST_UART_EN = 0xc0487407,
|
||||
TST_UART_DIS = 0xc0487408,
|
||||
TST_UART_READ = 0xc0487409,
|
||||
TST_UART_WRITE = 0xc048740a,
|
||||
}
|
||||
|
||||
|
||||
enum DevConOff {
|
||||
Connection = 0, // int8[4]
|
||||
Type = 4, // int8[4]
|
||||
Mode = 8, // int8[4]
|
||||
Size = 12
|
||||
}
|
||||
|
||||
enum UartCtlOff {
|
||||
TypeData = 0, // Types
|
||||
Port = 56, // int8
|
||||
Mode = 57, // int8
|
||||
Size = 58
|
||||
}
|
||||
|
||||
enum TypesOff {
|
||||
Name = 0, // int8[12]
|
||||
Type = 12, // int8
|
||||
Connection = 13, // int8
|
||||
Mode = 14, // int8
|
||||
DataSets = 15, // int8
|
||||
Format = 16, // int8
|
||||
Figures = 17, // int8
|
||||
Decimals = 18, // int8
|
||||
Views = 19, // int8
|
||||
RawMin = 20, // float32
|
||||
RawMax = 24, // float32
|
||||
PctMin = 28, // float32
|
||||
PctMax = 32, // float32
|
||||
SiMin = 36, // float32
|
||||
SiMax = 40, // float32
|
||||
InvalidTime = 44, // uint16
|
||||
IdValue = 46, // uint16
|
||||
Pins = 48, // int8
|
||||
Symbol = 49, // int8[5]
|
||||
Align = 54, // uint16
|
||||
Size = 56
|
||||
}
|
||||
|
||||
export class EV3UArtState {
|
||||
|
||||
constructor() {
|
||||
let data = new Uint8Array(UartOff.Size);
|
||||
MMapMethods.register("/dev/lms_uart", {
|
||||
data,
|
||||
beforeMemRead: () => {
|
||||
//console.log("uart before read");
|
||||
const inputNodes = ev3board().getInputNodes();
|
||||
for (let port = 0; port < DAL.NUM_INPUTS; port++) {
|
||||
const node = inputNodes[port];
|
||||
if (node) {
|
||||
// Actual
|
||||
const index = 0; //UartOff.Actual + port * 2;
|
||||
util.map16Bit(data, UartOff.Raw + DAL.MAX_DEVICE_DATALENGTH * 300 * port + DAL.MAX_DEVICE_DATALENGTH * index, Math.floor(node.getValue()))
|
||||
// Status
|
||||
data[UartOff.Status + port] = node.valueChange() ? UartStatus.UART_PORT_CHANGED : UartStatus.UART_DATA_READY;
|
||||
}
|
||||
}
|
||||
},
|
||||
read: buf => {
|
||||
let v = "vSIM"
|
||||
// for (let i = 0; i < buf.data.length; ++i)
|
||||
// buf.data[i] = v.charCodeAt(i) || 0
|
||||
console.log("uart read");
|
||||
console.log(buf.data);
|
||||
return buf.data.length
|
||||
},
|
||||
write: buf => {
|
||||
console.log("uart write");
|
||||
console.log(buf);
|
||||
return 2
|
||||
},
|
||||
ioctl: (id, buf) => {
|
||||
switch (id) {
|
||||
case IO.UART_SET_CONN: {
|
||||
// Set mode
|
||||
console.log("IO.UART_SET_CONN");
|
||||
for (let port = 0; port < DAL.NUM_INPUTS; port++) {
|
||||
const connection = buf.data[DevConOff.Connection + port]; // CONN_NONE, CONN_INPUT_UART
|
||||
const type = buf.data[DevConOff.Type + port];
|
||||
const mode = buf.data[DevConOff.Mode + port];
|
||||
console.log(`${port}, mode: ${mode}`)
|
||||
const node = ev3board().getInputNodes()[port];
|
||||
if (node) node.setMode(mode);
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
case IO.UART_CLEAR_CHANGED: {
|
||||
console.log("IO.UART_CLEAR_CHANGED")
|
||||
for (let port = 0; port < DAL.NUM_INPUTS; port++) {
|
||||
const connection = buf.data[DevConOff.Connection + port]; // CONN_NONE, CONN_INPUT_UART
|
||||
const type = buf.data[DevConOff.Type + port];
|
||||
const mode = buf.data[DevConOff.Mode + port];
|
||||
const node = ev3board().getInputNodes()[port];
|
||||
if (node) node.setMode(mode);
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
case IO.UART_READ_MODE_INFO: {
|
||||
console.log("IO.UART_READ_MODE_INFO")
|
||||
const port = buf.data[UartCtlOff.Port];
|
||||
const mode = buf.data[UartCtlOff.Mode];
|
||||
const node = ev3board().getInputNodes()[port];
|
||||
if (node) buf.data[UartCtlOff.TypeData + TypesOff.Type] = node.getDeviceType(); // DEVICE_TYPE_NONE, DEVICE_TYPE_TOUCH,
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
console.log("uart ioctl");
|
||||
console.log(id);
|
||||
console.log(buf);
|
||||
return 2;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
31
sim/state/ultrasonic.ts
Normal file
@ -0,0 +1,31 @@
|
||||
/// <reference path="./sensor.ts"/>
|
||||
|
||||
namespace pxsim {
|
||||
export class UltrasonicSensorNode extends UartSensorNode {
|
||||
id = NodeType.UltrasonicSensor;
|
||||
|
||||
private distance: number = 127; // in cm
|
||||
|
||||
constructor(port: number) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
getDeviceType() {
|
||||
return DAL.DEVICE_TYPE_ULTRASONIC;
|
||||
}
|
||||
|
||||
setDistance(distance: number) {
|
||||
if (this.distance != distance) {
|
||||
this.distance = distance;
|
||||
this.changed = true;
|
||||
this.valueChanged = true;
|
||||
|
||||
runtime.queueDisplayUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
getValue() {
|
||||
return this.distance * 10; // convert to 0.1 cm
|
||||
}
|
||||
}
|
||||
}
|
7
sim/state/util.ts
Normal file
@ -0,0 +1,7 @@
|
||||
namespace pxsim.util {
|
||||
|
||||
export function map16Bit(buffer: Uint8Array, index: number, value: number) {
|
||||
buffer[index] = value & 0xFF;
|
||||
buffer[index + 1] = (value >> 8) & 0xFF;
|
||||
}
|
||||
}
|
@ -7,6 +7,9 @@
|
||||
"out": "../built/sim.js",
|
||||
"rootDir": ".",
|
||||
"newLine": "LF",
|
||||
"sourceMap": false
|
||||
"sourceMap": false,
|
||||
"lib": ["dom", "dom.iterable", "scripthost", "es6"],
|
||||
"types": ["jquery", "bluebird"],
|
||||
"typeRoots": ["../node_modules/@types"]
|
||||
}
|
||||
}
|
||||
|
32
sim/visuals/assets/Color Sensor.svg
Normal file
@ -0,0 +1,32 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 33.22 34">
|
||||
<defs>
|
||||
<linearGradient id="linear-gradient" x1="-448.15" y1="475.99" x2="-448.15" y2="475.83" gradientTransform="matrix(32.16, 0, 0, -33.37, 14429.08, 15914.64)" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#a8aaa8"/>
|
||||
<stop offset="1" stop-color="#535453"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<title>Color Sensor</title>
|
||||
<g style="isolation: isolate">
|
||||
<g id="svg41">
|
||||
<g id="color_box" data-name="color box">
|
||||
<g id="color_grey" data-name="color grey">
|
||||
<path id="color_sideboxes" data-name="color sideboxes" d="M2.14,9.19H34a.7.7,0,0,1,.7.7V28a.7.7,0,0,1-.7.7H2.14a.7.7,0,0,1-.7-.7V9.89A.7.7,0,0,1,2.14,9.19Z" transform="translate(-1.44 -1.6)" style="fill: #a8aaa8"/>
|
||||
<g id="color_bigbox-2" data-name="color bigbox-2">
|
||||
<image width="33" height="34" transform="translate(0.06)" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAjCAYAAADxG9hnAAAACXBIWXMAAAsSAAALEgHS3X78AAAAzUlEQVRYR+3YMU4DMRBG4W8Q5eYMUEMuw/3ScQDugkTPcoSsa4ZibYjcUMVQ+Ekjj+Tif7YrT2Sm/8BtayIisOCurtemYEXJzIzMFBEL7vGIJ7vMtVnxgje8q09zxAmvOONzQJ1r3gnH9jQLHuw3cmMMB3tewXIZGrVG8p056vS/MkV6pkjPFOmZIj1TpGeK9EyRninSM0V6pkjPFOmZIj2XIn81n0h+RAo+sNWNUbXV3NI+4Sueaz9iJNFouWu0iVFEHIwb0jQK1szcvgDqy2NNnOFs5AAAAABJRU5ErkJggg==" style="opacity: 0.30000000000000004;mix-blend-mode: multiply"/>
|
||||
<path d="M5,3.33h26c1,0,1.78.57,1.78,1.27V32.77c0,.7-.8,1.27-1.78,1.27H5c-1,0-1.78-.57-1.78-1.27V4.6C3.25,3.9,4.05,3.33,5,3.33Z" transform="translate(-1.44 -1.6)" style="fill: url(#linear-gradient)"/>
|
||||
</g>
|
||||
<rect id="color_side_black_4" data-name="color side black 4" x="31.83" y="10.38" width="0.7" height="5.58"/>
|
||||
<rect id="color_side_black_3" data-name="color side black 3" x="0.84" y="10.38" width="0.7" height="5.58"/>
|
||||
<rect id="color_side_black_2" data-name="color side black 2" x="31.83" y="18.34" width="0.7" height="5.58"/>
|
||||
<rect id="color_side_black1" data-name="color side black1" x="0.84" y="18.34" width="0.7" height="5.58"/>
|
||||
</g>
|
||||
<path id="color_red" data-name="color red" d="M11.63,23.43a6.32,6.32,0,0,1,.15-1.37,8.79,8.79,0,1,1,12.54,0,6.42,6.42,0,1,1-12.55,2.7,6.61,6.61,0,0,1-.15-1.33Z" transform="translate(-1.44 -1.6)" style="fill: #d42715"/>
|
||||
<path id="color_black" data-name="color black" d="M13.11,23.43a4.89,4.89,0,0,1,.34-1.81,7.4,7.4,0,1,1,10.4-1.2,7.32,7.32,0,0,1-1.18,1.18,5,5,0,1,1-9.56,1.83Z" transform="translate(-1.44 -1.6)"/>
|
||||
<g id="color_sensors" data-name="color sensors">
|
||||
<circle id="color_sensor_white_big" data-name="color sensor white big" cx="16.61" cy="14.43" r="3.35" style="fill: #f1f1f1"/>
|
||||
<circle id="color_sensor_white_small" data-name="color sensor white small" cx="16.61" cy="21.69" r="1.81" style="fill: #f1f1f1"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.9 KiB |