From 0793c0c730a15297c5253282b9598d3b83118161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=B3r=C3=A1nt=20Pint=C3=A9r?= Date: Thu, 22 Feb 2024 22:14:34 +0100 Subject: [PATCH] Fix flow-control for MK5 --- data-templates/flow-control-mk5.json | 2 +- src/kernel/drivers/Drv8874Driver.hpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/data-templates/flow-control-mk5.json b/data-templates/flow-control-mk5.json index 3e0408e1..f17e84b0 100644 --- a/data-templates/flow-control-mk5.json +++ b/data-templates/flow-control-mk5.json @@ -9,7 +9,7 @@ "motor": "a" }, "flow-meter": { - "pin": 6 + "pin": 5 } } } diff --git a/src/kernel/drivers/Drv8874Driver.hpp b/src/kernel/drivers/Drv8874Driver.hpp index 1c9dec82..70995503 100644 --- a/src/kernel/drivers/Drv8874Driver.hpp +++ b/src/kernel/drivers/Drv8874Driver.hpp @@ -50,6 +50,13 @@ class Drv8874Driver } void drive(MotorPhase phase, double duty = 1) override { + if (duty == 0) { + Log.traceln("Stopping motor"); + sleep(); + return; + } + wakeUp(); + int dutyValue = in1Channel.maxValue() / 2 + (int) (in1Channel.maxValue() / 2 * duty); Log.traceln("Driving motor %s at %d%%", phase == MotorPhase::FORWARD ? "forward" : "reverse",