s

Dependencies:   LM75B C12832_lcd LCD_fonts

Files at this revision

API Documentation at this revision

Comitter:
an3
Date:
Sun Jan 05 18:10:25 2020 +0000
Parent:
1:133129bd3d45
Child:
3:1d052bd266c6
Commit message:
marcel ,my boi

Changed in this revision

MMA7660.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/MMA7660.lib	Fri Dec 06 16:47:34 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/Sissors/code/MMA7660/#36a163511e34
--- a/main.cpp	Fri Dec 06 16:47:34 2019 +0000
+++ b/main.cpp	Sun Jan 05 18:10:25 2020 +0000
@@ -1,125 +1,66 @@
 #include "mbed.h"
 #include "LM75B.h"
 #include "C12832_lcd.h"
-#include "MMA7660.h"
+
+
+DigitalOut myled(LED2);
 
-DigitalOut startLED(LED3);
-DigitalOut rgbLED[] = {DigitalOut(p23), DigitalOut(p24), DigitalOut(p25)};
 
-InterruptIn fireInterrupt(p14);
-
-Timeout startChecker;
+Serial pc(USBTX, USBRX);
+Thread led_thread;
 
-LM75B tempSensor(p28, p27);
-MMA7660 MMA(p28, p27);
-C12832_LCD lcdDisplay;
+Mutex verMutex; //Nr.5   weiss nicht wo es bei meiner Variante hinkäme
 
-Thread temp_thread;
-Thread gyro_thread;
+  char eingabe='5';
+  int eingabezahl;// nr.2 hälfte an;hälfte aus
+  int zeit_leucht=0.025;
+  int zeit_dunkel=0.025;
 
-Mutex lcdMutex;
 
-bool boardStarted = false;
-bool tempThreadRunning = false;
-bool gyroThreadRunning = false;
-
-void tmpThread()
+void ledthreaT()
 {
-    tempThreadRunning = true;
-    
-    while(boardStarted)
+    while(1)
     {
-        lcdMutex.lock();
+        eingabe = pc.getc();
+        pc.printf("Helligkeit: N=0% 1-9(10-90%) F(100%)");
         
-        lcdDisplay.cls();
-        lcdDisplay.locate(0, 0);
-        lcdDisplay.printf("Temp: %.2f", tempSensor.read());
+        if(eingabe=='N'){
+            eingabezahl=0;
+        }
+         if(eingabe=='F'){
+             eingabezahl=10;
+        }
+        if((eingabe<=9)&&(eingabe>=0)){
+            eingabezahl=(int)eingabe;  //
+        }
         
-        lcdMutex.unlock();
-        wait(0.5);
+        zeit_leucht = (eingabezahl*0.05)/10;
+        zeit_dunkel =0.05-zeit_leucht;
     }
     
-    tempThreadRunning = false;
 }
-
-void gyroThread()
-{
-    gyroThreadRunning = true;
-    
-    while(boardStarted)
-    {
-        int x = (x + MMA.x() * 32.0)/2.0;
-        int y = (y -(MMA.y() * 16.0))/2.0;
-        lcdMutex.lock();
-        lcdDisplay.locate(0, 20);
-        lcdDisplay.printf("X: %d; Y: %d", x, y);
-        lcdMutex.unlock();
-        
-        wait(0.1); //time delay
-        
-        lcdMutex.lock();
-        lcdDisplay.fillcircle(x+83, y+15, 3, 0); //erase bubble
-        lcdMutex.unlock();
-    }
-    
-    gyroThreadRunning = false;
-}
-
-void start()
-{
-    if(boardStarted)
-    {
-        boardStarted = false;
-        rgbLED[0] = 0;
-        rgbLED[1] = 1;
-        
-    }
-    else
-    {
-        boardStarted = true;
-        rgbLED[0] = 1;
-        rgbLED[1] = 0;
-    }
-}
-
-void pressButton()
-{
-    startChecker.attach(&start, 3.0);
-}
-
-void releaseButton()
-{
-    startChecker.detach();
-}
-
 int main()
 {
-    rgbLED[0] = rgbLED[1] = rgbLED[2] = 1;
-    rgbLED[0] = 0;
-    rgbLED[1] = 1;
+  
+  
     
-    fireInterrupt.rise(pressButton);
-    fireInterrupt.fall(releaseButton);
+  led_thread.start(ledThread);
     
-    lcdDisplay.set_font((unsigned char*) Arial_9);
+    
     
     while(1)
     {
-        if(boardStarted && !tempThreadRunning)
-        {
-            temp_thread.start(tmpThread);
-        }
-        
-        if(boardStarted && !gyroThreadRunning)
-        {
-            gyro_thread.start(gyroThread);
+        if(eingabe='N'){  //aufgabe 6 grundschulmässig gelöst
+        myled=0;
         }
-        
-        if(!boardStarted)
-        {
-            lcdMutex.lock();
-            lcdDisplay.cls();
-            lcdMutex.unlock();
-        }
+        else{
+        myled=1; 
+        wait(zeit_leucht);
+        myled=0; 
+        wait(zeit_dunkel); 
+        }   
     }
+    
+       
+    
 }