Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
71fe612ced | |||
e58ec06e91 | |||
538493369b | |||
56dd8e0875 | |||
1f7ef637b2 |
@ -48,7 +48,6 @@
|
||||
* [show mood](/reference/brick/show-mood)
|
||||
* [show image](/reference/brick/show-image)
|
||||
* [clear screen](/reference/brick/clear-screen)
|
||||
* [print ports](/reference/brick/print-ports)
|
||||
* [on event](/reference/brick/button/on-event)
|
||||
* [is pressed](/reference/brick/button/is-pressed)
|
||||
* [was pressed](/reference/brick/button/was-pressed)
|
||||
|
@ -19,7 +19,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
|
||||
|
||||
The editor work in [most modern browsers](/browsers), work [offline](/offline) once loaded and do not require any installation.
|
||||
|
||||
## [Compile and Flash: Your Program!](/device/usb)
|
||||
## Compile and Flash: Your Program!
|
||||
|
||||
When you have your code ready, you connect your @boardname@ to a computer via a USB cable
|
||||
so it appears as a mounted drive (named **EV3**).
|
||||
|
@ -39,10 +39,10 @@ const enum InfraredSensorEvent {
|
||||
namespace sensors {
|
||||
function mapButton(v: number) {
|
||||
switch (v) {
|
||||
case 1: return InfraredRemoteButton.TopLeft
|
||||
case 2: return InfraredRemoteButton.BottomLeft
|
||||
case 3: return InfraredRemoteButton.TopRight
|
||||
case 4: return InfraredRemoteButton.TopRight | InfraredRemoteButton.BottomRight
|
||||
case 1: return InfraredRemoteButton.TopLeft;
|
||||
case 2: return InfraredRemoteButton.BottomLeft;
|
||||
case 3: return InfraredRemoteButton.TopRight;
|
||||
case 4: return InfraredRemoteButton.BottomRight;
|
||||
case 5: return InfraredRemoteButton.TopLeft | InfraredRemoteButton.TopRight
|
||||
case 6: return InfraredRemoteButton.TopLeft | InfraredRemoteButton.BottomRight
|
||||
case 7: return InfraredRemoteButton.BottomLeft | InfraredRemoteButton.TopRight
|
||||
@ -68,14 +68,15 @@ namespace sensors {
|
||||
//% fixedInstances
|
||||
export class RemoteInfraredBeaconButton extends control.Component {
|
||||
position: InfraredRemoteButton;
|
||||
private button: brick.Button;
|
||||
private _button: brick.Button;
|
||||
constructor(position: InfraredRemoteButton, button: brick.Button) {
|
||||
super();
|
||||
this.button = button;
|
||||
this.position = position;
|
||||
this._button = button;
|
||||
}
|
||||
|
||||
_update(curr: boolean) {
|
||||
this.button._update(curr);
|
||||
this._button._update(curr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +91,7 @@ namespace sensors {
|
||||
//% weight=81 blockGap=8
|
||||
//% group="Remote Infrared Beacon"
|
||||
isPressed() {
|
||||
return this.button.isPressed();
|
||||
return this._button.isPressed();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +106,7 @@ namespace sensors {
|
||||
//% weight=80
|
||||
//% group="Remote Infrared Beacon"
|
||||
wasPressed() {
|
||||
return this.button.wasPressed();
|
||||
return this._button.wasPressed();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,7 +122,7 @@ namespace sensors {
|
||||
//% weight=99 blockGap=8
|
||||
//% group="Remote Infrared Beacon"
|
||||
onEvent(ev: ButtonEvent, body: () => void) {
|
||||
this.button.onEvent(ev, body);
|
||||
this._button.onEvent(ev, body);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +136,7 @@ namespace sensors {
|
||||
//% weight=99 blockGap=8
|
||||
//% group="Remote Infrared Beacon"
|
||||
pauseUntil(ev: ButtonEvent) {
|
||||
this.button.pauseUntil(ev);
|
||||
this._button.pauseUntil(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +164,7 @@ namespace sensors {
|
||||
_update(prev: number, curr: number) {
|
||||
if (this.mode == InfraredSensorMode.RemoteControl) {
|
||||
for (let i = 0; i < __remoteButtons.length; ++i) {
|
||||
let v = !!(curr & (1 << i))
|
||||
const v = !!(curr & __remoteButtons[i].position);
|
||||
__remoteButtons[i]._update(v)
|
||||
}
|
||||
} else if (this.mode == InfraredSensorMode.Proximity) {
|
||||
@ -294,24 +295,24 @@ namespace sensors {
|
||||
/**
|
||||
* Remote top-left button.
|
||||
*/
|
||||
//% whenUsed block="remote button top-left" weight=95 fixedInstance
|
||||
//% whenUsed block="remote button top left" weight=95 fixedInstance
|
||||
export const remoteButtonTopLeft = __irButton(InfraredRemoteButton.TopLeft)
|
||||
|
||||
/**
|
||||
* Remote top-right button.
|
||||
*/
|
||||
//% whenUsed block="remote button top-right" weight=95 fixedInstance
|
||||
//% whenUsed block="remote button top right" weight=95 fixedInstance
|
||||
export const remoteButtonTopRight = __irButton(InfraredRemoteButton.TopRight)
|
||||
|
||||
/**
|
||||
* Remote bottom-left button.
|
||||
*/
|
||||
//% whenUsed block="remote button bottom-left" weight=95 fixedInstance
|
||||
//% whenUsed block="remote button bottom left" weight=95 fixedInstance
|
||||
export const remoteButtonBottomLeft = __irButton(InfraredRemoteButton.BottomLeft)
|
||||
|
||||
/**
|
||||
* Remote bottom-right button.
|
||||
*/
|
||||
//% whenUsed block="remote button bottom-right" weight=95 fixedInstance
|
||||
//% whenUsed block="remote button bottom right" weight=95 fixedInstance
|
||||
export const remoteButtonBottomRight = __irButton(InfraredRemoteButton.BottomRight)
|
||||
}
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.0.90",
|
||||
"version": "0.0.91",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.0.90",
|
||||
"version": "0.0.91",
|
||||
"description": "LEGO Mindstorms EV3 for Microsoft MakeCode",
|
||||
"private": true,
|
||||
"keywords": [
|
||||
|
@ -83,7 +83,7 @@
|
||||
},
|
||||
"appTheme": {
|
||||
"accentColor": "#0089BF",
|
||||
"logoUrl": "https://lego.makecode.com",
|
||||
"logoUrl": "https://education.lego.com/",
|
||||
"logo": "./static/lego_education_logo.png",
|
||||
"highContrastLogo": "./static/lego_education_logo_white.png",
|
||||
"docsLogo": "./static/lego-logo.svg",
|
||||
@ -95,12 +95,12 @@
|
||||
"organizationUrl": "https://makecode.com/",
|
||||
"organizationLogo": "./static/Microsoft-logo_rgb_c-gray-square.png",
|
||||
"organizationWideLogo": "./static/Microsoft-logo_rgb_c-gray.png",
|
||||
"homeUrl": "https://lego.makecode.com/",
|
||||
"embedUrl": "https://lego.makecode.com/",
|
||||
"homeUrl": "https://makecode.legoeducation.com/",
|
||||
"embedUrl": "https://makecode.legoeducation.com/",
|
||||
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
|
||||
"termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977",
|
||||
"githubUrl": "https://github.com/Microsoft/pxt-ev3",
|
||||
"betaUrl": "https://lego.makecode.com/",
|
||||
"betaUrl": "https://makecode.legoeducation.com/about",
|
||||
"boardName": "LEGO Mindstorms EV3 Brick",
|
||||
"selectLanguage": true,
|
||||
"highContrast": true,
|
||||
@ -157,5 +157,5 @@
|
||||
"editor.background": "#ecf6ff"
|
||||
}
|
||||
},
|
||||
"ignoreDocsErrors": true
|
||||
"ignoreDocsErrors": false
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ namespace pxsim {
|
||||
switch(this.state) {
|
||||
case InfraredRemoteButton.TopLeft: return 1;
|
||||
case InfraredRemoteButton.BottomLeft: return 2;
|
||||
case InfraredRemoteButton.TopLeft: return 3;
|
||||
case InfraredRemoteButton.TopRight | InfraredRemoteButton.BottomRight: return 4;
|
||||
case InfraredRemoteButton.TopRight: return 3;
|
||||
case InfraredRemoteButton.BottomRight: return 4;
|
||||
case InfraredRemoteButton.TopLeft | InfraredRemoteButton.TopRight: return 5;
|
||||
case InfraredRemoteButton.TopLeft | InfraredRemoteButton.BottomRight: return 6;
|
||||
case InfraredRemoteButton.BottomLeft | InfraredRemoteButton.TopRight: return 7;
|
||||
case InfraredRemoteButton.BottomLeft | InfraredRemoteButton.BottomRight: return 8;
|
||||
case InfraredRemoteButton.CenterBeacon: return 9;
|
||||
case InfraredRemoteButton.CenterBeacon: return 9;
|
||||
case InfraredRemoteButton.BottomLeft | InfraredRemoteButton.TopLeft: return 10;
|
||||
case InfraredRemoteButton.TopRight | InfraredRemoteButton.BottomRight: return 11;
|
||||
default: return 0;
|
||||
|
@ -28,11 +28,11 @@ namespace pxsim.visuals {
|
||||
"bottomleft": InfraredRemoteButton.BottomLeft,
|
||||
"bottomright": InfraredRemoteButton.BottomRight
|
||||
}
|
||||
|
||||
|
||||
Object.keys(btns).forEach(bid => {
|
||||
const cid = btns[bid];
|
||||
const bel = content.getElementById(pxsim.visuals.normalizeId(this.id, bid));
|
||||
bel.className += " sim-button";
|
||||
bel.setAttribute("class", "sim-button");
|
||||
pointerEvents.down.forEach(evid => bel.addEventListener(evid, ev => {
|
||||
ev3board().remoteState.setPressed(cid, true);
|
||||
}));
|
||||
|
Reference in New Issue
Block a user