z

Dependencies:   BertlLib mbed

Files at this revision

API Documentation at this revision

Comitter:
manuelschnider
Date:
Tue Jun 14 10:51:28 2016 +0000
Commit message:
zz

Changed in this revision

BertlLib.lib Show annotated file Show diff for this revision Revisions of this file
BtnEventM0.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BertlLib.lib	Tue Jun 14 10:51:28 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/hollegha2/code/BertlLib/#78243412d2b3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BtnEventM0.h	Tue Jun 14 10:51:28 2016 +0000
@@ -0,0 +1,146 @@
+
+
+class BtnEventM0
+{
+public:
+    int16_t pressed;
+
+    BtnEventM0(PinName pin) : _isr(pin) {
+        pressed=0;
+    }
+
+    // Ist eine steigende Flanke aufgetreten ?
+    int CheckFlag() {
+        if( pressed ) {
+            pressed=0;
+            return 1;
+        }
+        return 0;
+    }
+
+    // 1..Button is pressed  else 0
+    int CheckButton() {
+        return _isr.read();
+    }
+
+    void Init() {
+        _isr.rise(this, &BtnEventM0::RisingISR);
+    }
+
+    void RisingISR() {
+        if( _isr.read() )
+            pressed = 1;
+    }
+protected:
+    InterruptIn _isr;
+};
+
+/*
+class BtnEventM02 : public BtnEventM0
+{
+public:
+    BtnEventM02(PinName pin) : BtnEventM0(pin) {
+        _tm.stop();
+        _tm.reset();
+        _state=1;
+    }
+
+    void Init() {
+        _isr.rise(this, &BtnEventM02::RisingISR);
+    }
+
+    void RisingISR() {
+        if( !_isr.read() )
+            return;
+        pressed = 1;
+        _tm.start();
+        _state = 2;
+    }
+
+    void CheckButton() {
+        if( _state==1 )
+            return;
+        if( _state==2 ) {
+            if( !_isr.read() ) {
+                _state = 1;
+                return;
+            }
+            if( _tm.read_ms()>500 ) {
+                _tm.reset();
+                _state = 3;
+                pressed = 1;
+            }
+        } else if( _state==3 ) {
+            if( !_isr.read() ) {
+                _state = 1;
+                return;
+            }
+            if( _tm.read_ms()>100 ) {
+                _tm.reset();
+                _state = 3;
+                pressed = 1;
+            }
+        }
+    }
+private:
+    int16_t _state;
+    Timer _tm;
+};
+*/
+
+class AnalogInHL : public AnalogIn
+{
+public:
+    AnalogInHL(PinName pin) : AnalogIn(pin) { }
+    int Read() {
+        return read_u16()>>6;
+    }
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 14 10:51:28 2016 +0000
@@ -0,0 +1,119 @@
+
+#include "mbed.h"
+#include "Serial_HL.h"
+#include "Bertl14.h"
+#include "BertlObjects.h"
+
+//              main=2^0  LS    ENC 2^2
+BusOut boardPow(p30,      P1_6, P1_7);
+AnalogInHL ls1(p18), ls2(p16), ls3(p19), ls4(p17);
+
+ void BlinkTask1();
+    void BlinkTask2();
+    Timer t1;
+
+    
+    void ForwardUntilWall();
+    void BackwardUntilWall();
+
+int main(void)
+{
+    boardPow=1; wait_ms(10);
+    InitBertl();
+    pex.useISR=0; leds=9;
+    pex.ClearLeds();
+    pex.WaitUntilFrontButtonPressed();
+   
+    
+    t1.start();
+    //nur zum testen
+    mL.SetPow(0.3); mR.SetPow(0.3);
+    
+    //Bertl-PingPong
+    while(1)
+    {
+     ForwardUntilWall();
+     BackwardUntilWall();
+    }
+    
+    return 1;
+}
+
+//Erweiterung:
+//  -Beim Vorwärtsfahren vorne blinken 
+//  -Beim Rückwärtsfahren hinten blinken
+
+//  pex.ToggleLeds(uintB_T aBitPattern); zum blinken
+
+
+
+void ForwardUntilWall()
+{
+    //motoren auf vorwärts
+     
+     //warten bis irgendein Frontbutton pressed#
+     while(1)
+  {
+    
+     if(ls4>600)
+     {
+     mL.SetPow(0); mR.SetPow(0);
+     //wait(100);
+     mL.SetPow(-0.3); mR.SetPow(-0.3);
+     
+     //BlinkTask1();
+     
+     }
+     break;
+     }
+}
+
+void BackwardUntilWall()
+{
+    //motoren auf rückwärts
+    
+    //warten bis irgendein BackButtonPressen
+    while(1)
+  {
+    
+    if(ls1>600)
+    {
+    mL.SetPow(0); mR.SetPow(0);
+     //wait(100);
+     mL.SetPow(0.3); mR.SetPow(0.3);
+     
+     //BlinkTask2();
+    }
+    break;
+    }
+    // while SChleife
+    // motoren aus    
+}
+
+
+
+void BlinkTask1()
+{
+  if( t1.read_ms()>25 ) { // 100ms sind abgelaufen
+    t1.reset();
+    pex.ToggleLeds(LED_FL1|LED_FL2);
+  }
+}
+
+void BlinkTask2()
+{
+  if( t1.read_ms()>25 ) { // 100ms sind abgelaufen
+    t1.reset();
+    pex.ToggleLeds(LED_BL1|LED_BL2);
+  }
+}
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 14 10:51:28 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file