AES-2015 / Mbed 2 deprecated Nucleo_URobot

Dependencies:   mbed

PositionSetter.cpp

Committer:
wanchp
Date:
2015-11-12
Revision:
0:a4ad8cb94c43

File content as of revision 0:a4ad8cb94c43:

#include "PositionSetter.h"

PositionSetter::PositionSetter() {
    // when no arguments, set to default
    // 3 axes (or motors )with 5 positions
    NofAxes = 3;
    NofPositions = 5;
    // first allocate memory 
    // for Position
    Position =  (Degree **) malloc(sizeof(Degree *) * NofAxes);
    for (int i = 0;  i < NofAxes; i++) { 
        Position[i] = (Degree *) malloc(sizeof(Degree) * NofPositions);
    }
    // for Duration
    Duration = (Time *) malloc(sizeof(Time) * NofPositions);
    Write = (bool *) malloc (sizeof(bool) * NofPositions); 
    for (int i = 0; i < NofPositions; i++) {
        for (int j = 0; j < NofAxes; j++) {
            Position[j][i] = (Degree) i*j;
        } 
        Duration[i] = (Time) i;
        Write[i] = true;
    }
}