wheelchair code for driver assitance

Dependencies:   mbed

Fork of wheelchairalexa by ryan lin

wheelchair.cpp

Committer:
ryanlin97
Date:
2018-07-16
Revision:
3:a5e71bfdb492
Parent:
1:c0beadca1617
Child:
4:29a27953fe70

File content as of revision 3:a5e71bfdb492:

#include "wheelchair.h"

Wheelchair::Wheelchair(PinName xPin, PinName yPin)
{
    x = new PwmOut(xPin);
    y = new PwmOut(yPin);
}
/*
* joystick has analog out of 200-700, scale values between 1.3 and 3.3
*/
void Wheelchair::move(float x_coor, float y_coor)
{
    printf("x is %f y is %f \n", 1.6*x_coor + 2.5, 1.6*y_coor + 2.5 + offset); 
    x->write(1.6*x_coor + 2.5);
    y->write(1.6*y_coor + 2.5 + offset);
    
}

void Wheelchair::forward()
{
    x->write(high);
    y->write(def+offset);
}

void Wheelchair::backward()
{
    x->write(low);
    y->write(def);
}

void Wheelchair::right()
{
    x->write(def);
    y->write(high);
}

void Wheelchair::left()
{
    x->write(def);
    y->write(low);
}

void Wheelchair::stop()
{
    x->write(def);
    y->write(def);
}