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.
Diff: MDDS30_oit.cpp
- Revision:
- 4:085a9c395959
- Parent:
- 3:a64fd9b238c5
- Child:
- 5:40f33560d8a1
--- a/MDDS30_oit.cpp Thu Jul 22 01:06:29 2021 +0000
+++ b/MDDS30_oit.cpp Sat Jul 24 11:13:57 2021 +0000
@@ -1,23 +1,31 @@
#include "MDDS30_oit.h"
+
MDDS30oit::MDDS30oit(PinName _txpin, PinName _rxpin) : md(_txpin, _rxpin, 115200)
{
-
- direction=0;
- leftfront=0;
- rightfront=0;
- leftback=0;
- rightback=0;
+ word=1;
+ word2=0;
+ direction=0;
+ leftfront=0;
+ rightfront=0;
+ leftback=0;
+ rightback=0;
+ direction=0;
+ leftfront=0;
+ rightfront=0;
+ leftback=0;
+ rightback=0;
- }
+}
void MDDS30oit::lefttire(float speed){
- speed=speed*63.0f;
+ speed=speed*127.0f;
if(speed>0){
direction=(word2<<1)|0;
}
else{
direction=(word2<<1)|1;
+ speed = -speed;
}
leftfront=(direction<<6)|(int)speed;
md.putc(leftfront);
@@ -26,12 +34,13 @@
}
void MDDS30oit::righttire(float speed){
- speed=speed*63.0f;
+ speed=speed*127.0f;
if(speed>0){
direction=(word<<1)|0;
}
else{
direction=(word<<1)|1;
+ speed = -speed;
}
rightfront=(direction<<6)|(int)speed;
md.putc(rightfront);