Filip Putz / Bertl

Dependencies:   HCSR

Fork of Bertl by Franz Pucher

Files at this revision

API Documentation at this revision

Comitter:
fpucher
Date:
Thu Nov 12 19:05:56 2015 +0000
Parent:
16:9ec833d98d0d
Child:
18:9480a699f9b7
Commit message:
Leds work now

Changed in this revision

Robot.h Show annotated file Show diff for this revision Revisions of this file
const.h Show annotated file Show diff for this revision Revisions of this file
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/Robot.h	Thu Nov 12 09:05:05 2015 +0000
+++ b/Robot.h	Thu Nov 12 19:05:56 2015 +0000
@@ -31,5 +31,6 @@
     bool facingEast();       // is the robot facing East?
     bool facingWest();       // is the robot facing West?
     bool anyBeepersInBeeperBag();    //are there any beepers in the bag?
-};
+    
+ };
 #endif
\ No newline at end of file
--- a/const.h	Thu Nov 12 09:05:05 2015 +0000
+++ b/const.h	Thu Nov 12 19:05:56 2015 +0000
@@ -31,14 +31,14 @@
 \warning maybe the number has to be adjusted */
 const int ANGLE = 12;      /*  nearly 90 degree turn left */
 
-const int BTN_FLL = 0x80;   //  button front left outer 
-const int BTN_FL  = 0x04;   // button front left
-const int BTN_FM  = 0x01;   // button front middle
-const int BTN_FR  = 0x08;   // button front right 
-const int BTN_FRR = 0x40;   // button front right outer
-const int BTN_BL  = 0x10;   // button back left
-const int BTN_BM  = 0x02;   // button back middle
-const int BTN_BR  = 0x20;   // button back right
+const int BTN_FLL = 0x80;   /**<   button front left outer */
+const int BTN_FL  = 0x04;   /**< button front left */
+const int BTN_FM  = 0x01;   /**< button front middle*/
+const int BTN_FR  = 0x08;   /**< button front right */
+const int BTN_FRR = 0x40;   /**< button front right outer*/
+const int BTN_BL  = 0x10;   /**< button back left*/
+const int BTN_BM  = 0x02;   /**< button back middle*/
+const int BTN_BR  = 0x20;   /**< button back right*/
 
 const int LED_FL1 = 0x01;   /**<  front LED white */
 const int LED_FL2 = 0x02;   /**< front LED yellow */
--- a/ur_Bertl.cpp	Thu Nov 12 09:05:05 2015 +0000
+++ b/ur_Bertl.cpp	Thu Nov 12 19:05:56 2015 +0000
@@ -29,6 +29,7 @@
     _interrupt.rise(this, &ur_Bertl::increment);    // attach increment function of this counter instance ie. motor sensor
     _count = 0;
     beepersInBag = 0;
+    TurnLedOff(0xFF);
 }
 
 ur_Bertl::ur_Bertl(PinName pin) :  _interrupt(pin)  // create the InterruptIn on the pin specified to Counter
@@ -42,6 +43,7 @@
     _interrupt.rise(this, &ur_Bertl::increment);    // attach increment function of this counter instance ie. motor sensor
     _count = 0;
     beepersInBag = 0;
+   TurnLedOff(0xFF);
 }
 
 // Pulblic methodes
@@ -146,6 +148,7 @@
 
 void ur_Bertl::TurnLedOn(int16_t led)
 {
+    leds = leds | led;
     char cmd[3];
 
     if(led == 0xBB) {
@@ -156,13 +159,14 @@
         LED_blue=0;
     }
     cmd[0] = 0x02;
-    cmd[1] = ~led;
+    cmd[1] = ~leds;
     i2c.write(addr, cmd, 2);
     wait(0.5);
 }
 
 void ur_Bertl::TurnLedOff(int16_t led)
 {
+    leds = leds & ~led;
     char cmd[3];
     if(led == 0xBB) {
         LED_blue=1;
@@ -172,7 +176,7 @@
         LED_blue=1;
     }
     cmd[0] = 0x02;
-    cmd[1] = led;
+    cmd[1] = ~leds;
     i2c.write(addr, cmd, 2);
     wait(0.5);
 }
--- a/ur_Bertl.h	Thu Nov 12 09:05:05 2015 +0000
+++ b/ur_Bertl.h	Thu Nov 12 19:05:56 2015 +0000
@@ -133,6 +133,7 @@
     int16_t btns;           /**< which button is pressed */
     InterruptIn _interrupt; /**< interrupted used*/
     volatile int _count;    /**< values of motor sensor*/
+    int16_t leds;               /**< save led status*/
 
     /**
     protected methodes for internal purposes only
@@ -166,6 +167,8 @@
     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 */   
     int Read();
+       bool IsLedOn(const int led);
+
 };
 /********************************************//**
  name:   Bertl.h \n