89a82b54dc
* support for IR proximity * fixing build issue * missing break * remove auto-start of sensor * setting mode on onEvent * flooring slider value * bump up proximity * fixing threshold blocks
35 lines
757 B
TypeScript
35 lines
757 B
TypeScript
/// <reference path="./sensor.ts"/>
|
|
|
|
namespace pxsim {
|
|
export enum InfraredSensorMode {
|
|
None = -1,
|
|
Proximity = 0,
|
|
Seek = 1,
|
|
RemoteControl = 2
|
|
}
|
|
|
|
export class InfraredSensorNode extends UartSensorNode {
|
|
id = NodeType.InfraredSensor;
|
|
|
|
private proximity: number = 50; // [0..100]
|
|
|
|
constructor(port: number) {
|
|
super(port);
|
|
}
|
|
|
|
getDeviceType() {
|
|
return DAL.DEVICE_TYPE_IR;
|
|
}
|
|
|
|
setPromixity(proximity: number) {
|
|
if (this.proximity != proximity) {
|
|
this.proximity = proximity;
|
|
this.setChangedState();
|
|
}
|
|
}
|
|
|
|
getValue() {
|
|
return this.proximity;
|
|
}
|
|
}
|
|
} |