Class Bertl added

Dependencies:   HCSR

Dependents:   BertlDrive_V2 BertlDrive_V2

Revision:
12:cedc088eaf05
Parent:
7:e7f74f072564
--- a/ur_Bertl.h	Fri Apr 24 09:16:40 2015 +0000
+++ b/ur_Bertl.h	Sun Apr 26 20:04:47 2015 +0000
@@ -1,14 +1,15 @@
 /***********************************
-name:   ur_Bertl.h      Version: 2.1
+name:   ur_Bertl.h      Version: 2.2
 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, ...
+        Step wise turns on left and rigth
         int ReturnButtonPressed() added which returns the int value of button pressed 
 ***********************************/
 #include "mbed.h"
+#include "const.h"
 
 #ifndef UR_BERTL_H
 #define UR_BERTL_H
@@ -17,7 +18,7 @@
 #define RIGHTSENSOR P1_13
 /********************************************//**
  name:   ur_Bertl.h \n
- version: 2.0 \n
+ version: 2.2 \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
@@ -94,7 +95,7 @@
 @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
+/*Sorry, but there are Javascript problems with this code
 
 int main()
 {
@@ -144,12 +145,12 @@
     ur_Bertl();                 /**< default constructor; you have to define constants in config.h such as SPEED, DISTANCE or ANGLE*/
     ur_Bertl(PinName pin);      /**< parameterized constructor; on what pin should the interrupt work; SPEED, DISTANCE or ANGLE have to bee defined in config.h */
 
-    void Move();                /**< Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()*/      
+    //void Move();                /**< Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()*/      
+    void Move(int move = 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. 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 */ 
     bool NextToABeeper();       /**< returns a boolean value true if the robot is on a black place or line; if not --> false */ 
@@ -164,4 +165,81 @@
     void BlueLedsON();          /**< ON all blue LEDs which are on the same Port 1_28 */   
     int Read();
 };
+/********************************************//**
+ name:   Bertl.h \n
+ version: 1.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 Bertl The Robot.
+   
+***********************************************/
+
+/** 
+@code
+//
+@endcode
+
+Example motor sensor test:
+@code
+#include "mbed.h"
+#include "ur_Bertl.h"
+#include "const.h"
+ 
+int main()
+{
+    ur_Bertl karel(LEFTSENSOR);  // RIGHTSENSOR
+
+    while(true) {
+        karel.NibbleLeds(karel.Read());
+    }
+}
+@endcode
+
+Example follow a line:
+@code
+#include "mbed.h"
+#include "ur_Bertl.h"
+#include "const.h"
+
+int main()
+{
+    Bertl karel;
+    
+    while(karel.WaitUntilButtonPressed())
+    {
+        karel.NibbleLeds(karel.GetLineValues());
+        switch(karel.GetLineValues())
+        {
+        case 0x00:
+            karel.TurnLeftStep(50);
+            break;
+        case 0x03: case 0x01: case 0x07:
+            karel.TurnLeftStep(20);
+            break;
+        case 0x0E: case 0x0A: case 0x08:
+            karel.TurnRigthStep(20);
+            break;
+        default:
+            karel.Move(20);
+            break;
+        }
+        if(!karel.FrontIsClear())
+            karel.TurnLeftStep(1000);
+    }
+}
+@endcode
+*/
+class Bertl : public ur_Bertl
+{
+protected:
+public:
+    //Bertl();                 /**< default constructor; you have to define constants in config.h such as SPEED, DISTANCE or ANGLE*/
+    void MoveBackwards(int move = MOVE);       /**< Robot moves as much back as the constant DISTANCE; if one of the buttons fire --> Error()*/
+    void TurnRigth();           /**< Robot turns rigth as much as the constant ANGLE*/ 
+    void TurnLeftStep(int step=STEPTIME);   /**< Robot turns left for a short time defined in STEPTIME */
+    void TurnRigthStep(int step=STEPTIME);  /**< Robot turns rigth for a short time defined in STEPTIME */
+    uint8_t GetLineValues();    /**< in the lower 4 bit are the values of the line sensor */
+};
 #endif
\ No newline at end of file