From d3dcb5de851603ffc066e6632ec5889d08894356 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Tue, 19 Dec 2017 17:01:45 -0800 Subject: [PATCH] Use setChangedState for touch and color sensors --- sim/state/color.ts | 9 +++++---- sim/state/touch.ts | 3 +-- sim/visuals/nodes/colorSensorView.ts | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sim/state/color.ts b/sim/state/color.ts index cb83bc04..42ce61df 100644 --- a/sim/state/color.ts +++ b/sim/state/color.ts @@ -29,11 +29,12 @@ namespace pxsim { getDeviceType() { return DAL.DEVICE_TYPE_COLOR; } - + setColor(color: number) { - this.color = color; - this.changed = true; - this.valueChanged = true; + if (this.color != color) { + this.color = color; + this.setChangedState(); + } } getValue() { diff --git a/sim/state/touch.ts b/sim/state/touch.ts index 7542ad5b..4c900561 100644 --- a/sim/state/touch.ts +++ b/sim/state/touch.ts @@ -14,8 +14,7 @@ namespace pxsim { public setPressed(pressed: boolean) { this.pressed.push(pressed); - this.changed = true; - this.valueChanged = true; + this.setChangedState(); } public isPressed() { diff --git a/sim/visuals/nodes/colorSensorView.ts b/sim/visuals/nodes/colorSensorView.ts index ae321d0f..19ee2ed7 100644 --- a/sim/visuals/nodes/colorSensorView.ts +++ b/sim/visuals/nodes/colorSensorView.ts @@ -12,5 +12,9 @@ namespace pxsim.visuals { public getPaddingRatio() { return 1 / 8; } + + public updateState() { + // TODO: show different color modes + } } } \ No newline at end of file