more tweaking of angle encoding
This commit is contained in:
parent
c989e2fdab
commit
7f5b8aed99
@ -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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user