Initial version of synchronized motors

This commit is contained in:
Pascal Serrarens 2024-01-23 17:44:27 +01:00
parent 4fcbcf80ad
commit c8ac0b645f
2 changed files with 33 additions and 0 deletions

13
SynchronizedMotors.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "SynchronizedMotors.h"
SynchronizedMotors::SynchronizedMotors(Motor *primaryMotor,
Motor *secondaryMotor) {
this->motorCount = 2;
this->motors = new Motor *[2] { primaryMotor, secondaryMotor };
}
void SynchronizedMotors::SetTargetSpeed(float speed) {
for (unsigned char motorIx = 0; motorIx < this->motorCount; motorIx++) {
this->motors[motorIx]->SetTargetSpeed(speed);
}
}

20
SynchronizedMotors.h Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#include "Motor.h"
namespace Passer {
namespace RoboidControl {
class SynchronizedMotors : public Motor {
public:
SynchronizedMotors(Motor *primaryMotor, Motor *secondaryMotor);
virtual void SetTargetSpeed(float speed) override;
protected:
unsigned char motorCount;
Motor **motors;
};
} // namespace RoboidControl
} // namespace Passer
using namespace Passer::RoboidControl;