Thresholds (#222)
* add threshold blocks * updated strings * added gap * reorg color/gyro blocks * fixing sound names * adding stop block * fixing exanmples
This commit is contained in:
		@@ -14,7 +14,7 @@ function accelerate() {
 | 
			
		||||
}
 | 
			
		||||
function update() {
 | 
			
		||||
    brick.clearScreen()
 | 
			
		||||
    brick.printLine("speed: " + speed, 1)
 | 
			
		||||
    brick.showString("speed: " + speed, 1)
 | 
			
		||||
    motors.largeBC.setSpeed(speed)
 | 
			
		||||
}
 | 
			
		||||
sensors.touch2.onEvent(TouchSensorEvent.Pressed, function () {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,5 +7,5 @@ loops.forever(function () {
 | 
			
		||||
})
 | 
			
		||||
motors.largeBC.setSpeed(-20);
 | 
			
		||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
 | 
			
		||||
motors.stopAllMotors();
 | 
			
		||||
motors.largeBC.stop();
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -9,5 +9,5 @@ loops.forever(function () {
 | 
			
		||||
})
 | 
			
		||||
motors.largeBC.setSpeed(-20);
 | 
			
		||||
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
 | 
			
		||||
motors.stopAllMotors();
 | 
			
		||||
motors.largeBC.stop();
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -4,10 +4,9 @@
 | 
			
		||||
let beep = false
 | 
			
		||||
beep = true
 | 
			
		||||
control.runInBackground(function () {
 | 
			
		||||
    motors.largeB.setSpeed(-20)
 | 
			
		||||
    motors.largeC.setSpeed(-20)
 | 
			
		||||
    motors.largeBC.setSpeed(-20)
 | 
			
		||||
    sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
 | 
			
		||||
    motors.stopAllMotors()
 | 
			
		||||
    motors.largeBC.stop()
 | 
			
		||||
    beep = false
 | 
			
		||||
})
 | 
			
		||||
control.runInBackground(function () {
 | 
			
		||||
 
 | 
			
		||||
@@ -11,5 +11,8 @@
 | 
			
		||||
  "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.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"
 | 
			
		||||
}
 | 
			
		||||
@@ -19,11 +19,13 @@
 | 
			
		||||
  "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 %condition|to %value",
 | 
			
		||||
  "sensors.color1|block": "color 1",
 | 
			
		||||
  "sensors.color2|block": "color 2",
 | 
			
		||||
  "sensors.color3|block": "color 3",
 | 
			
		||||
  "sensors.color4|block": "color 4",
 | 
			
		||||
  "sensors|block": "sensors",
 | 
			
		||||
  "{id:category}Sensors": "Sensors",
 | 
			
		||||
  "{id:group}Color Sensor": "Color Sensor"
 | 
			
		||||
  "{id:group}Color Sensor": "Color Sensor",
 | 
			
		||||
  "{id:group}Threshold": "Threshold"
 | 
			
		||||
}
 | 
			
		||||
@@ -152,7 +152,7 @@ namespace sensors {
 | 
			
		||||
        //% parts="colorsensor"
 | 
			
		||||
        //% blockNamespace=sensors
 | 
			
		||||
        //% sensor.fieldEditor="ports"
 | 
			
		||||
        //% weight=99
 | 
			
		||||
        //% weight=98
 | 
			
		||||
        //% group="Color Sensor"
 | 
			
		||||
        color(): ColorSensorColor {
 | 
			
		||||
            this.setMode(ColorSensorMode.Color)
 | 
			
		||||
@@ -221,6 +221,20 @@ namespace sensors {
 | 
			
		||||
        reflectedLight() {
 | 
			
		||||
            return this.light(LightIntensityMode.Reflected);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Sets a threshold value
 | 
			
		||||
         * @param condition the dark or bright light condition
 | 
			
		||||
         * @param value the value threshold
 | 
			
		||||
         */
 | 
			
		||||
        //% blockId=colorSetThreshold block="set %condition|to %value"
 | 
			
		||||
        //% group="Threshold" blockGap=8 weight=90
 | 
			
		||||
        setThreshold(condition: LightCondition, value: number) {
 | 
			
		||||
            if (condition == LightCondition.Dark)
 | 
			
		||||
                this.thresholdDetector.setLowThreshold(value)
 | 
			
		||||
            else
 | 
			
		||||
                this.thresholdDetector.setHighThreshold(value);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //% whenUsed block="color 3" weight=90 fixedInstance jres=icons.port3
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@
 | 
			
		||||
  "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": "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",
 | 
			
		||||
 
 | 
			
		||||
@@ -58,6 +58,7 @@
 | 
			
		||||
  "motors.MotorBase.setBrake|block": "set %motor|brake %brake",
 | 
			
		||||
  "motors.MotorBase.setReversed|block": "set %motor|reversed %reversed",
 | 
			
		||||
  "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|speed %speed=motorSpeedPicker|%",
 | 
			
		||||
  "motors.SynchedMotorPair.tank|block": "tank %motors|%speedLeft=motorSpeedPicker|%|%speedRight=motorSpeedPicker|%",
 | 
			
		||||
  "motors.largeAB|block": "large A+B",
 | 
			
		||||
 
 | 
			
		||||
@@ -187,7 +187,9 @@ namespace motors {
 | 
			
		||||
        /**
 | 
			
		||||
         * Stops the motor(s).
 | 
			
		||||
         */
 | 
			
		||||
        //%
 | 
			
		||||
        //% weight=6 blockGap=8
 | 
			
		||||
        //% group="Move"
 | 
			
		||||
        //% blockId=motorStop block="%motors|stop"
 | 
			
		||||
        stop() {
 | 
			
		||||
            this.init();
 | 
			
		||||
            stop(this._port, this._brake);
 | 
			
		||||
@@ -203,7 +205,7 @@ namespace motors {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Sets the motor speed for limited time or distance
 | 
			
		||||
         * Sets the motor speed for limited time or distance.
 | 
			
		||||
         * @param speed the speed from ``100`` full forward to ``-100`` full backward, eg: 50
 | 
			
		||||
         * @param value (optional) measured distance or rotation
 | 
			
		||||
         * @param unit (optional) unit of the value
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ namespace brick {
 | 
			
		||||
 | 
			
		||||
//% color="#C8509B" weight=95 icon="\uf10f"
 | 
			
		||||
//% labelLineWidth=0
 | 
			
		||||
//% groups='["Ultrasonic Sensor", "Touch Sensor", "Color Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Gyro Sensor"]'
 | 
			
		||||
//% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Gyro Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Threshold"]'
 | 
			
		||||
//% groupIcons='["\uf101","\uf103","\uf102","","","\uf104"]'
 | 
			
		||||
namespace sensors {
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ namespace sensors {
 | 
			
		||||
        //% parts="gyroscope"
 | 
			
		||||
        //% blockNamespace=sensors
 | 
			
		||||
        //% sensor.fieldEditor="ports"
 | 
			
		||||
        //% weight=65 blockGap=8
 | 
			
		||||
        //% weight=64 blockGap=8
 | 
			
		||||
        //% group="Gyro Sensor"
 | 
			
		||||
        angle(): number {
 | 
			
		||||
            if (this.calibrating)
 | 
			
		||||
@@ -70,7 +70,7 @@ namespace sensors {
 | 
			
		||||
        //% parts="gyroscope"
 | 
			
		||||
        //% blockNamespace=sensors
 | 
			
		||||
        //% sensor.fieldEditor="ports"
 | 
			
		||||
        //% weight=65 blockGap=8        
 | 
			
		||||
        //% weight=50 blockGap=8        
 | 
			
		||||
        //% group="Gyro Sensor"
 | 
			
		||||
        calibrate(): void {
 | 
			
		||||
            if (this.calibrating) return; // already in calibration mode
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,9 @@
 | 
			
		||||
  "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.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",
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
  "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 %condition|to %value",
 | 
			
		||||
  "sensors.RemoteInfraredBeaconButton.isPressed|block": "%button|is pressed",
 | 
			
		||||
  "sensors.RemoteInfraredBeaconButton.onEvent|block": "on %button|%event",
 | 
			
		||||
  "sensors.RemoteInfraredBeaconButton.wasPressed|block": "%button|was pressed",
 | 
			
		||||
@@ -20,5 +21,6 @@
 | 
			
		||||
  "sensors|block": "sensors",
 | 
			
		||||
  "{id:category}Sensors": "Sensors",
 | 
			
		||||
  "{id:group}Infrared Sensor": "Infrared Sensor",
 | 
			
		||||
  "{id:group}Remote Infrared Beacon": "Remote Infrared Beacon"
 | 
			
		||||
  "{id:group}Remote Infrared Beacon": "Remote Infrared Beacon",
 | 
			
		||||
  "{id:group}Threshold": "Threshold"
 | 
			
		||||
}
 | 
			
		||||
@@ -250,6 +250,21 @@ namespace sensors {
 | 
			
		||||
            this._setMode(IrSensorMode.Seek)
 | 
			
		||||
            return this.getNumber(NumberFormat.UInt16LE, this.channel * 2)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Sets a threshold value
 | 
			
		||||
         * @param condition the dark or bright light condition
 | 
			
		||||
         * @param value the value threshold
 | 
			
		||||
         */
 | 
			
		||||
        //% blockId=irSetThreshold block="set %condition|to %value"
 | 
			
		||||
        //% group="Threshold" blockGap=8
 | 
			
		||||
        setThreshold(condition: InfraredSensorEvent, value: number) {
 | 
			
		||||
            if (condition == InfraredSensorEvent.ObjectNear)
 | 
			
		||||
                this.proximityThreshold.setLowThreshold(value)
 | 
			
		||||
            else
 | 
			
		||||
                this.proximityThreshold.setHighThreshold(value);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //% fixedInstance whenUsed block="infrared 1" jres=icons.port1
 | 
			
		||||
 
 | 
			
		||||
@@ -33,34 +33,34 @@
 | 
			
		||||
  "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.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.communicationGo|block": "communication go",
 | 
			
		||||
  "sounds.communicationHello|block": "communication hello",
 | 
			
		||||
  "sounds.communicationHi|block": "communication hi",
 | 
			
		||||
  "sounds.communicationLego|block": "communication lego",
 | 
			
		||||
@@ -159,7 +159,7 @@
 | 
			
		||||
  "sounds.systemOverpower|block": "system overpower",
 | 
			
		||||
  "sounds.systemPowerDown|block": "system power down",
 | 
			
		||||
  "sounds.systemReady|block": "system ready",
 | 
			
		||||
  "sounds.systemStartUp|block": "S",
 | 
			
		||||
  "sounds.systemStartUp|block": "system start up",
 | 
			
		||||
  "{id:category}Music": "Music",
 | 
			
		||||
  "{id:category}Sound": "Sound",
 | 
			
		||||
  "{id:category}Sounds": "Sounds"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,53 +1,53 @@
 | 
			
		||||
namespace sounds {
 | 
			
		||||
    //% fixedInstance jres block="Animals cat purr"
 | 
			
		||||
    //% fixedInstance jres block="animals cat purr"
 | 
			
		||||
    export const animalsCatPurr = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals dog bark 1"
 | 
			
		||||
    //% fixedInstance jres block="animals dog bark 1"
 | 
			
		||||
    export const animalsDogBark1 = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals dog bark 2"
 | 
			
		||||
    //% fixedInstance jres block="animals dog bark 2"
 | 
			
		||||
    export const animalsDogBark2 = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals dog growl"
 | 
			
		||||
    //% fixedInstance jres block="animals dog growl"
 | 
			
		||||
    export const animalsDogGrowl = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals dog sniff"
 | 
			
		||||
    //% fixedInstance jres block="animals dog sniff"
 | 
			
		||||
    export const animalsDogSniff = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals dog whine"
 | 
			
		||||
    //% fixedInstance jres block="animals dog whine"
 | 
			
		||||
    export const animalsDogWhine = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals elephant call"
 | 
			
		||||
    //% fixedInstance jres block="animals elephant call"
 | 
			
		||||
    export const animalsElephantCall = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals insect buzz1"
 | 
			
		||||
    //% fixedInstance jres block="animals insect buzz1"
 | 
			
		||||
    export const animalsInsectBuzz1 = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals insect buzz2"
 | 
			
		||||
    //% fixedInstance jres block="animals insect buzz2"
 | 
			
		||||
    export const animalsInsectBuzz2 = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals insect chirp"
 | 
			
		||||
    //% fixedInstance jres block="animals insect chirp"
 | 
			
		||||
    export const animalsInsectChirp = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals snake hiss"
 | 
			
		||||
    //% fixedInstance jres block="animals snake hiss"
 | 
			
		||||
    export const animalsSnakeHiss = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals snake rattle"
 | 
			
		||||
    //% fixedInstance jres block="animals snake rattle"
 | 
			
		||||
    export const animalsSnakeRattle = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Animals trex roar"
 | 
			
		||||
    //% fixedInstance jres block="animals trex roar"
 | 
			
		||||
    export const animalsTRexRoar = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Colors black"
 | 
			
		||||
    //% fixedInstance jres block="colors black"
 | 
			
		||||
    export const colorsBlack = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Colors blue"
 | 
			
		||||
    //% fixedInstance jres block="colors blue"
 | 
			
		||||
    export const colorsBlue = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Colors brown"
 | 
			
		||||
    //% fixedInstance jres block="colors brown"
 | 
			
		||||
    export const colorsBrown = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Colors green"
 | 
			
		||||
    //% fixedInstance jres block="colors green"
 | 
			
		||||
    export const colorsGreen = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Colors red"
 | 
			
		||||
    //% fixedInstance jres block="colors red"
 | 
			
		||||
    export const colorsRed = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Colors white"
 | 
			
		||||
    //% fixedInstance jres block="colors white"
 | 
			
		||||
    export const colorsWhite = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Colors yellow"
 | 
			
		||||
    //% fixedInstance jres block="colors yellow"
 | 
			
		||||
    export const colorsYellow = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Communication bravo"
 | 
			
		||||
    //% fixedInstance jres block="communication bravo"
 | 
			
		||||
    export const communicationBravo = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Communication ev3"
 | 
			
		||||
    //% fixedInstance jres block="communication ev3"
 | 
			
		||||
    export const communicationEv3 = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Communication fantastic"
 | 
			
		||||
    //% fixedInstance jres block="communication fantastic"
 | 
			
		||||
    export const communicationFantastic = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Communication game over"
 | 
			
		||||
    //% fixedInstance jres block="communication game over"
 | 
			
		||||
    export const communicationGameOver = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="Communication go"
 | 
			
		||||
    //% fixedInstance jres block="communication go"
 | 
			
		||||
    export const communicationGo = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="communicationGoodJob"
 | 
			
		||||
    export const communicationGoodJob = music.fromWAV(hex``);
 | 
			
		||||
@@ -251,7 +251,7 @@ namespace sounds {
 | 
			
		||||
    export const systemPowerDown = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block="system ready"
 | 
			
		||||
    export const systemReady = music.fromWAV(hex``);
 | 
			
		||||
    //% fixedInstance jres block=S
 | 
			
		||||
    //% fixedInstance jres block="system start up"
 | 
			
		||||
    export const systemStartUp = music.fromWAV(hex``);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,5 +2,8 @@
 | 
			
		||||
  "sensors.UltraSonicSensor.distance": "Gets the distance from the sonar in centimeters",
 | 
			
		||||
  "sensors.UltraSonicSensor.onEvent": "Registers code to run when the given color is close",
 | 
			
		||||
  "sensors.UltraSonicSensor.onEvent|param|handler": "the code to run when detected",
 | 
			
		||||
  "sensors.UltraSonicSensor.pauseUntil": "Waits for the event to occur"
 | 
			
		||||
  "sensors.UltraSonicSensor.pauseUntil": "Waits for the event to occur",
 | 
			
		||||
  "sensors.UltraSonicSensor.setThreshold": "Sets a threshold value",
 | 
			
		||||
  "sensors.UltraSonicSensor.setThreshold|param|condition": "the dark or bright light condition",
 | 
			
		||||
  "sensors.UltraSonicSensor.setThreshold|param|value": "the value threshold"
 | 
			
		||||
}
 | 
			
		||||
@@ -5,10 +5,12 @@
 | 
			
		||||
  "sensors.UltraSonicSensor.distance|block": "%sensor|distance",
 | 
			
		||||
  "sensors.UltraSonicSensor.onEvent|block": "on %sensor|%event",
 | 
			
		||||
  "sensors.UltraSonicSensor.pauseUntil|block": "pause until %sensor| %event",
 | 
			
		||||
  "sensors.UltraSonicSensor.setThreshold|block": "set %condition|to %value",
 | 
			
		||||
  "sensors.ultrasonic1|block": "ultrasonic 1",
 | 
			
		||||
  "sensors.ultrasonic2|block": "ultrasonic 2",
 | 
			
		||||
  "sensors.ultrasonic3|block": "ultrasonic 3",
 | 
			
		||||
  "sensors.ultrasonic4|block": "ultrasonic 4",
 | 
			
		||||
  "{id:category}Sensors": "Sensors",
 | 
			
		||||
  "{id:group}Threshold": "Threshold",
 | 
			
		||||
  "{id:group}Ultrasonic Sensor": "Ultrasonic Sensor"
 | 
			
		||||
}
 | 
			
		||||
@@ -85,6 +85,22 @@ namespace sensors {
 | 
			
		||||
            this._setMode(0)
 | 
			
		||||
            return this._query();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Sets a threshold value
 | 
			
		||||
         * @param condition the dark or bright light condition
 | 
			
		||||
         * @param value the value threshold
 | 
			
		||||
         */
 | 
			
		||||
        //% blockId=ultrasonicSetThreshold block="set %condition|to %value"
 | 
			
		||||
        //% group="Threshold" blockGap=8
 | 
			
		||||
        setThreshold(condition: UltrasonicSensorEvent, value: number) {            
 | 
			
		||||
            switch(condition) {
 | 
			
		||||
                case UltrasonicSensorEvent.ObjectNear: this.promixityThreshold.setLowThreshold(value); break;
 | 
			
		||||
                case UltrasonicSensorEvent.ObjectFar: this.promixityThreshold.setHighThreshold(value); break;
 | 
			
		||||
                case UltrasonicSensorEvent.ObjectDetected: this.movementThreshold = value; break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
  
 | 
			
		||||
    //% fixedInstance whenUsed block="ultrasonic 4" jres=icons.port4
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user