Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of RCControlOOP by
Mousr.cpp
- Committer:
- mfillinois
- Date:
- 2014-09-21
- Revision:
- 1:e694ee3b4a7f
- Parent:
- 0:78e2af20cbf3
- Child:
- 2:e9042e88abf1
File content as of revision 1:e694ee3b4a7f:
#include "Mousr.h"
Mousr::Mousr() : m1a(p24), m1b(p23), m2a(p22), m2b(p21)
{
straightSpeed = 0.7;
rotateSlowSpeed = 0.1;
rotateSpeed = 0.3;
rotateFastSpeed = 0.9;
flipStraightSpeed = 0.9;
flipStraightWait = 0.6;
flipRotateSpeed = 0.9;
flipRotateWait = 0.2;
}
void Mousr::stop()
{
m1a = 0; m2a = 0; m1b = 0; m2b = 0; return;
}
void Mousr::straight(float speed)
{
m1a = speed; m1b = 0; m2a = speed; m2b = 0; return;
}
void Mousr::backwards(float speed)
{
m1a = 0; m2a = 0; m1b = speed; m2b = speed; return;
}
void Mousr::left(float speed)
{
m1a = 0; m1b = speed; m2a = speed; m2b = 0; return;
}
void Mousr::right(float speed)
{
m1a = speed; m1b = 0; m2a = 0; m2b = speed; return;
}
void Mousr::flipLeft()
{
straight(flipStraightSpeed);
wait(flipStraightWait);
left(flipRotateSpeed);
wait(flipRotateWait);
stop();
}
void Mousr::flipRight()
{
straight(flipStraightSpeed);
wait(flipStraightWait);
right(flipRotateSpeed);
wait(flipRotateWait);
stop();
}
// GETTER FUNCTIONS
float Mousr::getStraightSpeed()
{
return straightSpeed;
}
float Mousr::getRotateSlowSpeed()
{
return rotateSlowSpeed;
}
float Mousr::getRotateSpeed()
{
return rotateSpeed;
}
float Mousr::getRotateFastSpeed()
{
return rotateFastSpeed;
}
