First revision of tactile mouse code

Files at this revision

API Documentation at this revision

Comitter:
JPB515
Date:
Mon Apr 08 16:57:36 2019 +0000
Commit message:
First publish of tactile mouse code;

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
braille_mouse.cpp Show annotated file Show diff for this revision Revisions of this file
braille_mouse.hpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
stepper.cpp Show annotated file Show diff for this revision Revisions of this file
stepper.hpp Show annotated file Show diff for this revision Revisions of this file
tactile_display.cpp Show annotated file Show diff for this revision Revisions of this file
tactile_display.hpp Show annotated file Show diff for this revision Revisions of this file
tactile_mouse.hpp Show annotated file Show diff for this revision Revisions of this file
taxel.cpp Show annotated file Show diff for this revision Revisions of this file
taxel.hpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,57 @@
+# Getting started with Blinky on mbed OS
+
+This guide reviews the steps required to get Blinky working on an mbed OS platform.
+
+Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
+
+## Import the example application
+
+From the command-line, import the example:
+
+```
+mbed import mbed-os-example-blinky
+cd mbed-os-example-blinky
+```
+
+### Now compile
+
+Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
+
+```
+mbed compile -m K64F -t ARM
+```
+
+Your PC may take a few minutes to compile your code. At the end, you see the following result:
+
+```
+[snip]
++----------------------------+-------+-------+------+
+| Module                     | .text | .data | .bss |
++----------------------------+-------+-------+------+
+| Misc                       | 13939 |    24 | 1372 |
+| core/hal                   | 16993 |    96 |  296 |
+| core/rtos                  |  7384 |    92 | 4204 |
+| features/FEATURE_IPV4      |    80 |     0 |  176 |
+| frameworks/greentea-client |  1830 |    60 |   44 |
+| frameworks/utest           |  2392 |   512 |  292 |
+| Subtotals                  | 42618 |   784 | 6384 |
++----------------------------+-------+-------+------+
+Allocated Heap: unknown
+Allocated Stack: unknown
+Total Static RAM memory (data + bss): 7168 bytes
+Total RAM memory (data + bss + heap + stack): 7168 bytes
+Total Flash memory (text + data + misc): 43402 bytes
+Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin
+```
+
+### Program your board
+
+1. Connect your mbed device to the computer over USB.
+1. Copy the binary file to the mbed device.
+1. Press the reset button to start the program.
+
+The LED on your platform turns on and off.
+
+## Troubleshooting
+
+If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/braille_mouse.cpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,151 @@
+#include "braille_mouse.hpp"
+#include "tactile_mouse.hpp"
+
+/*  CELL OFFSETS
+76543210
+22-11-00 0
+22-11-00 1
+22-11-00 2
+-------- 3
+-------- 4
+55-44-33 5
+55-44-33 6
+55-44-33 7
+*/
+
+void brailleCharacter(tactileDisplay &display, int cell, char character){
+    int xOffset = getXOffset(cell);
+    int yOffset = getYOffset(cell);
+    
+    if ((character == 'c')||
+        (character == 'd')||
+        (character == 'f')||
+        (character == 'g')||
+        (character == 'i')||
+        (character == 'j')||
+        (character == 'm')||
+        (character == 'n')||
+        (character == 'p')||
+        (character == 'q')||
+        (character == 's')||
+        (character == 't')||
+        (character == 'w')||
+        (character == 'x')||
+        (character == 'y')||
+        (character == '3')||
+        (character == '4')||
+        (character == '6')||
+        (character == '7')||
+        (character == '9')||
+        (character == '0'))
+        {display.setTaxel((6+xOffset),(0+yOffset),100);}
+    else{display.setTaxel((6+xOffset),(0+yOffset),0);}
+    if ((character == 'd')||
+        (character == 'e')||
+        (character == 'g')||
+        (character == 'h')||
+        (character == 'j')||
+        (character == 'n')||
+        (character == 'o')||
+        (character == 'q')||
+        (character == 'r')||
+        (character == 't')||
+        (character == 'w')||
+        (character == 'y')||
+        (character == 'z')||
+        (character == '4')||
+        (character == '5')||
+        (character == '7')||
+        (character == '8')||
+        (character == '0'))
+        {display.setTaxel((5+xOffset),(0+yOffset),100);}
+    else{display.setTaxel((5+xOffset),(0+yOffset),0);}
+    if ((character == 'u')||
+        (character == 'v')||
+        (character == 'w')||
+        (character == 'x')||
+        (character == 'y')||
+        (character == 'z'))
+        {display.setTaxel((4+xOffset),(0+yOffset),100);}
+    else{display.setTaxel((4+xOffset),(0+yOffset),0);}
+    if ((character == 'i')||
+        (character == 'j')||
+        (character == 's')||
+        (character == 't')||
+        (character == 'w')||
+        (character == '9')||
+        (character == '0'))
+        {display.setTaxel((6+xOffset),(1+yOffset),0);}
+    else{display.setTaxel((6+xOffset),(1+yOffset),100);}
+    if ((character == 'a')||
+        (character == 'c')||
+        (character == 'd')||
+        (character == 'e')||
+        (character == 'k')||
+        (character == 'm')||
+        (character == 'n')||
+        (character == 'o')||
+        (character == 'u')||
+        (character == 'x')||
+        (character == 'y')||
+        (character == 'z')||
+        (character == '1')||
+        (character == '3')||
+        (character == '4')||
+        (character == '5'))
+        {display.setTaxel((5+xOffset),(1+yOffset),0);}
+    else{display.setTaxel((5+xOffset),(1+yOffset),100);}
+    if ((character == 'k')||
+        (character == 'l')||
+        (character == 'm')||
+        (character == 'n')||
+        (character == 'o')||
+        (character == 'p')||
+        (character == 'q')||
+        (character == 'r')||
+        (character == 's')||
+        (character == 't')||
+        (character == 'u')||
+        (character == 'v')||
+        (character == 'x')||
+        (character == 'y')||
+        (character == 'z'))
+        {display.setTaxel((4+xOffset),(1+yOffset),100);}
+    else{display.setTaxel((4+xOffset),(1+yOffset),0);}
+}
+
+/*  CELL OFFSETS
+76543210
+-000-333 0
+-000-333 1
+-------- 2
+-111-444 3
+-111-444 4
+-------- 5
+-222-555 6
+-222-555 7
+*/
+
+int getYOffset(int cell){
+    if ((cell == 0)||(cell == 3)){
+        return 0;
+    }
+    else if ((cell == 1)||(cell == 4)){
+        return 3;
+    }
+    else if ((cell == 2)||(cell == 5)){
+        return 6;
+    }
+    return -1;
+}
+
+int getXOffset(int cell){
+    if ((cell == 0)||(cell == 1)||(cell == 2)){
+        return 0;
+    }
+    else if ((cell == 3)||(cell == 4)||(cell == 5)){
+        return 4;
+    }
+    return -1;
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/braille_mouse.hpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,11 @@
+#ifndef BRAILLE_MOUSE_HPP
+#define BRAILLE_MOUSE_HPP
+
+#include "mbed.h"
+#include "tactile_display.hpp"
+
+void brailleCharacter(tactileDisplay &display, int cell, char character);
+int getXOffset(int cell);
+int getYOffset(int cell);
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,170 @@
+#include "mbed.h"
+#include "tactile_mouse.hpp"
+#include "braille_mouse.hpp"
+#include "tactile_display.hpp"
+#include "stepper.hpp"
+#include <vector>
+#include <ctime>
+
+//  ***PINS FOR EMBEDDED PCB***
+DigitalOut MotorA1(PD_4);
+DigitalOut MotorA2(PD_3);
+DigitalOut MotorB1(PD_1);
+DigitalOut MotorB2(PD_2);
+DigitalOut MUXA(PD_0);
+DigitalOut MUXB(PC_12);
+DigitalOut MUXC(PC_11);
+DigitalOut BOARD_MUXA(PE_6);
+DigitalOut BOARD_MUXB(PE_5);
+DigitalOut BOARD_MUXC(PE_4);
+DigitalOut step(PD_5);
+DigitalOut motorPower(PC_4);  //Power enable pin 44
+DigitalIn reversePin(PG_0, PullDown);
+
+Thread displayThread;
+bool running;
+
+void refreshDisplay(tactileDisplay *display){
+    int count = 0;
+    while(running){
+        (*display).stepDisplay();
+        //if((count%50)==0){
+            //removePin = !removePin;
+        //}
+        count++;
+    }
+    //Clear all latches
+    for(int m=0 ; m<8 ; m++){
+        for(int n=0 ; n<8 ; n++){
+            selectMotor(m,n);
+            M1stop(0.0005);
+        }
+    }
+}
+
+
+int main() {
+    
+    tactileDisplay display(8,8,3);
+    
+    step = 0;
+    motorPower = 0;
+    running = false;
+    
+    //Clear all latches
+    for(int m=0 ; m<8 ; m++){
+        for(int n=0 ; n<8 ; n++){
+            selectMotor(m,n);
+            M1stop(0.0005);
+        }
+    }
+    
+    motorPower = 1;
+    
+    //Establish serial connection
+    Serial pc(USBTX, USBRX);
+    
+    running = true;
+    displayThread.start(callback(refreshDisplay, &display));
+    char xin,yin;
+    char zin[5];
+    int x,y,z;
+    
+    while(1){
+        if(pc.readable()){
+            xin = pc.getc();
+            pc.getc();      //Throw away separator
+            yin = pc.getc();
+            pc.getc();      //Throw away separator
+            pc.scanf("%s",zin);
+            
+            //Make x integer
+            x = xin - '0';
+            
+            //Make y integer
+            y = yin - '0';
+            
+            //Make z integer
+            if(zin[0] == '-'){        //if negative
+                z = ((zin[1])+(zin[2]*10)+(zin[3]*100)+(zin[4]*1000))*(-1);
+            }
+            else{                   //if positive
+                z = ((zin[0])+(zin[1]*10)+(zin[2]*100)+(zin[3]*1000)+(zin[4]*10000))
+            }
+            
+            display.setTaxel(x,y,z);
+        }
+    }
+    
+    brailleCharacter(display, 0, 'e');
+    brailleCharacter(display, 1, 'i');
+    brailleCharacter(display, 2, 'e');
+    
+    wait(15);
+    
+    brailleCharacter(display, 3, 'n');
+    brailleCharacter(display, 4, 'i');
+    brailleCharacter(display, 5, 'w');
+    
+    wait(15);
+    
+    brailleCharacter(display, 0, 'g');
+    brailleCharacter(display, 1, 'i');
+    brailleCharacter(display, 2, 'b');
+    
+    wait(15);
+    
+    brailleCharacter(display, 0, 'g');
+    brailleCharacter(display, 1, 'o');
+    brailleCharacter(display, 2, 'd');
+    
+    wait(15);
+    
+    /*
+    //SQUARE
+    display.setTaxel(6,3,50);
+    display.setTaxel(3,3,50);
+    display.setTaxel(3,4,50);
+    display.setTaxel(3,5,50);
+    display.setTaxel(6,2,50);
+    display.setTaxel(6,3,50);
+    display.setTaxel(6,4,50);
+    display.setTaxel(6,5,50);
+    display.setTaxel(5,2,50);
+    display.setTaxel(5,5,50);
+    display.setTaxel(4,2,50);
+    display.setTaxel(4,5,50);
+    */
+    /*int dist = -4000;
+    if(reversePin == 1){ dist = dist * (-1);}
+    
+    for(int i=0 ; i<7 ; ++i){
+        for(int j=0 ; j<8 ; ++j){
+            display.setTaxel(i,j,(rand()%50));
+        }
+    }
+    */
+    wait(30);
+    
+    for(int i=0 ; i<7 ; ++i){
+        for(int j=0 ; j<8 ; ++j){
+            display.setTaxel(i,j,0);
+        }
+    }
+    
+    wait(50);
+    
+    running = false;
+    wait(1);
+    displayThread.join();
+    
+    //Clear all latches
+    for(int m=0 ; m<8 ; m++){
+        for(int n=0 ; n<8 ; n++){
+            selectMotor(m,n);
+            M1stop(0.0005);
+        }
+    }    
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#ae6c7c60f91c89cbf755a2f3c8ec9c66635849fd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stepper.cpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,209 @@
+#include "mbed.h"
+#include "tactile_mouse.hpp"
+#include "stepper.hpp"
+
+void M1downstep1(double delay){
+    MotorA1=0;
+    MotorA2=1;
+    MotorB1=0;
+    MotorB2=1;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    }
+
+void M1downstep2(double delay){
+    MotorA1=0;
+    MotorA2=1;
+    MotorB1=1;
+    MotorB2=0;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    }
+
+void M1downstep3(double delay){
+    MotorA1=1;
+    MotorA2=0;
+    MotorB1=1;
+    MotorB2=0;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    }
+
+void M1downstep4(double delay){
+    MotorA1=1;
+    MotorA2=0;
+    MotorB1=0;
+    MotorB2=1;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    }
+
+void M1upstep1(double delay){
+    MotorA1=1;
+    MotorA2=0;
+    MotorB1=0;
+    MotorB2=1;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    }
+
+void M1upstep3(double delay){
+    MotorA1=1;
+    MotorA2=0;
+    MotorB1=1;
+    MotorB2=0;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    }
+
+void M1upstep5(double delay){
+    MotorA1=0;
+    MotorA2=1;
+    MotorB1=1;
+    MotorB2=0;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    }
+
+void M1upstep7(double delay){
+    MotorA1=0;
+    MotorA2=1;
+    MotorB1=0;
+    MotorB2=1;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    }
+    
+    
+void M1stop(double delay){
+    MotorA1=0;
+    MotorA2=0;
+    MotorB1=0;
+    MotorB2=0;
+    wait(0.00001);
+    step = 1;
+    wait(0.00001);
+    step=0;
+    }
+    
+//Extend and retract functions take time delay in S
+void M1down(double delay){
+    M1upstep7(delay);
+    M1upstep5(delay);
+    M1upstep3(delay);
+    M1upstep1(delay);
+    M1stop(0);
+}//Steps are different - sequence actually turns out to be the same as the up sequence!
+    
+void M1up(double delay){
+    M1upstep1(delay);
+    M1upstep3(delay);
+    M1upstep5(delay);
+    M1upstep7(delay);
+    M1stop(0);
+}
+
+    
+    
+void selectMotor(int x, int y){
+    switch (x){
+        case 0: BOARD_MUXA=0;
+                BOARD_MUXB=0;
+                BOARD_MUXC=0;
+                break;
+        case 1: BOARD_MUXA=1;
+                BOARD_MUXB=0;
+                BOARD_MUXC=0;
+                break;
+        case 2: BOARD_MUXA=0;
+                BOARD_MUXB=1;
+                BOARD_MUXC=0;
+                break;
+        case 3: BOARD_MUXA=1;
+                BOARD_MUXB=1;
+                BOARD_MUXC=0;
+                break;
+        case 4: BOARD_MUXA=0;
+                BOARD_MUXB=0;
+                BOARD_MUXC=1;
+                break;
+        case 5: BOARD_MUXA=1;
+                BOARD_MUXB=0;
+                BOARD_MUXC=1;
+                break;
+        case 6: BOARD_MUXA=0;
+                BOARD_MUXB=1;
+                BOARD_MUXC=1;
+                break;
+        case 7: BOARD_MUXA=1;
+                BOARD_MUXB=1;
+                BOARD_MUXC=1;
+                break;
+        default:BOARD_MUXA=0;
+                BOARD_MUXB=0;
+                BOARD_MUXC=0;
+                break;
+    }
+    switch (y){
+        case 0: MUXA=0;
+                MUXB=0;
+                MUXC=0;
+                break;
+        case 1: MUXA=1;
+                MUXB=0;
+                MUXC=0;
+                break;
+        case 2: MUXA=0;
+                MUXB=1;
+                MUXC=0;
+                break;
+        case 3: MUXA=1;
+                MUXB=1;
+                MUXC=0;
+                break;
+        case 4: MUXA=0;
+                MUXB=0;
+                MUXC=1;
+                break;
+        case 5: MUXA=1;
+                MUXB=0;
+                MUXC=1;
+                break;
+        case 6: MUXA=0;
+                MUXB=1;
+                MUXC=1;
+                break;
+        case 7: MUXA=1;
+                MUXB=1;
+                MUXC=1;
+                break;
+        default:MUXA=0;
+                MUXB=0;
+                MUXC=0;
+                break;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stepper.hpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,21 @@
+#ifndef STEPPER_HPP
+#define STEPPER_HPP
+
+#include "mbed.h"
+
+void M1downstep1(double delay);
+void M1downstep2(double delay);
+void M1downstep3(double delay);
+void M1downstep4(double delay);
+void M1upstep1(double delay);
+void M1upstep3(double delay);
+void M1upstep5(double delay);
+void M1upstep7(double delay);
+void M1stop(double delay);
+
+void M1down(double delay);
+void M1up(double delay);
+
+void selectMotor(int x, int y);
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tactile_display.cpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,79 @@
+#include "mbed.h"
+#include "tactile_display.hpp"
+#include "tactile_mouse.hpp"
+
+tactileDisplay::tactileDisplay(){}
+
+tactileDisplay::tactileDisplay(int x, int y){
+    xSize = x;
+    ySize = y;
+    size = x * y;
+    maxActive = size;       //By default, all motors can be active at once;
+    
+    for(int j=0 ; j<ySize ; ++j){
+        for(int i=0 ; i<xSize ; ++i){
+            taxel* tempTaxel = new taxel(i,j);
+            taxels.push_back(tempTaxel);
+        }
+    }
+}
+
+tactileDisplay::tactileDisplay(int x, int y, int max){
+    xSize = x;
+    ySize = y;
+    size = x * y;
+    maxActive = max;
+    
+    for(int j=0 ; j<ySize ; ++j){
+        for(int i=0 ; i<xSize ; ++i){
+            taxel* tempTaxel = new taxel(i,j);
+            taxels.push_back(tempTaxel);
+        }
+    }
+}
+
+tactileDisplay::~tactileDisplay(){
+    xSize = 8;
+    ySize = 8;
+    size = 64;
+    
+    for(int i=0 ; i<xSize ; ++i){
+        for(int j=0 ; j<ySize ; ++j){
+            taxel* tempTaxel = new taxel(i,j);
+            taxels.push_back(tempTaxel);
+        }
+    }
+    
+}
+
+void zero(){}
+
+int tactileDisplay::coordtoidx(int x, int y){
+    int idx=-1;
+    
+    if((x>=0)&&(x<xSize)){
+        if((y>=0)&&(y<ySize)){
+            idx = (xSize*y) + x;
+        }
+    }
+    return idx;
+}
+
+void tactileDisplay::setTaxel(int x, int y, int target){
+    int idx = coordtoidx(x,y);
+    taxels[idx]->setTarget(target);
+}
+
+void tactileDisplay::stepDisplay(){
+    int nMoved = 0;
+    vector<int> moved;
+    for(int i=0 ; ((i<size) && (nMoved<=maxActive)) ; ++i){
+        if(taxels[i]->stepToTarget()){
+            nMoved++;
+            moved.push_back(i);
+        }
+    }
+    //for(int i=0 ; i<nMoved ; ++i){
+    //    taxels[moved[i]]->stop();
+    //}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tactile_display.hpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,28 @@
+#ifndef TACTILE_DISPLAY_HPP
+#define TACTILE_DISPLAY_HPP
+
+#include "mbed.h"
+#include "taxel.hpp"
+
+#include <vector>
+
+class tactileDisplay{
+    public:
+    tactileDisplay();
+    tactileDisplay(int x, int y);
+    tactileDisplay(int x, int y, int max);
+    ~tactileDisplay();
+    void zero();
+    int coordtoidx(int x, int y);
+    void setTaxel(int x, int y, int steps);
+    void stepDisplay();
+    
+    private:
+    int xSize;
+    int ySize;
+    int size;
+    int maxActive;
+    vector<taxel*> taxels;
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tactile_mouse.hpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,19 @@
+#ifndef TACTILE_MOUSE_HPP
+#define TACTILE_MOUSE_HPP
+
+#include "mbed.h"
+
+extern DigitalOut MotorA1;
+extern DigitalOut MotorA2;
+extern DigitalOut MotorB1;
+extern DigitalOut MotorB2;
+extern DigitalOut MUXA;
+extern DigitalOut MUXB;
+extern DigitalOut MUXC;
+extern DigitalOut BOARD_MUXA;
+extern DigitalOut BOARD_MUXB;
+extern DigitalOut BOARD_MUXC;
+extern DigitalOut step;
+extern DigitalIn reversePin;
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taxel.cpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,266 @@
+#include "mbed.h"
+#include "tactile_mouse.hpp"
+#include "taxel.hpp"
+
+taxel::taxel(){
+    steps=0;
+    targetSteps=0;
+    lastStep=1;
+    delay = 0.003;
+    changed = false;
+}
+
+taxel::taxel(int x_, int y_){
+    x=x_;
+    y=y_;
+    steps=0;
+    targetSteps=0;
+    lastStep=1;
+    delay = 0.003;
+    changed = false;
+}
+
+taxel::~taxel(){}
+
+void taxel::step1(){
+    MotorA1=1;
+    MotorA2=0;
+    MotorB1=0;
+    MotorB2=1;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    lastStep = 1;
+    }
+
+void taxel::step2(){
+    MotorA1=1;
+    MotorA2=0;
+    MotorB1=1;
+    MotorB2=0;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    lastStep = 2;
+    }
+
+void taxel::step3(){
+    MotorA1=0;
+    MotorA2=1;
+    MotorB1=1;
+    MotorB2=0;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    lastStep = 3;
+    }
+
+void taxel::step4(){
+    MotorA1=0;
+    MotorA2=1;
+    MotorB1=0;
+    MotorB2=1;
+    wait(0.000001);
+    step = 1;
+    wait(0.000001);
+    step=0;
+    wait(delay);
+    lastStep = 4;
+    }
+    
+    
+void taxel::stop(){
+    MotorA1=0;
+    MotorA2=0;
+    MotorB1=0;
+    MotorB2=0;
+    step = 1;
+    step=0;
+    }
+    
+//Extend and retract functions take time delay in S
+void taxel::down(){
+    step4();
+    step3();
+    step2();
+    step1();
+    stop();
+}
+    
+void taxel::up(){
+    step1();
+    step2();
+    step3();
+    step4();
+    stop();
+}
+    
+void taxel::selectMotor(int x, int y){
+    switch (x){
+        case 0: BOARD_MUXA=0;
+                BOARD_MUXB=0;
+                BOARD_MUXC=0;
+                break;
+        case 1: BOARD_MUXA=1;
+                BOARD_MUXB=0;
+                BOARD_MUXC=0;
+                break;
+        case 2: BOARD_MUXA=0;
+                BOARD_MUXB=1;
+                BOARD_MUXC=0;
+                break;
+        case 3: BOARD_MUXA=1;
+                BOARD_MUXB=1;
+                BOARD_MUXC=0;
+                break;
+        case 4: BOARD_MUXA=0;
+                BOARD_MUXB=0;
+                BOARD_MUXC=1;
+                break;
+        case 5: BOARD_MUXA=1;
+                BOARD_MUXB=0;
+                BOARD_MUXC=1;
+                break;
+        case 6: BOARD_MUXA=0;
+                BOARD_MUXB=1;
+                BOARD_MUXC=1;
+                break;
+        case 7: BOARD_MUXA=1;
+                BOARD_MUXB=1;
+                BOARD_MUXC=1;
+                break;
+        default:BOARD_MUXA=0;
+                BOARD_MUXB=0;
+                BOARD_MUXC=0;
+                break;
+    }
+    switch (y){
+        case 0: MUXA=0;
+                MUXB=0;
+                MUXC=0;
+                break;
+        case 1: MUXA=1;
+                MUXB=0;
+                MUXC=0;
+                break;
+        case 2: MUXA=0;
+                MUXB=1;
+                MUXC=0;
+                break;
+        case 3: MUXA=1;
+                MUXB=1;
+                MUXC=0;
+                break;
+        case 4: MUXA=0;
+                MUXB=0;
+                MUXC=1;
+                break;
+        case 5: MUXA=1;
+                MUXB=0;
+                MUXC=1;
+                break;
+        case 6: MUXA=0;
+                MUXB=1;
+                MUXC=1;
+                break;
+        case 7: MUXA=1;
+                MUXB=1;
+                MUXC=1;
+                break;
+        default:MUXA=0;
+                MUXB=0;
+                MUXC=0;
+                break;
+    }
+}
+
+void taxel::stepUp(){
+    selectMotor(x,y);
+    switch (lastStep){
+        case 1:
+            step2();
+            break;
+        case 2:
+            step3();
+            break;
+        case 3:
+            step4();
+            break;
+        case 4:
+            step1();
+            break;
+    }
+    steps++;
+    //deactivate.attach(callback(this, &taxel::stop), 0.015);
+    wait(0.02);
+    stop();
+}
+
+void taxel::stepDown(){
+    selectMotor(x,y);
+    switch (lastStep){
+        case 1:
+            step4();
+            break;
+        case 2:
+            step1();
+            break;
+        case 3:
+            step2();
+            break;
+        case 4:
+            step3();
+            break;
+    }
+    steps--;
+    //deactivate.attach(callback(this, &taxel::stop), 0.015);
+    wait(0.02);
+    stop();
+}
+
+void taxel::setTarget(int target){
+    if(target != steps){
+        changed = true;
+    }
+    targetSteps = target;
+    
+}
+
+bool taxel::stepToTarget(){
+    if(!changed){
+        return changed;
+    }
+    if(steps > targetSteps){
+        stepDown();
+        if(steps == targetSteps){
+            changed = false;
+        }
+        return changed;
+    }
+    
+    if(steps < targetSteps){
+        stepUp();
+        if(steps == targetSteps){
+            changed = false;
+        }
+        return changed;
+    }
+    return changed;  //Should never get here
+}
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taxel.hpp	Mon Apr 08 16:57:36 2019 +0000
@@ -0,0 +1,39 @@
+#ifndef TAXEL_HPP
+#define TAXEL_HPP
+
+#include "mbed.h"
+
+class taxel{
+    public:
+    taxel();
+    taxel(int x_, int y_);
+    ~taxel();
+    void step1();
+    void step2();
+    void step3();
+    void step4();
+    void stop();
+    
+    void down();
+    void up();
+    
+    void stepDown();
+    void stepUp();
+    
+    void selectMotor(int x, int y);
+    
+    void setTarget(int target);
+    bool stepToTarget();
+    
+    private:
+    int x;
+    int y;
+    int lastStep;
+    int steps;
+    int targetSteps;
+    double delay;
+    bool changed;
+    Timeout deactivate;
+};
+
+#endif
\ No newline at end of file