PickBeeperToWall
Revision 8:e7f74f072564, committed 2015-04-13
- Comitter:
- bulmecisco
- Date:
- Mon Apr 13 15:28:10 2015 +0000
- Parent:
- 7:df6830254e8b
- Child:
- 9:07e55b300ff1
- Commit message:
- int ReturnButtonPressed() added which returns the int value of button pressed
Changed in this revision
ur_Bertl.cpp | Show annotated file Show diff for this revision Revisions of this file |
ur_Bertl.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ur_Bertl.cpp Fri Apr 10 09:31:54 2015 +0000 +++ b/ur_Bertl.cpp Mon Apr 13 15:28:10 2015 +0000 @@ -1,11 +1,12 @@ /*********************************** -name: ur_Bertl.cpp Version: 2.0 +name: ur_Bertl.cpp Version: 2.1 author: PE HTL BULME email: pe@bulme.at WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/ description: Implementation portion of class ur_Bertl The Robot - boolean commands added for if/else, while, ... + boolean commands added for if/else, while, ... + int ReturnButtonPressed() added which returns the int value of button pressed ***********************************/ #include "mbed.h" #include "config.h" @@ -282,6 +283,22 @@ return wert; } +int ur_Bertl::ReturnButtonPressed() +{ + char cmd[3]; // array for I2C + int16_t btns; + + cmd[0] = 0x06; + cmd[1] = 0x00; + i2c.write(addr, cmd, 2); + + cmd[0]=0x01; + i2c.write(addr, cmd, 1); + i2c.read(addr|1, cmd, 1); + btns = cmd[0]; + DEBUG_PRINT("Button: %d", btns); + return btns; +} // Protected methodes int ur_Bertl::bottomIsBlack()
--- a/ur_Bertl.h Fri Apr 10 09:31:54 2015 +0000 +++ b/ur_Bertl.h Mon Apr 13 15:28:10 2015 +0000 @@ -1,11 +1,12 @@ /*********************************** -name: ur_Bertl.h Version: 2.0 +name: ur_Bertl.h Version: 2.1 author: PE HTL BULME email: pe@bulme.at WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/ description: Definition portion of the class ur_Bertl The Robot boolean commands added for if/else, while, ... + int ReturnButtonPressed() added which returns the int value of button pressed ***********************************/ #include "mbed.h" @@ -152,7 +153,8 @@ bool WaitUntilButtonPressed(); /**< wait until any button is pressed at the robot */ bool FrontIsClear(); /**< returns a boolean value true if front is free; if not false */ bool NextToABeeper(); /**< returns a boolean value true if the robot is on a black place or line; if not --> false */ - bool IsButtonPressed(const int btn); + bool IsButtonPressed(const int btn); /**< returns true if Button btn is pressed, else false */ + int ReturnButtonPressed(); /**< returns the int value of button pressed */ int AnyBeeperInBag(); /**< returns an int value (if > 0 equal true) how many beepers in bag; if zero --> false */ void NibbleLeds(int value); /**< methode for the 4 (half byte) yellow LEDs at the back left side; ie. you can show how many beeper a robot has in his bag with: karel.NibbleLeds(karel.AnyBeeperInBag())*/ void TurnLedOn(int16_t led);/**< turns the specified one or more LEDs ON; description and name in const.h, such as LED_FL1 = 0x01; front LED white */