more annotations
This commit is contained in:
parent
c85c68ab68
commit
b0380fbef8
@ -30,7 +30,7 @@
|
||||
"input.GyroSensor.rate": "Get the current rotation rate from the gyroscope.",
|
||||
"input.IrSensor.distance": "Get the distance measured by the infrared sensor.",
|
||||
"input.IrSensor.remoteCommand": "Get the remote commandreceived the infrared sensor.",
|
||||
"input.UltraSonicSensor.getDistance": "Get distance in mm",
|
||||
"input.UltraSonicSensor.distance": "Gets the distance from the sonar in millimeters",
|
||||
"input.buttonDown": "Down button.",
|
||||
"input.buttonEnter": "Enter button.",
|
||||
"input.buttonLeft": "Left button.",
|
||||
|
@ -25,6 +25,7 @@
|
||||
"input.GyroSensor.rate|block": "%color|rotation rate",
|
||||
"input.IrSensor.distance|block": "%infrared|distance",
|
||||
"input.IrSensor.remoteCommand|block": "%infrared|remote command",
|
||||
"input.UltraSonicSensor.distance|block": "%sonar|distance",
|
||||
"input.buttonDown|block": "button down",
|
||||
"input.buttonEnter|block": "button enter",
|
||||
"input.buttonLeft|block": "button left",
|
||||
@ -47,6 +48,10 @@
|
||||
"input.touchSensor2|block": "touch sensor 2",
|
||||
"input.touchSensor3|block": "touch sensor 3",
|
||||
"input.touchSensor4|block": "touch sensor 4",
|
||||
"input.ultrasonic1|block": "ultrasonic 1",
|
||||
"input.ultrasonic2|block": "ultrasonic 1",
|
||||
"input.ultrasonic3|block": "ultrasonic 1",
|
||||
"input.ultrasonic4|block": "ultrasonic 1",
|
||||
"input|block": "input",
|
||||
"output.getCurrentSpeed|block": "motor %out|speed",
|
||||
"output.pattern|block": "%pattern",
|
||||
@ -65,9 +70,12 @@
|
||||
"{id:category}Output": "Output",
|
||||
"{id:category}Screen": "Screen",
|
||||
"{id:category}Serial": "Serial",
|
||||
"{id:group}Buttons": "Buttons",
|
||||
"{id:group}Color Sensor": "Color Sensor",
|
||||
"{id:group}Gyroscope": "Gyroscope",
|
||||
"{id:group}Infrared sensor": "Infrared sensor",
|
||||
"{id:group}Lights": "Lights",
|
||||
"{id:group}Motors": "Motors",
|
||||
"{id:group}Screen": "Screen"
|
||||
"{id:group}Screen": "Screen",
|
||||
"{id:group}Sonar": "Sonar"
|
||||
}
|
@ -93,6 +93,7 @@ namespace input {
|
||||
//% button.fieldOptions.width=220
|
||||
//% button.fieldOptions.columns=3
|
||||
//% weight=81 blockGap=8
|
||||
//% group="Buttons"
|
||||
isPressed() {
|
||||
return this._isPressed
|
||||
}
|
||||
@ -110,6 +111,7 @@ namespace input {
|
||||
//% button.fieldOptions.width=220
|
||||
//% button.fieldOptions.columns=3
|
||||
//% weight=80 blockGap=8
|
||||
//% group="Buttons"
|
||||
wasPressed() {
|
||||
const r = this._wasPressed
|
||||
this._wasPressed = false
|
||||
@ -130,6 +132,7 @@ namespace input {
|
||||
//% button.fieldOptions.width=220
|
||||
//% button.fieldOptions.columns=3
|
||||
//% weight=99
|
||||
//% group="Buttons"
|
||||
onEvent(ev: ButtonEvent, body: () => void) {
|
||||
control.onEvent(this._id, ev, body)
|
||||
}
|
||||
|
@ -118,7 +118,8 @@ namespace input {
|
||||
//% blockId=infraredGetDistance
|
||||
//% parts="infrared"
|
||||
//% blockNamespace=input
|
||||
//% weight=65 blockGap=8
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Infrared sensor"
|
||||
distance() {
|
||||
this.setMode(IrSensorMode.Proximity)
|
||||
return this.getNumber(NumberFormat.UInt8LE, 0)
|
||||
@ -134,6 +135,7 @@ namespace input {
|
||||
//% parts="infrared"
|
||||
//% blockNamespace=input
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Infrared sensor"
|
||||
remoteCommand() {
|
||||
this.setMode(IrSensorMode.RemoteControl)
|
||||
return this.getNumber(NumberFormat.UInt8LE, this.channel)
|
||||
|
@ -1,5 +1,6 @@
|
||||
namespace input {
|
||||
|
||||
//% fixedInstances
|
||||
export class UltraSonicSensor extends internal.UartSensor {
|
||||
constructor(port: number) {
|
||||
super(port)
|
||||
@ -9,23 +10,33 @@ namespace input {
|
||||
return DAL.DEVICE_TYPE_ULTRASONIC
|
||||
}
|
||||
|
||||
/** Get distance in mm */
|
||||
getDistance() {
|
||||
/**
|
||||
* Gets the distance from the sonar in millimeters
|
||||
* @param sonar the ultrasonic sensor
|
||||
*/
|
||||
//% help=input/ultrasonic/distance
|
||||
//% block="%sonar|distance"
|
||||
//% blockId=sonarGetDistance
|
||||
//% parts="ultrasonic"
|
||||
//% blockNamespace=input
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Sonar"
|
||||
distance() {
|
||||
// it supposedly also has an inch mode, but we stick to mm
|
||||
this._setMode(0)
|
||||
return this.getNumber(NumberFormat.UInt16LE, 0) & 0x0fff
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed
|
||||
//% fixedInstance whenUsed block="ultrasonic 1"
|
||||
export const ultrasonic1: UltraSonicSensor = new UltraSonicSensor(1)
|
||||
|
||||
//% whenUsed
|
||||
//% fixedInstance whenUsed block="ultrasonic 1"
|
||||
export const ultrasonic2: UltraSonicSensor = new UltraSonicSensor(2)
|
||||
|
||||
//% whenUsed
|
||||
//% fixedInstance whenUsed block="ultrasonic 1"
|
||||
export const ultrasonic3: UltraSonicSensor = new UltraSonicSensor(3)
|
||||
|
||||
//% whenUsed
|
||||
//% fixedInstance whenUsed block="ultrasonic 1"
|
||||
export const ultrasonic4: UltraSonicSensor = new UltraSonicSensor(4)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user