From 58294883d7a8a2032108d782abc20933197be81b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Sun, 13 Oct 2019 00:35:20 -0700 Subject: [PATCH] blink fix (#949) --- libs/color-sensor/color.ts | 2 -- libs/core/input.ts | 14 ++++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/color-sensor/color.ts b/libs/color-sensor/color.ts index ef7fc9fe..90105692 100644 --- a/libs/color-sensor/color.ts +++ b/libs/color-sensor/color.ts @@ -1,5 +1,4 @@ const enum ColorSensorMode { - None = 0, //% block="reflected light intensity" ReflectedLightIntensity = 0, //% block="ambient light intensity" @@ -59,7 +58,6 @@ namespace sensors { constructor(port: number) { super(port) - this._setMode(ColorSensorMode.None); this.thresholdDetector = new sensors.ThresholdDetector(this.id()); this.calibrating = false; } diff --git a/libs/core/input.ts b/libs/core/input.ts index aba85155..3966ed56 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -277,21 +277,23 @@ void cUiUpdatePower(void) const conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS) let r = 0; for (let i = 0; i < conns.length; ++i) { - r = (r << 8 | conns[i]); + r = conns[i] + (r << 6) + (r << 16) - r; } return r; } let nonActivated = 0; function detectDevices() { - //control.dmesg(`detect devices (${nonActivated} na)`) + control.dmesg(`detect devices (hash ${hashDevices()})`) const conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS) let numChanged = 0; const uartSensors: SensorInfo[] = []; for (const sensorInfo of sensorInfos) { const newConn = conns[sensorInfo.port] - if (newConn == sensorInfo.connType) { + if (newConn == sensorInfo.connType + && sensorInfo.sensor + && sensorInfo.sensor.isActive()) { // control.dmesg(`connection unchanged ${newConn} at ${sensorInfo.port}`) continue; } @@ -427,11 +429,11 @@ void cUiUpdatePower(void) constructor(port: number) { super(port) this.mode = 0 - this.realmode = 0 + this.realmode = -1 } _activated() { - this.realmode = 0 + this.realmode = -1 this._setMode(this.mode) } @@ -458,7 +460,7 @@ void cUiUpdatePower(void) reset() { if (this.isActive()) uartReset(this._port); - this.realmode = 0; + this.realmode = -1; } }