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

Committer:
chevamax
Date:
Sat Apr 01 12:29:59 2017 +0000
Revision:
17:cce0eada6d82
Parent:
15:79a78f997f18
Version finale

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chevamax 15:79a78f997f18 1 #include "mbed.h"
chevamax 15:79a78f997f18 2 #include "niveau.h"
chevamax 15:79a78f997f18 3 #include "debug.h"
chevamax 15:79a78f997f18 4
chevamax 15:79a78f997f18 5
chevamax 17:cce0eada6d82 6 Niveau::Niveau(PinName GS, PinName pfort, PinName pm, PinName pfaible) : gs(GS), p1(pfort) , p2(pm) , p3(pfaible){
chevamax 17:cce0eada6d82 7 gs.mode(PullDown);
chevamax 17:cce0eada6d82 8 p1.mode(PullDown);
chevamax 17:cce0eada6d82 9 p2.mode(PullDown);
chevamax 17:cce0eada6d82 10 p3.mode(PullDown);
chevamax 15:79a78f997f18 11 }
chevamax 17:cce0eada6d82 12
chevamax 17:cce0eada6d82 13 //Retourne le i eme bit du char c
chevamax 17:cce0eada6d82 14 char getiemebit3(char c, int i)
chevamax 17:cce0eada6d82 15 {
chevamax 17:cce0eada6d82 16 return ((c>>(7-i)) & 1);
chevamax 17:cce0eada6d82 17 }
chevamax 17:cce0eada6d82 18
chevamax 15:79a78f997f18 19 char Niveau::getNiveauCuve(){
chevamax 17:cce0eada6d82 20 debug( "GS : %d\n\r",gs.read());
chevamax 17:cce0eada6d82 21 debug( "p1 : %d\n\r",p1.read());
chevamax 17:cce0eada6d82 22 debug( "p2 : %d\n\r",p2.read());
chevamax 17:cce0eada6d82 23 debug( "p3 : %d\n\r",p3.read());
chevamax 17:cce0eada6d82 24
chevamax 17:cce0eada6d82 25 char a = 0;
chevamax 17:cce0eada6d82 26 if(gs.read()){
chevamax 17:cce0eada6d82 27 a = (char) (gs.read()<<3);
chevamax 17:cce0eada6d82 28 }else{
chevamax 17:cce0eada6d82 29 a = (char) ((p1.read()<<2) | (p2.read()<<1) | (p3.read()));
chevamax 17:cce0eada6d82 30 }
chevamax 17:cce0eada6d82 31 //niveauCuve
chevamax 17:cce0eada6d82 32 /*debug("Niveau cuve : ");
chevamax 17:cce0eada6d82 33 for(int i=0; i < 8; i++){
chevamax 17:cce0eada6d82 34 if(getiemebit3(a, i)){
chevamax 17:cce0eada6d82 35 debug("1");
chevamax 17:cce0eada6d82 36 }
chevamax 17:cce0eada6d82 37 else{
chevamax 17:cce0eada6d82 38 debug("0");
chevamax 17:cce0eada6d82 39 }
chevamax 17:cce0eada6d82 40 }
chevamax 17:cce0eada6d82 41 debug("\r\n");*/
chevamax 17:cce0eada6d82 42 return a;
chevamax 15:79a78f997f18 43 }