various fixes
This commit is contained in:
parent
38b2fc7b95
commit
d4ee9d2d62
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -121,10 +121,9 @@ namespace sensors.internal {
|
|||||||
|
|
||||||
powerMM = control.mmap("/dev/lms_power", 2, 0)
|
powerMM = control.mmap("/dev/lms_power", 2, 0)
|
||||||
|
|
||||||
devPoller = new Poller(250, () => { return hashDevices(); },
|
devPoller = new Poller(500,
|
||||||
(prev, curr) => {
|
() => { return hashDevices(); },
|
||||||
detectDevices();
|
(prev, curr) => { detectDevices(); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getActiveSensors(): Sensor[] {
|
export function getActiveSensors(): Sensor[] {
|
||||||
@ -277,7 +276,7 @@ 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;
|
||||||
}
|
}
|
||||||
@ -291,7 +290,9 @@ void cUiUpdatePower(void)
|
|||||||
|
|
||||||
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 +428,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 +459,7 @@ void cUiUpdatePower(void)
|
|||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
if (this.isActive()) uartReset(this._port);
|
if (this.isActive()) uartReset(this._port);
|
||||||
this.realmode = 0;
|
this.realmode = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,7 +571,7 @@ void cUiUpdatePower(void)
|
|||||||
while (ports.length) {
|
while (ports.length) {
|
||||||
const port = ports.pop();
|
const port = ports.pop();
|
||||||
const status = waitNonZeroUartStatus(port)
|
const status = waitNonZeroUartStatus(port)
|
||||||
control.dmesg(`UART set mode ${status} at ${port}`);
|
control.dmesg(`UART status ${status} at ${port}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace pxsim {
|
namespace pxsim {
|
||||||
|
|
||||||
export enum ColorSensorMode {
|
export enum ColorSensorMode {
|
||||||
None = -1,
|
|
||||||
Reflected = 0,
|
Reflected = 0,
|
||||||
Ambient = 1,
|
Ambient = 1,
|
||||||
Colors = 2,
|
Colors = 2,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
namespace pxsim {
|
namespace pxsim {
|
||||||
export const enum GyroSensorMode {
|
export const enum GyroSensorMode {
|
||||||
None = -1,
|
|
||||||
Angle = 0,
|
Angle = 0,
|
||||||
Rate = 1,
|
Rate = 1,
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ namespace pxsim {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum InfraredSensorMode {
|
export enum InfraredSensorMode {
|
||||||
None = -1,
|
|
||||||
Proximity = 0,
|
Proximity = 0,
|
||||||
Seek = 1,
|
Seek = 1,
|
||||||
RemoteControl = 2
|
RemoteControl = 2
|
||||||
|
Loading…
Reference in New Issue
Block a user