Markus Reiner / Mbed 2 deprecated info_181024_stm_schalter

Dependencies:   mbed C12832 LM75B

Files at this revision

API Documentation at this revision

Comitter:
mexx
Date:
Wed Nov 28 09:52:19 2018 +0000
Parent:
3:972b50928bd6
Commit message:
doku

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 972b50928bd6 -r 2a67507b5ee1 main.cpp
--- a/main.cpp	Tue Nov 27 17:45:43 2018 +0000
+++ b/main.cpp	Wed Nov 28 09:52:19 2018 +0000
@@ -31,7 +31,7 @@
 bool CheckSw1(void);
 bool CheckSw2(void);
 void Time (void);
-void TimeOut(void);
+void TimeOut(void); 
 void Flip (void);
 void TempOut (void);
 void TimeOutError(void);
@@ -48,9 +48,11 @@
 enum State {ST_AUS=0, ST_EIN, ST_TimeOut, ST_TempOut, ST_Error};
 //State state;
 State volatile state;
-Timer getTime;
-Ticker TickFlip;//für blinken der LED
-Timeout resetTime;
+Timer getTime; //Timer-Schnittstelle dient zum Erstellen, Starten, Stoppen und Lesen eines Timers 
+Ticker TickFlip;//für blinken der LED     //wiederkehrenden Interrupt 
+Timeout resetTime;//Die Timeout-Schnittstelle wird verwendet, um einen Interrupt 
+                    //einzurichten, um eine Funktion nach einer bestimmten Verzögerung aufzurufen.
+
 volatile int counter; // Volatile, damit es nicht auf unterschiedlichen Cores ausgeführt wird
 
 
@@ -86,12 +88,12 @@
     {}
 }
 
-void ErrorBlinken(void) 
+void ErrorBlinken(void) ///blineken bei allen fehlern
 {
     Led4 = !Led4;
     }
 
-void TimeOutError (void) {
+void TimeOutError (void) {///unerwartter fehler
         state = ST_Error;
         TickFlip.attach(&ErrorBlinken, 0.3);
         lcd.cls();      // löscht lcd (clear screen)
@@ -105,7 +107,7 @@
         lcd.printf("State: %i", state);   //Ausgabe am Display
     }
 
-void TempOut(void) {
+void TempOut(void) {//temp ausgabe
         lcd.cls();      // löscht lcd (clear screen)
         lcd.locate(0,0);   // x-position, y-position (x: 0-128; y: 0-32)
         lcd.printf("Temp Out");
@@ -153,10 +155,11 @@
         printf ("Sw2Rise \n");
         if(state == ST_EIN || state == ST_TimeOut || state == ST_TempOut)      
         Sw2Pressed = true;
+        // je weleer status schalte weiter
         wait(0.2);
     }
 
-bool CheckSw2(void) {
+bool CheckSw2(void) {//Werte true oder false 
         if(Sw2Pressed == true) {
             lcd.cls();      // löscht lcd (clear screen)
             lcd.locate(0,0);   // x-position, y-position (x: 0-128; y: 0-32)
@@ -183,11 +186,11 @@
             lcd.locate(0,0);   // x-position, y-position (x: 0-128; y: 0-32)
             lcd.printf("Sekunden: %f", getTime.read());
             printf("Sekunden: %f \n", getTime.read());
-            getTime.reset();
+            getTime.reset();//Timer löschen
         }
     }      
 
-bool CheckSw1(void) {
+bool CheckSw1(void) {  ////Werte true oder false 
         if(Sw1Pressed == true) {
             lcd.cls();      // löscht lcd (clear screen)
             lcd.locate(0,0);   // x-position, y-position (x: 0-128; y: 0-32)
@@ -207,6 +210,7 @@
         lcd.printf("Sw1Rise");
         printf ("Sw1Rise \n");
         if(state == ST_EIN || state == ST_AUS) {
+            // wenn Taste getrückt wird wechsel je welcher status
             Sw1Pressed = true;// Umschalten auf WAHR, es wurde gedrückt
             wait_ms(200);
         }// Entprellung der Taste, bei mir 100ms da der Taster furchtbar prellt...
@@ -224,8 +228,8 @@
 
     // aufruf um die Led blinken zu lassen
     TickFlip.attach(&Flip, 0.5);// the address of the function to be attached (Flip) and the interval (2 seconds)
-    resetTime.attach(&TimeOutError, 10);
-    Led1 = true;
+    resetTime.attach(&TimeOutError, 10);//time out starten
+    Led1 = true; //led ein
 
     while(1) {
 
@@ -241,22 +245,22 @@
 
         
         if(CheckSw2() == true) {
-            state = ST_TimeOut;
-            resetTime.detach();
+            state = ST_TimeOut;  // state timeOut
+            resetTime.detach(); // timeout rücksetzen
 //          exit
             return;
         }
         if(CheckSw1() == true) {
-            state = ST_AUS;
+            state = ST_AUS;// state aus
             Led1 = false;
-            resetTime.detach();
+            resetTime.detach();// timeout rücksetzen
 //          exit
             return;
         }
     }
 }
 
-void Flip (void)
+void Flip (void)  //MIT TICKER 2X blinken
 {
     lcd.cls();      // löscht lcd (clear screen)
     lcd.locate(0,0);   // x-position, y-position (x: 0-128; y: 0-32)
@@ -266,14 +270,14 @@
     Led4 = !Led4;// umschalten der LED
     
     if (counter == 3) {
-        TickFlip.detach();
+        TickFlip.detach();//ticker stopp
         counter = 0;
     } 
     else 
         counter++;// Variable die hochgezählt wird um die LED 2 mal blinken zu lassen
     }
 
-void Aus (void)
+void Aus (void)//10s timerout starten
 {
     resetTime.attach(&TimeOutError, 10);
     lcd.cls();              // löscht lcd (clear screen)
@@ -290,15 +294,15 @@
             return;
         }
 
-        if(CheckSw1() == true) {
+        if(CheckSw1() == true) {  //wenn sw1 gedrückt
             state = ST_EIN;
-            resetTime.detach();
+            resetTime.detach(); // timerout wieder stoppen
             return;
         }
 
     }
 }               
-void StateMachine()
+void StateMachine()  //mit den ganzen möglichen Statuse
 {
     switch (state) 
     {