Jack Hansdampf / Mbed OS Garagentor

Dependencies:   LCD_i2c_GSOE

Files at this revision

API Documentation at this revision

Comitter:
jack1930
Date:
Thu Jul 01 10:11:10 2021 +0000
Parent:
0:763fd05f2a27
Child:
2:ce1e2d72919d
Commit message:
Anspassung der Bezeichnungen

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jun 30 12:54:13 2021 +0000
+++ b/main.cpp	Thu Jul 01 10:11:10 2021 +0000
@@ -13,7 +13,7 @@
 #define BLINKING_RATE_MS                                                    500
 
 #define Init 0
-#define Zu 1
+#define Geschlossen 1
 #define Oeffnen 2
 #define Offen 3
 #define Schliessen 4
@@ -29,8 +29,8 @@
 AnalogIn Poti(PA_0);
 DigitalOut Leuchte(PC_0);
 
-int Zustand=Init;
-
+int zustand=Init;
+float tastgrad;
 string meldung[]={"Tor-auf","Tor-zu","Tor-stop","Tor-faehrt"};
 
 void blinkenEin()
@@ -64,19 +64,19 @@
    __enable_irq();  
 }
 
-void ADC_PWMCW()
+void torAufCW()
 {
     CCW=0;
     CW=Poti;
 }
 
-void ADC_PWMCCW()
+void torZuCCW()
 {
     CW=0;
     CCW=Poti;
 }
 
-void LCDout(int nr)
+void lcdOut(int nr)
 {
   mylcd.clear();
   mylcd.cursorpos(0);
@@ -100,13 +100,12 @@
    TIM6->ARR=249;   //250ms
   
 }
-void ISR_EXT_IR()
+void schnellstop()
 {
-    if (Zustand==Schliessen || Zustand==Oeffnen)
+    if (zustand==Schliessen || zustand==Oeffnen)
     {
-       Zustand=Gestoppt;
-       motorstop();
-       LCDout(2); 
+       zustand=Gestoppt;
+       lcdOut(2); 
        doppelteFrequenz();
     }
 }
@@ -118,75 +117,76 @@
     Stop.mode(PullDown);
     EndschalterOffen.mode(PullDown);
     EndschalterZu.mode(PullDown);
-    Stop.fall(&ISR_EXT_IR);
+    Stop.fall(&schnellstop);
     Stop.enable_irq();
     CW.period_us(100);
     CCW.period_us(100);
-    CW=0;
-    CCW=0;
     Timer_init();
-    Zustand=Zu;
+    
 }
 
 
 int main()
 {
-
     init();
+    zustand=Geschlossen;
+    motorstop();
+    lcdOut(1);
     while (true) {
-     switch(Zustand)
+     switch(zustand)
         {
-        case Zu: if (TorAuf==1)
-                {
-                 
-                 Zustand=Oeffnen;
+        case Geschlossen: if (TorAuf==1)
+                {                 
+                 zustand=Oeffnen;
                  blinkenEin();
-                 LCDout(3);
+                 lcdOut(3);
                 }
                 break;
         case Oeffnen: 
-              ADC_PWMCCW();
+              torAufCW();
               if (EndschalterOffen==1)
               {
                   blinkenAus();
-                  Zustand=Offen;
+                  zustand=Offen;
                   motorstop();
-                  LCDout(0);
+                  lcdOut(0);
               }
               break;
         case Offen: if (TorZu==1)
                 {
-                Zustand=Schliessen;
+                zustand=Schliessen;
                 blinkenEin();
-                LCDout(3);
+                lcdOut(3);
                 }
                 break;
         case Schliessen: 
-                ADC_PWMCW();
+                torZuCCW();
                 if (EndschalterZu==1) 
                 {
-                    Zustand=Zu;
-                    LCDout(1);
+                    zustand=Geschlossen;
+                    lcdOut(1);
                     motorstop();
                     blinkenAus();
                 }
                 break;
         case Gestoppt:
+            motorstop();
             if (TorAuf==1)
                 {
-                 LCDout(3);
-                 Zustand=Oeffnen;
+                 lcdOut(3);
+                 zustand=Oeffnen;
                  blinkenEin();
                  normaleFrequenz();
                 }
             if (TorZu==1)
                 {
-                LCDout(3);
-                Zustand=Schliessen;
+                lcdOut(3);
+                zustand=Schliessen;
                 blinkenEin();
                 normaleFrequenz();
                 }
                 break;
         }
+        HAL_Delay(20);
     }
 }
--- a/mbed-os.lib	Wed Jun 30 12:54:13 2021 +0000
+++ b/mbed-os.lib	Thu Jul 01 10:11:10 2021 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9
+https://github.com/ARMmbed/mbed-os/#b1796dedeb8accde1cbaecf136fab96895e23d81