fixing color / gyro
This commit is contained in:
parent
334d5aca9a
commit
c85c68ab68
@ -23,9 +23,9 @@
|
||||
"input.Button.onEvent": "Do something when a button or sensor is clicked, double clicked, etc...",
|
||||
"input.Button.onEvent|param|body": "code to run when the event is raised",
|
||||
"input.Button.wasPressed": "See if the button was pressed again since the last time you checked.",
|
||||
"input.ColorSensor.getAmbientLight": "Get current ambient light value from the color sensor.",
|
||||
"input.ColorSensor.getColor": "Get the current color from the color sensor.",
|
||||
"input.ColorSensor.getReflectedLight": "Get current reflected light value from the color sensor.",
|
||||
"input.ColorSensor.ambientLight": "Get current ambient light value from the color sensor.",
|
||||
"input.ColorSensor.color": "Get the current color from the color sensor.",
|
||||
"input.ColorSensor.reflectedLight": "Get current reflected light value from the color sensor.",
|
||||
"input.GyroSensor.angle": "Get the current angle from the gyroscope.",
|
||||
"input.GyroSensor.rate": "Get the current rotation rate from the gyroscope.",
|
||||
"input.IrSensor.distance": "Get the distance measured by the infrared sensor.",
|
||||
|
@ -18,9 +18,9 @@
|
||||
"input.Button.isPressed|block": "%button|is pressed",
|
||||
"input.Button.onEvent|block": "on %button|%event",
|
||||
"input.Button.wasPressed|block": "%button|was pressed",
|
||||
"input.ColorSensor.getAmbientLight|block": "%color| ambient light",
|
||||
"input.ColorSensor.getColor|block": "%color| color",
|
||||
"input.ColorSensor.getReflectedLight|block": "%color| reflected light",
|
||||
"input.ColorSensor.ambientLight|block": "%color| ambient light",
|
||||
"input.ColorSensor.color|block": "%color| color",
|
||||
"input.ColorSensor.reflectedLight|block": "%color| reflected light",
|
||||
"input.GyroSensor.angle|block": "%color|angle",
|
||||
"input.GyroSensor.rate|block": "%color|rotation rate",
|
||||
"input.IrSensor.distance|block": "%infrared|distance",
|
||||
@ -34,6 +34,10 @@
|
||||
"input.color2|block": "color sensor 2",
|
||||
"input.color3|block": "color sensor 3",
|
||||
"input.color4|block": "color sensor 4",
|
||||
"input.gyro1|block": "gyroscope 1",
|
||||
"input.gyro2|block": "gyroscope 2",
|
||||
"input.gyro3|block": "gyroscope 3",
|
||||
"input.gyro4|block": "gyroscope 4",
|
||||
"input.remoteBottomLeft|block": "remote bottom-left",
|
||||
"input.remoteBottomRight|block": "remote bottom-right",
|
||||
"input.remoteCenter|block": "remote center",
|
||||
@ -61,6 +65,8 @@
|
||||
"{id:category}Output": "Output",
|
||||
"{id:category}Screen": "Screen",
|
||||
"{id:category}Serial": "Serial",
|
||||
"{id:group}Color Sensor": "Color Sensor",
|
||||
"{id:group}Gyroscope": "Gyroscope",
|
||||
"{id:group}Lights": "Lights",
|
||||
"{id:group}Motors": "Motors",
|
||||
"{id:group}Screen": "Screen"
|
||||
|
@ -45,7 +45,8 @@ namespace input {
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=input
|
||||
//% weight=65 blockGap=8
|
||||
getAmbientLight() {
|
||||
//% group="Color Sensor"
|
||||
ambientLight() {
|
||||
this.setMode(ColorSensorMode.Ambient)
|
||||
return this.getNumber(NumberFormat.UInt8LE, 0)
|
||||
}
|
||||
@ -60,7 +61,8 @@ namespace input {
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=input
|
||||
//% weight=64 blockGap=8
|
||||
getReflectedLight(): number {
|
||||
//% group="Color Sensor"
|
||||
reflectedLight(): number {
|
||||
this.setMode(ColorSensorMode.Reflect)
|
||||
return this.getNumber(NumberFormat.UInt8LE, 0)
|
||||
}
|
||||
@ -75,7 +77,8 @@ namespace input {
|
||||
//% parts="colorsensor"
|
||||
//% blockNamespace=input
|
||||
//% weight=66 blockGap=8
|
||||
getColor(): ColorSensorColor {
|
||||
//% group="Color Sensor"
|
||||
color(): ColorSensorColor {
|
||||
this.setMode(ColorSensorMode.Color)
|
||||
return this.getNumber(NumberFormat.UInt8LE, 0)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ const enum GyroSensorMode {
|
||||
}
|
||||
|
||||
namespace input {
|
||||
//% fixedInstance
|
||||
//% fixedInstances
|
||||
export class GyroSensor extends internal.UartSensor {
|
||||
constructor(port: number) {
|
||||
super(port)
|
||||
@ -28,7 +28,8 @@ namespace input {
|
||||
//% blockId=gyroGetAngle
|
||||
//% parts="gyroscope"
|
||||
//% blockNamespace=input
|
||||
//% weight=65 blockGap=8
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Gyroscope"
|
||||
angle() {
|
||||
this.setMode(GyroSensorMode.Angle)
|
||||
return this.getNumber(NumberFormat.Int16LE, 0)
|
||||
@ -44,21 +45,22 @@ namespace input {
|
||||
//% parts="gyroscope"
|
||||
//% blockNamespace=input
|
||||
//% weight=65 blockGap=8
|
||||
//% group="Gyroscope"
|
||||
rate() {
|
||||
this.setMode(GyroSensorMode.Rate)
|
||||
return this.getNumber(NumberFormat.Int16LE, 0)
|
||||
}
|
||||
}
|
||||
|
||||
//% whenUsed
|
||||
//% fixedInstance whenUsed block="gyroscope 1"
|
||||
export const gyro1: GyroSensor = new GyroSensor(1)
|
||||
|
||||
//% whenUsed
|
||||
//% fixedInstance whenUsed block="gyroscope 2"
|
||||
export const gyro2: GyroSensor = new GyroSensor(2)
|
||||
|
||||
//% whenUsed
|
||||
//% fixedInstance whenUsed block="gyroscope 3"
|
||||
export const gyro3: GyroSensor = new GyroSensor(3)
|
||||
|
||||
//% whenUsed
|
||||
//% fixedInstance whenUsed block="gyroscope 4"
|
||||
export const gyro4: GyroSensor = new GyroSensor(4)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user