Fix crash when updating DRV8833 Diff Drive

This commit is contained in:
Pascal Serrarens 2025-06-18 15:38:46 +02:00
parent 6eafbe538f
commit 634d560ee1
2 changed files with 6 additions and 8 deletions

View File

@ -8,7 +8,6 @@ namespace Arduino {
#pragma region DRV8833
DRV8833::DRV8833(Configuration config, Thing* parent) : Thing(parent) {
std::cout << "DRV8833\n";
this->type = Type::Undetermined;
this->name = "DRV8833";
this->pinStandby = config.standby;
@ -27,16 +26,15 @@ DRV8833::DRV8833(Configuration config, Thing* parent) : Thing(parent) {
DRV8833::DifferentialDrive::DifferentialDrive(DRV8833::Configuration config,
Thing* parent)
: drv8833(config, this),
RoboidControl::DifferentialDrive(nullptr, nullptr, parent) {
this->drv8833 = DRV8833(config, this);
this->leftWheel = this->drv8833.motorA;
this->rightWheel = this->drv8833.motorB;
: RoboidControl::DifferentialDrive(nullptr, nullptr, parent) {
this->drv8833 = new DRV8833(config, this);
this->leftWheel = this->drv8833->motorA;
this->rightWheel = this->drv8833->motorB;
}
void DRV8833::DifferentialDrive::Update(bool recurse) {
RoboidControl::DifferentialDrive::Update(recurse);
this->drv8833.Update(false);
this->drv8833->Update(false);
}
#pragma endregion Differential drive

View File

@ -45,7 +45,7 @@ class DRV8833::DifferentialDrive : public RoboidControl::DifferentialDrive {
virtual void Update(bool recurse = false) override;
protected:
DRV8833 drv8833;
DRV8833* drv8833 = nullptr;
};
#pragma endregion Differential drive