reading nxt analog sensor dev type
This commit is contained in:
parent
030cd46c5f
commit
fe39902d10
@ -285,36 +285,53 @@ void cUiUpdatePower(void)
|
||||
let nonActivated = 0;
|
||||
function detectDevices() {
|
||||
//control.dmesg(`detect devices (${nonActivated} na)`)
|
||||
const conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS)
|
||||
const inDcm = analogMM.slice(AnalogOff.InDcm, DAL.NUM_INPUTS)
|
||||
const inConn = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS)
|
||||
let numChanged = 0;
|
||||
const uartSensors: SensorInfo[] = [];
|
||||
|
||||
for (const sensorInfo of sensorInfos) {
|
||||
const newConn = conns[sensorInfo.port]
|
||||
const newConn = inConn[sensorInfo.port]
|
||||
if (newConn == sensorInfo.connType) {
|
||||
// control.dmesg(`connection unchanged ${newConn} at ${sensorInfo.port}`)
|
||||
continue;
|
||||
}
|
||||
numChanged++
|
||||
sensorInfo.connType = newConn
|
||||
sensorInfo.devType = DAL.DEVICE_TYPE_NONE
|
||||
if (newConn == DAL.CONN_INPUT_UART) {
|
||||
sensorInfo.devType = DAL.DEVICE_TYPE_NONE;
|
||||
switch (newConn) {
|
||||
case DAL.CONN_INPUT_UART: {
|
||||
control.dmesg(`new UART connection at ${sensorInfo.port}`)
|
||||
updateUartMode(sensorInfo.port, 0);
|
||||
uartSensors.push(sensorInfo);
|
||||
} else if (newConn == DAL.CONN_NXT_IIC) {
|
||||
control.dmesg(`new IIC connection at ${sensorInfo.port}`)
|
||||
break;
|
||||
}
|
||||
case DAL.CONN_NXT_IIC: {
|
||||
control.dmesg(`new NXT IIC connection at ${sensorInfo.port}`)
|
||||
sensorInfo.devType = DAL.DEVICE_TYPE_IIC_UNKNOWN
|
||||
sensorInfo.iicid = readIICID(sensorInfo.port)
|
||||
control.dmesg(`IIC ID ${sensorInfo.iicid.length}`)
|
||||
} else if (newConn == DAL.CONN_INPUT_DUMB) {
|
||||
break;
|
||||
} case DAL.CONN_NXT_DUMB: { // analog NXT sensor
|
||||
control.dmesg(`new NXT analog connection at ${sensorInfo.port}`);
|
||||
sensorInfo.devType = inDcm[sensorInfo.port];
|
||||
control.dmesg(`NXT analog dev type ${sensorInfo.devType}`);
|
||||
break;
|
||||
}
|
||||
case DAL.CONN_INPUT_DUMB: {
|
||||
control.dmesg(`new DUMB connection at ${sensorInfo.port}`)
|
||||
// TODO? for now assume touch
|
||||
sensorInfo.devType = DAL.DEVICE_TYPE_TOUCH
|
||||
} else if (newConn == DAL.CONN_NONE || newConn == 0) {
|
||||
break;
|
||||
}
|
||||
case DAL.CONN_NONE:
|
||||
case 0: {
|
||||
//control.dmesg(`disconnect at port ${sensorInfo.port}`)
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
control.dmesg(`unknown connection type: ${newConn} at ${sensorInfo.port}`)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -805,9 +822,9 @@ void cUiUpdatePower(void)
|
||||
TST_UART_READ = 0xc0487409,
|
||||
TST_UART_WRITE = 0xc048740a,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace sensors {
|
||||
namespace sensors {
|
||||
export enum ThresholdState {
|
||||
Normal = 1,
|
||||
High = 2,
|
||||
@ -893,4 +910,4 @@ namespace sensors {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user