Compare commits

...

35 Commits

Author SHA1 Message Date
b10b636766 0.0.88 2018-02-02 09:48:51 -08:00
ba47fb0589 Support for remote control buttons (#300)
* refactor beacon function inside IR sensor

* towards sim support

* channel labels

* reverting to singletons

* hiding unused apis

* lazy allocation of button instances

* tracking button state

* hook up the state
2018-02-02 09:48:27 -08:00
f36e14fe69 renaming remote button names 2018-02-01 22:33:05 -08:00
8bab919db2 0.0.87 2018-02-01 22:21:15 -08:00
89a82b54dc Ir proximity in simulator (#299)
* support for IR proximity

* fixing build issue

* missing break

* remove auto-start of sensor

* setting mode on onEvent

* flooring slider value

* bump up proximity

* fixing threshold blocks
2018-02-01 22:03:01 -08:00
15ee6ebe9c 0.0.86 2018-02-01 16:46:10 -08:00
9bf50665fc improving the spacing & block names (#298) 2018-02-01 16:21:08 -08:00
f594cdefac add infrared sensor in ev3 library (#296) 2018-02-01 16:18:20 -08:00
5ce7a83f5d 0.0.85 2018-02-01 14:41:42 -08:00
d7ef7c353c typo in generated filter 2018-02-01 14:08:28 -08:00
c7cb300cd9 fixing lights in Edge/Firefox 2018-02-01 14:03:36 -08:00
4e194536d3 0.0.84 2018-01-31 20:10:23 -08:00
570cd7474f upgrade pxt 2018-01-31 20:10:13 -08:00
9ea5597734 0.0.83 2018-01-31 18:10:38 -08:00
2c0cc6a3d7 Use decodebase64 (#295)
* avoid atob directly

* prevent port names to be selected

* updated pxt
2018-01-31 18:10:15 -08:00
08f79c5a1a 0.0.82 2018-01-31 15:39:03 -08:00
f817912e07 bump pxt 2018-01-31 15:38:51 -08:00
603932c2b6 0.0.81 2018-01-31 14:21:45 -08:00
a0907e7229 fixing button down issues on touch/mouse (#294) 2018-01-31 14:21:17 -08:00
635d4a7624 Fixing race condition of button animation (#292) 2018-01-31 11:48:53 -08:00
69d3938d85 0.0.80 2018-01-31 10:04:55 -08:00
f08f9105ba Clean generated files (#289)
* clean generated files

* updating gitingore to drop generated files

* updated package lock
2018-01-31 10:04:40 -08:00
7228cbe1cb updated logo 2018-01-31 09:04:52 -08:00
1ea0a0172a adding highcontrast logo 2018-01-31 08:53:21 -08:00
d548dfb578 moving print ports to examples (#288) 2018-01-31 08:44:58 -08:00
a52ce112dc adding high contrast lego logo 2018-01-31 08:44:35 -08:00
ea956f1a73 Buttons rename (#287)
* renaming up/down/click to released/pressed/bump

* missing images

* fixing signature issue

* updated strings

* white lego logo
2018-01-31 08:28:00 -08:00
ba1b9a54b4 0.0.79 2018-01-30 22:41:37 -08:00
59e39fa76d fixing field width 2018-01-30 22:41:18 -08:00
9187c47e09 0.0.78 2018-01-30 22:22:44 -08:00
fcf91caeb4 Zoom screen (#285)
* always start with full brick layout

* adding 'on start' to template

* render entire board when selected

* zoom brick when clicking on screen

* resize when zooming

* toggle zooming of the brick

* inject close icon when selected

* fix toggling
2018-01-30 22:22:21 -08:00
822227eb48 Brick ref topics 02 (#283)
* Add brick button topics

* Add the rest of the brick api
2018-01-30 20:58:18 -08:00
8a331648d6 Field editor fixes in Firefox (#284)
* fixing speed field picker

* switching to open sans

* alignment-baseline not support in FF
2018-01-30 20:40:41 -08:00
4f70d341e4 Start on the 'brick' api topics (#280)
* Start on the 'brick' api topics

* Add the delay to clear screen example

* Better output for clearsceen example
2018-01-30 17:02:22 -08:00
e06659ab4c removing group icons (#282) 2018-01-30 16:40:08 -08:00
131 changed files with 1458 additions and 1746 deletions

3
.gitignore vendored
View File

@ -16,6 +16,9 @@ clients/win10/*.opendb
clients/**/bin/**
clients/**/obj/**
clients/electron/projects
libs/**/_locales/**
libs/**/shims.d.ts
libs/**/enums.d.ts
videos/**

View File

@ -41,3 +41,17 @@
## Reference #reference
* [Reference](/reference)
* [Brick](/reference/brick)
* [show string](/reference/brick/show-string)
* [show number](/reference/brick/show-number)
* [show value](/reference/brick/show-value)
* [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)
* [pause until](/reference/brick/button/pause-until)
* [set light](/reference/brick/set-light)
* [battery level](/reference/brick/battery-level)

View File

@ -7,12 +7,12 @@ Welcome to the **Microsoft MakeCode** editor for the **@boardname@**!
You can program the @boardname@ using [Blocks](/blocks) or [JavaScript](/javascript) in your web browser:
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, () => {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.setSpeed(50)
})
```
```typescript
brick.buttonEnter.onEvent(ButtonEvent.Click, () => {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.setSpeed(50)
})
```
@ -33,7 +33,7 @@ You can run your code using the micro:bit simulator, all within the confines of
The simulator has support for the LED screen, buttons, as well as compass, accelerometer, and digital I/O pins.
```sim
brick.buttonEnter.onEvent(ButtonEvent.Click, () => {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.setSpeed(50)
})
```

View File

@ -2,7 +2,7 @@
```blocks
let speed = 0;
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
if (speed < 100)
speed = speed + 10;
motors.largeBC.setSpeed(speed);

View File

@ -2,12 +2,12 @@
```blocks
let speed = 0;
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
if (speed < 100)
speed = speed + 10;
motors.largeBC.setSpeed(speed);
})
sensors.touch2.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
if (speed > -100)
speed = speed - 10;
motors.largeBC.setSpeed(speed);

View File

@ -17,11 +17,11 @@ function update() {
brick.showString("speed: " + speed, 1)
motors.largeBC.setSpeed(speed)
}
sensors.touch2.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
accelerate()
update()
})
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
decelerate()
update()
})

View File

@ -1,7 +1,7 @@
# Ignition Activity 1
```blocks
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.eyesDizzy)
})
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectDetected, function () {

View File

@ -7,7 +7,7 @@ sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Bright,
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
brick.showImage(images.objectsLightOn)
})
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.objectsLightOn);
})
```

View File

@ -1,9 +1,9 @@
# Reversing the robot Activity 1
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.setSpeed(50)
sensors.touch1.pauseUntil(TouchSensorEvent.Pressed)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.setSpeed(0)
loops.pause(1000)
brick.setLight(BrickLight.OrangeFlash)

View File

@ -1,10 +1,10 @@
# Reversing the robot Activity 2
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
sensors.touch1.pauseUntil(TouchSensorEvent.Pressed)
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.setSpeed(50)
sensors.touch2.pauseUntil(TouchSensorEvent.Pressed)
sensors.touch2.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.setSpeed(0)
loops.pause(1000)
brick.setLight(BrickLight.OrangeFlash)

View File

@ -1,12 +1,12 @@
# Reversing the robot Activity 3
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showImage(images.eyesSleeping)
sensors.touch1.pauseUntil(TouchSensorEvent.Pressed)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
brick.showImage(images.eyesNeutral)
motors.largeBC.setSpeed(50)
sensors.touch2.pauseUntil(TouchSensorEvent.Pressed)
sensors.touch2.pauseUntil(ButtonEvent.Pressed)
brick.showImage(images.eyesTiredMiddle)
motors.largeBC.setSpeed(0)
loops.pause(1000)

View File

@ -2,16 +2,16 @@
```blocks
let drive: number[] = []
brick.buttonLeft.onEvent(ButtonEvent.Click, function () {
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function () {
drive.push(1)
})
brick.buttonRight.onEvent(ButtonEvent.Click, function () {
brick.buttonRight.onEvent(ButtonEvent.Bumped, function () {
drive.push(3)
})
brick.buttonUp.onEvent(ButtonEvent.Click, function () {
brick.buttonUp.onEvent(ButtonEvent.Bumped, function () {
drive.push(4)
})
brick.buttonDown.onEvent(ButtonEvent.Click, function () {
brick.buttonDown.onEvent(ButtonEvent.Bumped, function () {
drive.push(5)
})
pauseUntil(() => drive.length >= 5)

View File

@ -2,23 +2,23 @@
```blocks
let drive: number[] = []
brick.buttonLeft.onEvent(ButtonEvent.Click, function () {
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function () {
drive.push(1)
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonRight.onEvent(ButtonEvent.Click, function () {
brick.buttonRight.onEvent(ButtonEvent.Bumped, function () {
drive.push(3)
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonUp.onEvent(ButtonEvent.Click, function () {
brick.buttonUp.onEvent(ButtonEvent.Bumped, function () {
drive.push(4)
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonDown.onEvent(ButtonEvent.Click, function () {
brick.buttonDown.onEvent(ButtonEvent.Bumped, function () {
drive.push(5)
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonEnter.pauseUntil(ButtonEvent.Click);
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
loops.pause(1000)
music.playSoundEffectUntilDone(sounds.communicationGo)
for (let d of drive) {

View File

@ -1,7 +1,7 @@
# Three Point Turn Activity 1
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
motors.largeBC.tank(-30, -75)

View File

@ -1,7 +1,7 @@
# Three Point Turn Activity 2
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
motors.largeBC.tank(-30, -75)

View File

@ -1,7 +1,7 @@
# Three Point Turn Activity 3
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
motors.largeBC.tank(-30, -75)

View File

@ -1,7 +1,7 @@
# Traffic Lights Activity 1
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Click, function () {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(20, 20)
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.largeBC.tank(0, 0)

View File

@ -111,7 +111,7 @@ function stop() {
motors.stopAllMotors()
state = 0
moods.knockedOut.show();
sensors.touch3.pauseUntil(TouchSensorEvent.Pressed)
sensors.touch3.pauseUntil(ButtonEvent.Pressed)
moods.neutral.show();
}
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () {

View File

@ -149,7 +149,7 @@ loops.forever(function () {
brick.setLight(BrickLight.RedPulse);
brick.showImage(images.eyesKnockedOut)
music.playSoundEffect(sounds.movementsSpeedDown)
sensors.touch3.pauseUntil(TouchSensorEvent.Pressed)
sensors.touch3.pauseUntil(ButtonEvent.Pressed)
brick.setLight(BrickLight.Off);
})

View File

@ -11,7 +11,7 @@ function INI() {
motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds);
motors.mediumA.setSpeed(-50, 90, MoveUnit.Degrees);
motors.largeC.setSpeed(50)
sensors.touch1.pauseUntil(TouchSensorEvent.Pressed);
sensors.touch1.pauseUntil(ButtonEvent.Pressed);
motors.largeC.setSpeed(-50, 0.86, MoveUnit.Rotations);
}

View File

@ -11,7 +11,7 @@ function INI() {
motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds);
motors.mediumA.setSpeed(-50, 90, MoveUnit.Degrees);
motors.largeC.setSpeed(50)
sensors.touch1.pauseUntil(TouchSensorEvent.Pressed);
sensors.touch1.pauseUntil(ButtonEvent.Pressed);
motors.largeC.setSpeed(-50, 0.86, MoveUnit.Rotations);
}

View File

@ -149,7 +149,7 @@ loops.forever(function () {
brick.setLight(BrickLight.RedPulse);
brick.showImage(images.eyesKnockedOut)
music.playSoundEffect(sounds.movementsSpeedDown)
sensors.touch3.pauseUntil(TouchSensorEvent.Pressed)
sensors.touch3.pauseUntil(ButtonEvent.Pressed)
brick.setLight(BrickLight.Off);
})

View File

@ -3,10 +3,10 @@
Use a touch sensor to make the brick happy.
```blocks
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
sensors.touch1.onEvent(TouchSensorEvent.Released, function () {
sensors.touch1.onEvent(ButtonEvent.Released, function () {
brick.showImage(images.expressionsSick)
})
```

View File

@ -44,7 +44,7 @@ loops.forever(function () {
lasterror = error
if (brick.buttonEnter.wasPressed()) {
motors.largeBC.setSpeed(0)
brick.buttonDown.pauseUntil(ButtonEvent.Click)
brick.buttonDown.pauseUntil(ButtonEvent.Bumped)
}
})
```

View File

@ -0,0 +1,40 @@
# Print Ports
```typescript
/**
* Print the port states on the screen
*/
//% blockId=brickPrintPorts block="print ports"
//% help=brick/print-ports
//% weight=1 group="Screen"
function printPorts() {
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;
print(`${scale(data.actualSpeed)}%`, x, brick.LINE_HEIGHT)
print(`${scale(data.count)}>`, x, 2 * brick.LINE_HEIGHT)
print(`${scale(data.tachoCount)}|`, 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 v = si._query();
print(`${scale(v)}`, x, 9 * brick.LINE_HEIGHT)
}
}
```

View File

@ -3,7 +3,7 @@
This program will activate an alarm when an object is lifted from the Touch Sensor.
```blocks
sensors.touch1.onEvent(TouchSensorEvent.Released, function () {
sensors.touch1.onEvent(ButtonEvent.Released, function () {
music.playSoundEffectUntilDone(sounds.informationActivate);
})
```

View File

@ -1,8 +1,11 @@
# Reference
```namespaces
brick.showMood(moods.sleeping);
```
## See Also
[brick](/reference/brick),
[touch sensor](/reference/sensors/touch-sensor),
[color sensor](/reference/sensors/color-sensor)

30
docs/reference/brick.md Normal file
View File

@ -0,0 +1,30 @@
# Brick
## Screen
```cards
brick.showMood(moods.sleeping);
brick.showImage(images.expressionsBigSmile);
brick.showString("Hello world!", 1);
brick.showNumber(0, 1);
brick.showValue("item", 0, 1);
brick.clearScreen();
```
## Buttons
```cards
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
});
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
brick.buttonEnter.isPressed()
brick.buttonEnter.wasPressed()
brick.setLight(BrickLight.Red);
```
## Other
```cards
brick.batteryLevel()
```

View File

@ -0,0 +1,33 @@
# battery Level
Return the current battery level.
```sig
brick.batteryLevel();
```
## Returns
* a [number](/types/number) which is the current charge level of the brick's battery. This is a percentage of total charge left in the battery.
## Example
Show the battery level percentage on the screen. Also, show a green light if the battery level is above 15%. If the battery level is below 15% but above 5%, show a orange light. But, if the battery level is below 5%, show a pulsing red light.
```blocks
let battery = 0;
loops.forever(function() {
brick.showString("Battery level:", 1)
brick.showNumber(battery, 2)
battery = brick.batteryLevel();
if (battery > 15)
{
brick.setLight(BrickLight.Green);
} else if (battery > 5) {
brick.setLight(BrickLight.Orange);
} else {
brick.setLight(BrickLight.RedPulse)
}
loops.pause(30000)
})
```

View File

@ -0,0 +1,53 @@
# is Pressed
Check if a button is being pressed or not.
```sig
brick.buttonEnter.isPressed()
```
## ~hint
**Touch sensors**
Your @boardname@ has touch sensors that work like buttons. Instead of saying `enter` or `left` as the source button, use a touch sensor block with a sensor name like `touch 1`.
```block
if (sensors.touch1.isPressed()) {
console.log("Hey, I feel pressed.");
}
```
Read about [touch sensors](/reference/sensors/touch-sensor) and using them as touch buttons.
## ~
## Returns
* a [boolean](types/boolean): `true` if the button is pressed, `false` if the button is not pressed
## Example
Set the brick light to green when the `down` is pressed. When the button is not pressed, the brick light is red.
```blocks
let isRed = false;
loops.forever(function() {
if (brick.buttonLeft.isPressed()) {
brick.setLight(BrickLight.Green);
isRed = false;
} else {
if (!isRed) {
brick.setLight(BrickLight.Red);
isRed = true;
}
}
})
```
## See also
[was pressed](/reference/brick/button/was-pressed),
[on event](/reference/brick/button/on-event)
[Touch sensors](/reference/sensors/touch-sensor)

View File

@ -0,0 +1,57 @@
# on Event
Run some code when a button is clicked, pressed down, or released.
```sig
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
});
```
## ~hint
**Touch sensors**
Your @boardname@ has touch sensors that work like buttons. Instead of saying `enter` or `left` as the source button, use a touch sensor block with a sensor name like `touch 1`.
```block
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.setLight(BrickLight.Orange);
});
```
Read about [touch sensors](/reference/sensors/touch-sensor) and using them as touch buttons.
## ~
## Parameters
* **ev**: the button action to run some code for. The button actions (events) are:
> * ``click``: button was clicked (pressed and released)
> * ``up``: button is released from just being pressed
> * ``down``: button is just pressed down
* **body**: the code you want to run when something happens with a button
## Example
Check for event on the ENTER button. Put a message on the screen when the button is pressed, clicked, or released.
```blocks
brick.showString("ENTER is: UP", 1);
brick.buttonEnter.onEvent(ButtonEvent.Released, function () {
brick.showString("ENTER is: UP ", 1);
});
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
brick.showString("ENTER is: DOWN ", 1);
});
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showString("ENTER was: CLICKED", 1);
});
```
### See also
[is pressed](/reference/brick/button/is-pressed),
[was pressed](/reference/brick/button/was-pressed),
[Touch sensor](/reference/sensors/touch-sensor)

View File

@ -0,0 +1,37 @@
# pause Until
Causes your program to wait until an event at a button happens.
```sig
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
```
## Parameters
* **ev**: the button action to wait for. The button actions (events) are:
> * ``click``: button was clicked (pressed and released)
> * ``up``: button is released from just being pressed
> * ``down``: button is just pressed down
## Example
Wait for the `up` button to go up before continuing with displaying a message on the screen.
```blocks
let waitTime = 0;
brick.showString("We're going to wait", 1);
brick.showString("for you to press and", 2);
brick.showString("release the UP button", 3);
waitTime = control.millis();
brick.buttonUp.pauseUntil(ButtonEvent.Bumped);
brick.clearScreen();
if (control.millis() - waitTime > 5000) {
brick.showString("Ok, that took awhile!", 1)
} else {
brick.showString("Ah, you let go!", 1)
}
```
## See also
[on event](/reference/brick/button/on-event)

View File

@ -0,0 +1,50 @@
# was Pressed
Check if a button was pressed earlier.
```sig
brick.buttonEnter.wasPressed()
```
The fact that a button was pressed earlier is remembered. Once **was pressed** is used, this fact is forgotten and the result is `false` the next time you check with **was pressed** button _state_ is reset). But, if you press the button again before you check with **was pressed**, it will tell you `true`.
## ~hint
**Touch sensors**
Your @boardname@ has touch sensors that work like buttons. Instead of saying `enter` or `left` as the source button, use a touch sensor block with a sensor name like `touch 1`.
```block
if (sensors.touch1.wasPressed()) {
console.log("Hey, I was pressed.");
}
```
Read about [touch sensors](/reference/sensors/touch-sensor) and using them as touch buttons.
## ~
## Returns
* a [boolean](types/boolean): `true` if the button was pressed before, `false` if the button was not pressed before
## Example
Set the brick light to green if the `right` button was pressed before the `left` button. If not, the brick light is turned off when the `left` button is pressed.
```blocks
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() {
if (brick.buttonRight.wasPressed()) {
brick.setLight(BrickLight.Green)
} else {
brick.setLight(BrickLight.Off)
}
})
```
## See also
[is pressed](/reference/brick/button/is-pressed),
[on event](/reference/brick/button/on-event)
[Touch sensors](/reference/sensors/touch-sensor)

View File

@ -0,0 +1,22 @@
# clear Screen
Clear any text or numbers displayed on the screen. The screen will be blank.
```sig
brick.clearScreen();
```
## Example
Clear the screen after displaying the message.
```blocks
brick.showString("This message will", 1);
brick.showString("self-destruct in:", 2);
brick.showString("seconds", 5);
for (let i = 0; i < 10; i++) {
brick.showNumber(10 - i, 4);
loops.pause(1000);
}
brick.clearScreen();
```

View File

@ -0,0 +1,37 @@
# set Light
Set the light on the brick to a solid or flashing color.
```sig
brick.setLight(BrickLight.Red);
```
## Parameters
* **pattern**: the color or color pattern for the brick light to show. The brick light can have these color patterns:
>* `off`: brick light is off
>* `green`: solid green
>* `red`: solid red
>* `orange`: solid orange
>* `green flash`: flashing green
>* `red flash`: flashing red
>* `orange flash`: flashing orange
>* `green pulse`: pulsing green
>* `red pulse`: pulsing red
>* `orange pulse`: pulsing orange
## Example
Repeatedly show a different color pattern for the brick light.
```blocks
loops.forever(function () {
brick.setLight(BrickLight.Orange)
loops.pause(1000)
brick.setLight(BrickLight.GreenFlash)
loops.pause(2000)
brick.setLight(BrickLight.RedPulse)
loops.pause(2000)
brick.setLight(BrickLight.Off)
loops.pause(500)
})
```

View File

@ -0,0 +1,24 @@
# show Image
Show an image on the brick's display.
```sig
brick.showImage(images.expressionsBigSmile);
```
You can choose one of several images to show on the display.
## Parameters
**image**: A image to show on the brick's display. Use the image picker to choose the image you want to show.
## Example
Show a sleeping image on the brick's display.
```blocks
brick.showImage(images.expressionsZzz)
```
## See also
[show image](/reference/brick/show-mood)

View File

@ -0,0 +1,24 @@
# show Number
Show a number on the screen at the line you select.
```sig
brick.showNumber(0, 1);
```
## Parameters
* **value**: a [number](/types/number) to show on the brick's screen.
* **line**: The line number on the screen where the value is displayed. The line numbers for the screen start with line `1`.
## Example
Show the number `1000` on the screen.
```blocks
brick.showNumber(1000, 1);
```
## See also
[show string](/reference/brick/show-string), [show value](/reference/brick/show-value)

View File

@ -0,0 +1,29 @@
# show String
Show some text on a the screen at the line you select.
```sig
brick.showString("Hello world", 1)
```
## Parameters
* **text**: a [string](/types/string) to show on the brick's screen.
* **line**: the line [number](/types/number) on the screen where the text is displayed. The line numbers for the screen start with line `1`.
## Example
Show a greeting on the screen. Then, respond with another message when ENTER is pressed.
```blocks
brick.showString("Hello, I dare you to", 1);
brick.showString("press ENTER...", 2);
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showString("Hey! Don't push my", 4);
brick.showString("buttons.", 5);
});
```
## See also
[show number](/reference/brick/show-number)

View File

@ -0,0 +1,29 @@
# show Value
Show a name-value-pair on the screen at the line you select.
```sig
brick.showValue("item", 0, 1);
```
Name-value-pairs are used to report data values to the screen. If you want to show the current temperature on the screen, you might use `"temp"` as the data name for the the value.
## Parameters
* **name**: a [string](/types/string) which is the name of the data value.
* **value**: a [number](/types/number) to show on the brick's screen.
* **line**: The line number on the screen where the value is displayed. The line numbers for the screen start with line `1`.
## Example
Show the current amount of ambient light detected by sensor 2.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showValue("color", sensors.color2.light(LightIntensityMode.Ambient), 1)
})
```
## See also
[show number](/reference/brick/show-number)

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

209
docs/static/lego-logo-white.svg vendored Normal file
View File

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg10"
width="236.9"
height="56.7"
version="1.1"
sodipodi:docname="lego-logo-white.svg"
inkscape:export-filename="C:\gh\pxt-ev3\docs\static\lego_education_logo_white.png"
inkscape:export-xdpi="138.33701"
inkscape:export-ydpi="138.33701"
inkscape:version="0.92.1 r15371">
<metadata
id="metadata54">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1600"
inkscape:window-height="837"
id="namedview52"
showgrid="false"
inkscape:zoom="4.8374843"
inkscape:cx="118.45"
inkscape:cy="28.35"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg10" />
<defs
id="defs14">
<clipPath
id="clipPath26">
<path
d="M332 275.6h177.7v42.5H332z"
id="path24" />
</clipPath>
<clipPath
id="clipPath76">
<path
d="M332 275.6h177.7v42.5H332z"
id="path74" />
</clipPath>
</defs>
<g
id="g18"
transform="matrix(1.33333 0 0 -1.33333 0 56.7)"
inkscape:export-xdpi="138.33701"
inkscape:export-ydpi="138.33701">
<g
id="g130"
transform="translate(-332 -275.6)">
<g
id="g20">
<g
clip-path="url(#clipPath26)"
id="g22">
<g
transform="translate(387.6 297.7)"
id="g28">
<path
id="path30"
d="M0 0h6.3c0 1.4-.2 2.2-.5 2.6-.4.3-1.3.5-2.7.5C1.7 3 .8 2.9.5 2.5.2 2 0 1.3 0 0m6.3-4.1h3.4c0-2-.6-3.3-1.8-4-.8-.4-2.4-.6-4.8-.6-2.6 0-4.4.5-5.3 1.6-.8 1-1.2 2.8-1.2 5.5S-3 3-2.2 4C-1.4 5.1.4 5.7 3 5.7 6 5.7 7.8 5 8.6 4c.7-1 1.1-3 1.1-6.2H0c0-1.7.1-2.7.4-3.2.4-.6 1.3-.8 2.7-.8 1.2 0 2 0 2.3.2.6.3 1 .9 1 1.8"
fill="#fff" />
</g>
<g
transform="translate(406.4 300.7)"
id="g32">
<path
id="path34"
d="M0 0c-1.4 0-2.2-.4-2.6-1.1a7 7 0 0 1-.5-3c0-2 .2-3.3.4-3.8.4-.9 1.3-1.3 2.7-1.3 1.6 0 2.6.4 3 1.2.3.6.4 1.8.4 3.8a7 7 0 0 1-.5 3.1C2.4-.4 1.5 0 0 0m3.4-11.7v2.2C2.7-11 1.2-11.8-1-11.8c-2.4 0-4 .7-4.7 2.2-.5 1-.7 2.7-.7 5.4 0 2.3.3 4 .9 5C-4.8 2-3.3 2.5-1 2.5s3.7-.7 4.2-2h.2v7.9h3.3v-20.2z"
fill="#fff" />
</g>
<g
transform="translate(428.8 289)"
id="g36">
<path
id="path38"
d="M0 0h-3.3v2.2C-4 .6-5.6-.1-7.9-.1c-3.2 0-4.8 1.3-4.8 4v10.2h3.4V5.2c0-1 .1-1.8.4-2.1.3-.4 1-.7 2-.7 1.2 0 2.1.3 2.6.9.5.5.8 1.4.8 2.7v8H0z"
fill="#fff" />
</g>
<g
transform="translate(441 294.4)"
id="g40">
<path
id="path42"
d="M0 0h3.4c0-2.3-.5-3.8-1.6-4.6-.8-.6-2.4-1-4.8-1-2.7 0-4.4.6-5.2 1.7-.8 1-1.1 2.8-1.1 5.6 0 2.7.3 4.5 1 5.4C-7.3 8.3-5.6 9-3 9c2.3 0 3.9-.3 4.8-1 1-.6 1.6-2 1.6-4.1H0c0 1-.2 1.8-.7 2-.4.4-1.2.5-2.3.5-1.4 0-2.3-.3-2.6-1-.2-.5-.4-1.7-.4-3.6 0-2 .1-3.2.4-3.6.3-.7 1.2-1 2.6-1 1.3 0 2 .1 2.4.5.4.3.6 1.1.6 2.4"
fill="#fff" />
</g>
<g
transform="translate(452.8 295.4)"
id="g44">
<path
id="path46"
d="M0 0c-1.1 0-1.8 0-2.2-.2-.6-.3-1-1-1-1.8 0-1 .3-1.6.8-1.8.4-.3 1.2-.4 2.4-.4 1.1 0 1.8.1 2.2.3.6.3 1 1 1 1.9 0 .9-.4 1.4-1 1.7A6 6 0 0 1 0 0m3.1-6.3l.1 1.7c-.3-.8-1-1.3-1.9-1.6-.5-.2-1.4-.3-2.5-.3-1.8 0-3.1.3-4 .9C-6-5-6.4-3.8-6.4-2-6.5-.3-6 .8-5 1.5c.7.5 2 .8 3.8.8 1.1 0 2 0 2.5-.2C2 1.8 2.7 1.4 3 .7h.1v1.8c0 1.2-.1 2-.4 2.4-.4.5-1.3.7-2.6.7-.9 0-1.5 0-1.9-.3-.5-.3-.7-.8-.7-1.7H-6c0 1.9.6 3.1 1.8 3.7.8.4 2.2.6 4.2.6 2.4 0 4-.3 4.9-1 1-.7 1.5-2.2 1.5-4.4v-8.8z"
fill="#fff" />
</g>
<g
transform="translate(460.9 300.6)"
id="g48">
<path
id="path50"
d="M0 0v2.6h1.8v3.2H5V2.6h5.5V0H5v-7.2c0-.7 0-1.2.2-1.4.2-.3.6-.5 1.3-.5.8 0 1.3.3 1.5 1l.2 2h3c0-2-.3-3.4-.8-4.2-.7-.9-2-1.4-3.9-1.4-1.8 0-3 .3-3.7.9-.8.6-1.1 1.8-1.1 3.6V0z"
fill="#fff" />
</g>
<path
id="path52"
d="M478.2 289h-3.4v14.2h3.4zm0 17.3h-3.4v3h3.4z"
fill="#fff" />
<g
transform="translate(487.5 300.7)"
id="g54">
<path
id="path56"
d="M0 0c-1.4 0-2.4-.3-2.8-1-.3-.4-.5-1.7-.5-3.6 0-2 .2-3.2.5-3.7.4-.6 1.3-1 2.8-1 1.5 0 2.4.4 2.8 1 .3.5.5 1.7.5 3.7S3-1.4 2.8-1C2.4-.3 1.5 0 0 0m0 2.6C2.8 2.6 4.7 2 5.5 1c.8-.9 1.1-2.7 1.1-5.6 0-2.9-.3-4.8-1-5.6-1-1-2.8-1.6-5.6-1.6s-4.7.5-5.5 1.6c-.8.8-1.1 2.7-1.1 5.6 0 2.9.3 4.7 1 5.6 1 1 2.8 1.6 5.6 1.6"
fill="#fff" />
</g>
<g
transform="translate(497 303.2)"
id="g58">
<path
id="path60"
d="M0 0h3.4v-2.1A3 3 0 0 0 5.3-.2C6 0 6.7 0 8 0c1.8 0 3-.3 3.8-1 .7-.9 1-2.1 1-4v-9H9.4v9c0 1-.2 1.7-.6 2-.3.5-1 .7-2 .7-1.4 0-2.4-.4-2.8-1-.4-.6-.6-1.5-.6-3V-14H0z"
fill="#fff" />
</g>
<path
id="path62"
d="M384.5 316.4h125.2v1.7H384.5z"
fill="#006cb6" />
<path
id="path64"
d="M384.5 275.6H471v1.7h-86.5z"
fill="#006cb6" />
<path
id="path66"
d="M482.3 275.6h27.4v1.7h-27.4z"
fill="#006cb6" />
</g>
</g>
<path
id="path68"
d="M332.3 275.9h42v42h-42z"
fill="#fff" />
<g
id="g70">
<g
clip-path="url(#clipPath76)"
id="g72">
<g
transform="translate(371.5 300.4)"
id="g78">
<path
id="path80"
d="M0 0c0-1.3-.5-3-.9-4C-2.3-8.4-4-11.1-8-11.1c-1.2 0-3.2.3-4 2.4l-.2.5-.3-.5a6.5 6.5 0 0 0-5-2.4c-1.6 0-2.8.5-3.6 1.4l-.2.3-.2-.3c-.8-.9-2.3-1.4-4-1.4-1.4 0-2.5.4-3.3 1.3l-.2.2-.2-.2c-.8-.9-2.2-1.3-3.9-1.3-2 0-3.2 1.2-3.3 3 0 3 2.7 9 3.9 10.8a3.4 3.4 0 0 0 3.1 1.8c1 0 1.6-.2 2-.6.3-.4.4-.7.4-1.4v-1l.5.9c1.2 2 3.3 2.2 5.3 2.2 1.3 0 2.6-.5 3-1.3l.2-.3.3.2a6 6 0 0 0 4 1.4c1.8 0 3.1-.5 3.9-1.3l.4-.7.2-.4.3.3c1.1 1.4 2.6 2 4.5 2 1.5 0 2.6-.4 3.4-1.2C0 2.3 0 1 0 0m-39.2-24.5h42v42h-42z"
fill="#ffed00" />
</g>
<g
transform="translate(372.7 298.8)"
id="g82">
<path
id="path84"
d="M0 0a24 24 0 0 0-1.8-5.5c-1.4-3-3.4-5.3-7.2-5.3-2 0-3.7.6-4.7 1.8a7.6 7.6 0 0 0-5-1.9 6 6 0 0 0-3.8 1.2 7.3 7.3 0 0 0-7.7 0 7 7 0 0 0-4-1.1C-37-10.8-39-9-39-6.5c0 3.3 2.7 9.4 4 11.5a5 5 0 0 0 4.4 2.4c2 0 2.7-.5 3-1.3 1.6 1.4 3.6 1.4 5 1.4 1.7 0 2.7-.4 3.5-1 1.2.6 2.6 1 4.2 1 2 0 3.6-.5 4.7-1.5a7 7 0 0 0 4.6 1.5c2.3 0 3.8-.9 4.7-2.1C.5 3.6.2 1.9 0 0m-40.3-22.9h42v42h-42z"
fill="#e20614" />
</g>
<path
id="path86"
d="M374 276.2h-41.4v41.3H374zm-42-.6h42.6v42.5H332z"
fill="#1c1c1b" />
<g
transform="translate(372.7 306.3)"
id="g88">
<path
id="path90"
d="M0 0a1 1 0 0 1-1-1c0-.6.4-1 1-1s1 .4 1 1C1-.5.6 0 0 0m0-.2a.8.8 0 1 0 0-1.6.8.8 0 0 0 0 1.6m.5-1.4l-.1.3-.2.2.3.3c0 .2-.2.3-.4.3h-.5v-1h.2v.4H0l.2-.3v-.2zm-.7.7v.2H0l.2-.1L0-.9z"
fill="#1c1c1b" />
</g>
<g
transform="translate(367.4 300.5)"
id="g92">
<path
id="path94"
d="M0 0c0-1-1.6-5.4-2.2-6.4-.2-.4-.5-.7-1-.7s-.6.3-.7.6c0 1 1.8 6 2.4 6.7.3.4.6.5 1 .5C0 .7 0 .3 0 0m2.9-1.8c-.4-1.8-1.2-3.9-2-5.5-1.5-2.6-3.2-3-4.8-3-1.5 0-3.2.7-3.2 3 0 1.7.7 4 1.3 5.7 1 2.8 2.2 5.1 5.7 5 4 0 3.3-3.6 3-5.2m-13 2.5c-.5 0-.9-.3-1.2-.7-.6-1-2-4.5-2.2-6-.1-1 .3-1.1.8-1.1.7 0 1.6.8 1.9 2.1 0 0-1.5 0-1 1.3.3 1.3 1 1.5 2.2 1.6 2.4 0 2.2-1.7 2-2.6-.6-3-2.8-5.5-5.9-5.5-2 0-3.4 1.1-3.4 3.3 0 1.5.8 3.9 1.4 5.3 1.3 3 2.6 5 6 5 2 0 3.7-.7 3.5-2.6-.2-1.4-1-2.2-2.2-2.3-.4 0-1.8 0-1.3 1.4.1.5.2.8-.5.8m-10.7-5.2l-.6-2a7 7 0 0 0 2 .2c1.1 0 1.8-.4 1.8-1.3 0-2-2.3-2.6-3.9-2.6-1.7 0-3.2 1-3.2 2.8A21 21 0 0 0-22.3.4c1.4 2.8 2.8 3.1 5.2 3.1 1.1 0 2.3-.4 2.3-1.4 0-1.4-1.2-2-2.3-2H-19s-.4-.6-.8-1.7c2.2.3 3.1-.2 2.8-1.5-.5-1.7-2-1.8-3.8-1.4m-7-2c2.2.4 2.7-.4 2.6-1.1-.2-2.2-2.1-2.6-3.8-2.6-1.2 0-2.3.6-2.4 2 0 2.5 2.5 8.3 3.7 10.2.6 1 1.3 1.4 2.3 1.4 1 0 1.3-.5 1.3-1.1 0-1.7-2.8-6.8-3.6-8.8M-.3 4.7a6 6 0 0 1-4.7-2l-.5.7c-.9 1-2.2 1.4-4 1.4-1.8 0-3.3-.6-4.3-1.4-.5.8-1.8 1.4-3.3 1.4-2 0-4.2-.3-5.5-2.4 0 .8-.1 1.2-.5 1.6-.6.6-1.4.7-2.2.7-1.5 0-2.6-.6-3.4-2-1.1-1.8-4-7.9-3.9-10.8 0-2 1.3-3.3 3.6-3.4 1.8 0 3.2.5 4.1 1.4.8-.9 2-1.4 3.5-1.4 1.6 0 3.2.5 4.2 1.6.8-1 2.1-1.6 3.8-1.6 2.1 0 4 1 5.2 2.6.7-1.9 2.4-2.6 4.3-2.6 4.1 0 6 2.8 7.4 7.3.4 1 .8 2.7.9 4.1.1 2.4-.9 4.8-4.7 4.8"
fill="#1c1c1b" />
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -77,7 +77,7 @@ export function deployCoreAsync(resp: pxtc.CompileResult, isCli = false) {
let rbfBIN = pxt.U.fromHex(rbfHex)
pxt.HF2.write16(rbfBIN, 4, rbfBIN.length)
let origElfUF2 = UF2.parseFile(pxt.U.stringToUint8Array(atob(resp.outfiles[pxt.outputName()])))
let origElfUF2 = UF2.parseFile(pxt.U.stringToUint8Array(ts.pxtc.decodeBase64(resp.outfiles[pxt.outputName()])))
let mkFile = (ext: string, data: Uint8Array = null) => {
let f = UF2.newBlockFile()

View File

@ -40,7 +40,8 @@ export class FieldSpeed extends Blockly.FieldSlider implements Blockly.FieldCust
var labelContainer = document.createElement('div');
this.speedSVG = document.createElementNS("http://www.w3.org/2000/svg", "svg") as SVGGElement;
pxsim.svg.hydrate(this.speedSVG, {
viewBox: "0 0 200 100"
viewBox: "0 0 200 100",
width: "170"
});
labelContainer.appendChild(this.speedSVG);
@ -58,7 +59,7 @@ export class FieldSpeed extends Blockly.FieldSlider implements Blockly.FieldCust
this.reporter = pxsim.svg.child(this.speedSVG, "text", {
'x': 100, 'y': 80,
'text-anchor': 'middle', 'alignment-baseline': 'middle',
'text-anchor': 'middle', 'dominant-baseline': 'middle',
'style': 'font-size: 50px',
'class': 'sim-text inverted number'
}) as SVGTextElement;

View File

@ -56,7 +56,7 @@ export class FieldTurnRatio extends Blockly.FieldSlider implements Blockly.Field
}, marker);
this.reporter_ = pxsim.svg.child(svg, "text", {
'x': FieldTurnRatio.HALF, 'y': 96,
'text-anchor': 'middle', 'alignment-baseline': 'middle',
'text-anchor': 'middle', 'dominant-baseline': 'middle',
'style': 'font-size: 50px',
'class': 'sim-text inverted number'
}) as SVGTextElement;

View File

@ -1,26 +0,0 @@
{
"automation": "Automation, process control and robotic controllers",
"automation.Behavior": "A behavior",
"automation.Behavior.update": "Called on each behavior iteration even for suppresed behaviors",
"automation.Behavior.update|param|elapsed": "milli seconds since last call",
"automation.BehaviorManager": "A manager for behaviors",
"automation.BehaviorManager.add": "Adds a new behavior to the behavior manager",
"automation.BehaviorManager.add|param|behavior": "the behavior to add",
"automation.BehaviorManager.start": "Starts the behavior control loop",
"automation.BehaviorManager.stop": "Stops the execution loop",
"automation.PIDController": "A PID controller.\n* Reference: Feedback System, Karl Johan Astrom & Rickard M. Murry",
"automation.PIDController.compute": "Computes the output based on the system state",
"automation.PIDController.setControlSaturation": "Sets the control saturation values",
"automation.PIDController.setControlSaturation|param|high": "highest control value, eg: 100",
"automation.PIDController.setControlSaturation|param|low": "lowest control value, eg: -100",
"automation.PIDController.setDerivativeFilter": "Sets the derivative filter gain",
"automation.PIDController.setDerivativeFilter|param|N": "the filter gain, eg:10",
"automation.PIDController.setGains": "Sets the PID gains",
"automation.PIDController.setGains|param|b": "setpoint weight, eg: 0.9",
"automation.PIDController.setGains|param|kd": "derivative gain",
"automation.PIDController.setGains|param|ki": "integral gain",
"automation.PIDController.setGains|param|kp": "proportional gain",
"automation.PIDController.setPoint": "Updates the desired setpoint",
"automation.addBehavior": "Adds the behavior and starts it",
"automation.addBehavior|param|behavior": "a behavior"
}

View File

@ -1,12 +0,0 @@
{
"automation.PIDController.compute|block": "%pid|compute for timestep %timestep|(ms) at state %y",
"automation.PIDController.setControlSaturation|block": "set %pid|control saturation from %low|to %high",
"automation.PIDController.setDerivativeFilter|block": "set %pid|derivative filter %N",
"automation.PIDController.setGains|block": "set %pid|gains kp %kp|ki %ki|kd %kd",
"automation.PIDController.setPoint|block": "set %pid|point to %ysp",
"automation.addBehavior|block": "add behavior %behavior",
"automation|block": "automation",
"{id:category}Automation": "Automation",
"{id:group}Behaviors": "Behaviors",
"{id:group}PID": "PID"
}

View File

@ -1,157 +0,0 @@
{
"Array": "Add, remove, and replace items in lists.\n\nAdd, remove, and replace items in lists.",
"Array.filter": "Return the elements of an array that meet the condition specified in a callback function.",
"Array.filter|param|callbackfn": "A function that accepts up to two arguments. The filter method calls the callbackfn function one time for each element in the array.",
"Array.get": "Get the value at a particular index",
"Array.get|param|index": "the zero-based position in the list of the item, eg: 0",
"Array.indexOf": "Return the index of the first occurrence of a value in an array.",
"Array.indexOf|param|fromIndex": "The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.",
"Array.indexOf|param|item": "The value to locate in the array.",
"Array.insertAt": "Insert the value at a particular index, increases length by 1",
"Array.insertAt|param|index": "the zero-based position in the list to insert the value, eg: 0",
"Array.length": "Get or set the length of an array. This number is one more than the index of the last element the array.",
"Array.map": "Call a defined callback function on each element of an array, and return an array containing the results.",
"Array.map|param|callbackfn": "A function that accepts up to two arguments. The map method calls the callbackfn function one time for each element in the array.",
"Array.pop": "Remove the last element from an array and return it.",
"Array.push": "Append a new element to an array.",
"Array.reduce": "Call the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.",
"Array.reduce|param|callbackfn": "A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the array.",
"Array.reduce|param|initialValue": "Initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.",
"Array.removeAt": "Remove the element at a certain index.",
"Array.removeElement": "Remove the first occurence of an object. Returns true if removed.",
"Array.reverse": "Reverse the elements in an array. The first array element becomes the last, and the last array element becomes the first.",
"Array.set": "Store a value at a particular index",
"Array.set|param|index": "the zero-based position in the list to store the value, eg: 0",
"Array.shift": "Remove the first element from an array and return it. This method changes the length of the array.",
"Array.slice": "Return a section of an array.",
"Array.slice|param|end": "The end of the specified portion of the array. eg: 0",
"Array.slice|param|start": "The beginning of the specified portion of the array. eg: 0",
"Array.sort": "Sort the elements of an array in place and returns the array. The sort is not necessarily stable.",
"Array.splice": "Remove elements from an array.",
"Array.splice|param|deleteCount": "The number of elements to remove. eg: 0",
"Array.splice|param|start": "The zero-based location in the array from which to start removing elements. eg: 0",
"Array.unshift": "Add one element to the beginning of an array and return the new length of the array.",
"Boolean.toString": "Returns a string representation of an object.",
"Buffer.fill": "Fill (a fragment) of the buffer with given value.",
"Buffer.getNumber": "Read a number in specified format from the buffer.",
"Buffer.length": "Returns the length of a Buffer object.",
"Buffer.rotate": "Rotate buffer left in place.\n\n\n\nstart. eg: -1",
"Buffer.rotate|param|length": "number of elements in buffer. If negative, length is set as the buffer length minus",
"Buffer.rotate|param|offset": "number of bytes to shift; use negative value to shift right",
"Buffer.rotate|param|start": "start offset in buffer. Default is 0.",
"Buffer.setNumber": "Write a number in specified format in the buffer.",
"Buffer.shift": "Shift buffer left in place, with zero padding.\n\n\n\nstart. eg: -1",
"Buffer.shift|param|length": "number of elements in buffer. If negative, length is set as the buffer length minus",
"Buffer.shift|param|offset": "number of bytes to shift; use negative value to shift right",
"Buffer.shift|param|start": "start offset in buffer. Default is 0.",
"Buffer.slice": "Return a copy of a fragment of a buffer.",
"Buffer.toHex": "Convert a buffer to its hexadecimal representation.",
"Buffer.write": "Write contents of `src` at `dstOffset` in current buffer.",
"Math": "More complex operations with numbers.",
"Math.abs": "Returns the absolute value of a number (the value without regard to whether it is positive or negative).\nFor example, the absolute value of -5 is the same as the absolute value of 5.",
"Math.abs|param|x": "A numeric expression for which the absolute value is needed.",
"Math.acos": "Returns the arccosine (in radians) of a number",
"Math.acos|param|x": "A number",
"Math.asin": "Returns the arcsine (in radians) of a number",
"Math.asin|param|x": "A number",
"Math.atan": "Returns the arctangent (in radians) of a number",
"Math.atan2": "Returns the arctangent of the quotient of its arguments.",
"Math.atan2|param|x": "A number",
"Math.atan2|param|y": "A number",
"Math.atan|param|x": "A number",
"Math.ceil": "Returns the smallest number greater than or equal to its numeric argument.",
"Math.ceil|param|x": "A numeric expression.",
"Math.constrain": "Constrains a number to be within a range",
"Math.cos": "Returns the cosine of a number.",
"Math.cos|param|x": "An angle in radians",
"Math.exp": "Returns returns ``e^x``.",
"Math.exp|param|x": "A number",
"Math.floor": "Returns the greatest number less than or equal to its numeric argument.",
"Math.floor|param|x": "A numeric expression.",
"Math.icos": "Returns the cosine of an input angle. This is an 8-bit approximation.",
"Math.icos|param|theta": "input angle from 0-255",
"Math.idiv": "Returns the value of integer signed 32 bit division of two numbers.",
"Math.idiv|param|x": "The first number",
"Math.idiv|param|y": "The second number",
"Math.imul": "Returns the value of integer signed 32 bit multiplication of two numbers.",
"Math.imul|param|x": "The first number",
"Math.imul|param|y": "The second number",
"Math.isin": "Returns the sine of an input angle. This is an 8-bit approximation.",
"Math.isin|param|theta": "input angle from 0-255",
"Math.log": "Returns the natural logarithm (base e) of a number.",
"Math.log|param|x": "A number",
"Math.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
"Math.map|param|fromHigh": "the upper bound of the value's current range, eg: 1023",
"Math.map|param|fromLow": "the lower bound of the value's current range",
"Math.map|param|toHigh": "the upper bound of the value's target range, eg: 4",
"Math.map|param|toLow": "the lower bound of the value's target range",
"Math.map|param|value": "value to map in ranges",
"Math.max": "Returns the larger of two supplied numeric expressions.",
"Math.min": "Returns the smaller of two supplied numeric expressions.",
"Math.pow": "Returns the value of a base expression taken to a specified power.",
"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|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.",
"Math.round|param|x": "The value to be rounded to the nearest number.",
"Math.sign": "Returns the sign of the x, indicating whether x is positive, negative or zero.",
"Math.sign|param|x": "The numeric expression to test",
"Math.sin": "Returns the sine of a number.",
"Math.sin|param|x": "An angle in radians",
"Math.sqrt": "Returns the square root of a number.",
"Math.sqrt|param|x": "A numeric expression.",
"Math.tan": "Returns the tangent of a number.",
"Math.tan|param|x": "An angle in radians",
"Math.trunc": "Returns the number with the decimal part truncated.",
"Math.trunc|param|x": "A numeric expression.",
"Number.toString": "Returns a string representation of a number.",
"String": "Combine, split, and search text strings.\n\nCombine, split, and search text strings.",
"String.charAt": "Return the character at the specified index.",
"String.charAt|param|index": "The zero-based index of the desired character.",
"String.charCodeAt": "Return the Unicode value of the character at the specified location.",
"String.charCodeAt|param|index": "The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.",
"String.compare": "See how the order of characters in two strings is different (in ASCII encoding).",
"String.compare|param|that": "String to compare to target string",
"String.concat": "Returns a string that contains the concatenation of two or more strings.",
"String.concat|param|other": "The string to append to the end of the string.",
"String.fromCharCode": "Make a string from the given ASCII character code.",
"String.isEmpty": "Returns a value indicating if the string is empty",
"String.length": "Returns the length of a String object.",
"String.substr": "Return a substring of the current string.",
"String.substr|param|length": "number of characters to extract",
"String.substr|param|start": "first character index; can be negative from counting from the end, eg:0",
"control": "Program controls and events.",
"control.AnimationQueue.cancel": "Cancels the current running animation and clears the queue",
"control.AnimationQueue.runUntilDone": "Runs 'render' in a loop until it returns false or the 'stop' function is called",
"control.assert": "Display an error code and stop the program when the assertion is `false`.",
"control.deviceSerialNumber": "Derive a unique, consistent serial number of this device from internal data.",
"control.millis": "Gets the number of milliseconds elapsed since power on.",
"control.onEvent": "Run code when a registered event happens.",
"control.onEvent|param|value": "the event value to match",
"control.panic": "Display an error code and stop the program.",
"control.panic|param|code": "an error number to display. eg: 5",
"control.reset": "Reset the device.",
"control.runInParallel": "Run other code in the parallel.",
"control.waitForEvent": "Blocks the calling thread until the specified event is raised.",
"control.waitMicros": "Block the current fiber for the given microseconds",
"control.waitMicros|param|micros": "number of micro-seconds to wait. eg: 4",
"hex": "Tagged hex literal converter",
"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",
"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.",
"serial.writeNumber": "Write a number to the serial port.",
"serial.writeString": "Write some text to the serial port.",
"serial.writeValue": "Write a name:value pair as a line of text to the serial port.",
"serial.writeValue|param|name": "name of the value stream, eg: \"x\"",
"serial.writeValue|param|value": "to write"
}

View File

@ -1,55 +0,0 @@
{
"Array.indexOf|block": "%list| find index of %value",
"Array.insertAt|block": "%list| insert at %index| value %value",
"Array.length|block": "length of %VALUE",
"Array.pop|block": "get and remove last value from %list",
"Array.push|block": "%list| add value %value| to end",
"Array.removeAt|block": "%list| remove value at %index",
"Array.reverse|block": "reverse %list",
"Array.shift|block": "get and remove first value from %list",
"Array.unshift|block": "%list| insert %value| at beginning",
"Array|block": "Array",
"Math.constrain|block": "constrain %value|between %low|and %high",
"Math.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
"Math.randomRange|block": "pick random %min|to %limit",
"Math|block": "Math",
"String.charAt|block": "char from %this=text|at %pos",
"String.compare|block": "compare %this=text| to %that",
"String.fromCharCode|block": "text from char code %code",
"String.length|block": "length of %VALUE",
"String.substr|block": "substring of %this=text|from %start|of length %length",
"String|block": "String",
"control.assert|block": "assert %cond|with value %code",
"control.deviceSerialNumber|block": "device serial number",
"control.millis|block": "millis (ms)",
"control.onEvent|block": "on event|from %src|with value %value",
"control.panic|block": "panic %code",
"control.reset|block": "reset",
"control.runInParallel|block": "run in parallel",
"control.waitForEvent|block": "wait for event|from %src|with value %value",
"control.waitMicros|block": "wait (µs)%micros",
"control|block": "control",
"fieldeditors|block": "fieldeditors",
"loops.forever|block": "forever",
"loops.pause|block": "pause %pause=timePicker|ms",
"loops|block": "loops",
"parseInt|block": "parse to integer %text",
"serial.writeBuffer|block": "serial|write buffer %buffer",
"serial.writeLine|block": "serial|write line %text",
"serial.writeNumber|block": "serial|write number %value",
"serial.writeString|block": "serial|write string %text",
"serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "serial",
"{id:category}Array": "Array",
"{id:category}Arrays": "Arrays",
"{id:category}Boolean": "Boolean",
"{id:category}Buffer": "Buffer",
"{id:category}Control": "Control",
"{id:category}Helpers": "Helpers",
"{id:category}Loops": "Loops",
"{id:category}Math": "Math",
"{id:category}Number": "Number",
"{id:category}Serial": "Serial",
"{id:category}String": "String",
"{id:category}Text": "Text"
}

34
libs/base/enums.d.ts vendored
View File

@ -1,34 +0,0 @@
// Auto-generated. Do not edit.
declare const enum NumberFormat {
Int8LE = 1,
UInt8LE = 2,
Int16LE = 3,
UInt16LE = 4,
Int32LE = 5,
Int8BE = 6,
UInt8BE = 7,
Int16BE = 8,
UInt16BE = 9,
Int32BE = 10,
UInt32LE = 11,
UInt32BE = 12,
Float32LE = 13,
Float64LE = 14,
Float32BE = 15,
Float64BE = 16,
}
declare const enum ValType {
Undefined = 0,
Boolean = 1,
Number = 2,
String = 3,
Object = 4,
Function = 5,
}
// Auto-generated. Do not edit. Really.

159
libs/base/shims.d.ts vendored
View File

@ -1,159 +0,0 @@
// Auto-generated. Do not edit.
//% indexerGet=BufferMethods::getByte indexerSet=BufferMethods::setByte
declare interface Buffer {
/**
* Write a number in specified format in the buffer.
*/
//% shim=BufferMethods::setNumber
setNumber(format: NumberFormat, offset: int32, value: number): void;
/**
* Read a number in specified format from the buffer.
*/
//% shim=BufferMethods::getNumber
getNumber(format: NumberFormat, offset: int32): number;
/** Returns the length of a Buffer object. */
//% property shim=BufferMethods::length
length: int32;
/**
* Fill (a fragment) of the buffer with given value.
*/
//% offset.defl=0 length.defl=-1 shim=BufferMethods::fill
fill(value: int32, offset?: int32, length?: int32): void;
/**
* Return a copy of a fragment of a buffer.
*/
//% offset.defl=0 length.defl=-1 shim=BufferMethods::slice
slice(offset?: int32, length?: int32): Buffer;
/**
* Shift buffer left in place, with zero padding.
* @param offset number of bytes to shift; use negative value to shift right
* @param start start offset in buffer. Default is 0.
* @param length number of elements in buffer. If negative, length is set as the buffer length minus
* start. eg: -1
*/
//% start.defl=0 length.defl=-1 shim=BufferMethods::shift
shift(offset: int32, start?: int32, length?: int32): void;
/**
* Convert a buffer to its hexadecimal representation.
*/
//% shim=BufferMethods::toHex
toHex(): string;
/**
* Rotate buffer left in place.
* @param offset number of bytes to shift; use negative value to shift right
* @param start start offset in buffer. Default is 0.
* @param length number of elements in buffer. If negative, length is set as the buffer length minus
* start. eg: -1
*/
//% start.defl=0 length.defl=-1 shim=BufferMethods::rotate
rotate(offset: int32, start?: int32, length?: int32): void;
/**
* Write contents of `src` at `dstOffset` in current buffer.
*/
//% shim=BufferMethods::write
write(dstOffset: int32, src: Buffer): void;
}
declare namespace loops {
/**
* Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute
*/
//% help=loops/forever weight=100 afterOnStart=true
//% blockId=forever block="forever" blockAllowMultiple=1 shim=loops::forever
function forever(a: () => void): void;
/**
* Pause for the specified time in milliseconds
* @param ms how long to pause for, eg: 100, 200, 500, 1000, 2000
*/
//% help=loops/pause weight=99
//% async block="pause %pause=timePicker|ms"
//% blockId=device_pause shim=loops::pause
function pause(ms: int32): void;
}
declare namespace control {
/**
* Gets the number of milliseconds elapsed since power on.
*/
//% help=control/millis weight=50
//% blockId=control_running_time block="millis (ms)" shim=control::millis
function millis(): int32;
/**
* Run code when a registered event happens.
* @param id the event compoent id
* @param value the event value to match
*/
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src|with value %value"
//% blockExternalInputs=1
//% help="control/on-event" flags.defl=16 shim=control::onEvent
function onEvent(src: int32, value: int32, handler: () => void, flags?: int32): void;
/**
* Reset the device.
*/
//% weight=30 async help=control/reset blockGap=8
//% blockId="control_reset" block="reset" shim=control::reset
function reset(): void;
/**
* Block the current fiber for the given microseconds
* @param micros number of micro-seconds to wait. eg: 4
*/
//% help=control/wait-micros weight=29 async
//% blockId="control_wait_us" block="wait (µs)%micros" shim=control::waitMicros
function waitMicros(micros: int32): void;
/**
* Run other code in the parallel.
*/
//% help=control/run-in-parallel handlerStatement=1
//% blockId="control_run_in_parallel" block="run in parallel" blockGap=8 shim=control::runInParallel
function runInParallel(a: () => void): void;
/**
* Blocks the calling thread until the specified event is raised.
*/
//% help=control/wait-for-event async
//% blockId=control_wait_for_event block="wait for event|from %src|with value %value" shim=control::waitForEvent
function waitForEvent(src: int32, value: int32): void;
/**
* Derive a unique, consistent serial number of this device from internal data.
*/
//% blockId="control_device_serial_number" block="device serial number" weight=9
//% help=control/device-serial-number shim=control::deviceSerialNumber
function deviceSerialNumber(): int32;
}
declare namespace serial {
/**
* Write some text to the serial port.
*/
//% help=serial/write-string
//% weight=87 blockHidden=true
//% blockId=serial_writestring block="serial|write string %text" shim=serial::writeString
function writeString(text: string): void;
/**
* Send a buffer across the serial connection.
*/
//% help=serial/write-buffer weight=6 blockHidden=true
//% blockId=serial_writebuffer block="serial|write buffer %buffer" shim=serial::writeBuffer
function writeBuffer(buffer: Buffer): void;
}
// Auto-generated. Do not edit. Really.

View File

@ -1,3 +1,5 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="forever"></block>
<variables></variables>
<block type="pxt-on-start" x="0" y="0"></block>
<block type="forever" x="176" y="0"></block>
</xml>

View File

@ -1,10 +0,0 @@
{
"chassis": "A differential drive robot",
"chassis.Chassis": "A differential drive robot",
"chassis.Chassis.drive": "Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)\nusing a unicycle model.",
"chassis.Chassis.drive|param|rotationSpeed": "rotation of the robot around the center point, eg: 30",
"chassis.Chassis.drive|param|speed": "speed of the center point between motors, eg: 10",
"chassis.Chassis.setBaseLength": "Sets the base length in centimeters",
"chassis.Chassis.setMotors": "Sets the motors used by the chassis, default is B+C",
"chassis.Chassis.setWheelRadius": "Sets the wheel radius in centimeters"
}

View File

@ -1,8 +0,0 @@
{
"chassis.Chassis.drive|block": "drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s",
"chassis.Chassis.setBaseLength|block": "set %chassis|base length to %cm|(cm)",
"chassis.Chassis.setMotors|block": "set %chassis|motors to %motors",
"chassis.Chassis.setWheelRadius|block": "set %chassis|wheel radius to %cm|(cm)",
"chassis|block": "chassis",
"{id:category}Chassis": "Chassis"
}

View File

@ -1,22 +0,0 @@
{
"sensors.ColorSensor": "The color sensor is a digital sensor that can detect the color or intensity\nof light that enters the small window on the face of the sensor.",
"sensors.ColorSensor.calibrateLight": "Collects measurement of the light condition and adjusts the threshold to 10% / 90%.",
"sensors.ColorSensor.color": "Get the current color from the color sensor.",
"sensors.ColorSensor.colorMode": "Gets the current color mode",
"sensors.ColorSensor.light": "Measures the ambient or reflected light value from 0 (darkest) to 100 (brightest).",
"sensors.ColorSensor.onColorDetected": "Registers code to run when the given color is detected.",
"sensors.ColorSensor.onColorDetected|param|color": "the color to detect, eg: ColorSensorColor.Blue",
"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.pauseForColor": "Waits for the given color to be detected",
"sensors.ColorSensor.pauseForColor|param|color": "the color to detect",
"sensors.ColorSensor.pauseForLight": "Waits for the given color to be detected",
"sensors.ColorSensor.setThreshold": "Sets a threshold value",
"sensors.ColorSensor.setThreshold|param|condition": "the dark or bright light condition",
"sensors.ColorSensor.setThreshold|param|value": "the value threshold",
"sensors.ColorSensor.threshold": "Gets the threshold value",
"sensors.ColorSensor.threshold|param|condition": "the light condition",
"sensors.color": "Returns a color that the sensor can detect"
}

View File

@ -1,34 +0,0 @@
{
"ColorSensorColor.Black|block": "black",
"ColorSensorColor.Blue|block": "blue",
"ColorSensorColor.Brown|block": "brown",
"ColorSensorColor.Green|block": "green",
"ColorSensorColor.None|block": "none",
"ColorSensorColor.Red|block": "red",
"ColorSensorColor.White|block": "white",
"ColorSensorColor.Yellow|block": "yellow",
"ColorSensorMode.AmbientLightIntensity|block": "ambient light intensity",
"ColorSensorMode.Color|block": "color",
"ColorSensorMode.ReflectedLightIntensity|block": "reflected light intensity",
"LightCondition.Dark|block": "dark",
"LightIntensityMode.Ambient|block": "ambient light",
"LightIntensityMode.Reflected|block": "reflected light",
"sensors.ColorSensor.calibrateLight|block": "calibrate|%sensor|for %mode|light",
"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|%condition",
"sensors.ColorSensor.setThreshold|block": "set %sensor|%condition|to %value",
"sensors.ColorSensor.threshold|block": "%sensor|%condition",
"sensors.color1|block": "color 1",
"sensors.color2|block": "color 2",
"sensors.color3|block": "color 3",
"sensors.color4|block": "color 4",
"sensors.color|block": "color %color",
"sensors|block": "sensors",
"{id:category}Sensors": "Sensors",
"{id:group}Color Sensor": "Color Sensor",
"{id:group}Threshold": "Threshold"
}

View File

@ -115,7 +115,7 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% sensor.fieldEditor="ports"
//% weight=100 blockGap=8
//% weight=100 blockGap=12
//% group="Color Sensor"
onColorDetected(color: ColorSensorColor, handler: () => void) {
this.setMode(ColorSensorMode.Color)
@ -174,7 +174,7 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% sensor.fieldEditor="ports"
//% weight=89 blockGap=8
//% weight=89 blockGap=12
//% group="Color Sensor"
onLightChanged(mode: LightIntensityMode, condition: LightCondition, handler: () => void) {
this.setMode(<ColorSensorMode><number>mode)

View File

@ -1,115 +0,0 @@
{
"BrickLight": "Patterns for lights under the buttons.",
"ButtonEvent": "User interaction on buttons",
"Draw": "Drawing modes",
"Image.buffer": "Returns the underlaying Buffer object.",
"Image.doubled": "Double size of an image.",
"Image.draw": "Draw an image on the screen.",
"Image.height": "Returns the height of an image.",
"Image.width": "Returns the width of an image.",
"MMap.getNumber": "Read a number in specified format from the buffer.",
"MMap.ioctl": "Perform ioctl(2) on the underlaying file",
"MMap.length": "Returns the length of a Buffer object.",
"MMap.lseek": "Set pointer on the underlaying file.",
"MMap.read": "Perform read(2) on the underlaying file",
"MMap.setNumber": "Write a number in specified format in the buffer.",
"MMap.slice": "Read a range of bytes into a buffer.",
"MMap.write": "Perform write(2) on the underlaying file",
"SeekWhence": "Mode for lseek()",
"brick.Button": "Generic button class, for device buttons and sensors.",
"brick.Button.isPressed": "Check if button is currently pressed or not.",
"brick.Button.onEvent": "Do something when a button or sensor is clicked, up or down.",
"brick.Button.onEvent|param|body": "code to run when the event is raised",
"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.batteryLevel": "Returns the current battery level",
"brick.buttonDown": "Down button on the EV3 Brick.",
"brick.buttonEnter": "Enter button on the EV3 Brick.",
"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.printPorts": "Prints the port states on the screen",
"brick.setLight": "Set lights.",
"brick.setLight|param|pattern": "the lights pattern to use. eg: BrickLight.Orange",
"brick.showImage": "Shows an image on screen",
"brick.showImage|param|image": "image to draw",
"brick.showNumber": "Shows a number on the screen",
"brick.showNumber|param|line": "the line number to print the text at, eg: 1",
"brick.showNumber|param|value": "the numeric value",
"brick.showString": "Show text on the screen at a specific line.",
"brick.showString|param|line": "the line number to print the text at, eg: 1",
"brick.showString|param|text": "the text to print on the screen, eg: \"Hello world\"",
"brick.showValue": "Shows a name, value pair on the screen",
"brick.showValue|param|line": "the line number to print the text at, eg: 1",
"brick.showValue|param|value": "the numeric value",
"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.Timer": "A timer",
"control.Timer.millis": "Gets the elapsed time in millis since the last reset",
"control.Timer.pauseUntil": "Pauses until the timer reaches the given amount of milliseconds",
"control.Timer.pauseUntil|param|ms": "how long to pause for, eg: 5, 100, 200, 500, 1000, 2000",
"control.Timer.reset": "Resets the timer",
"control.Timer.seconds": "Gets the elapsed time in seconds since the last reset",
"control.allocateNotifyEvent": "Allocates the next user notification event",
"control.deviceFirmwareVersion": "Determine the version of system software currently running.",
"control.dmesg": "Write data to DMESG debugging buffer.",
"control.mmap": "Create new file mapping in memory",
"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 angle.",
"motors.Motor.clearCounts": "Clears the motor count",
"motors.Motor.setRegulated": "Indicates if the motor speed should be regulated. Default is true.",
"motors.Motor.setRegulated|param|value": "true for regulated motor",
"motors.Motor.speed": "Gets motor actual speed.",
"motors.Motor.tacho": "Gets motor tachometer count.",
"motors.Motor.toString": "Returns the status of the motor",
"motors.MotorBase.isReady": "Returns a value indicating if the motor is still running a previous command.",
"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 motor speed for limited time or distance.",
"motors.MotorBase.setSpeed|param|speed": "the speed from ``100`` full forward to ``-100`` full backward, eg: 50",
"motors.MotorBase.setSpeed|param|unit": "(optional) unit of the value",
"motors.MotorBase.setSpeed|param|value": "(optional) measured distance or rotation",
"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|turnRatio": "the ratio of power sent to the follower motor, from ``-200`` to ``200``, eg: 0",
"motors.SynchedMotorPair.steer|param|unit": "(optional) unit of the value",
"motors.SynchedMotorPair.steer|param|value": "(optional) move duration or rotation",
"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|speedLeft": "the speed on the left motor, eg: 50",
"motors.SynchedMotorPair.tank|param|speedRight": "the speed on the right motor, eg: 50",
"motors.SynchedMotorPair.tank|param|unit": "(optional) unit of the value",
"motors.SynchedMotorPair.tank|param|value": "(optional) move duration or rotation",
"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.",
"screen.imageOf": "Makes an image bound to a buffer.",
"screen.unpackPNG": "Decompresses a 1-bit gray scale PNG image to image format.",
"serial": "Reading and writing data over a serial connection.",
"serial.writeDmesg": "Send DMESG debug buffer over serial."
}

View File

@ -1,112 +0,0 @@
{
"BrickLight.GreenFlash|block": "green flash",
"BrickLight.GreenPulse|block": "green pulse",
"BrickLight.Green|block": "green",
"BrickLight.Off|block": "off",
"BrickLight.OrangeFlash|block": "orange flash",
"BrickLight.OrangePulse|block": "orange pulse",
"BrickLight.Orange|block": "orange",
"BrickLight.RedFlash|block": "red flash",
"BrickLight.RedPulse|block": "red pulse",
"BrickLight.Red|block": "red",
"ButtonEvent.Click|block": "click",
"ButtonEvent.Down|block": "down",
"ButtonEvent.Up|block": "up",
"MoveUnit.Degrees|block": "degrees",
"MoveUnit.MilliSeconds|block": "milliseconds",
"MoveUnit.Rotations|block": "rotations",
"MoveUnit.Seconds|block": "seconds",
"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": "%button|is pressed",
"brick.Button.onEvent|block": "on %button|%event",
"brick.Button.pauseUntil|block": "pause until %button|%event",
"brick.Button.wasPressed|block": "%button|was pressed",
"brick.batteryLevel|block": "battery level",
"brick.buttonDown|block": "button down",
"brick.buttonEnter|block": "button enter",
"brick.buttonLeft|block": "button left",
"brick.buttonRight|block": "button right",
"brick.buttonUp|block": "button up",
"brick.clearScreen|block": "clear screen",
"brick.printPorts|block": "print ports",
"brick.setLight|block": "set light to %pattern",
"brick.showImage|block": "show image %image=screen_image_picker",
"brick.showNumber|block": "show number %name|at line %line",
"brick.showString|block": "show string %text|at line %line",
"brick.showValue|block": "show value %name|= %text|at line %line",
"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.Timer.millis|block": "%timer|millis",
"control.Timer.pauseUntil|block": "%timer|pause until (ms) %ms",
"control.Timer.reset|block": "%timer|reset",
"control.Timer.seconds|block": "%timer|seconds",
"control.raiseEvent|block": "raise event|from %src|with value %value",
"control.timer1|block": "timer 1",
"control.timer2|block": "timer 2",
"control.timer3|block": "timer 3",
"control.timer4|block": "timer 4",
"control.timer5|block": "timer 5",
"control.timer6|block": "timer 6",
"control.timer7|block": "timer 7",
"control.timer8|block": "timer 8",
"control|block": "control",
"motors.Motor.angle|block": "%motor|angle",
"motors.Motor.clearCounts|block": "%motor|clear counts",
"motors.Motor.setRegulated|block": "set %motor|regulated %value=toggleOnOff",
"motors.Motor.speed|block": "%motor|speed",
"motors.Motor.tacho|block": "%motor|tacho",
"motors.MotorBase.pauseUntilReady|block": "%motor|pause until ready",
"motors.MotorBase.reset|block": "%motors|reset",
"motors.MotorBase.setBrake|block": "set %motor|brake %brake=toggleOnOff",
"motors.MotorBase.setReversed|block": "set %motor|reversed %reversed=toggleOnOff",
"motors.MotorBase.setSpeed|block": "set %motor|speed to %speed=motorSpeedPicker|%",
"motors.MotorBase.stop|block": "%motors|stop",
"motors.SynchedMotorPair.steer|block": "steer %chassis|turn ratio %turnRatio=motorTurnRatioPicker|speed %speed=motorSpeedPicker|%",
"motors.SynchedMotorPair.tank|block": "tank %motors|%speedLeft=motorSpeedPicker|%|%speedRight=motorSpeedPicker|%",
"motors.largeAB|block": "large A+B",
"motors.largeAD|block": "large A+D",
"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",
"{id:category}MMap": "MMap",
"{id:category}Motors": "Motors",
"{id:category}Output": "Output",
"{id:category}Screen": "Screen",
"{id:category}Sensors": "Sensors",
"{id:category}Serial": "Serial",
"{id:group}Buttons": "Buttons",
"{id:group}Counters": "Counters",
"{id:group}More": "More",
"{id:group}Move": "Move",
"{id:group}Screen": "Screen",
"{id:group}Sensors": "Sensors"
}

View File

@ -5,6 +5,7 @@ namespace brick {
*/
//% blockId=brickBatteryLevel block="battery level"
//% group="More"
//% help=brick/battery-level
export function batteryLevel(): number {
const info = sensors.internal.getBatteryInfo();
return info.current;

View File

@ -29,14 +29,15 @@ const enum BrickLight {
* User interaction on buttons
*/
const enum ButtonEvent {
//% block="click"
Click = 1,
//% block="up"
Up = 3,
//% block="down"
Down = 4,
//% block="pressed"
Pressed = 4,
//% block="bumped"
Bumped = 1,
//% block="released"
Released = 3,
}
namespace brick {
/**
* Generic button class, for device buttons and sensors.
@ -62,12 +63,12 @@ namespace brick {
if (curr) {
this._wasPressed = true;
this.downTime = control.millis()
control.raiseEvent(this._id, ButtonEvent.Down)
control.raiseEvent(this._id, ButtonEvent.Pressed)
} else {
control.raiseEvent(this._id, ButtonEvent.Up)
control.raiseEvent(this._id, ButtonEvent.Released)
const delta = control.millis() - this.downTime;
if (delta < 500)
control.raiseEvent(this._id, ButtonEvent.Click)
control.raiseEvent(this._id, ButtonEvent.Bumped)
}
}
@ -75,7 +76,7 @@ namespace brick {
* Check if button is currently pressed or not.
* @param button the button to query the request
*/
//% help=input/button/is-pressed
//% help=brick/button/is-pressed
//% block="%button|is pressed"
//% blockId=buttonIsPressed
//% parts="brick"
@ -91,7 +92,7 @@ namespace brick {
* See if the button was pressed again since the last time you checked.
* @param button the button to query the request
*/
//% help=input/button/was-pressed
//% help=brick/button/was-pressed
//% block="%button|was pressed"
//% blockId=buttonWasPressed
//% parts="brick"
@ -111,11 +112,11 @@ namespace brick {
* @param event the kind of button gesture that needs to be detected
* @param body code to run when the event is raised
*/
//% help=input/button/on-event
//% help=brick/button/on-event
//% blockId=buttonEvent block="on %button|%event"
//% parts="brick"
//% blockNamespace=brick
//% weight=99 blockGap=8
//% weight=99 blockGap=16
//% group="Buttons"
//% button.fieldEditor="brickbuttons"
onEvent(ev: ButtonEvent, body: () => void) {
@ -126,7 +127,7 @@ namespace brick {
* Waits until the event is raised
* @param ev the event to wait for
*/
//% help=input/button/pause-until
//% help=brick/button/pause-until
//% blockId=buttonWaitUntil block="pause until %button|%event"
//% parts="brick"
//% blockNamespace=brick
@ -251,6 +252,7 @@ namespace brick {
*/
//% blockId=setLights block="set light to %pattern"
//% weight=100 group="Buttons"
//% help=brick/set-light
export function setLight(pattern: BrickLight): void {
if (currPattern === pattern)
return

View File

@ -66,8 +66,8 @@ namespace console.screen {
if (!lines) {
lines = [];
console.addListener(log);
brick.buttonUp.onEvent(ButtonEvent.Click, () => scroll(-3))
brick.buttonDown.onEvent(ButtonEvent.Click, () => scroll(3))
brick.buttonUp.onEvent(ButtonEvent.Bumped, () => scroll(-3))
brick.buttonDown.onEvent(ButtonEvent.Bumped, () => scroll(3))
}
}

29
libs/core/enums.d.ts vendored
View File

@ -1,29 +0,0 @@
// Auto-generated. Do not edit.
/**
* Mode for lseek()
*/
declare const enum SeekWhence {
Set = 0,
Current = 1,
End = 2,
}
/**
* Drawing modes
*/
declare const enum Draw {
Normal = 0x00,
Clear = 0x01,
Xor = 0x02,
Fill = 0x04,
Transparent = 0x08,
Double = 0x10,
Quad = 0x20,
}
// Auto-generated. Do not edit. Really.

View File

@ -187,7 +187,7 @@ namespace motors {
*/
//% weight=6 blockGap=8
//% group="Move"
//% blockId=motorStop block="%motors|stop"
//% blockId=motorStop block="stop %motors|"
stop() {
this.init();
stop(this._port, this._brake);
@ -206,7 +206,7 @@ namespace motors {
*/
//% weight=5
//% group="Move"
//% blockId=motorReset block="%motors|reset"
//% blockId=motorReset block="reset %motors|"
reset() {
this.init();
reset(this._port);
@ -279,7 +279,7 @@ namespace motors {
* Pauses the execution until the previous command finished.
* @param timeOut optional maximum pausing time in milliseconds
*/
//% blockId=motorPauseUntilRead block="%motor|pause until ready"
//% blockId=motorPauseUntilRead block="pause until %motor|ready"
//% weight=90
//% group="Move"
pauseUntilReady(timeOut?: number) {
@ -385,7 +385,7 @@ namespace motors {
/**
* Clears the motor count
*/
//% blockId=motorClearCount block="%motor|clear counts"
//% blockId=motorClearCount block="clear %motor|counters"
//% weight=68
//% blockGap=8
//% group="Counters"

View File

@ -72,6 +72,7 @@ namespace brick {
*/
//% blockId=screen_print block="show string %text|at line %line"
//% weight=98 group="Screen" inlineInputMode="inline" blockGap=8
//% help=brick/show-string
//% line.min=1 line.max=10
export function showString(text: string, line: number) {
const NUM_LINES = 9;
@ -87,6 +88,7 @@ namespace brick {
*/
//% blockId=screenShowNumber block="show number %name|at line %line"
//% weight=96 group="Screen" inlineInputMode="inline" blockGap=8
//% help=brick/show-number
//% line.min=1 line.max=10
export function showNumber(value: number, line: number) {
showString("" + value, line);
@ -99,6 +101,7 @@ namespace brick {
*/
//% blockId=screenShowValue block="show value %name|= %text|at line %line"
//% weight=96 group="Screen" inlineInputMode="inline" blockGap=8
//% help=brick/show-value
//% line.min=1 line.max=10
export function showValue(name: string, value: number, line: number) {
value = Math.round(value * 1000) / 1000;
@ -136,11 +139,12 @@ namespace brick {
}
/**
* Shows an image on screen
* Show an image on the screen
* @param image image to draw
*/
//% blockId=screen_show_image block="show image %image=screen_image_picker"
//% weight=100 group="Screen" blockGap=8
//% help=brick/show-image
export function showImage(image: Image) {
if (!image) return;
image.draw(0, 0, Draw.Normal);
@ -160,10 +164,11 @@ namespace brick {
}
/**
* Clears the screen
* Clear the screen
*/
//% blockId=screen_clear_screen block="clear screen"
//% weight=90 group="Screen"
//% help=brick/clear-screen
export function clearScreen() {
screen.clear();
}
@ -206,39 +211,4 @@ namespace brick {
if (y < y1)
setLineCore(x, x1, y, mode);
}
/**
* Prints the port states on the screen
*/
//% blockId=brickPrintPorts block="print ports"
//% weight=1 group="Screen"
export function printPorts() {
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;
print(`${scale(data.actualSpeed)}%`, x, brick.LINE_HEIGHT)
print(`${scale(data.count)}>`, x, 2 * brick.LINE_HEIGHT)
print(`${scale(data.tachoCount)}|`, 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 v = si._query();
print(`${scale(v)}`, x, 9 * brick.LINE_HEIGHT)
}
}
}

144
libs/core/shims.d.ts vendored
View File

@ -1,144 +0,0 @@
// Auto-generated. Do not edit.
declare namespace control {
/** Create new file mapping in memory */
//% shim=control::mmap
function mmap(filename: string, size: int32, offset: int32): MMap;
}
declare interface MMap {
/**
* Write a number in specified format in the buffer.
*/
//% shim=MMapMethods::setNumber
setNumber(format: NumberFormat, offset: int32, value: number): void;
/**
* Read a number in specified format from the buffer.
*/
//% shim=MMapMethods::getNumber
getNumber(format: NumberFormat, offset: int32): number;
/**
* Read a range of bytes into a buffer.
*/
//% offset.defl=0 length.defl=-1 shim=MMapMethods::slice
slice(offset?: int32, length?: int32): Buffer;
/** Returns the length of a Buffer object. */
//% property shim=MMapMethods::length
length: int32;
/** Perform ioctl(2) on the underlaying file */
//% shim=MMapMethods::ioctl
ioctl(id: uint32, data: Buffer): int32;
/** Perform write(2) on the underlaying file */
//% shim=MMapMethods::write
write(data: Buffer): int32;
/** Perform read(2) on the underlaying file */
//% shim=MMapMethods::read
read(data: Buffer): int32;
/** Set pointer on the underlaying file. */
//% shim=MMapMethods::lseek
lseek(offset: int32, whence: SeekWhence): int32;
}
declare namespace control {
/**
* Announce that an event happened to registered handlers.
* @param src ID of the Component that generated the event
* @param value Component specific code indicating the cause of the event.
* @param mode optional definition of how the event should be processed after construction.
*/
//% weight=21 blockGap=12 blockId="control_raise_event"
//% block="raise event|from %src|with value %value" blockExternalInputs=1 shim=control::raiseEvent
function raiseEvent(src: int32, value: int32): void;
/**
* Allocates the next user notification event
*/
//% help=control/allocate-notify-event shim=control::allocateNotifyEvent
function allocateNotifyEvent(): int32;
/** Write data to DMESG debugging buffer. */
//% shim=control::dmesg
function dmesg(s: string): void;
}
declare namespace serial {
/** Send DMESG debug buffer over serial. */
//% shim=serial::writeDmesg
function writeDmesg(): void;
}
declare namespace screen {
/** Decompresses a 1-bit gray scale PNG image to image format. */
//% shim=screen::unpackPNG
function unpackPNG(png: Buffer): Image;
}
declare namespace screen {
/** Clear screen and reset font to normal. */
//% shim=screen::clear
function clear(): void;
/** Makes an image bound to a buffer. */
//% shim=screen::imageOf
function imageOf(buf: Buffer): Image;
}
//% fixedInstances
declare interface Image {
/** Returns the underlaying Buffer object. */
//% property shim=ImageMethods::buffer
buffer: Buffer;
/** Returns the width of an image. */
//% property shim=ImageMethods::width
width: int32;
/** Returns the height of an image. */
//% property shim=ImageMethods::height
height: int32;
/** Double size of an image. */
//% shim=ImageMethods::doubled
doubled(): Image;
/** Draw an image on the screen. */
//% shim=ImageMethods::draw
draw(x: int32, y: int32, mode: Draw): void;
}
declare namespace output {
/**
* Create a new zero-initialized buffer.
* @param size number of bytes in the buffer
*/
//% 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.

View File

@ -6,25 +6,25 @@ brick.setLight(BrickLight.Orange)
brick.heart.doubled().draw(100, 50, Draw.Double | Draw.Transparent)
brick.buttonEnter.onEvent(ButtonEvent.Click, () => {
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
screen.clear()
})
brick.buttonLeft.onEvent(ButtonEvent.Click, () => {
brick.buttonLeft.onEvent(ButtonEvent.Bumped, () => {
brick.drawRect(10, 70, 20, 10, Draw.Fill)
brick.setLight(BrickLight.Red)
brick.setFont(brick.microbitFont())
})
brick.buttonRight.onEvent(ButtonEvent.Click, () => {
brick.buttonRight.onEvent(ButtonEvent.Bumped, () => {
brick.print("Right!", 10, 60)
})
brick.buttonDown.onEvent(ButtonEvent.Click, () => {
brick.buttonDown.onEvent(ButtonEvent.Bumped, () => {
brick.print("Down! ", 10, 60)
})
brick.buttonUp.onEvent(ButtonEvent.Click, () => {
brick.buttonUp.onEvent(ButtonEvent.Bumped, () => {
brick.print("Up! ", 10, 60)
})

View File

@ -1,17 +0,0 @@
{
"datalog": "A data logging framework",
"datalog.DatalogStorage": "A storage for datalog data",
"datalog.DatalogStorage.appendHeaders": "Appends the headers in datalog",
"datalog.DatalogStorage.appendRow": "Appends a row of data",
"datalog.DatalogStorage.flush": "Flushes any buffered data",
"datalog.DatalogStorage.init": "Initializes the storage",
"datalog.addRow": "Starts a row of data",
"datalog.addValue": "Adds a cell to the row of data",
"datalog.addValue|param|name": "name of the cell, eg: \"x\"",
"datalog.addValue|param|value": "value of the cell, eg: 0",
"datalog.flush": "Commits any buffered row to disk",
"datalog.setEnabled": "Turns on or off datalogging",
"datalog.setSampleInterval": "Sets the minimum number of milli seconds between rows",
"datalog.setSampleInterval|param|millis": "milliseconds between each sample, eg: 50",
"datalog.setStorage": "* @param storage custom storage solution"
}

View File

@ -1,8 +0,0 @@
{
"datalog.addRow|block": "datalog add row",
"datalog.addValue|block": "datalog add %name|=%value",
"datalog.setEnabled|block": "datalog %enabled=toggleOnOff",
"datalog.setSampleInterval|block": "set datalog sampling interval to %millis|(ms)",
"datalog|block": "datalog",
"{id:category}Datalog": "Datalog"
}

View File

@ -1 +0,0 @@
{}

View File

@ -1 +0,0 @@
{}

View File

@ -1,21 +1,20 @@
//% color="#68C3E2" weight=100 icon="\uf106"
//% groups='["Buttons", "Screen"]'
//% labelLineWidth=0
//% labelLineWidth=60
namespace brick {
}
//% color="#C8509B" weight=95 icon="\uf10f"
//% labelLineWidth=0
//% labelLineWidth=100
//% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Gyro Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Threshold"]'
//% groupIcons='["\uf101","\uf103","\uf102","","","\uf104"]'
namespace sensors {
}
//% color="#A5CA18" weight=90 icon="\uf10d"
//% groups='["Move", "Counters"]'
//% labelLineWidth=0
//% labelLineWidth=50
namespace motors {
}

View File

@ -14,6 +14,7 @@
"touch-sensor": "file:../touch-sensor",
"ultrasonic-sensor": "file:../ultrasonic-sensor",
"gyro-sensor": "file:../gyro-sensor",
"infrared-sensor": "file:../infrared-sensor",
"mood": "file:../mood"
},
"public": true

View File

@ -1,7 +0,0 @@
{
"sensors.GyroSensor.angle": "Get the current angle from the gyroscope.",
"sensors.GyroSensor.drift": "Gets the computed rate drift",
"sensors.GyroSensor.rate": "Get the current rotation rate from the gyroscope.",
"sensors.GyroSensor.reset": "Forces a calibration of the gyro. Must be called when the sensor is completely still.",
"sensors.GyroSensor.setDriftCorrection": "Enables or disable drift correction"
}

View File

@ -1,11 +0,0 @@
{
"sensors.GyroSensor.angle|block": "%sensor|angle",
"sensors.GyroSensor.rate|block": "%sensor|rate",
"sensors.GyroSensor.reset|block": "%sensor|reset",
"sensors.gyro1|block": "gyro 1",
"sensors.gyro2|block": "gyro 2",
"sensors.gyro3|block": "gyro 3",
"sensors.gyro4|block": "gyro 4",
"{id:category}Sensors": "Sensors",
"{id:group}Gyro Sensor": "Gyro Sensor"
}

View File

@ -82,12 +82,12 @@ namespace sensors {
* Forces a calibration of the gyro. Must be called when the sensor is completely still.
*/
//% help=input/gyro/calibrate
//% block="%sensor|reset"
//% block="reset %sensor|"
//% blockId=gyroReset
//% parts="gyroscope"
//% blockNamespace=sensors
//% sensor.fieldEditor="ports"
//% weight=50 blockGap=8
//% weight=50
//% group="Gyro Sensor"
reset(): void {
if (this.calibrating) return; // already in calibration mode

View File

@ -1,21 +0,0 @@
{
"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.setThreshold": "Sets a threshold value",
"sensors.InfraredSensor.setThreshold|param|condition": "the dark or bright light condition",
"sensors.InfraredSensor.setThreshold|param|value": "the value threshold",
"sensors.InfraredSensor.threshold": "Gets the threshold value",
"sensors.InfraredSensor.threshold|param|condition": "the proximity condition",
"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",
"sensors.RemoteInfraredBeaconButton.wasPressed": "See if the remote button was pressed again since the last time you checked.",
"sensors.remoteButtonBottomLeft": "Remote bottom-left button.",
"sensors.remoteButtonBottomRight": "Remote bottom-right button.",
"sensors.remoteButtonCenter": "Remote beacon (center) button.",
"sensors.remoteButtonTopLeft": "Remote top-left button.",
"sensors.remoteButtonTopRight": "Remote top-right button."
}

View File

@ -1,27 +0,0 @@
{
"InfraredSensorEvent.ObjectDetected|block": "object detected",
"InfraredSensorEvent.ObjectNear|block": "object near",
"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.InfraredSensor.setThreshold|block": "set %sensor|%condition|to %value",
"sensors.InfraredSensor.threshold|block": "%sensor|%condition",
"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",
"sensors.remoteButtonTopLeft|block": "top-left",
"sensors.remoteButtonTopRight|block": "top-right",
"sensors|block": "sensors",
"{id:category}Sensors": "Sensors",
"{id:group}Infrared Sensor": "Infrared Sensor",
"{id:group}Remote Infrared Beacon": "Remote Infrared Beacon",
"{id:group}Threshold": "Threshold"
}

View File

@ -1,29 +1,37 @@
const enum IrSensorMode {
const enum InfraredSensorMode {
None = -1,
Proximity = 0,
Seek = 1,
RemoteControl = 2,
}
const enum IrRemoteChannel {
const enum InfraredRemoteChannel {
//% block="channel 0"
Ch0 = 0, // top
//% block="channel 1"
Ch1 = 1,
//% block="channel 2"
Ch2 = 2,
//% block="channel 3"
Ch3 = 3,
}
const enum IrRemoteButton {
None = 0x00,
const enum InfraredRemoteButton {
//% block="center beacon"
CenterBeacon = 0x01,
//% block="top left"
TopLeft = 0x02,
//% block="bottom left"
BottomLeft = 0x04,
//% block="top right"
TopRight = 0x08,
//% block="bottom right"
BottomRight = 0x10,
}
const enum InfraredSensorEvent {
//% block="object near"
ObjectNear = 1,
ObjectNear = 3,
//% block="object detected"
ObjectDetected = 2
}
@ -31,55 +39,37 @@ const enum InfraredSensorEvent {
namespace sensors {
function mapButton(v: number) {
switch (v) {
case 0: return IrRemoteButton.None
case 1: return IrRemoteButton.TopLeft
case 2: return IrRemoteButton.BottomLeft
case 3: return IrRemoteButton.TopRight
case 4: return IrRemoteButton.TopRight | IrRemoteButton.BottomRight
case 5: return IrRemoteButton.TopLeft | IrRemoteButton.TopRight
case 6: return IrRemoteButton.TopLeft | IrRemoteButton.BottomRight
case 7: return IrRemoteButton.BottomLeft | IrRemoteButton.TopRight
case 8: return IrRemoteButton.BottomLeft | IrRemoteButton.BottomRight
case 9: return IrRemoteButton.CenterBeacon
case 10: return IrRemoteButton.BottomLeft | IrRemoteButton.TopLeft
case 11: return IrRemoteButton.TopRight | IrRemoteButton.BottomRight
default: return IrRemoteButton.None
case 1: return InfraredRemoteButton.TopLeft
case 2: return InfraredRemoteButton.BottomLeft
case 3: return InfraredRemoteButton.TopRight
case 4: return InfraredRemoteButton.TopRight | InfraredRemoteButton.BottomRight
case 5: return InfraredRemoteButton.TopLeft | InfraredRemoteButton.TopRight
case 6: return InfraredRemoteButton.TopLeft | InfraredRemoteButton.BottomRight
case 7: return InfraredRemoteButton.BottomLeft | InfraredRemoteButton.TopRight
case 8: return InfraredRemoteButton.BottomLeft | InfraredRemoteButton.BottomRight
case 9: return InfraredRemoteButton.CenterBeacon
case 10: return InfraredRemoteButton.BottomLeft | InfraredRemoteButton.TopLeft
case 11: return InfraredRemoteButton.TopRight | InfraredRemoteButton.BottomRight
default: return 0;
}
}
let buttons: RemoteInfraredBeaconButton[]
function create(ir: InfraredSensor) {
// it's created by referencing it
}
export function irButton(id: IrRemoteButton): RemoteInfraredBeaconButton {
if (buttons == null) {
buttons = []
for (let i = 0; i < 5; ++i) {
buttons.push(new RemoteInfraredBeaconButton(new brick.Button()))
}
// make sure sensors are up
create(infraredSensor1)
create(infraredSensor2)
create(infraredSensor3)
create(infraredSensor4)
const __remoteButtons: RemoteInfraredBeaconButton[] = [];
function __irButton(id: InfraredRemoteButton): RemoteInfraredBeaconButton {
for(let i = 0; i < __remoteButtons.length; ++i) {
if (__remoteButtons[i].position == id)
return __remoteButtons[i];
}
let num = -1
while (id) {
id >>= 1;
num++;
}
num = Math.clamp(0, buttons.length - 1, num)
return buttons[num]
const btn = new RemoteInfraredBeaconButton(id, new brick.Button());
__remoteButtons.push(btn);
return btn;
}
//% fixedInstances
export class RemoteInfraredBeaconButton extends control.Component {
position: InfraredRemoteButton;
private button: brick.Button;
constructor(button: brick.Button) {
constructor(position: InfraredRemoteButton, button: brick.Button) {
super();
this.button = button;
}
@ -133,40 +123,51 @@ namespace sensors {
onEvent(ev: ButtonEvent, body: () => void) {
this.button.onEvent(ev, body);
}
/**
* Pauses until the given event is raised
* @param ev the event to wait for
*/
//% help=input/remote-infrared-beacon/pause-until
//% blockId=remotebuttonEvent block="pause until %button|%event"
//% parts="remote"
//% blockNamespace=sensors
//% weight=99 blockGap=8
//% group="Remote Infrared Beacon"
pauseUntil(ev: ButtonEvent) {
this.button.pauseUntil(ev);
}
}
//% fixedInstances
export class InfraredSensor extends internal.UartSensor {
private channel: IrRemoteChannel;
private proximityThreshold: sensors.ThresholdDetector;
private _channel: InfraredRemoteChannel;
private _proximityThreshold: sensors.ThresholdDetector;
constructor(port: number) {
super(port)
this.channel = IrRemoteChannel.Ch0
this.proximityThreshold = new sensors.ThresholdDetector(this._id, 0, 100, 10, 90);
irButton(0) // make sure buttons array is initalized
// and set the mode, as otherwise button events won't work
this.mode = IrSensorMode.RemoteControl;
this._channel = InfraredRemoteChannel.Ch0
this._proximityThreshold = new sensors.ThresholdDetector(this._id, 0, 100, 10, 90);
this.setMode(InfraredSensorMode.Proximity);
}
_query() {
if (this.mode == IrSensorMode.RemoteControl)
return mapButton(this.getNumber(NumberFormat.UInt8LE, this.channel));
else if (this.mode == IrSensorMode.Proximity) {
if (this.mode == InfraredSensorMode.RemoteControl)
return mapButton(this.getNumber(NumberFormat.UInt8LE, this._channel));
else if (this.mode == InfraredSensorMode.Proximity) {
return this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff;
}
return 0
}
_update(prev: number, curr: number) {
if (this.mode == IrSensorMode.RemoteControl) {
for (let i = 0; i < buttons.length; ++i) {
if (this.mode == InfraredSensorMode.RemoteControl) {
for (let i = 0; i < __remoteButtons.length; ++i) {
let v = !!(curr & (1 << i))
buttons[i]._update(v)
__remoteButtons[i]._update(v)
}
} else if (this.mode == IrSensorMode.Proximity) {
this.proximityThreshold.setLevel(curr);
} else if (this.mode == InfraredSensorMode.Proximity) {
this._proximityThreshold.setLevel(curr);
}
}
@ -174,13 +175,7 @@ namespace sensors {
return DAL.DEVICE_TYPE_IR
}
setRemoteChannel(c: IrRemoteChannel) {
c = Math.clamp(0, 3, c | 0)
this.channel = c
this.setMode(IrSensorMode.RemoteControl)
}
setMode(m: IrSensorMode) {
setMode(m: InfraredSensorMode) {
this._setMode(m)
}
@ -196,6 +191,7 @@ namespace sensors {
//% weight=100 blockGap=8
//% group="Infrared Sensor"
onEvent(event: InfraredSensorEvent, handler: () => void) {
this._setMode(InfraredSensorMode.Proximity)
control.onEvent(this._id, event, handler);
}
@ -210,6 +206,7 @@ namespace sensors {
//% weight=99 blockGap=8
//% group="Infrared Sensor"
pauseUntil(event: InfraredSensorEvent) {
this._setMode(InfraredSensorMode.Proximity)
control.waitForEvent(this._id, event);
}
@ -222,36 +219,27 @@ namespace sensors {
//% blockId=infraredGetProximity
//% parts="infrared"
//% blockNamespace=sensors
//% weight=65 blockGap=8
//% weight=98 blockGap=8
//% group="Infrared Sensor"
proximity(): number {
this._setMode(IrSensorMode.Proximity)
this._setMode(InfraredSensorMode.Proximity)
return this.getNumber(NumberFormat.UInt8LE, 0)
}
/**
* Get the remote commandreceived the infrared sensor.
* @param sensor the infrared sensor
* Sets the remote channel to listen from
* @param channel the channel to listen
*/
//% help=input/infrared/remote-command
//% block="%sensor|remote command"
//% blockId=infraredGetRemoteCommand
//% parts="infrared"
//% blockNamespace=sensors
//% blockId=irSetRemoteChannel block="set %sensor|remote channel to %channel"
//% weight=65
//% group="Infrared Sensor"
remoteCommand(): number {
this._setMode(IrSensorMode.RemoteControl)
return this.getNumber(NumberFormat.UInt8LE, this.channel)
//% group="Remote Infrared Beacon"
setRemoteChannel(channel: InfraredRemoteChannel) {
this.setMode(InfraredSensorMode.RemoteControl)
channel = Math.clamp(0, 3, channel | 0)
this._channel = channel;
}
// TODO
getDirectionAndDistance() {
this._setMode(IrSensorMode.Seek)
return this.getNumber(NumberFormat.UInt16LE, this.channel * 2)
}
/**
* Sets a threshold value
* @param condition the dark or bright light condition
@ -260,11 +248,11 @@ namespace sensors {
//% blockId=irSetThreshold block="set %sensor|%condition|to %value"
//% group="Threshold" blockGap=8 weight=49
//% value.min=0 value.max=100
setThreshold(condition: InfraredSensorEvent, value: number) {
setPromixityThreshold(condition: InfraredSensorEvent, value: number) {
if (condition == InfraredSensorEvent.ObjectNear)
this.proximityThreshold.setLowThreshold(value)
this._proximityThreshold.setLowThreshold(value)
else
this.proximityThreshold.setHighThreshold(value);
this._proximityThreshold.setHighThreshold(value);
}
/**
@ -274,9 +262,15 @@ namespace sensors {
//% blockId=irGetThreshold block="%sensor|%condition"
//% group="Threshold" blockGap=8 weight=49
//% sensor.fieldEditor="ports"
threshold(condition: InfraredSensorEvent): number {
return this.proximityThreshold.threshold(<ThresholdState><number>LightCondition.Dark);
}
proximityThreshold(condition: InfraredSensorEvent): number {
return this._proximityThreshold.threshold(<ThresholdState><number>LightCondition.Dark);
}
// TODO
private getDirectionAndDistance() {
this._setMode(InfraredSensorMode.Seek)
return this.getNumber(NumberFormat.UInt16LE, this._channel * 2)
}
}
//% fixedInstance whenUsed block="infrared 1" jres=icons.port1
@ -291,34 +285,33 @@ namespace sensors {
//% fixedInstance whenUsed block="infrared 4" jres=icons.port4
export const infraredSensor4: InfraredSensor = new InfraredSensor(4)
/**
* Remote beacon (center) button.
*/
//% whenUsed block="center" weight=95 fixedInstance
export const remoteButtonCenter = irButton(IrRemoteButton.CenterBeacon)
//% whenUsed block="remote button center" weight=95 fixedInstance
export const remoteButtonCenter = __irButton(InfraredRemoteButton.CenterBeacon)
/**
* Remote top-left button.
*/
//% whenUsed block="top-left" weight=95 fixedInstance
export const remoteButtonTopLeft = irButton(IrRemoteButton.TopLeft)
//% whenUsed block="remote button top-left" weight=95 fixedInstance
export const remoteButtonTopLeft = __irButton(InfraredRemoteButton.TopLeft)
/**
* Remote top-right button.
*/
//% whenUsed block="top-right" weight=95 fixedInstance
export const remoteButtonTopRight = irButton(IrRemoteButton.TopRight)
//% whenUsed block="remote button top-right" weight=95 fixedInstance
export const remoteButtonTopRight = __irButton(InfraredRemoteButton.TopRight)
/**
* Remote bottom-left button.
*/
//% whenUsed block="bottom-left" weight=95 fixedInstance
export const remoteButtonBottomLeft = irButton(IrRemoteButton.BottomLeft)
//% whenUsed block="remote button bottom-left" weight=95 fixedInstance
export const remoteButtonBottomLeft = __irButton(InfraredRemoteButton.BottomLeft)
/**
* Remote bottom-right button.
*/
//% whenUsed block="bottom-right" weight=95 fixedInstance
export const remoteButtonBottomRight = irButton(IrRemoteButton.BottomRight)
//% whenUsed block="remote button bottom-right" weight=95 fixedInstance
export const remoteButtonBottomRight = __irButton(InfraredRemoteButton.BottomRight)
}

View File

@ -1,17 +0,0 @@
{
"brick.Mood": "A mood",
"brick.Mood.show": "Shows the mood on the EV3",
"brick.showMood": "Shows a mood",
"moods.angry": "An angry mood",
"moods.awake": "A awake mood",
"moods.dizzy": "A dizzy mood",
"moods.knockedOut": "A knocked out mood",
"moods.love": "In love mood",
"moods.middleLeft": "Looking around left",
"moods.middleRight": "Looking around right",
"moods.neutral": "In a neutral mood",
"moods.sad": "A sad mood",
"moods.sleeping": "A sleeping mood",
"moods.tired": "A tired mood",
"moods.winking": "In laughing mood"
}

View File

@ -1,8 +0,0 @@
{
"brick.showMood|block": "show mood %mood=mood_image_picker",
"brick|block": "brick",
"moods|block": "moods",
"{id:category}Brick": "Brick",
"{id:category}Moods": "Moods",
"{id:group}Screen": "Screen"
}

View File

@ -0,0 +1,37 @@
# show Mood
Show a mood on the brick. A mood will have a image on the display along with a sound and solid or flashing light.
```sig
brick.showMood(moods.sleeping)
```
You can choose one of several moods to show on the display. Use a mood to help show what your @boardname@ is doing at the moment.
## Parameters
**mood**: A mood to show on the brick. Choose one of these moods:
>* ``sleeping``
* ``awake``
* ``tired``
* ``angry``
* ``sad``
* ``dizzy``
* ``knockedOut``
* ``middleLeft``
* ``middleRight``
* ``love``
* ``winking``
* ``neutral``
## Example
Show a ``winking`` mood on the brick.
```blocks
brick.showMood(moods.winking)
```
## See also
[show image](/reference/brick/show-image)

View File

@ -1,9 +1,10 @@
namespace brick {
/**
* Shows a mood
* Show a mood on the brick's screen
*/
//% weight=90
//% blockId=moodShow block="show mood %mood=mood_image_picker"
//% help=brick/show-mood
//% weight=101 group="Screen" blockGap=8
export function showMood(mood: Mood) {
if(mood)

View File

@ -1,29 +0,0 @@
{
"Sound.buffer": "Returns the underlaying Buffer object.",
"Sound.play": "Play sound.",
"music": "Generation of music tones.",
"music.beat": "Return the duration of a beat in milliseconds (the beat fraction).",
"music.beat|param|fraction": "the fraction of the current whole note, eg: BeatFraction.Half",
"music.changeTempoBy": "Change the tempo up or down by some amount of beats per minute (bpm).",
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
"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.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.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)",
"music.rest": "Rest, or play silence, for some time (in milleseconds).",
"music.rest|param|ms": "rest duration in milliseconds (ms), eg: 100",
"music.ringTone": "Play a tone.",
"music.ringTone|param|frequency": "pitch of the tone to play in Hertz (Hz), eg: Note.C",
"music.setTempo": "Set the tempo a number of beats per minute (bpm).",
"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...100, eg: 50",
"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."
}

View File

@ -1,166 +0,0 @@
{
"BeatFraction.Breve|block": "4",
"BeatFraction.Double|block": "2",
"BeatFraction.Eighth|block": "1/8",
"BeatFraction.Half|block": "1/2",
"BeatFraction.Quarter|block": "1/4",
"BeatFraction.Sixteenth|block": "1/16",
"BeatFraction.Whole|block": "1",
"Note.CSharp3|block": "C#3",
"Note.CSharp4|block": "C#4",
"Note.CSharp5|block": "C#5",
"Note.CSharp|block": "C#",
"Note.FSharp3|block": "F#3",
"Note.FSharp4|block": "F#4",
"Note.FSharp5|block": "F#5",
"Note.FSharp|block": "F#",
"Note.GSharp3|block": "G#3",
"Note.GSharp4|block": "G#4",
"Note.GSharp5|block": "G#5",
"Note.GSharp|block": "G#",
"SoundOutputDestination.Pin|block": "pin",
"SoundOutputDestination.Speaker|block": "speaker",
"music.beat|block": "%fraction|beat",
"music.changeTempoBy|block": "change tempo by %value|(bpm)",
"music.noteFrequency|block": "%note",
"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.stopAllSounds|block": "stop all sounds",
"music.tempo|block": "tempo (bpm)",
"music|block": "music",
"sounds.animalsCatPurr|block": "animals cat purr",
"sounds.animalsDogBark1|block": "animals dog bark 1",
"sounds.animalsDogBark2|block": "animals dog bark 2",
"sounds.animalsDogGrowl|block": "animals dog growl",
"sounds.animalsDogSniff|block": "animals dog sniff",
"sounds.animalsDogWhine|block": "animals dog whine",
"sounds.animalsElephantCall|block": "animals elephant call",
"sounds.animalsInsectBuzz1|block": "animals insect buzz1",
"sounds.animalsInsectBuzz2|block": "animals insect buzz2",
"sounds.animalsInsectChirp|block": "animals insect chirp",
"sounds.animalsSnakeHiss|block": "animals snake hiss",
"sounds.animalsSnakeRattle|block": "animals snake rattle",
"sounds.animalsTRexRoar|block": "animals trex roar",
"sounds.colorsBlack|block": "colors black",
"sounds.colorsBlue|block": "colors blue",
"sounds.colorsBrown|block": "colors brown",
"sounds.colorsGreen|block": "colors green",
"sounds.colorsRed|block": "colors red",
"sounds.colorsWhite|block": "colors white",
"sounds.colorsYellow|block": "colors yellow",
"sounds.communicationBravo|block": "communication bravo",
"sounds.communicationEv3|block": "communication ev3",
"sounds.communicationFantastic|block": "communication fantastic",
"sounds.communicationGameOver|block": "communication game over",
"sounds.communicationGoodJob|block": "communicationGoodJob",
"sounds.communicationGoodbye|block": "communication goodbye",
"sounds.communicationGood|block": "communication good",
"sounds.communicationGo|block": "communication go",
"sounds.communicationHello|block": "communication hello",
"sounds.communicationHi|block": "communication hi",
"sounds.communicationLego|block": "communication lego",
"sounds.communicationMindstorms|block": "communication mindstorms",
"sounds.communicationMorning|block": "communication morning",
"sounds.communicationNo|block": "communication no",
"sounds.communicationOkay|block": "communication okay",
"sounds.communicationOkeyDokey|block": "communication okey dokey",
"sounds.communicationSorry|block": "communication sorry",
"sounds.communicationThankYou|block": "communication thank you",
"sounds.communicationYes|block": "communication yes",
"sounds.expressionsBoing|block": "expressions boing",
"sounds.expressionsBoo|block": "expressions boo",
"sounds.expressionsCheering|block": "expressions cheering",
"sounds.expressionsCrunching|block": "expressions crunching",
"sounds.expressionsCrying|block": "expressions crying",
"sounds.expressionsFanfare|block": "expressions fanfare",
"sounds.expressionsKungFu|block": "expressions kung fu",
"sounds.expressionsLaughing1|block": "expressions laughing1",
"sounds.expressionsLaughing2|block": "expressions laughing2",
"sounds.expressionsMagicWand|block": "expressions magic wand",
"sounds.expressionsOuch|block": "expressions ouch",
"sounds.expressionsShouting|block": "expressions shouting",
"sounds.expressionsSmack|block": "expressions smack",
"sounds.expressionsSneezing|block": "expressions sneezing",
"sounds.expressionsSnoring|block": "expressions snoring",
"sounds.expressionsUhOh|block": "expressions uh oh",
"sounds.informationActivate|block": "information activate",
"sounds.informationAnalyze|block": "information analyze",
"sounds.informationBackwards|block": "information backwards",
"sounds.informationColor|block": "information color",
"sounds.informationDetected|block": "information detected",
"sounds.informationDown|block": "information down",
"sounds.informationErrorAlarm|block": "information error alarm",
"sounds.informationError|block": "information error",
"sounds.informationFlashing|block": "information flashing",
"sounds.informationForward|block": "information forward",
"sounds.informationLeft|block": "information left",
"sounds.informationObject|block": "information object",
"sounds.informationRight|block": "information right",
"sounds.informationSearching|block": "information searching",
"sounds.informationStart|block": "information start",
"sounds.informationStop|block": "information stop",
"sounds.informationTouch|block": "information touch",
"sounds.informationTurn|block": "information turn",
"sounds.informationUp|block": "information up",
"sounds.mechanicalAirRelease|block": "mechanical air release",
"sounds.mechanicalAirbrake|block": "mechanical airbrake",
"sounds.mechanicalBackingAlert|block": "mechanical backing alert",
"sounds.mechanicalBlip1|block": "mechanical blip1",
"sounds.mechanicalBlip2|block": "mechanical blip2",
"sounds.mechanicalBlip3|block": "mechanical blip3",
"sounds.mechanicalBlip4|block": "mechanical blip4",
"sounds.mechanicalHorn1|block": "mechanical horn1",
"sounds.mechanicalHorn2|block": "mechanical horn2",
"sounds.mechanicalLaser|block": "mechanical laser",
"sounds.mechanicalMotorIdle|block": "mechanical motor idle",
"sounds.mechanicalMotorStart|block": "mechanical motor start",
"sounds.mechanicalMotorStop|block": "mechanical motor stop",
"sounds.mechanicalRatchet|block": "mechanical ratchet",
"sounds.mechanicalSonar|block": "mechanical sonar",
"sounds.mechanicalTickTack|block": "mechanical tick tack",
"sounds.mechanicalWalk|block": "mechanical walk",
"sounds.movementsArm1|block": "movements arm1",
"sounds.movementsArm2|block": "movements arm2",
"sounds.movementsArm3|block": "movements arm3",
"sounds.movementsArm4|block": "movements arm4",
"sounds.movementsDropLoad|block": "movements drop load",
"sounds.movementsLiftLoad|block": "movements lift load",
"sounds.movementsServo1|block": "movements servo1",
"sounds.movementsServo2|block": "movements servo2",
"sounds.movementsServo3|block": "movements servo3",
"sounds.movementsServo4|block": "movements servo4",
"sounds.movementsSlideLoad|block": "movements slide load",
"sounds.movementsSnap|block": "movements snap",
"sounds.movementsSpeedDown|block": "movements speed down",
"sounds.movementsSpeedIdle|block": "movements speed idle",
"sounds.movementsSpeedUp|block": "movements speed up",
"sounds.movementsSpeeding|block": "movements speeding",
"sounds.numbersEight|block": "numbers eight",
"sounds.numbersFive|block": "numbers five",
"sounds.numbersFour|block": "numbers four",
"sounds.numbersNine|block": "numbers nine",
"sounds.numbersOne|block": "numbers one",
"sounds.numbersSeven|block": "numbers seven",
"sounds.numbersSix|block": "numbers six",
"sounds.numbersTen|block": "numbers ten",
"sounds.numbersThree|block": "numbers three",
"sounds.numbersTwo|block": "numbers two",
"sounds.numbersZero|block": "numbers zero",
"sounds.systemClick|block": "system click",
"sounds.systemConfirm|block": "system confirm",
"sounds.systemConnect|block": "system connect",
"sounds.systemDownload|block": "system download",
"sounds.systemGeneralAlert|block": "system general alert",
"sounds.systemOverpower|block": "system overpower",
"sounds.systemPowerDown|block": "system power down",
"sounds.systemReady|block": "system ready",
"sounds.systemStartUp|block": "system start up",
"{id:category}Music": "Music",
"{id:category}Sound": "Sound",
"{id:category}Sounds": "Sounds"
}

56
libs/music/shims.d.ts vendored
View File

@ -1,56 +0,0 @@
// Auto-generated. Do not edit.
declare namespace music {
/**
* Set the output volume of the sound synthesizer.
* @param volume the volume 0...100, eg: 50
*/
//% weight=96
//% blockId=synth_set_volume block="set volume %volume"
//% parts="speaker" blockGap=8
//% volume.min=0 volume.max=100
//% help=music/set-volume
//% weight=1 shim=music::setVolume
function setVolume(volume: int32): void;
/**
* Play a tone through the speaker for some amount of time.
* @param frequency pitch of the tone to play in Hertz (Hz)
* @param ms tone duration in milliseconds (ms)
*/
//% help=music/play-tone
//% blockId=music_play_note block="play tone|at %note=device_note|for %duration=device_beat"
//% parts="headphone" async
//% blockNamespace=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=97 shim=music::stopAllSounds
function stopAllSounds(): void;
/** Makes a sound bound to a buffer in WAV format. */
//% shim=music::fromWAV
function fromWAV(buf: Buffer): Sound;
}
//% fixedInstances
declare interface Sound {
/** Returns the underlaying Buffer object. */
//% property shim=SoundMethods::buffer
buffer: Buffer;
/** Play sound. */
//% promise shim=SoundMethods::play
play(): void;
}
// Auto-generated. Do not edit. Really.

View File

@ -1,29 +0,0 @@
{
"storage.Storage.append": "Append string data to a new or existing file.",
"storage.Storage.appendBuffer": "Append a buffer to a new or existing file.",
"storage.Storage.appendCSV": "Append a row of CSV data",
"storage.Storage.appendCSVHeaders": "Append a row of CSV headers",
"storage.Storage.appendCSVHeaders|param|filename": "the file name to append data, eg: \"data.csv\"",
"storage.Storage.appendCSVHeaders|param|headers": "the data to append",
"storage.Storage.appendCSV|param|data": "the data to append",
"storage.Storage.appendCSV|param|filename": "the file name to append data, eg: \"data.csv\"",
"storage.Storage.appendLine": "Appends a new line of data in the file",
"storage.Storage.appendLine|param|data": "the data to append",
"storage.Storage.appendLine|param|filename": "the file name to append data, eg: \"data.txt\"",
"storage.Storage.append|param|data": "the data to append",
"storage.Storage.append|param|filename": "the file name to append data, eg: \"data.txt\"",
"storage.Storage.exists": "Tests if a file exists",
"storage.Storage.exists|param|filename": "the file name to append data, eg: \"data.txt\"",
"storage.Storage.limit": "Resizing the size of a file to stay under the limit",
"storage.Storage.limit|param|filename": "name of the file to drop",
"storage.Storage.limit|param|size": "maximum length",
"storage.Storage.overwrite": "Overwrite file with string data.",
"storage.Storage.overwriteWithBuffer": "Overwrite file with a buffer.",
"storage.Storage.overwrite|param|data": "the data to append",
"storage.Storage.overwrite|param|filename": "the file name to append data, eg: \"data.txt\"",
"storage.Storage.read": "Read contents of file as a string.",
"storage.Storage.readAsBuffer": "Read contents of file as a buffer.",
"storage.Storage.remove": "Delete a file, or do nothing if it doesn't exist.",
"storage.Storage.size": "Return the size of the file, or -1 if it doesn't exists.",
"storage.temporary": "Temporary storage in memory, deleted when the device restarts."
}

View File

@ -1,15 +0,0 @@
{
"storage.Storage.appendCSVHeaders|block": "storage %source|%filename|append CSV headers %headers",
"storage.Storage.appendCSV|block": "storage %source|%filename|append CSV %data",
"storage.Storage.appendLine|block": "storage %source|%filename|append line %data",
"storage.Storage.append|block": "storage %source|%filename|append %data",
"storage.Storage.exists|block": "storage %source|%filename|exists",
"storage.Storage.limit|block": "storage %source|limit %filename|to %size|bytes",
"storage.Storage.overwrite|block": "storage %source|%filename|overwrite with|%data",
"storage.Storage.read|block": "storage %source|read %filename|as string",
"storage.Storage.remove|block": "storage %source|remove %filename",
"storage.Storage.size|block": "storage %source|%filename|size",
"storage.temporary|block": "temporary",
"storage|block": "storage",
"{id:category}Storage": "Storage"
}

View File

@ -1,17 +0,0 @@
// Auto-generated. Do not edit.
declare namespace storage {
/** Will be moved. */
//% shim=storage::__stringToBuffer
function __stringToBuffer(s: string): Buffer;
/** Will be moved. */
//% shim=storage::__bufferToString
function __bufferToString(s: Buffer): string;
/** Create named directory. */
//% shim=storage::__mkdir
function __mkdir(filename: string): void;
}
// Auto-generated. Do not edit. Really.

View File

@ -1,11 +0,0 @@
{
"TestEvent": "Various test event in the execution cycle",
"tests": "A 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, eg: 5",
"tests.onEvent": "Registers code to be called at various points in the test execution",
"tests.test": "Registers a test to run"
}

View File

@ -1,11 +0,0 @@
{
"TestEvent.RunSetUp|block": "run setup",
"TestEvent.RunTearDown|block": "run teardown",
"TestEvent.TestSetUp|block": "test setup",
"TestEvent.TestTearDown|block": "test teardown",
"tests.assertClose|block": "assert %message|%expected|close to %actual|by %tolerance",
"tests.assert|block": "assert %message|%condition",
"tests.test|block": "test %name",
"tests|block": "tests",
"{id:category}Tests": "Tests"
}

View File

@ -1,8 +0,0 @@
{
"TouchSensorEvent": "Touch sensor interactions",
"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.pauseUntil": "Wait until the touch sensor is touched",
"sensors.TouchSensor.wasPressed": "Check if touch sensor is touched since it was last checked."
}

View File

@ -1,15 +0,0 @@
{
"TouchSensorEvent.Bumped|block": "bumped",
"TouchSensorEvent.Pressed|block": "pressed",
"TouchSensorEvent.Released|block": "released",
"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.touch1|block": "touch 1",
"sensors.touch2|block": "touch 2",
"sensors.touch3|block": "touch 3",
"sensors.touch4|block": "touch 4",
"{id:category}Sensors": "Sensors",
"{id:group}Touch Sensor": "Touch Sensor"
}

View File

@ -1,7 +1,7 @@
# Touch Sensor
```cards
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
sensors.touch1.isPressed();

Some files were not shown because too many files have changed in this diff Show More