s

Dependencies:   LM75B C12832_lcd LCD_fonts

Revision:
3:1d052bd266c6
Parent:
2:b4a812174f7e
--- a/main.cpp	Sun Jan 05 18:10:25 2020 +0000
+++ b/main.cpp	Tue Jan 07 09:42:23 2020 +0000
@@ -2,65 +2,84 @@
 #include "LM75B.h"
 #include "C12832_lcd.h"
 
-
 DigitalOut myled(LED2);
 
-
 Serial pc(USBTX, USBRX);
 Thread led_thread;
+Thread low_time_thread;
+Thread high_time_thread;
 
 Mutex verMutex; //Nr.5   weiss nicht wo es bei meiner Variante hinkäme
 
-  char eingabe='5';
-  int eingabezahl;// nr.2 hälfte an;hälfte aus
-  int zeit_leucht=0.025;
-  int zeit_dunkel=0.025;
+  int ton = 0.5;
+  int toff = 0.5;
 
-
-void ledthreaT()
+void ledThread()
 {
     while(1)
+    {    
+        myled=1; 
+        wait(ton);
+        myled=0; 
+        wait(toff); 
+        }   
+    }  
+}
+
+hightime()
+{
+    while( (eingabe!='R')&&(eingabe!='L') )
     {
         eingabe = pc.getc();
-        pc.printf("Helligkeit: N=0% 1-9(10-90%) F(100%)");
+        if(eingabe=='+'){ ton+=0.1;}
+        if(eingabe=='-'){ ton-=0.1;}
         
-        if(eingabe=='N'){
-            eingabezahl=0;
-        }
-         if(eingabe=='F'){
-             eingabezahl=10;
-        }
-        if((eingabe<=9)&&(eingabe>=0)){
-            eingabezahl=(int)eingabe;  //
-        }
+        if(ton>=2)  {ton=2.0;}
+        if(ton<=0.1){ton=0.1;}
+    }    
+}
+
+lowtime()
+{
+    while( (eingabe!='R')&&eingabe!='L') )
+    {
+        eingabe = pc.getc();
+        if(eingabe=='+'){ toff+=0.1;}
+        if(eingabe=='-'){ toff-=0.1;}
         
-        zeit_leucht = (eingabezahl*0.05)/10;
-        zeit_dunkel =0.05-zeit_leucht;
-    }
-    
+        if(toff>=2)  {toff=2.0;}
+        if(toff<=0.1){toff=0.1;}
+    }    
 }
+
 int main()
 {
   
+ 
+  led_thread.start(ledThread); //thread
   
-    
-  led_thread.start(ledThread);
-    
-    
-    
+  pc.printf("Helligkeit:auswählen H-leuchtzeit, L-Dunkelzeit, R-reset");
+  eingabe = pc.getc();
     while(1)
     {
-        if(eingabe='N'){  //aufgabe 6 grundschulmässig gelöst
-        myled=0;
-        }
-        else{
-        myled=1; 
-        wait(zeit_leucht);
-        myled=0; 
-        wait(zeit_dunkel); 
-        }   
+            
+        if(eingabe == 'R'){
+            ton=toff=0.5;
+            }
+        if(eingabe == 'H'){
+            pc.printf("+ für 0.1sek mehr, - für weniger");
+            high_time_thread.start(hightime);          
+            }
+        if(eingabe == 'L'){
+            pc.printf("+ für 0.1sek mehr, - für weniger");
+            low_time_thread.start(lowtime);          
+            }
+        
+        
+        
     }
     
+    
        
     
 }