bringing back show ports (#377)
* bringing back show ports * added firmware links in docs * updated color rendering * better rendering of touch/ultra/ir * better data per sensor
This commit is contained in:
parent
89e1819399
commit
550528c695
@ -27,6 +27,12 @@ so it appears as a mounted drive (named **EV3**).
|
||||
Compilation to machine code from [Blocks](/blocks) or [JavaScript](/javascript) happens in the browser. You save the binary
|
||||
program to a **.uf2** file, which you then copy to the **EV3** drive, which flashes the device with the new program.
|
||||
|
||||
### ~ hint
|
||||
|
||||
Not seeing the **EV3** drive? Make sure to upgrade your firmware at https://ev3manager.education.lego.com/.
|
||||
|
||||
### ~
|
||||
|
||||
## Simulator: Test Your Code
|
||||
|
||||
You can run your code using the micro:bit simulator, all within the confines of a web browser.
|
||||
|
@ -96,6 +96,22 @@ namespace sensors {
|
||||
return 0
|
||||
}
|
||||
|
||||
_info(): string {
|
||||
switch (this.mode) {
|
||||
case ColorSensorMode.Color:
|
||||
return ["none",
|
||||
"black",
|
||||
"blue",
|
||||
"green",
|
||||
"yellow",
|
||||
"red",
|
||||
"white",
|
||||
"brown"][this._query()];
|
||||
default:
|
||||
return this._query().toString();
|
||||
}
|
||||
}
|
||||
|
||||
_update(prev: number, curr: number) {
|
||||
if (this.calibrating) return; // simply ignore data updates while calibrating
|
||||
if (this.mode == ColorSensorMode.Color)
|
||||
|
@ -177,6 +177,10 @@ namespace sensors.internal {
|
||||
return 0
|
||||
}
|
||||
|
||||
_info(): string {
|
||||
return this._query().toString();
|
||||
}
|
||||
|
||||
_update(prev: number, curr: number) {
|
||||
}
|
||||
|
||||
|
@ -161,6 +161,14 @@ namespace sensors {
|
||||
return 0
|
||||
}
|
||||
|
||||
_info(): string {
|
||||
if (this.mode == InfraredSensorMode.RemoteControl)
|
||||
return "remote";
|
||||
else if (this.mode == InfraredSensorMode.Proximity)
|
||||
return `${this._query()}%`;
|
||||
return "";
|
||||
}
|
||||
|
||||
_update(prev: number, curr: number) {
|
||||
if (this.mode == InfraredSensorMode.RemoteControl) {
|
||||
for (let i = 0; i < __remoteButtons.length; ++i) {
|
||||
|
@ -78,6 +78,43 @@ namespace brick {
|
||||
screen.drawImage(image, 0, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the sensor and motor states attached to ports
|
||||
*/
|
||||
//% blockId=brickShowPorts block="show ports"
|
||||
//% help=brick/show-ports blockGap=8
|
||||
//% weight=10 group="Screen"
|
||||
export function showPorts() {
|
||||
const col = 44;
|
||||
clearScreen();
|
||||
|
||||
function scale(x: number) {
|
||||
if (Math.abs(x) > 1000) return Math.round(x / 100) / 10 + "k";
|
||||
return ("" + (x >> 0));
|
||||
}
|
||||
|
||||
// motors
|
||||
const datas = motors.getAllMotorData();
|
||||
for (let i = 0; i < datas.length; ++i) {
|
||||
const data = datas[i];
|
||||
if (!data.actualSpeed && !data.count) continue;
|
||||
const x = i * col;
|
||||
screen.print("ABCD"[i], x, brick.LINE_HEIGHT)
|
||||
screen.print(`${scale(data.actualSpeed)}%`, x, 2* brick.LINE_HEIGHT)
|
||||
screen.print(`${scale(data.count)}>`, x, 3 * brick.LINE_HEIGHT)
|
||||
}
|
||||
|
||||
// sensors
|
||||
const sis = sensors.internal.getActiveSensors();
|
||||
for (let i = 0; i < sis.length; ++i) {
|
||||
const si = sis[i];
|
||||
const x = (si.port() - 1) * col;
|
||||
const inf = si._info();
|
||||
screen.print(si.port() + "", x, 8 * brick.LINE_HEIGHT)
|
||||
screen.print(inf, x, 9 * brick.LINE_HEIGHT)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An image
|
||||
* @param image the image
|
||||
@ -96,7 +133,7 @@ namespace brick {
|
||||
*/
|
||||
//% blockId=screen_clear_screen block="clear screen"
|
||||
//% weight=90 group="Screen"
|
||||
//% help=brick/clear-screen
|
||||
//% help=brick/clear-screen weight=1
|
||||
export function clearScreen() {
|
||||
screen.fill(0)
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ namespace sensors {
|
||||
return this._readPin6() > 2500 ? 1 : 0
|
||||
}
|
||||
|
||||
_info(): string {
|
||||
return this._query() ? "pres" : "rel";
|
||||
}
|
||||
|
||||
_update(prev: number, curr: number) {
|
||||
this.button._update(curr > 0)
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace sensors {
|
||||
super(port)
|
||||
this.promixityThreshold = new sensors.ThresholdDetector(this.id(), 0, 255, 10, 100); // range is 0..255cm
|
||||
this.movementThreshold = 1;
|
||||
this._setMode(0);
|
||||
}
|
||||
|
||||
_deviceType() {
|
||||
@ -28,6 +29,10 @@ namespace sensors {
|
||||
return ((this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff) / 10) >> 0; // range is 0..2550, in 0.1 cm increments.
|
||||
}
|
||||
|
||||
_info(): string {
|
||||
return `${this.distance()}cm`
|
||||
}
|
||||
|
||||
_update(prev: number, curr: number) {
|
||||
// is there an object near?
|
||||
this.promixityThreshold.setLevel(curr);
|
||||
@ -38,7 +43,7 @@ namespace sensors {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers code to run when the given color is close
|
||||
* Registers code to run when an object is close or far
|
||||
* @param handler the code to run when detected
|
||||
*/
|
||||
//% help=sensors/ultrasonic/on-event
|
||||
|
54
package-lock.json
generated
54
package-lock.json
generated
@ -3274,19 +3274,19 @@
|
||||
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
|
||||
},
|
||||
"pxt-common-packages": {
|
||||
"version": "0.19.4",
|
||||
"resolved": "https://registry.npmjs.org/pxt-common-packages/-/pxt-common-packages-0.19.4.tgz",
|
||||
"integrity": "sha512-sAccQrTh+LNuuDuQlkeuGaRu99+7iORfiREJV7eemqzr5yuspgA9aLif0FYFIPas37RD8Uoz+n36RxgsKZoLJg==",
|
||||
"version": "0.20.14",
|
||||
"resolved": "https://registry.npmjs.org/pxt-common-packages/-/pxt-common-packages-0.20.14.tgz",
|
||||
"integrity": "sha512-DlZIDfDSH5jGq5K4k+9QtALzcedT+lYBNnxUWrbAK/GOxkqXZxhwGGvi1O2p6eFOfCWBuH0kjBlui3dzxeF0LA==",
|
||||
"requires": {
|
||||
"autoprefixer": "6.7.7",
|
||||
"pxt-core": "3.4.3",
|
||||
"pxt-core": "3.5.11",
|
||||
"rtlcss": "2.2.1"
|
||||
}
|
||||
},
|
||||
"pxt-core": {
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.4.3.tgz",
|
||||
"integrity": "sha512-zsBf5/pf9B5vS4THqTQLOFodi+o0GtX2npvT3efF6Cql29dXtzVYKUAxSclzGCtNljI34dC++CLaaPfYfzMOnQ==",
|
||||
"version": "3.5.11",
|
||||
"resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.5.11.tgz",
|
||||
"integrity": "sha512-niFvx2PbvWqNPikB0uyR22Pnsc7ipOfWsB656KvnenK4lRNUMEFcxUg4B+65+NZZQypEHk5OxsD3nbE62749EA==",
|
||||
"requires": {
|
||||
"bluebird": "3.5.1",
|
||||
"browserify": "13.3.0",
|
||||
@ -3298,7 +3298,7 @@
|
||||
"lzma": "2.3.2",
|
||||
"marked": "0.3.12",
|
||||
"node-hid": "0.5.7",
|
||||
"postcss": "6.0.17",
|
||||
"postcss": "6.0.21",
|
||||
"request": "2.83.0",
|
||||
"rimraf": "2.5.4",
|
||||
"rtlcss": "2.2.1",
|
||||
@ -3307,21 +3307,21 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-styles": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
|
||||
"integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==",
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
||||
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
|
||||
"requires": {
|
||||
"color-convert": "1.9.1"
|
||||
}
|
||||
},
|
||||
"chalk": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz",
|
||||
"integrity": "sha512-QUU4ofkDoMIVO7hcx1iPTISs88wsO8jA92RQIm4JAwZvFGGAV2hSAA1NX7oVj2Ej2Q6NDTcRDjPTFrMCRZoJ6g==",
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz",
|
||||
"integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==",
|
||||
"requires": {
|
||||
"ansi-styles": "3.2.0",
|
||||
"ansi-styles": "3.2.1",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"supports-color": "5.2.0"
|
||||
"supports-color": "5.3.0"
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
@ -3330,13 +3330,13 @@
|
||||
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
|
||||
},
|
||||
"postcss": {
|
||||
"version": "6.0.17",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.17.tgz",
|
||||
"integrity": "sha512-Bl1nybsSzWYbP8O4gAVD8JIjZIul9hLNOPTGBIlVmZNUnNAGL+W0cpYWzVwfImZOwumct4c1SDvSbncVWKtXUw==",
|
||||
"version": "6.0.21",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.21.tgz",
|
||||
"integrity": "sha512-y/bKfbQz2Nn/QBC08bwvYUxEFOVGfPIUOTsJ2CK5inzlXW9SdYR1x4pEsG9blRAF/PX+wRNdOah+gx/hv4q7dw==",
|
||||
"requires": {
|
||||
"chalk": "2.3.1",
|
||||
"chalk": "2.3.2",
|
||||
"source-map": "0.6.1",
|
||||
"supports-color": "5.2.0"
|
||||
"supports-color": "5.3.0"
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
@ -3345,9 +3345,9 @@
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.2.0.tgz",
|
||||
"integrity": "sha512-F39vS48la4YvTZUPVeTqsjsFNrvcMwrV3RLZINsmHo+7djCvuUzSIeXOnZ5hmjef4bajL1dNccN+tg5XAliO5Q==",
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz",
|
||||
"integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==",
|
||||
"requires": {
|
||||
"has-flag": "3.0.0"
|
||||
}
|
||||
@ -3710,9 +3710,9 @@
|
||||
"integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk="
|
||||
},
|
||||
"semantic-ui-less": {
|
||||
"version": "2.2.12",
|
||||
"resolved": "https://registry.npmjs.org/semantic-ui-less/-/semantic-ui-less-2.2.12.tgz",
|
||||
"integrity": "sha1-0ChpjwgOgc2wv4DlXl5jf8mUNdQ=",
|
||||
"version": "2.2.14",
|
||||
"resolved": "https://registry.npmjs.org/semantic-ui-less/-/semantic-ui-less-2.2.14.tgz",
|
||||
"integrity": "sha512-JLkTqjOtct+OwM/JRv0SH76gCC0eE98xp5G4D29e9VbJ66QjWD3nB3waB7drpaMUFXo/YbKcyNOJBgMamcJI0Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"jquery": "3.2.1"
|
||||
|
@ -100,10 +100,18 @@
|
||||
"selectLanguage": true,
|
||||
"highContrast": true,
|
||||
"docMenu": [
|
||||
{
|
||||
"name": "Support",
|
||||
"path": "https://service.lego.com"
|
||||
},
|
||||
{
|
||||
"name": "About",
|
||||
"path": "/about"
|
||||
},
|
||||
{
|
||||
"name": "Upgrade Firmware",
|
||||
"path": "https://ev3manager.education.lego.com/"
|
||||
},
|
||||
{
|
||||
"name": "Blocks",
|
||||
"path": "/blocks"
|
||||
|
Loading…
Reference in New Issue
Block a user