From 7f5b8aed99bcc9de49d2bafeadf1313c1ff49987 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 19 Dec 2017 17:15:53 -0800 Subject: [PATCH] more tweaking of angle encoding --- sim/state/motor.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 => {