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
Diff: Mousr.cpp
- Revision:
- 0:78e2af20cbf3
- Child:
- 1:e694ee3b4a7f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mousr.cpp Mon Sep 08 11:32:04 2014 +0000
@@ -0,0 +1,75 @@
+#include "Mousr.h"
+
+Mousr::Mousr() : m1a(p24), m1b(p23), m2a(p22), m2b(p21)
+{
+ straightSpeed = 1.0;
+ rotateSlowSpeed = 0.3;
+ rotateSpeed = 0.5;
+ rotateFastSpeed = 0.8;
+ flipStraightSpeed = 0.6;
+ flipStraightWait = 0.6;
+ flipRotateSpeed = 0.5;
+ flipRotateWait = 0.5;
+}
+
+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);
+}
+
+void Mousr::flipRight()
+{
+ straight(flipStraightSpeed);
+ wait(flipStraightWait);
+ right(flipRotateSpeed);
+ wait(flipRotateWait);
+}
+
+// GETTER FUNCTIONS
+float Mousr::getStraightSpeed()
+{
+ return straightSpeed;
+}
+
+float Mousr::getRotateSlowSpeed()
+{
+ return straightSpeed;
+}
+
+float Mousr::getRotateSpeed()
+{
+ return straightSpeed;
+}
+
+float Mousr::getRotateFastSpeed()
+{
+ return straightSpeed;
+}
\ No newline at end of file
