final-changes
This commit is contained in:
@ -43,8 +43,8 @@ namespace pxsim {
|
||||
this.setChangedState();
|
||||
}
|
||||
|
||||
setColor(colors: number) {
|
||||
this.color = colors;
|
||||
setColor(color: number) {
|
||||
this.color = color;
|
||||
this.setChangedState();
|
||||
}
|
||||
|
||||
@ -60,12 +60,15 @@ namespace pxsim {
|
||||
this.mode = mode;
|
||||
if (this.mode == ColorSensorMode.RefRaw) {
|
||||
this.color = 512;
|
||||
this.colors = [0, 0, 0];
|
||||
this.modeReturnArr = false;
|
||||
} else if (this.mode == ColorSensorMode.RgbRaw) {
|
||||
this.color = 0;
|
||||
this.colors = [128, 128, 128];
|
||||
this.modeReturnArr = true;
|
||||
} else { // Reflection or ambiend light
|
||||
this.color = 50;
|
||||
this.colors = [0, 0, 0];
|
||||
this.modeReturnArr = false;
|
||||
}
|
||||
this.changed = true;
|
||||
|
@ -91,13 +91,15 @@ namespace pxsim {
|
||||
if (node && node.isUart()) {
|
||||
// Actual
|
||||
const index = 0; //UartOff.Actual + port * 2;
|
||||
//console.log(node.isModeReturnArr()); // Узнать возвращает ли режим датчика массив значений
|
||||
let value, values;
|
||||
if (!node.isModeReturnArr()) {
|
||||
value = Math.floor(node.getValue());
|
||||
const value = Math.floor(node.getValue());
|
||||
util.map16Bit(data, UartOff.Raw + DAL.MAX_DEVICE_DATALENGTH * 300 * port + DAL.MAX_DEVICE_DATALENGTH * index, value);
|
||||
} else values = node.getValues();
|
||||
//util.map16Bit(data, UartOff.Raw + DAL.MAX_DEVICE_DATALENGTH * 300 * port + DAL.MAX_DEVICE_DATALENGTH * index, value);
|
||||
} else {
|
||||
const values = node.getValues();
|
||||
for (let i = 0, offset = 0; i < values.length; i++, offset += 2) {
|
||||
util.map16Bit(data, UartOff.Raw + DAL.MAX_DEVICE_DATALENGTH * 300 * port + DAL.MAX_DEVICE_DATALENGTH * index + offset, Math.floor(values[i]));
|
||||
}
|
||||
}
|
||||
// Status
|
||||
data[UartOff.Status + port] = node.valueChange() ? UartStatus.UART_PORT_CHANGED : UartStatus.UART_DATA_READY;
|
||||
}
|
||||
|
Reference in New Issue
Block a user