diff --git a/sim/state/motor.ts b/sim/state/motor.ts index e2a5c9f0..fffab968 100644 --- a/sim/state/motor.ts +++ b/sim/state/motor.ts @@ -16,18 +16,19 @@ namespace pxsim { data, beforeMemRead: () => { const outputs = ev3board().outputNodes; - console.log("motor before read"); + // console.log("motor before read"); for (let port = 0; port < DAL.NUM_OUTPUTS; ++port) { const output = outputs[port]; const speed = output ? Math.round(outputs[port].getSpeed()) : 0; const angle = output ? Math.round(outputs[port].getAngle()) : 0; + const tci = MotorDataOff.TachoCounts + port * MotorDataOff.Size; const tsi = MotorDataOff.TachoSensor + port * MotorDataOff.Size; - data[MotorDataOff.TachoCounts + port * MotorDataOff.Size] = 0; // Tacho count + data[tci] = data[tci + 1] = data[tci + 2] = data[tci + 3] = 0; // Tacho count data[MotorDataOff.Speed + port * MotorDataOff.Size] = speed; // Speed data[tsi] = angle & 0xff; // Count data[tsi + 1] = (angle >> 8) & 0xff; // Count data[tsi + 2] = (angle >> 16) & 0xff; // Count - data[tsi + 3] = (angle >> 24) & 0xff; // Count + data[tsi + 3] = (angle >> 24); // Count } }, read: buf => {