final-changes

This commit is contained in:
Dmitriy Antipov
2023-05-13 22:53:44 +03:00
parent d6d4479889
commit 333b487bb6
6 changed files with 46 additions and 27 deletions

View File

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

View File

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