7ABELI_Test

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
PDanner
Date:
Thu Nov 29 18:42:11 2018 +0000
Parent:
0:6c449413c99f
Commit message:
7ABELI_Test; ;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6c449413c99f -r 515886a9f0b2 main.cpp
--- a/main.cpp	Thu Nov 29 17:16:16 2018 +0000
+++ b/main.cpp	Thu Nov 29 18:42:11 2018 +0000
@@ -1,7 +1,10 @@
 #include "mbed.h"
 
 BusOut leds(LED1, LED2, LED3, LED4);
-typedef enum {ST_EIN, ST_AUS} nextState;
+InterruptIn sw1(p14);    // Joy Stick Center
+enum State {ST_START, ST_EIN, ST_AUS, ST_ENDE};
+State state;
+int btnCount = 0; 
 
 class IsAnEvent : public InterruptIn {
         volatile int16_t _pressed;
@@ -33,24 +36,26 @@
     return 0;
 }
 
-InterruptIn sw1(p14);    // Joy Stick Center
+// ----------------- Stm Klasse ------------------
 
-// ----------------- Stm Klasse ------------------
 class Stm {
   public:
         Stm() { state=ST_AUS; }
         
+        void Start();
         void LedOn();
         void LedOff();
- 
-        uint8_t state;
+        void Ende();
 };
 
+void Stm::Start(){
+    leds = 15;
+    wait_ms(500);
+    leds = 0;    
+}
+
 void Stm::LedOn(){
     while(true) {
-        leds = 15;
-        wait_ms(500);
-        leds = 0;
         if(sw1.CheckFlag()) {
             state = ST_AUS;
             return;
@@ -66,4 +71,32 @@
             return;
         }
     }
+}
+
+Stm stm;
+ 
+void stateMachine()
+{
+    switch (stm.state)
+    {
+    case ST_START: stm.Start();
+        break;
+    case ST_EIN: stm.Ein();
+        break;
+    case ST_AUS: stm.Aus();
+        break;
+    case STM_ENDE: stm.Ende();
+    default: stm.Error();
+        break;
+    }
+}
+ 
+int main()
+{
+    printf("Hello STM class\n");
+    sw1.InitIsr();
+ 
+    while(1) {
+        stateMachine(); 
+    }
 }
\ No newline at end of file