Compare commits

..

4 Commits

4 changed files with 12 additions and 9 deletions

View File

@ -26,14 +26,15 @@ DRV8833::DRV8833(Configuration config, Thing* parent) : Thing(parent) {
DRV8833::DifferentialDrive::DifferentialDrive(DRV8833::Configuration config, DRV8833::DifferentialDrive::DifferentialDrive(DRV8833::Configuration config,
Thing* parent) Thing* parent)
: RoboidControl::DifferentialDrive(this->drv8833.motorA, : RoboidControl::DifferentialDrive(nullptr, nullptr, parent) {
this->drv8833.motorB, this->drv8833 = new DRV8833(config, this);
parent), this->leftWheel = this->drv8833->motorA;
drv8833(config, this) {} this->rightWheel = this->drv8833->motorB;
}
void DRV8833::DifferentialDrive::Update(bool recurse) { void DRV8833::DifferentialDrive::Update(bool recurse) {
RoboidControl::DifferentialDrive::Update(recurse); RoboidControl::DifferentialDrive::Update(recurse);
this->drv8833.Update(false); this->drv8833->Update(false);
} }
#pragma endregion Differential drive #pragma endregion Differential drive

View File

@ -19,6 +19,8 @@ class DRV8833 : public Thing {
int BIn1; int BIn1;
int BIn2; int BIn2;
int standby = 255; int standby = 255;
constexpr Configuration(int a1, int a2, int b1, int b2, int standby = 255) : AIn1(a1), AIn2(a2), BIn1(b1), BIn2(b2), standby(standby) {}
}; };
/// @brief Setup a DRV8833 motor controller /// @brief Setup a DRV8833 motor controller
@ -43,7 +45,7 @@ class DRV8833::DifferentialDrive : public RoboidControl::DifferentialDrive {
virtual void Update(bool recurse = false) override; virtual void Update(bool recurse = false) override;
protected: protected:
DRV8833 drv8833; DRV8833* drv8833 = nullptr;
}; };
#pragma endregion Differential drive #pragma endregion Differential drive

View File

@ -65,7 +65,7 @@ UltrasonicSensor::TouchSensor::TouchSensor(Configuration config, Thing* parent)
void UltrasonicSensor::TouchSensor::Update(bool recursive) { void UltrasonicSensor::TouchSensor::Update(bool recursive) {
RoboidControl::TouchSensor::Update(recursive); RoboidControl::TouchSensor::Update(recursive);
this->ultrasonic.Update(false); this->ultrasonic.Update(false);
this->internalTouch |= (this->ultrasonic.distance > 0 && this->internalTouch = (this->ultrasonic.distance > 0 &&
this->ultrasonic.distance <= this->touchDistance); this->ultrasonic.distance <= this->touchDistance);
} }

View File

@ -40,9 +40,9 @@ int main() {
// and sleep for 100ms // and sleep for 100ms
#if defined(ARDUINO) #if defined(ARDUINO)
delay(100); delay(10);
#else #else
sleep_for(milliseconds(100)); sleep_for(milliseconds(10));
#endif #endif
} }