Revised to use positive logic
authorGraham <dev@netlinux.org.uk>
Thu, 7 Sep 2017 18:29:16 +0000 (19:29 +0100)
committerGraham <dev@netlinux.org.uk>
Thu, 7 Sep 2017 18:29:16 +0000 (19:29 +0100)
UnoBLDC.cpp

index df47fc7..5c4a0b9 100644 (file)
@@ -24,12 +24,12 @@ static const char TrinaryStep[][TRITS + 1] = {
 
 static const unsigned char SensePattern[] =
 {
-    0b001000,
-    0b010000,
-    0b100000,
     0b000001,
     0b000010,
-    0b000100
+    0b000100,
+    0b001000,
+    0b010000,
+    0b100000
 };
 
 #elif STEP == 12
@@ -51,18 +51,18 @@ static const char TrinaryStep[][TRITS + 1] = {
 
 static const unsigned char SensePattern[] =
 {
-    0b001000,
-    0b011000,
-    0b010000,
-    0b110000,
-    0b100000,
-    0b100001,
     0b000001,
     0b000011,
     0b000010,
     0b000110,
     0b000100,
-    0b001100
+    0b001100,
+    0b001000,
+    0b011000,
+    0b010000,
+    0b110000,
+    0b100000,
+    0b100001
 };
 
 #endif
@@ -112,7 +112,7 @@ void KeyPress (const char Character)
             Run = false;
             Manual = true;
             DDRB = (D[Character - '0'] << 3);   // set the direction
-            PORTB = (~P[Character - '0'] << 3) | 0b111;    // set the bits (including the pullups)
+            PORTB = (P[Character - '0'] << 3) | 0b111;    // set the bits (including the pullups)
             break;
 
         case '6':
@@ -172,7 +172,7 @@ void SensorChange()
     if (Run && (ThisStep != NOSTEP))
     {
         DDRB = (D[StepCount] << 3); // set the direction
-        PORTB = (~P[StepCount] << 3) | 0b111;  // set the bits (including the pullups)
+        PORTB = (P[StepCount] << 3) | 0b111;  // set the bits (including the pullups)
     }
 }