Markus Reiner / Mbed 2 deprecated MarkusReiner7ABELI

Dependencies:   mbed

Revision:
2:73177929c8b4
Parent:
1:fb317288084d
Child:
3:4bbef030b4b4
--- a/main.cpp	Thu Nov 29 17:16:30 2018 +0000
+++ b/main.cpp	Thu Nov 29 17:29:13 2018 +0000
@@ -9,88 +9,52 @@
 //DigitalOut led4(LED4);
 DigitalIn  btn(P14); 
 
-enum Status {ST_LEDOFF=0, ST_LEDEIN=1,};
+enum Status {ST_LEDOFF=0, ST_LEDEIN=1,ST_Error};
 Status volatile status;
-// States
-//typedef enum {ST_EIN, ST_AUS, ST_ERROR, ST_STATE1} nextState;
-// alternativ
-//const int ST_EIN = 0;
-//const int ST_AUS = 1;
-//onst int ST_ERROR = 2;
- 
-// ---------------- Event Klasse --------------------------
-class SwEvent {
-        InterruptIn _isr;
-        bool _pressed;
-        void _RisingISR();
- 
+
+class IsA : BusOut{
+    
+    IsA():BusOut(LED1, LED2, LED3, LED4){};
+    
+    void LedOFF(){write(0x00);}
+    
+    void LedON(int lVal){write(lVal)};
+    void LedON(){write(0x0f);}
+    
+    };
+
+class IsAnEvent : public InterruptIn {
+        volatile int16_t _pressed;
+        void _RisingISR(); 
     public:
-        SwEvent(PinName pin) : _isr(pin) { 
-            _pressed = false;
-        }
-        int CheckFlag();    // das muss im do-Zweig (while(true) Schleife) ständig abgefragt werden
+        IsAnEvent() : InterruptIn(p15) {};
+        IsAnEvent(PinName pin) : InterruptIn(pin) {
+             rise(callback(this, &IsAnEvent::_RisingISR)); 
+            _pressed=0; 
+        };
+        int CheckFlag();
         void InitIsr();
 };
- 
-int SwEvent::CheckFlag() {
+
+void IsAnEvent::InitIsr() { 
+    rise(callback(this, &IsAnEvent::_RisingISR)); 
+}
+
+void IsAnEvent::_RisingISR() {
+    wait_ms(50);
+    if( read() )
+        _pressed = true;
+}
+int IsAnEvent::CheckFlag() {
     if( _pressed ) { 
         _pressed = false; 
         return 1; 
     }
     return 0;
 }
- 
-void SwEvent::InitIsr() { 
-    _isr.rise(callback(this, &SwEvent::_RisingISR)); 
-}
- 
-void SwEvent::_RisingISR() {
-    wait_ms(100);
-    _pressed = true;
-}
- 
-SwEvent sw1(p14);    // Joy Stick Center
- 
-// ----------------- Stm Klasse -----------------------------
-class Stm {
-  public:
-        Stm() { state=ST_AUS; }
-        
-        void Ein();
-        void Aus();
-        void Error();
- 
-        uint8_t state;
-};
- 
- 
-void Stm::Ein(){
-    while(true) {
-        led1 = 0;
-        if(sw1.CheckFlag()) {
-            state = ST_AUS;
-            return;
-        }
-    }
-}
- 
-void Stm::Aus(){
-    while(true) {
-        led1 = 1;
-        if(sw1.CheckFlag()) {
-            state = ST_EIN;
-            return;
-        }
-    }
-}
- 
-void Stm::Error(){
-    while(1) {
-        led3 = ~led3;
-        wait_ms(200);
-    }
-}
- 
+
+
+
 Stm stm;
  
 void stateMachine()
@@ -116,3 +80,4 @@
         stateMachine(); 
     }
 }
+