diff --git a/Makefile b/Makefile index c39ae36..54937ce 100644 --- a/Makefile +++ b/Makefile @@ -50,3 +50,5 @@ setup: $(ARDUINO_DIR)/arduino-cli $(ARDUINO_CLI) core update-index $(ARDUINO_CLI) core install $(CORES) $(ARDUINO_CLI) core list + +.PHONY: clean %.hex all setup diff --git a/src/BasicStepperDriver.cpp b/src/BasicStepperDriver.cpp index c296eba..4ccec48 100644 --- a/src/BasicStepperDriver.cpp +++ b/src/BasicStepperDriver.cpp @@ -138,7 +138,7 @@ void BasicStepperDriver::startMove(long steps, long time){ float a2 = 1.0 / profile.accel + 1.0 / profile.decel; float sqrt_candidate = t*t - 2 * a2 * d; // in √b^2-4ac if (sqrt_candidate >= 0){ - speed = min(speed, (t - sqrt(sqrt_candidate)) / a2); + speed = min(speed, (t - (float)sqrt(sqrt_candidate)) / a2); }; } // how many microsteps from 0 to target speed diff --git a/src/MultiDriver.cpp b/src/MultiDriver.cpp index 7ea00b1..92789f5 100644 --- a/src/MultiDriver.cpp +++ b/src/MultiDriver.cpp @@ -67,7 +67,7 @@ long MultiDriver::nextAction(void){ */ void MultiDriver::startBrake(void){ FOREACH_MOTOR( - if (event_timers[i] >= 0){ + if (event_timers[i] > 0){ motors[i]->startBrake(); } ) @@ -91,10 +91,9 @@ bool MultiDriver::isRunning(void){ * positive to move forward, negative to reverse, 0 to remain still */ void MultiDriver::move(long steps1, long steps2, long steps3){ - unsigned long next_event; startMove(steps1, steps2, steps3); while (!ready){ - next_event = nextAction(); + nextAction(); } } diff --git a/src/MultiDriver.h b/src/MultiDriver.h index 97ec61b..07e4e54 100644 --- a/src/MultiDriver.h +++ b/src/MultiDriver.h @@ -36,7 +36,7 @@ class MultiDriver { // ready to start a new move bool ready = true; // when next state change is due for each motor - long event_timers[MAX_MOTORS]; + unsigned long event_timers[MAX_MOTORS]; unsigned long next_action_interval = 0; unsigned long last_action_end = 0; diff --git a/src/SyncDriver.cpp b/src/SyncDriver.cpp index d562b2c..527dd61 100644 --- a/src/SyncDriver.cpp +++ b/src/SyncDriver.cpp @@ -16,14 +16,12 @@ */ void SyncDriver::startMove(long steps1, long steps2, long steps3){ long steps[3] = {steps1, steps2, steps3}; - long timing[MAX_MOTORS]; /* * find which motor would take the longest to finish, */ long move_time = 0; FOREACH_MOTOR( long m = motors[i]->getTimeForMove(abs(steps[i])); - timing[i] = m; if (m > move_time){ move_time = m; }