BertlTemplate4

Dependencies:   BertlLib mbed

Files at this revision

API Documentation at this revision

Comitter:
Wizo
Date:
Thu Nov 15 17:50:36 2018 +0000
Commit message:
BertlTemplate4

Changed in this revision

BertlLib_copy.lib Show annotated file Show diff for this revision Revisions of this file
BertlPingPongDirection.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_copy.lib	Thu Nov 15 17:50:36 2018 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/hollegha2/code/BertlLib/#20c3213c3ada
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BertlPingPongDirection.cpp	Thu Nov 15 17:50:36 2018 +0000
@@ -0,0 +1,235 @@
+#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);
+
+// ls5 nur beim Betrl15
+// AnalogInHL ls1(p18), ls2(p16), ls3(p19), ls4(p17); // B14
+
+//AnalogInHL ls1(p18), ls2(p16), ls3(p20), ls4(p19), ls5(p17); // B15
+//void ButonBlinker();
+
+//void MotorTest ();
+
+//void BackW();
+void ForW();
+void Left();
+void Right();
+void BlinkTask();
+int direction = 0; //0= zurück, 1 = vorwärts
+Timer t1;
+
+
+
+
+
+int main(void)
+{
+    boardPow = 1; wait_ms(10);
+    InitBertl();
+    pex.useISR = 0; leds = 9;
+    pex.ClearLeds();
+    t1.start();
+    pex.WaitUntilButtonPressed();
+    while (1)
+    {
+        //ButonBlinker();
+        //MotorTest ();
+        //BackW();
+        //wait_ms(1000);
+        ForW();
+        wait_ms(1000);
+    }
+
+    return 1;
+}
+/*
+void ButonBlinker()
+{
+pex.ReadButtons();
+
+if (pex.IsButton(BTN_FLL))
+{
+pex.SetLeds(LED_FL1|LED_FL2);
+}
+
+if (pex.IsButton(BTN_FRR))
+{
+pex.SetLeds(LED_FR1|LED_FR2);
+}
+wait_ms(100);
+pex.ClearLeds();
+wait_ms(100);
+}
+*/
+
+/*
+void MotorTest ()
+{
+if (pex.IsButton(BTN_FRR||BTN_FLL))
+{
+mL.SetPow(-0.2);
+mR.SetPow(-0.2);
+}
+
+
+else if (pex.IsButton(BTN_BR||BTN_BL))
+{
+mL.SetPow(0.2);
+mR.SetPow(0.2);
+}
+
+//mL.SetPow(0.2);
+//mR.SetPow(0.2);
+
+//wait_ms(2000);
+
+//mL.SetPow(-0.2);
+//mR.SetPow(-0.2);
+
+//wait_ms(2000);
+
+
+
+
+}
+*/
+
+//void BackW()
+//{
+//  pex.ClearLeds();
+//  mL.SetPow(0.3);
+//  mR.SetPow(0.3);
+//  direction = 0;
+//
+//  //  pex.SetLeds(LED_BL1 | LED_BL2);
+//  //  pex.SetLeds(LED_BR1 | LED_BR2);
+//
+//  while (1)
+//  {
+//      pex.ReadButtons();
+//      BlinkTask();
+//
+//      if (pex.IsAnyBackButton())
+//      {
+//          break;
+//      }
+//
+//  }
+//  mL.SetPow(0);
+//  mR.SetPow(0);
+//
+//
+//}
+
+
+void ForW()
+{
+    pex.ClearLeds();
+    mL.SetPow(-0.3);
+    mR.SetPow(-0.3);
+    direction = 1;
+
+    //  pex.SetLeds(LED_FL1 | LED_FL2);
+    //  pex.SetLeds(LED_FR1 | LED_FR2);
+
+    while (1)
+    {
+        pex.ReadButtons();
+        BlinkTask();
+
+        if (pex.IsRightFrontButton())
+        {
+            mL.SetPow(-0.3);
+            mR.SetPow(-0.5);
+            //break;
+        }
+        else if (pex.IsLeftFrontButton())
+        {
+            mL.SetPow(-0.5);
+            mR.SetPow(-0.3);
+        }
+        else if (pex.IsMiddleFrontButton())
+        {
+            mL.SetPow(-0.5);
+            mR.SetPow(-0.5);
+        }
+
+    }
+    mL.SetPow(0);
+    mR.SetPow(0);
+
+}
+
+/*void Right()
+{
+    pex.ClearLeds();
+    mL.SetPow(-0.3);
+    mR.SetPow(-0.3);
+    direction = 1;
+
+    //  pex.SetLeds(LED_FL1 | LED_FL2);
+    //  pex.SetLeds(LED_FR1 | LED_FR2);
+
+    while (1)
+    {
+        pex.ReadButtons();
+        BlinkTask();
+
+        if (pex.IsAnyFrontButton())
+        {
+            break;
+        }
+
+    }
+    mL.SetPow(0);
+    mR.SetPow(0);
+
+}*/
+
+void Left()
+{
+    pex.ClearLeds();
+    mL.SetPow(-0.3);
+    mR.SetPow(-0.3);
+    direction = 1;
+
+    //  pex.SetLeds(LED_FL1 | LED_FL2);
+    //  pex.SetLeds(LED_FR1 | LED_FR2);
+
+    while (1)
+    {
+        pex.ReadButtons();
+        BlinkTask();
+
+        if (pex.IsAnyFrontButton())
+        {
+            break;
+        }
+
+    }
+    mL.SetPow(0);
+    mR.SetPow(0);
+
+}
+
+void BlinkTask()
+{
+    if (t1.read_ms()>100) // alle 100ms = 10Hz
+    {
+        t1.reset(); // timer neu starten
+        if (direction == 0)
+        {
+            pex.ToggleLeds(LED_BL1 | LED_BL2);
+            pex.ToggleLeds(LED_BR1 | LED_BR2);
+        }
+        else
+        {
+            pex.ToggleLeds(LED_FL1 | LED_FL2);
+            pex.ToggleLeds(LED_FR1 | LED_FR2);
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 15 17:50:36 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/aa5281ff4a02
\ No newline at end of file