Add ultrasonic and gyro (untested)

This commit is contained in:
Michal Moskal
2017-07-10 15:07:23 +01:00
parent babdf45fc3
commit d3263d8456
5 changed files with 60 additions and 1 deletions

34
libs/core/gyro.ts Normal file
View File

@ -0,0 +1,34 @@
const enum GyroSensorMode {
None = -1,
Angle = 0,
Rate = 1,
}
namespace input {
export class GyroSensor extends internal.UartSensor {
constructor() {
super()
}
_deviceType() {
return LMS.DEVICE_TYPE_GYRO
}
setMode(m: GyroSensorMode) {
this._setMode(m)
}
getAngle() {
this.setMode(GyroSensorMode.Angle)
return this.getNumber(NumberFormat.Int16LE, 0)
}
getRate() {
this.setMode(GyroSensorMode.Rate)
return this.getNumber(NumberFormat.Int16LE, 0)
}
}
//% whenUsed
export const gyro: GyroSensor = new GyroSensor()
}