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
niveau.cpp
00001 #include "mbed.h" 00002 #include "niveau.h" 00003 #include "debug.h" 00004 00005 00006 Niveau::Niveau(PinName GS, PinName pfort, PinName pm, PinName pfaible) : gs(GS), p1(pfort) , p2(pm) , p3(pfaible){ 00007 gs.mode(PullDown); 00008 p1.mode(PullDown); 00009 p2.mode(PullDown); 00010 p3.mode(PullDown); 00011 } 00012 00013 //Retourne le i eme bit du char c 00014 char getiemebit3(char c, int i) 00015 { 00016 return ((c>>(7-i)) & 1); 00017 } 00018 00019 char Niveau::getNiveauCuve(){ 00020 debug( "GS : %d\n\r",gs.read()); 00021 debug( "p1 : %d\n\r",p1.read()); 00022 debug( "p2 : %d\n\r",p2.read()); 00023 debug( "p3 : %d\n\r",p3.read()); 00024 00025 char a = 0; 00026 if(gs.read()){ 00027 a = (char) (gs.read()<<3); 00028 }else{ 00029 a = (char) ((p1.read()<<2) | (p2.read()<<1) | (p3.read())); 00030 } 00031 //niveauCuve 00032 /*debug("Niveau cuve : "); 00033 for(int i=0; i < 8; i++){ 00034 if(getiemebit3(a, i)){ 00035 debug("1"); 00036 } 00037 else{ 00038 debug("0"); 00039 } 00040 } 00041 debug("\r\n");*/ 00042 return a; 00043 }
Generated on Thu Jul 14 2022 10:55:31 by 1.7.2