From c8ac77098335485cde4c1e4c94cfadfff1d7113f Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 19 Dec 2017 16:18:17 -0800 Subject: [PATCH] read motor state into lms_motor --- sim/state/motor.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sim/state/motor.ts b/sim/state/motor.ts index 5398c98a..ded9a837 100644 --- a/sim/state/motor.ts +++ b/sim/state/motor.ts @@ -15,11 +15,13 @@ namespace pxsim { MMapMethods.register("/dev/lms_motor", { data, beforeMemRead: () => { + const outputs = ev3board().outputNodes; console.log("motor before read"); for (let port = 0; port < DAL.NUM_OUTPUTS; ++port) { - data[MotorDataOff.TachoCounts * port] = 0; // Tacho count - data[MotorDataOff.Speed * port] = 50; // Speed - data[MotorDataOff.TachoSensor * port] = 0; // Count + const output = outputs[port]; + data[MotorDataOff.TachoCounts + port * MotorDataOff.Size] = 0; // Tacho count + data[MotorDataOff.Speed + port * MotorDataOff.Size] = output ? outputs[port].getSpeed() : 0; // Speed + data[MotorDataOff.TachoSensor + port * MotorDataOff.Size] = output ? outputs[port].getAngle() : 0; // Count } }, read: buf => {