pxt-ev3/sim/state/gyro.ts

37 lines
728 B
TypeScript
Raw Normal View History

2017-12-18 22:04:17 +01:00
namespace pxsim {
export const enum GyroSensorMode {
2017-12-18 22:04:17 +01:00
None = -1,
Angle = 0,
Rate = 1,
}
export class GyroSensorNode extends UartSensorNode {
id = NodeType.GyroSensor;
private rate: number = 0;
constructor(port: number) {
super(port);
}
getDeviceType() {
return DAL.DEVICE_TYPE_GYRO;
}
setRate(rate: number) {
rate = rate | 0;
2017-12-18 22:04:17 +01:00
if (this.rate != rate) {
this.rate = rate;
this.setChangedState();
2017-12-18 22:04:17 +01:00
}
}
getRate() {
return this.rate;
}
2017-12-18 22:04:17 +01:00
getValue() {
return this.getRate();
2017-12-18 22:04:17 +01:00
}
}
}