David Pasztor / Mbed 2 deprecated Motor_control

Dependencies:   mbed-rtos mbed

commands.h

Committer:
NKarandey
Date:
2017-03-24
Revision:
49:731c95cd5852
Child:
51:bab6e5eb864a

File content as of revision 49:731c95cd5852:

#include <vector>

#include "mbed.h"
#include "controlLoops.h"

Ticker lifeTicker;

volatile bool commandFinished = false;
void stopCommand() {
    commandFinished = true;
    lifeTicker.detach();
    controlTicker.detach();
}

void rotateWith(float r, float v) {

}

void setVelocity(float v) {
//    targetV = v;
//    goalRevs = 900.0f;
//    print("Spinning with V=%.2f\n\r", targetV);

    lifeTicker.attach(&stopCommand, 10);
}

void playTune(float freq) {
    motorPWMPeriod = 1.0f / freq;
//    motorOut(0, 0.5);
    Thread::wait(1000);
}

void playTunes(const vector<float>& tunes) {
    for (int i=0; i<tunes.size(); ++i) {
        playTune(tunes[i]);
    }
//    motorPWMPeriod = defaultMotorPWMPeriod;
    stopMotor();
}