renaming brick.setLight to brick.setStatusLight (#307)

* renaming brick.setLight to brick.setStatusLight

* updated docs
This commit is contained in:
Peli de Halleux 2018-02-06 22:18:39 -08:00 committed by GitHub
parent 88c58b4e76
commit e94ac6f6f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 60 additions and 60 deletions

View File

@ -52,7 +52,7 @@
* [is pressed](/reference/brick/button/is-pressed) * [is pressed](/reference/brick/button/is-pressed)
* [was pressed](/reference/brick/button/was-pressed) * [was pressed](/reference/brick/button/was-pressed)
* [pause until](/reference/brick/button/pause-until) * [pause until](/reference/brick/button/pause-until)
* [set light](/reference/brick/set-light) * [set light](/reference/brick/set-status-light)
* [battery level](/reference/brick/battery-level) * [battery level](/reference/brick/battery-level)
* [Motors](/reference/motors) * [Motors](/reference/motors)
* [set speed](/reference/motors/motor/set-speed) * [set speed](/reference/motors/motor/set-speed)

View File

@ -6,7 +6,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
sensors.touch1.pauseUntil(ButtonEvent.Pressed) sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.setSpeed(0) motors.largeBC.setSpeed(0)
loops.pause(1000) loops.pause(1000)
brick.setLight(BrickLight.OrangeFlash) brick.setStatusLight(StatusLight.OrangeFlash)
motors.largeBC.setSpeed(-50) motors.largeBC.setSpeed(-50)
loops.pause(2000) loops.pause(2000)
motors.largeBC.setSpeed(0) motors.largeBC.setSpeed(0)

View File

@ -7,7 +7,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
sensors.touch2.pauseUntil(ButtonEvent.Pressed) sensors.touch2.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.setSpeed(0) motors.largeBC.setSpeed(0)
loops.pause(1000) loops.pause(1000)
brick.setLight(BrickLight.OrangeFlash) brick.setStatusLight(StatusLight.OrangeFlash)
motors.largeBC.setSpeed(-50) motors.largeBC.setSpeed(-50)
loops.pause(2000) loops.pause(2000)
motors.largeBC.setSpeed(0) motors.largeBC.setSpeed(0)

View File

@ -10,7 +10,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showImage(images.eyesTiredMiddle) brick.showImage(images.eyesTiredMiddle)
motors.largeBC.setSpeed(0) motors.largeBC.setSpeed(0)
loops.pause(1000) loops.pause(1000)
brick.setLight(BrickLight.OrangeFlash) brick.setStatusLight(StatusLight.OrangeFlash)
brick.showImage(images.eyesDizzy) brick.showImage(images.eyesDizzy)
motors.largeBC.setSpeed(-50) motors.largeBC.setSpeed(-50)
loops.pause(2000) loops.pause(2000)

View File

@ -146,11 +146,11 @@ loops.forever(function () {
} }
motors.stopAllMotors() motors.stopAllMotors()
st = 0; st = 0;
brick.setLight(BrickLight.RedPulse); brick.setStatusLight(StatusLight.RedPulse);
brick.showImage(images.eyesKnockedOut) brick.showImage(images.eyesKnockedOut)
music.playSoundEffect(sounds.movementsSpeedDown) music.playSoundEffect(sounds.movementsSpeedDown)
sensors.touch3.pauseUntil(ButtonEvent.Pressed) sensors.touch3.pauseUntil(ButtonEvent.Pressed)
brick.setLight(BrickLight.Off); brick.setStatusLight(StatusLight.Off);
}) })
// BHV // BHV

View File

@ -29,7 +29,7 @@ function DN() {
function MNRH() { function MNRH() {
motors.mediumC.setBrake(true) motors.mediumC.setBrake(true)
brick.showImage(images.legoEv3icon) brick.showImage(images.legoEv3icon)
brick.setLight(BrickLight.OrangePulse) brick.setStatusLight(StatusLight.OrangePulse)
while (!brick.buttonEnter.wasPressed()) { while (!brick.buttonEnter.wasPressed()) {
if (brick.buttonUp.wasPressed()) { if (brick.buttonUp.wasPressed()) {
motors.mediumC.setSpeed(-100); motors.mediumC.setSpeed(-100);
@ -41,7 +41,7 @@ function MNRH() {
} }
motors.mediumC.stop(); motors.mediumC.stop();
motors.mediumC.clearCounts(); motors.mediumC.clearCounts();
brick.setLight(BrickLight.Green); brick.setStatusLight(StatusLight.Green);
} }
function IS(t: number) { function IS(t: number) {

View File

@ -20,9 +20,9 @@ INI()
let down = false; let down = false;
loops.forever(function () { loops.forever(function () {
brick.showImage(images.informationQuestionMark) brick.showImage(images.informationQuestionMark)
brick.setLight(BrickLight.OrangePulse); brick.setStatusLight(StatusLight.OrangePulse);
pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed()) pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed())
brick.setLight(BrickLight.Off) brick.setStatusLight(StatusLight.Off)
music.playSoundEffect(sounds.mechanicalAirRelease) music.playSoundEffect(sounds.mechanicalAirRelease)
brick.showImage(images.informationAccept) brick.showImage(images.informationAccept)
if (down) { if (down) {

View File

@ -20,9 +20,9 @@ INI()
let down = false; let down = false;
loops.forever(function () { loops.forever(function () {
brick.showImage(images.informationQuestionMark) brick.showImage(images.informationQuestionMark)
brick.setLight(BrickLight.OrangePulse); brick.setStatusLight(StatusLight.OrangePulse);
pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed()) pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed())
brick.setLight(BrickLight.Off) brick.setStatusLight(StatusLight.Off)
music.playSoundEffect(sounds.mechanicalAirRelease) music.playSoundEffect(sounds.mechanicalAirRelease)
brick.showImage(images.informationAccept) brick.showImage(images.informationAccept)
if (down) { if (down) {

View File

@ -146,11 +146,11 @@ loops.forever(function () {
} }
motors.stopAllMotors() motors.stopAllMotors()
st = 0; st = 0;
brick.setLight(BrickLight.RedPulse); brick.setStatusLight(StatusLight.RedPulse);
brick.showImage(images.eyesKnockedOut) brick.showImage(images.eyesKnockedOut)
music.playSoundEffect(sounds.movementsSpeedDown) music.playSoundEffect(sounds.movementsSpeedDown)
sensors.touch3.pauseUntil(ButtonEvent.Pressed) sensors.touch3.pauseUntil(ButtonEvent.Pressed)
brick.setLight(BrickLight.Off); brick.setStatusLight(StatusLight.Off);
}) })
// BHV // BHV

View File

@ -20,7 +20,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped); brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
brick.buttonEnter.isPressed() brick.buttonEnter.isPressed()
brick.buttonEnter.wasPressed() brick.buttonEnter.wasPressed()
brick.setLight(BrickLight.Red); brick.setStatusLight(StatusLight.Red);
``` ```
## Other ## Other

View File

@ -22,11 +22,11 @@ loops.forever(function() {
battery = brick.batteryLevel(); battery = brick.batteryLevel();
if (battery > 15) if (battery > 15)
{ {
brick.setLight(BrickLight.Green); brick.setStatusLight(StatusLight.Green);
} else if (battery > 5) { } else if (battery > 5) {
brick.setLight(BrickLight.Orange); brick.setStatusLight(StatusLight.Orange);
} else { } else {
brick.setLight(BrickLight.RedPulse) brick.setStatusLight(StatusLight.RedPulse)
} }
loops.pause(30000) loops.pause(30000)
}) })

View File

@ -34,11 +34,11 @@ Set the brick light to green when the `down` is pressed. When the button is not
let isRed = false; let isRed = false;
loops.forever(function() { loops.forever(function() {
if (brick.buttonLeft.isPressed()) { if (brick.buttonLeft.isPressed()) {
brick.setLight(BrickLight.Green); brick.setStatusLight(StatusLight.Green);
isRed = false; isRed = false;
} else { } else {
if (!isRed) { if (!isRed) {
brick.setLight(BrickLight.Red); brick.setStatusLight(StatusLight.Red);
isRed = true; isRed = true;
} }
} }

View File

@ -16,7 +16,7 @@ Your @boardname@ has touch sensors that work like buttons. Instead of saying `en
```block ```block
sensors.touch1.onEvent(ButtonEvent.Pressed, function () { sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.setLight(BrickLight.Orange); brick.setStatusLight(StatusLight.Orange);
}); });
``` ```

View File

@ -35,9 +35,9 @@ Set the brick light to green if the `right` button was pressed before the `left`
```blocks ```blocks
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() { brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() {
if (brick.buttonRight.wasPressed()) { if (brick.buttonRight.wasPressed()) {
brick.setLight(BrickLight.Green) brick.setStatusLight(StatusLight.Green)
} else { } else {
brick.setLight(BrickLight.Off) brick.setStatusLight(StatusLight.Off)
} }
}) })
``` ```

View File

@ -3,7 +3,7 @@
Set the light on the brick to a solid or flashing color. Set the light on the brick to a solid or flashing color.
```sig ```sig
brick.setLight(BrickLight.Red); brick.setStatusLight(StatusLight.Red);
``` ```
## Parameters ## Parameters
@ -25,13 +25,13 @@ Repeatedly show a different color pattern for the brick light.
```blocks ```blocks
loops.forever(function () { loops.forever(function () {
brick.setLight(BrickLight.Orange) brick.setStatusLight(StatusLight.Orange)
loops.pause(1000) loops.pause(1000)
brick.setLight(BrickLight.GreenFlash) brick.setStatusLight(StatusLight.GreenFlash)
loops.pause(2000) loops.pause(2000)
brick.setLight(BrickLight.RedPulse) brick.setStatusLight(StatusLight.RedPulse)
loops.pause(2000) loops.pause(2000)
brick.setLight(BrickLight.Off) brick.setStatusLight(StatusLight.Off)
loops.pause(500) loops.pause(500)
}) })
``` ```

View File

@ -3,9 +3,9 @@
```blocks ```blocks
loops.forever(function () { loops.forever(function () {
if (sensors.color1.ambientLight() > 20) { if (sensors.color1.ambientLight() > 20) {
brick.setLight(BrickLight.Green) brick.setStatusLight(StatusLight.Green)
} else { } else {
brick.setLight(BrickLight.Orange) brick.setStatusLight(StatusLight.Orange)
} }
}) })
``` ```

View File

@ -3,9 +3,9 @@
```blocks ```blocks
loops.forever(function () { loops.forever(function () {
if (sensors.color1.color() == ColorSensorColor.Green) { if (sensors.color1.color() == ColorSensorColor.Green) {
brick.setLight(BrickLight.Green) brick.setStatusLight(StatusLight.Green)
} else { } else {
brick.setLight(BrickLight.Orange) brick.setStatusLight(StatusLight.Orange)
} }
}) })
``` ```

View File

@ -3,9 +3,9 @@
```blocks ```blocks
loops.forever(function () { loops.forever(function () {
if (sensors.color1.reflectedLight() > 20) { if (sensors.color1.reflectedLight() > 20) {
brick.setLight(BrickLight.Green) brick.setStatusLight(StatusLight.Green)
} else { } else {
brick.setLight(BrickLight.Orange) brick.setStatusLight(StatusLight.Orange)
} }
}) })
``` ```

View File

@ -2,7 +2,7 @@
/** /**
* Patterns for lights under the buttons. * Patterns for lights under the buttons.
*/ */
const enum BrickLight { const enum StatusLight {
//% block=off enumval=0 //% block=off enumval=0
Off = 0, Off = 0,
//% block=green enumval=1 //% block=green enumval=1
@ -244,16 +244,16 @@ namespace control {
namespace brick { namespace brick {
// the brick starts with the red color // the brick starts with the red color
let currPattern: BrickLight = BrickLight.Red; let currPattern: StatusLight = StatusLight.Red;
/** /**
* Set lights. * Set lights.
* @param pattern the lights pattern to use. eg: BrickLight.Orange * @param pattern the lights pattern to use. eg: BrickLight.Orange
*/ */
//% blockId=setLights block="set light to %pattern" //% blockId=setLights block="set status light to %pattern"
//% weight=100 group="Buttons" //% weight=100 group="Buttons"
//% help=brick/set-light //% help=brick/set-status-light
export function setLight(pattern: BrickLight): void { export function setStatusLight(pattern: StatusLight): void {
if (currPattern === pattern) if (currPattern === pattern)
return return
currPattern = pattern; currPattern = pattern;

View File

@ -2,7 +2,7 @@ screen.clear()
brick.print("PXT!", 10, 30, Draw.Quad) brick.print("PXT!", 10, 30, Draw.Quad)
brick.drawRect(40, 40, 20, 10, Draw.Fill) brick.drawRect(40, 40, 20, 10, Draw.Fill)
brick.setLight(BrickLight.Orange) brick.setStatusLight(StatusLight.Orange)
brick.heart.doubled().draw(100, 50, Draw.Double | Draw.Transparent) brick.heart.doubled().draw(100, 50, Draw.Double | Draw.Transparent)
@ -12,7 +12,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
brick.buttonLeft.onEvent(ButtonEvent.Bumped, () => { brick.buttonLeft.onEvent(ButtonEvent.Bumped, () => {
brick.drawRect(10, 70, 20, 10, Draw.Fill) brick.drawRect(10, 70, 20, 10, Draw.Fill)
brick.setLight(BrickLight.Red) brick.setStatusLight(StatusLight.Red)
brick.setFont(brick.microbitFont()) brick.setFont(brick.microbitFont())
}) })

View File

@ -18,9 +18,9 @@ namespace brick {
export class Mood { export class Mood {
private image: Image; private image: Image;
private sound: Sound; private sound: Sound;
private light: BrickLight; private light: StatusLight;
constructor(image: Image, sound: Sound, light: BrickLight) { constructor(image: Image, sound: Sound, light: StatusLight) {
this.image = image; this.image = image;
this.sound = sound; this.sound = sound;
this.light = light; this.light = light;
@ -30,7 +30,7 @@ namespace brick {
* Shows the mood on the EV3 * Shows the mood on the EV3
*/ */
show() { show() {
brick.setLight(this.light); brick.setStatusLight(this.light);
brick.showImage(this.image); brick.showImage(this.image);
music.playSoundEffectUntilDone(this.sound); music.playSoundEffectUntilDone(this.sound);
loops.pause(20); loops.pause(20);
@ -56,71 +56,71 @@ namespace moods {
* A sleeping mood * A sleeping mood
*/ */
//% fixedInstance jres=images.eyesSleeping //% fixedInstance jres=images.eyesSleeping
export const sleeping = new brick.Mood(images.eyesSleeping, sounds.expressionsSnoring, BrickLight.OrangePulse); export const sleeping = new brick.Mood(images.eyesSleeping, sounds.expressionsSnoring, StatusLight.OrangePulse);
/** /**
* A awake mood * A awake mood
*/ */
//% fixedInstance jres=images.eyesAwake //% fixedInstance jres=images.eyesAwake
export const awake = new brick.Mood(images.eyesAwake, sounds.informationActivate, BrickLight.Orange); export const awake = new brick.Mood(images.eyesAwake, sounds.informationActivate, StatusLight.Orange);
/** /**
* A tired mood * A tired mood
*/ */
//% fixedInstance jres=images.eyesTiredMiddle //% fixedInstance jres=images.eyesTiredMiddle
export const tired = new brick.Mood(images.eyesTiredMiddle, sounds.expressionsSneezing, BrickLight.OrangeFlash); export const tired = new brick.Mood(images.eyesTiredMiddle, sounds.expressionsSneezing, StatusLight.OrangeFlash);
/** /**
* An angry mood * An angry mood
*/ */
//% fixedInstance jres=images.eyesAngry //% fixedInstance jres=images.eyesAngry
export const angry = new brick.Mood(images.eyesAngry, sounds.animalsDogGrowl, BrickLight.RedPulse); export const angry = new brick.Mood(images.eyesAngry, sounds.animalsDogGrowl, StatusLight.RedPulse);
/** /**
* A sad mood * A sad mood
*/ */
//% fixedInstance jres=images.eyesTear //% fixedInstance jres=images.eyesTear
export const sad = new brick.Mood(images.eyesTear, sounds.animalsDogWhine, BrickLight.Red); export const sad = new brick.Mood(images.eyesTear, sounds.animalsDogWhine, StatusLight.Red);
/** /**
* A dizzy mood * A dizzy mood
*/ */
//% fixedInstance jres=images.eyesDizzy //% fixedInstance jres=images.eyesDizzy
export const dizzy = new brick.Mood(images.eyesDizzy, sounds.expressionsUhOh, BrickLight.OrangeFlash); export const dizzy = new brick.Mood(images.eyesDizzy, sounds.expressionsUhOh, StatusLight.OrangeFlash);
/** /**
* A knocked out mood * A knocked out mood
*/ */
//% fixedInstance jres=images.eyesKnockedOut //% fixedInstance jres=images.eyesKnockedOut
export const knockedOut = new brick.Mood(images.eyesKnockedOut, sounds.informationError, BrickLight.RedFlash); export const knockedOut = new brick.Mood(images.eyesKnockedOut, sounds.informationError, StatusLight.RedFlash);
/** /**
* Looking around left * Looking around left
*/ */
//% fixedInstance jres=images.eyesMiddleLeft //% fixedInstance jres=images.eyesMiddleLeft
export const middleLeft = new brick.Mood(images.eyesMiddleLeft, sounds.informationAnalyze, BrickLight.Off); export const middleLeft = new brick.Mood(images.eyesMiddleLeft, sounds.informationAnalyze, StatusLight.Off);
/** /**
* Looking around right * Looking around right
*/ */
//% fixedInstance jres=images.eyesMiddleRight //% fixedInstance jres=images.eyesMiddleRight
export const middleRight = new brick.Mood(images.eyesMiddleRight, sounds.informationAnalyze, BrickLight.Off); export const middleRight = new brick.Mood(images.eyesMiddleRight, sounds.informationAnalyze, StatusLight.Off);
/** /**
* In love mood * In love mood
*/ */
//% fixedInstance jres=images.eyesLove //% fixedInstance jres=images.eyesLove
export const love = new brick.Mood(images.eyesLove, sounds.expressionsMagicWand, BrickLight.GreenPulse); export const love = new brick.Mood(images.eyesLove, sounds.expressionsMagicWand, StatusLight.GreenPulse);
/** /**
* In laughing mood * In laughing mood
*/ */
//% fixedInstance jres=images.eyesWinking //% fixedInstance jres=images.eyesWinking
export const winking = new brick.Mood(images.eyesWinking, sounds.expressionsLaughing1, BrickLight.GreenFlash); export const winking = new brick.Mood(images.eyesWinking, sounds.expressionsLaughing1, StatusLight.GreenFlash);
/** /**
* In a neutral mood * In a neutral mood
*/ */
//% fixedInstance jres=images.eyesNeutral //% fixedInstance jres=images.eyesNeutral
export const neutral = new brick.Mood(images.eyesNeutral, undefined, BrickLight.Green); export const neutral = new brick.Mood(images.eyesNeutral, undefined, StatusLight.Green);
} }

View File

@ -3,9 +3,9 @@
```blocks ```blocks
loops.forever(function () { loops.forever(function () {
if (sensors.touch1.isPressed()) { if (sensors.touch1.isPressed()) {
brick.setLight(BrickLight.Green) brick.setStatusLight(StatusLight.Green)
} else { } else {
brick.setLight(BrickLight.Orange) brick.setStatusLight(StatusLight.Orange)
} }
}) })
``` ```

View File

@ -3,9 +3,9 @@
```blocks ```blocks
loops.forever(function () { loops.forever(function () {
if (sensors.touch1.wasPressed()) { if (sensors.touch1.wasPressed()) {
brick.setLight(BrickLight.Green) brick.setStatusLight(StatusLight.Green)
} else { } else {
brick.setLight(BrickLight.Orange) brick.setStatusLight(StatusLight.Orange)
} }
}) })
``` ```