blink fix (#949)

This commit is contained in:
Peli de Halleux 2019-10-13 00:35:20 -07:00
parent 38b2fc7b95
commit 58294883d7
2 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,4 @@
const enum ColorSensorMode { const enum ColorSensorMode {
None = 0,
//% block="reflected light intensity" //% block="reflected light intensity"
ReflectedLightIntensity = 0, ReflectedLightIntensity = 0,
//% block="ambient light intensity" //% block="ambient light intensity"
@ -59,7 +58,6 @@ namespace sensors {
constructor(port: number) { constructor(port: number) {
super(port) super(port)
this._setMode(ColorSensorMode.None);
this.thresholdDetector = new sensors.ThresholdDetector(this.id()); this.thresholdDetector = new sensors.ThresholdDetector(this.id());
this.calibrating = false; this.calibrating = false;
} }

View File

@ -277,21 +277,23 @@ void cUiUpdatePower(void)
const conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS) const conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS)
let r = 0; let r = 0;
for (let i = 0; i < conns.length; ++i) { for (let i = 0; i < conns.length; ++i) {
r = (r << 8 | conns[i]); r = conns[i] + (r << 6) + (r << 16) - r;
} }
return r; return r;
} }
let nonActivated = 0; let nonActivated = 0;
function detectDevices() { function detectDevices() {
//control.dmesg(`detect devices (${nonActivated} na)`) control.dmesg(`detect devices (hash ${hashDevices()})`)
const conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS) const conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS)
let numChanged = 0; let numChanged = 0;
const uartSensors: SensorInfo[] = []; const uartSensors: SensorInfo[] = [];
for (const sensorInfo of sensorInfos) { for (const sensorInfo of sensorInfos) {
const newConn = conns[sensorInfo.port] 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}`) // control.dmesg(`connection unchanged ${newConn} at ${sensorInfo.port}`)
continue; continue;
} }
@ -427,11 +429,11 @@ void cUiUpdatePower(void)
constructor(port: number) { constructor(port: number) {
super(port) super(port)
this.mode = 0 this.mode = 0
this.realmode = 0 this.realmode = -1
} }
_activated() { _activated() {
this.realmode = 0 this.realmode = -1
this._setMode(this.mode) this._setMode(this.mode)
} }
@ -458,7 +460,7 @@ void cUiUpdatePower(void)
reset() { reset() {
if (this.isActive()) uartReset(this._port); if (this.isActive()) uartReset(this._port);
this.realmode = 0; this.realmode = -1;
} }
} }