Class Bertl added

Dependencies:   HCSR

Dependents:   BERTL_ButtonLeds Bertl_Arbeit FollowLine SerialPC ... more

Fork of ur_Bertl by BULME_BERTL_2CHEL

Revision:
4:76acfddc26fb
Parent:
1:fafbac0ba96d
Child:
5:6b667e2cb800
--- a/ur_Bertl.h	Thu Mar 26 13:06:00 2015 +0000
+++ b/ur_Bertl.h	Tue Apr 07 12:30:39 2015 +0000
@@ -1,11 +1,11 @@
 /***********************************
-name:   ur_Bertl.h      Version: 1.0
+name:   ur_Bertl.h      Version: 2.0
 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
-
-
+        Definition portion of the class ur_Bertl The Robot
+        boolean commands added for if/else, while, ...
 ***********************************/
 #include "mbed.h"
 
@@ -15,11 +15,12 @@
 #define LEFTSENSOR P1_12
 #define RIGHTSENSOR P1_13
 /********************************************//**
- name:   ur_Bertl.h 
- version: 1.0
- author: PE HTL BULME.
- email:  pe@bulme.at
- description:
+ name:   ur_Bertl.h \n
+ version: 2.0 \n
+ author:PE HTL BULME \n
+ email: pe@bulme.at \n
+ WIKI:  https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/wiki/Homepage \n
+ description: 
     Definition and documentation portion of the class ur_Bertl The Robot.
    
 ***********************************************/
@@ -90,11 +91,40 @@
    karel.ShutOff();
 } 
 @endcode
+Example IF/ELSE Commands (update ur_Bertl 2.0 from https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/
+@code
+/* Sorry, but there are Javascript problems with this code
+
+int main()
+{
+    ur_Bertl karel;
+
+    while( karel.WaitUntilButtonPressed() ) {}
+    if( karel.NextToABeeper()) {
+        karel.PickBeeper();
+        karel.NibbleLeds(karel.AnyBeeperInBag());   //show number of beepers in bag on 4 yellow Leds
+    }
+    wait(1);
+    if( karel.AnyBeeperInBag() ) {
+        karel.PutBeeper();
+        karel.NibbleLeds(karel.AnyBeeperInBag());  
+    }
+    wait(1);
+    if( karel.FrontIsClear() )
+        karel.Move();
+    else
+        karel.TurnLeft();
+
+    karel.ShutOff();
+}
+
+
+@endcode
  */
 class ur_Bertl
 {
 protected:
-    int beepersInBag;       /**< how many beepers does the robot have in his bag*/
+    int beepersInBag;       /**< how many beepers does the robot have in his bag;\n you can show it with: karel.NibbleLeds(karel.AnyBeeperInBag())*/
     char cmd[3];            /**< I2C command */
     int16_t btns;           /**< which button is pressed */
     InterruptIn _interrupt; /**< interrupted used*/
@@ -106,6 +136,7 @@
     void increment();       /**< ISR to increment sensor values of motor */
     bool backIsClear();     /**< don't now for what */
     bool frontButtonPressed();/**< TRUE if a a button on the front of Robot is pressed else FALSE */
+    int bottomIsBlack();    /**< check line sensor; returns BCD value */
     void error();           /**< Error: stops the robot and all LEDs are blinking*/
 
 public:
@@ -115,16 +146,19 @@
     void Move();                /**< Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()*/      
     void TurnLeft();            /**< Robot turns left as much as the constant ANGLE*/      
     void PutBeeper();           /**< if Robot has any Beepers in his bag he can put one or more Beeper; if not --> Error(()*/  
-    void PickBeeper();          /**< if Robot stands on a black item he can pick one or more Beeper (max. 16 --> Error()); if not --> Error()*/   
+    void PickBeeper();          /**< if Robot stands on a black item he can pick one or more Beeper (max. 15 --> Error()); if not --> Error()*/   
+    void ShutOff();             /**<  turnes the robot off */
+    void MoveBackwards();       /**< Robot moves as much back as the constant DISTANCE; if one of the buttons fire --> Error()*/
+    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 */ 
-    void NibbleLeds(int value); /**< methode for the 4 (half byte) yellow LEDs at the back left side */
+    bool NextToABeeper();       /**< returns a boolean value true if the robot is on a black place or line; if not --> false */ 
+    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 */
     void TurnLedOff(int16_t led);/**< turns the specified one or more LEDs OFF; description and name in const.h, such as LED_FL1 = 0x01; front LED white */
-    bool WaitUntilButtonPressed();  /**< wait until any button is pressed at the robot */
     void RGBLed(bool red, bool green, bool blue); /**<RGB Led with red, green and blue component of the Color */
     void BlueLedsOFF();         /**< OFF all blue LEDs which are on the same Port 1_28 */   
     void BlueLedsON();          /**< ON all blue LEDs which are on the same Port 1_28 */   
-    void ShutOff();             /**<  turnes the robot off */
     int Read();
 };
 #endif
\ No newline at end of file