DataAquisitieMisan3

Dependencies:   LM75B MMA7660 Servo mbed

Fork of DataAquisitieMisan by Michiel Van Endert

Revision:
4:0632609d4862
Parent:
3:194d842b7ba1
--- a/main.cpp	Tue May 19 11:18:48 2015 +0000
+++ b/main.cpp	Tue May 19 11:58:45 2015 +0000
@@ -29,8 +29,8 @@
  
 //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  
 //  //  //  //  //  //  //*Variabelen aanmaken  */  //  //  //  //  //  //  //
-float potentiometer1 = 0;
-float potentiometer2 = 0;
+int potentiometer1 = 0;
+int potentiometer2 = 0;
 float Xaxis = 0;
 float Yaxis = 0;
 float Zaxis = 0;
@@ -40,6 +40,10 @@
 int rood = 0;
 int groen = 0;
 int blauw = 0;
+int xas = 0 ;
+int yas = 0 ;
+int potmet1 = 0;
+int potmet2 = 0;
  
 /*
 char orientation;
@@ -52,10 +56,10 @@
 char Back;
 */ 
  
-RPCVariable<float> rpc_potentiometer1(&potentiometer1,"potentiometer1");
-RPCVariable<float> rpc_potentiometer2(&potentiometer2,"potentiometer2");
-RPCVariable<float> rpc_Xaxis(&Xaxis,"Xaxis");
-RPCVariable<float> rpc_Yaxis(&Yaxis,"Yaxis");
+RPCVariable<int> rpc_potentiometer1(&potentiometer1,"potentiometer1");
+RPCVariable<int> rpc_potentiometer2(&potentiometer2,"potentiometer2");
+RPCVariable<int> rpc_xas(&xas,"xas");
+RPCVariable<int> rpc_yas(&yas,"yas");
  
 RPCVariable<int> rpc_rood(&rood,"rood");
 RPCVariable<int> rpc_groen(&groen,"groen");
@@ -152,8 +156,94 @@
 //  //  //  //  //  //  //* RGB routine voor kleurwijzigen met de Joystick  */  //  //  //  //  //
 void RGB_routine()
 {
+   
+   
+   if (right)
+    {
+        if (kleur < 2)
+        {
+        kleur = kleur++;                                    
+        }
+        if (kleur == 2)
+        {
+        kleur = 0;
+        }   
+    }
+    
+    if (left)
+    {                               
+        if (kleur > 0)
+        {
+        kleur = kleur--;                                    
+        }
+        if (kleur == 0)
+        {
+        kleur = 2;
+        }      
+    } 
+     
     if (up)
     {
+        if(kleur == 0 & rood <1)
+        {
+        rood = rood + 0.05;
+        }
+        if(kleur == 0 && rood == 1)
+        {
+        rood = 0;
+        }
+        if(kleur == 1 && groen <1)
+        {
+        groen = groen + 0.05;
+        }
+        if(kleur == 1 && groen == 1)
+        {
+        groen = 0;
+        }
+        if(kleur == 2 && blauw <1)
+        {
+        blauw = blauw + 0.05;
+        }
+        if(kleur == 2 && blauw == 1)
+        {
+        blauw = 0;
+        }
+    }
+    
+    if (down)
+    {
+        if(kleur == 0 && rood <0)
+        {
+        rood = rood - 0.05;
+        }
+        if(kleur == 0 && rood == 0)
+        {
+        rood = 1;
+        }
+        if(kleur == 1 && groen <0)
+        {
+        groen = groen - 0.05;
+        }
+        if(kleur == 1 && groen == 0)
+        {
+        groen = 1;
+        }
+        if(kleur == 2 && blauw <0)
+        {
+        blauw = blauw - 0.05;
+        }
+        if(kleur == 2 && blauw == 0)
+        {
+        blauw = 1;
+        }
+    }
+   
+   
+   
+   
+   
+   /* if (up)
+    {
         switch (kleur)
         {
             case 0:
@@ -220,7 +310,7 @@
     }
     
  
-    
+    */
     
     
     
@@ -234,11 +324,11 @@
     
      
     glcd.locate(0,0);                            //Zet de cursor op X = 0 & Y = 0
-    glcd.printf("R: %i", r);
+    glcd.printf("R: %i", up);
     glcd.locate(0,9);                            //Zet de cursor op X = 0 & Y = 10    
-    glcd.printf("G: %i", g);
+    glcd.printf("G: %i", down);
     glcd.locate(0,18);                           //Zet de cursor op X = 0 & Y = 18      
-    glcd.printf("B: %i", b);
+    glcd.printf("B: %i", blauw);
     wait(0.5);      
               
 }
@@ -247,13 +337,13 @@
 //  //  //  //  //  //  //* Inlezen en visualiseren van de potentiometers   */  //  //  //  //  //
 void ReadPot()
 {
-    potentiometer1 = pot1;       //steek de waarde van de Potentiometer1 in ai1
-    potentiometer2 = pot2;       //steek de waarde van de Potentiometer2 in ai2
+    potentiometer1 = pot1*100;       //steek de waarde van de Potentiometer1 in ai1
+    potentiometer2 = pot2*100;       //steek de waarde van de Potentiometer2 in ai2
     
     glcd.locate(0,0);                            //Zet de cursor op X = 0 & Y = 0
-    glcd.printf("Pot 1: %f ", potentiometer1);              //Print de waarde van de potententiometer 1 op het display
+    glcd.printf("Pot 1: %i ", potentiometer1);              //Print de waarde van de potententiometer 1 op het display
     glcd.locate(0,10);                           //Zet de cursor op X = 0 & Y = 10
-    glcd.printf("Pot 2: %f ", potentiometer2);              //Print de waarde van de potententiometer 2 op het display
+    glcd.printf("Pot 2: %i ", potentiometer2);              //Print de waarde van de potententiometer 2 op het display
     wait(0.5);                                         //Wacht 1 seconde       
 }
  
@@ -268,6 +358,8 @@
     Xaxis = MMA.x();
     Yaxis = MMA.y();
     Zaxis = MMA.z();
+    xas = Xaxis*100 ;
+    yas = Yaxis*100 ;
     
     glcd.locate(0,0);                            //Zet de cursor op X = 0 & Y = 0
     glcd.printf("X-Axis: %f G", Xaxis);
@@ -293,7 +385,7 @@
     glcd.locate(0,0);                            //Zet de cursor op X = 0 & Y = 0
     glcd.printf("Servo-1: %f", Servo1);
     glcd.locate(0,10);                            //Zet de cursor op X = 0 & Y = 10    
-    glcd.printf("Servo-2 %f", Servo2);
+    glcd.printf("Servo-2: %f", Servo2);
  
     wait(0.5);     
 }