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:
35
sim/state/infrared.ts
Normal file
35
sim/state/infrared.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,8 @@ namespace pxsim {
|
||||
LargeMotor = 4,
|
||||
GyroSensor = 5,
|
||||
ColorSensor = 6,
|
||||
UltrasonicSensor = 7
|
||||
UltrasonicSensor = 7,
|
||||
InfraredSensor = 8
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
|
Reference in New Issue
Block a user