Polytech school project. RICM4 students, see http://air.imag.fr/index.php/Projets-2016-2017-Station_de_pompage_connect%C3%A9e for more information

Dependencies:   SX1272Lib mbed WakeUp

Fork of SX1272PingPong by Semtech

Revision:
17:cce0eada6d82
Parent:
15:79a78f997f18
diff -r 85fb5e37def7 -r cce0eada6d82 niveau.cpp
--- a/niveau.cpp	Fri Mar 03 13:42:44 2017 +0000
+++ b/niveau.cpp	Sat Apr 01 12:29:59 2017 +0000
@@ -3,8 +3,41 @@
 #include "debug.h"
 
 
-Niveau::Niveau(){
+Niveau::Niveau(PinName GS, PinName pfort, PinName pm, PinName pfaible) : gs(GS), p1(pfort) , p2(pm) , p3(pfaible){
+    gs.mode(PullDown);
+    p1.mode(PullDown);
+    p2.mode(PullDown);
+    p3.mode(PullDown);
 }
+
+//Retourne le i eme bit du char c
+char getiemebit3(char c, int i)
+{
+     return ((c>>(7-i)) & 1);
+}
+
 char Niveau::getNiveauCuve(){
-    return 'a';//(char) ((p1<<2) | (p2<<1) | (p3));
+    debug( "GS : %d\n\r",gs.read());
+    debug( "p1 : %d\n\r",p1.read());
+    debug( "p2 : %d\n\r",p2.read());
+    debug( "p3 : %d\n\r",p3.read());
+    
+    char a = 0;
+    if(gs.read()){
+        a = (char) (gs.read()<<3);
+    }else{
+        a = (char) ((p1.read()<<2) | (p2.read()<<1) | (p3.read()));
+    }
+    //niveauCuve
+    /*debug("Niveau cuve : ");
+    for(int i=0; i < 8; i++){
+        if(getiemebit3(a, i)){
+            debug("1");
+        }
+        else{
+            debug("0");
+        }
+    }
+    debug("\r\n");*/
+    return a;
 }
\ No newline at end of file