From fafb837120305b58855a0be79e8f5bc1a3b2d3d2 Mon Sep 17 00:00:00 2001 From: Tim Leuschner Date: Sun, 8 Sep 2019 17:30:17 +0200 Subject: [PATCH] removed my changes to platformio&my_user_config, removed the unnessesary digitalwrites in adjustMicrosteps() --- lib/A4988_Stepper/src/A4988_Stepper.cpp | 42 +++++++------------------ lib/A4988_Stepper/src/A4988_Stepper.h | 1 + platformio.ini | 5 ++- sonoff/my_user_config.h | 11 ++++--- sonoff/xdrv_25_A4988_Stepper.ino | 2 +- 5 files changed, 22 insertions(+), 39 deletions(-) diff --git a/lib/A4988_Stepper/src/A4988_Stepper.cpp b/lib/A4988_Stepper/src/A4988_Stepper.cpp index 5d723195d..cbd72390a 100644 --- a/lib/A4988_Stepper/src/A4988_Stepper.cpp +++ b/lib/A4988_Stepper/src/A4988_Stepper.cpp @@ -14,7 +14,7 @@ Drives a bipolar motor, controlled by A4988 stepper driver circuit */ - +// #include "Arduino.h" #include "A4988_Stepper.h" A4988_Stepper::A4988_Stepper( int m_spr @@ -60,35 +60,16 @@ void A4988_Stepper::adjustPins(void) { void A4988_Stepper::adjustMicrosteps() { if ((motor_ms1_pin<99)&&(motor_ms2_pin<99)&&(motor_ms3_pin<99)) { - switch (motor_MIS){ - case 1: - digitalWrite(motor_ms1_pin, LOW); - digitalWrite(motor_ms2_pin, LOW); - digitalWrite(motor_ms3_pin, LOW); - break; - case 2: - digitalWrite(motor_ms1_pin, HIGH); - digitalWrite(motor_ms2_pin, LOW); - digitalWrite(motor_ms3_pin, LOW); - break; - digitalWrite(motor_ms1_pin, LOW); - digitalWrite(motor_ms2_pin, HIGH); - digitalWrite(motor_ms3_pin, LOW); - case 4: - digitalWrite(motor_ms1_pin, HIGH); - digitalWrite(motor_ms2_pin, HIGH); - digitalWrite(motor_ms3_pin, LOW); - break; - case 8: - digitalWrite(motor_ms1_pin, LOW); - digitalWrite(motor_ms2_pin, LOW); - digitalWrite(motor_ms3_pin, HIGH); - break; - case 16: - digitalWrite(motor_ms1_pin, HIGH); - digitalWrite(motor_ms2_pin, HIGH); - digitalWrite(motor_ms3_pin, HIGH); - break; + unsigned short i = 0; + while (i < 5){ + if (motor_MIS & (1<