Ir proximity in simulator (#299)

* 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
This commit is contained in:
Peli de Halleux
2018-02-01 22:03:01 -08:00
committed by GitHub
parent 15ee6ebe9c
commit 89a82b54dc
8 changed files with 285 additions and 10 deletions

35
sim/state/infrared.ts Normal file
View File

@ -0,0 +1,35 @@
/// <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;
}
}
}

View File

@ -7,7 +7,8 @@ namespace pxsim {
LargeMotor = 4,
GyroSensor = 5,
ColorSensor = 6,
UltrasonicSensor = 7
UltrasonicSensor = 7,
InfraredSensor = 8
}
export interface Node {