test code

Test here yourself. Login with test test
Forum rules
Login with
test
test
To edit posts register an account yourself.

test code

Postby Test » 12 Apr 2017, 08:24

test code for test code

Code: Select all
bool MCP3424::isConversionFinished(){

uint8_t _requestedByte;

if(_resolution!=18){
_requestedByte = 3;
} else _requestedByte = 4;

Wire.requestFrom(_adresse, _requestedByte);

uint8_t _i=0;

while(Wire.available()) _buffer[_i++]=Wire.read();

return (_buffer[_requestedByte-1] & 0b10000000);

}


long MCP3424::measure(){

long _resultat=0;

while(isConversionFinished()==1);

switch (_resolution){

case 12:

 _resultat = (((long)_buffer[0] & 0x0F) << 8) | ((long)_buffer[1] & 0xFF);
 
 _resultat |= long(_buffer[0] & 0x80) << 24;

 _resultat = _resultat*1000.0/_PGA;

 break;

 case 14:
 
_resultat = (((long)_buffer[0] & 0xBF) << 8) | ((long)_buffer[1] & 0xFF);

_resultat |= long(_buffer[0] & 0x80) << 24;

_resultat = _resultat*250/_PGA;

 break;

case 16:

_resultat = (((long)_buffer[0] & 0x7F) << 8) | ((long)_buffer[1] & 0xFF);

 _resultat |= long(_buffer[0] & 0x80) << 24;

_resultat = _resultat*62.5/_PGA;

 break;



waiting comments
Test
 
Posts: 1172
Joined: 22 Jun 2009, 15:48
Location: Test

Return to Test Forum 7

Who is online

Users browsing this forum: No registered users and 15 guests