blink fix (#949)
This commit is contained in:
parent
a06331eef1
commit
5f5bdd7294
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -275,21 +275,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;
|
||||||
}
|
}
|
||||||
@ -425,11 +427,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +458,7 @@ void cUiUpdatePower(void)
|
|||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
if (this.isActive()) uartReset(this._port);
|
if (this.isActive()) uartReset(this._port);
|
||||||
this.realmode = 0;
|
this.realmode = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user