Changed Up libary
Fork of Bertl by
Diff: ur_Bertl.cpp
- Revision:
- 13:3ce84646fd74
- Parent:
- 12:cedc088eaf05
- Child:
- 15:43d6a7e6e64a
diff -r cedc088eaf05 -r 3ce84646fd74 ur_Bertl.cpp --- a/ur_Bertl.cpp Sun Apr 26 20:04:47 2015 +0000 +++ b/ur_Bertl.cpp Mon Apr 27 13:13:45 2015 +0000 @@ -1,5 +1,6 @@ /*********************************** -name: ur_Bertl.cpp Version: 2.2 +name: ur_Bertl.cpp Version: 3.0 + class Bertl included author: PE HTL BULME email: pe@bulme.at WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/ @@ -13,7 +14,7 @@ #include "ur_Bertl.h" // Constructor -ur_Bertl::ur_Bertl() : _interrupt(P1_12) // left sensor P1_13 +ur_Bertl::ur_Bertl() : _interrupt(MOTORENC) { i2c.frequency(40000); // I2C init char init1[2] = {0x6, 0x00}; @@ -374,7 +375,7 @@ } // -------------------- BERTL CLASS ------------------------------------- -void Bertl::MoveBackwards(int move) +int Bertl::MoveBackwards(int move) { int count = _count; //wait_ms(250); // waite until Bertl stops @@ -393,8 +394,35 @@ MotorR_EN=MotorL_EN=0; if(move == MOVE) wait_ms(250); + return _count - count; } // ------------------------- BERT CLASS -------------------------------------- +int Bertl::Move(int move) +{ + int count = _count; + MotorR_EN=MotorL_EN=1; // both motor ENABLE + MotorR_FORWARD = MotorL_FORWARD = 1; // both motor forward ON +#ifdef TIME + wait_ms(move); +#else + + while(_count < count+move) { + //if(!FrontIsClear()) // more convenient because there are no accidents :-) + // break; +#ifdef FRONTBUTTON + if(frontButtonPressed()) + error(); +#endif + DEBUG_PRINT("count: %d _count: %d", count, _count); + } +#endif + MotorR_FORWARD = MotorL_FORWARD = 0; // both motor off + MotorR_EN=MotorL_EN=0; + if(move == MOVE) + wait_ms(250); + return _count - count; +} + void Bertl::TurnRigth() { int count = _count; @@ -475,4 +503,11 @@ detect = linesensor; return detect; -} \ No newline at end of file +} + +void Bertl::RGBLed(bool red, bool green, bool blue) +{ + RGB_blue=!blue; + RGB_red=!red; + RGB_green=!green; +}