various fixes

This commit is contained in:
Peli de Halleux 2019-10-13 00:01:34 -07:00
parent 38b2fc7b95
commit d4ee9d2d62
5 changed files with 11 additions and 15 deletions

View File

@ -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;
}

View File

@ -121,10 +121,9 @@ namespace sensors.internal {
powerMM = control.mmap("/dev/lms_power", 2, 0)
devPoller = new Poller(250, () => { return hashDevices(); },
(prev, curr) => {
detectDevices();
});
devPoller = new Poller(500,
() => { return hashDevices(); },
(prev, curr) => { detectDevices(); });
}
export function getActiveSensors(): Sensor[] {
@ -277,7 +276,7 @@ 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;
}
@ -291,7 +290,9 @@ void cUiUpdatePower(void)
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 +428,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 +459,7 @@ void cUiUpdatePower(void)
reset() {
if (this.isActive()) uartReset(this._port);
this.realmode = 0;
this.realmode = -1;
}
}
@ -570,7 +571,7 @@ void cUiUpdatePower(void)
while (ports.length) {
const port = ports.pop();
const status = waitNonZeroUartStatus(port)
control.dmesg(`UART set mode ${status} at ${port}`);
control.dmesg(`UART status ${status} at ${port}`);
}
}

View File

@ -3,7 +3,6 @@
namespace pxsim {
export enum ColorSensorMode {
None = -1,
Reflected = 0,
Ambient = 1,
Colors = 2,

View File

@ -1,6 +1,5 @@
namespace pxsim {
export const enum GyroSensorMode {
None = -1,
Angle = 0,
Rate = 1,
}

View File

@ -44,7 +44,6 @@ namespace pxsim {
}
export enum InfraredSensorMode {
None = -1,
Proximity = 0,
Seek = 1,
RemoteControl = 2