Sensor names are now part of the block text (#341)
* Sensor names are now part of the block text * Use ports field editor
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							2d355bb2ca
						
					
				
				
					commit
					130a47d684
				
			@@ -43,10 +43,10 @@ namespace sensors {
 | 
			
		||||
         */
 | 
			
		||||
        //% help=sensors/ultrasonic/on-event
 | 
			
		||||
        //% blockId=ultrasonicOn
 | 
			
		||||
        //% block="on %sensor|%event"
 | 
			
		||||
        //% block="on **ultrasonic** %this|%event"
 | 
			
		||||
        //% parts="ultrasonicsensor"
 | 
			
		||||
        //% blockNamespace=sensors
 | 
			
		||||
        //% sensor.fieldEditor="ports"
 | 
			
		||||
        //% this.fieldEditor="ports"
 | 
			
		||||
        //% weight=100 blockGap=8
 | 
			
		||||
        //% group="Ultrasonic Sensor"
 | 
			
		||||
        onEvent(event: UltrasonicSensorEvent, handler: () => void) {
 | 
			
		||||
@@ -57,13 +57,13 @@ namespace sensors {
 | 
			
		||||
         * Waits for the event to occur
 | 
			
		||||
         */
 | 
			
		||||
        //% help=sensors/ultrasonic/pause-until
 | 
			
		||||
        //% block="pause until %sensor| %event"
 | 
			
		||||
        //% block="pause until **ultrasonic** %this| %event"
 | 
			
		||||
        //% blockId=ultrasonicWait
 | 
			
		||||
        //% parts="ultrasonicsensor"
 | 
			
		||||
        //% blockNamespace=sensors
 | 
			
		||||
        //% sensor.fieldEditor="ports"
 | 
			
		||||
        //% this.fieldEditor="ports"
 | 
			
		||||
        //% weight=99 blockGap=8
 | 
			
		||||
        //% group="Ultrasonic Sensor"        
 | 
			
		||||
        //% group="Ultrasonic Sensor"
 | 
			
		||||
        pauseUntil(event: UltrasonicSensorEvent) {
 | 
			
		||||
            control.waitForEvent(this._id, event);
 | 
			
		||||
        }
 | 
			
		||||
@@ -73,13 +73,13 @@ namespace sensors {
 | 
			
		||||
         * @param sensor the ultrasonic sensor port
 | 
			
		||||
         */
 | 
			
		||||
        //% help=sensors/ultrasonic/distance
 | 
			
		||||
        //% block="%sensor|distance"
 | 
			
		||||
        //% block="**ultrasonic** %this|distance"
 | 
			
		||||
        //% blockId=sonarGetDistance
 | 
			
		||||
        //% parts="ultrasonicsensor"
 | 
			
		||||
        //% blockNamespace=sensors
 | 
			
		||||
        //% sensor.fieldEditor="ports"
 | 
			
		||||
        //% this.fieldEditor="ports"
 | 
			
		||||
        //% weight=65
 | 
			
		||||
        //% group="Ultrasonic Sensor"     
 | 
			
		||||
        //% group="Ultrasonic Sensor"
 | 
			
		||||
        distance(): number {
 | 
			
		||||
            // it supposedly also has an inch mode, but we stick to cm
 | 
			
		||||
            this._setMode(0)
 | 
			
		||||
@@ -92,9 +92,10 @@ namespace sensors {
 | 
			
		||||
         * @param condition the dark or bright light condition
 | 
			
		||||
         * @param value the value threshold
 | 
			
		||||
         */
 | 
			
		||||
        //% blockId=ultrasonicSetThreshold block="set %sensor|%condition|to %value"
 | 
			
		||||
        //% blockId=ultrasonicSetThreshold block="set **ultrasonic** %this|%condition|to %value"
 | 
			
		||||
        //% group="Threshold" blockGap=8 weight=80
 | 
			
		||||
        //% value.min=0 value.max=255
 | 
			
		||||
        //% this.fieldEditor="ports"
 | 
			
		||||
        setThreshold(condition: UltrasonicSensorEvent, value: number) {
 | 
			
		||||
            switch (condition) {
 | 
			
		||||
                case UltrasonicSensorEvent.ObjectNear: this.promixityThreshold.setLowThreshold(value); break;
 | 
			
		||||
@@ -107,9 +108,9 @@ namespace sensors {
 | 
			
		||||
         * Gets the threshold value
 | 
			
		||||
         * @param condition the proximity condition
 | 
			
		||||
         */
 | 
			
		||||
        //% blockId=ultrasonicGetThreshold block="%sensor|%condition"
 | 
			
		||||
        //% blockId=ultrasonicGetThreshold block="**ultrasonic** %this|%condition"
 | 
			
		||||
        //% group="Threshold" blockGap=8 weight=79
 | 
			
		||||
        //% sensor.fieldEditor="ports"
 | 
			
		||||
        //% this.fieldEditor="ports"
 | 
			
		||||
        threshold(condition: UltrasonicSensorEvent): number {
 | 
			
		||||
            switch (condition) {
 | 
			
		||||
                case UltrasonicSensorEvent.ObjectNear: this.promixityThreshold.threshold(ThresholdState.Low); break;
 | 
			
		||||
@@ -120,15 +121,15 @@ namespace sensors {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //% fixedInstance whenUsed block="ultrasonic 4" jres=icons.port4
 | 
			
		||||
    //% fixedInstance whenUsed block="4" jres=icons.port4
 | 
			
		||||
    export const ultrasonic4: UltraSonicSensor = new UltraSonicSensor(4)
 | 
			
		||||
 | 
			
		||||
    //% fixedInstance whenUsed block="ultrasonic 1" jres=icons.port1
 | 
			
		||||
    //% fixedInstance whenUsed block="1" jres=icons.port1
 | 
			
		||||
    export const ultrasonic1: UltraSonicSensor = new UltraSonicSensor(1)
 | 
			
		||||
 | 
			
		||||
    //% fixedInstance whenUsed block="ultrasonic 2" jres=icons.port2
 | 
			
		||||
    //% fixedInstance whenUsed block="2" jres=icons.port2
 | 
			
		||||
    export const ultrasonic2: UltraSonicSensor = new UltraSonicSensor(2)
 | 
			
		||||
 | 
			
		||||
    //% fixedInstance whenUsed block="ultrasonic 3" jres=icons.port3
 | 
			
		||||
    //% fixedInstance whenUsed block="3" jres=icons.port3
 | 
			
		||||
    export const ultrasonic3: UltraSonicSensor = new UltraSonicSensor(3)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user