version3 mit 4 Leds

Files at this revision

API Documentation at this revision

Comitter:
corsa1600
Date:
Thu Mar 14 18:44:06 2019 +0000
Parent:
1:f17f1b284f68
Commit message:
Version mit 4 Leds

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Mar 14 18:32:08 2019 +0000
+++ b/main.cpp	Thu Mar 14 18:44:06 2019 +0000
@@ -2,7 +2,11 @@
  
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
-Thread thread;
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+Thread thread(osPriorityHigh);
+Thread thread3(osPriorityNormal);
+Thread thread4(osPriorityLow);
  
 void led2_thread() 
 {
@@ -12,7 +16,34 @@
         wait(0.5);
         
         for (int j=0; j<100; j++)
-            for (int i=0; i<100000; i++)
+            for (int i=0; i<100; i++)
+                x = y*z+x;
+        
+    }
+}
+void led3_thread() 
+{
+    double x, y =1.99, z=0.99;
+    while (true) {
+        led3 = !led3;
+        wait(0.5);
+        
+        for (int j=0; j<100; j++)
+            for (int i=0; i<100; i++)
+                x = y*z+x;
+        
+    }
+}
+
+void led4_thread() 
+{
+    double x, y =1.99, z=0.99;
+    while (true) {
+        led4 = !led4;
+        wait(0.5);
+        
+        for (int j=0; j<100; j++)
+            for (int i=0; i<100; i++)
                 x = y*z+x;
         
     }
@@ -20,12 +51,15 @@
  
 int main() {
     thread.start(led2_thread);
+    thread3.start(led3_thread);
+    thread4.start(led4_thread);
+    osThreadSetPriority(osThreadGetId(), osPriorityBelowNormal);
      double x, y=1.99, z=0.99;
     while (true) {
         led1 = !led1;
         wait(0.25);
         for (int j=0; j<200; j++)
-            for (int i=0; i<100000; i++)
+            for (int i=0; i<200; i++)
                 x = y*z+x;
         
     }