Klassen

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
corsa1600
Date:
Mon Feb 04 16:59:33 2019 +0000
Commit message:
Klassen

Changed in this revision

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/main.cpp	Mon Feb 04 16:59:33 2019 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+ 
+ 
+ //-------------------Inherited Switch Event Class from InterruptIn----------------------
+ 
+class SwEventInh : public InterruptIn                               // Verknüpft mir auf meine Klasse eine andere
+{
+        
+        volatile int16_t _pressed;                                  // volatile => damit nur auf einer CPU gearbeitet wird
+        void _risingISR();                                          // ruft die Funktion auf
+ 
+    public:
+        SwEventInh(PinName pin) : InterruptIn(pin)                  // create the InterruptIn on the pin specified to SwEvent
+    {         
+        rise(callback(this, &SwEventInh::_risingISR));              // attach ISR-function of this SwEvent instance 
+        _pressed=0; 
+            
+            
+    }
+    
+        int checkFlag();                                            // must in do-condition (while(true)-loop) continuously interrogated
+};
+// ---------------- Switch Event Class Methodes --------------------------
+
+int SwEventInh :: checkFlag()                                       // :: Scope Operator => verweist
+{
+    if( _pressed )                                                  // true/False Abfrage
+    {
+        _pressed = 0; 
+        return 1;
+    }
+    return 0;
+}
+ 
+void SwEventInh::_risingISR() 
+{            
+    if( read() )
+        _pressed = 1;
+}
+
+
+
+
+SwEventInh sw1(p14);
+
+DigitalOut myled(LED1);
+ 
+int main() 
+{
+    
+    myled=1;
+    wait(1);
+    myled=0;
+    
+    printf("Hello");
+    while (1)
+    {
+        sw1.read();
+        if(sw1.checkFlag())
+        myled= ! myled;
+        }
+    
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 04 16:59:33 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file