1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-15 15:03:07 +01:00

Add power management sensor INA226

This commit is contained in:
norbert-walter
2022-03-24 17:02:15 +01:00
parent 9150552b34
commit 55c69e37e5
5 changed files with 167 additions and 133 deletions

View File

@@ -377,10 +377,14 @@ int AMS_5600::readOneByte(int in_adr)
Wire.write(in_adr);
Wire.endTransmission();
Wire.requestFrom(_ams5600_Address, (uint8_t) 1);
/*
while (Wire.available() == 0)
;
retVal = Wire.read();
*/
if(Wire.available() >= 1){
retVal = Wire.read();
}
return retVal;
}
@@ -416,11 +420,20 @@ word AMS_5600::readTwoBytesTogether(int addr_in)
Wire.write(addr_in);
Wire.endTransmission();
Wire.requestFrom(_ams5600_Address, (uint8_t) 2);
/*
while (Wire.available() < 2)
;
int highByte = Wire.read();
int lowByte = Wire.read();
*/
int highByte = 0;
int lowByte = 0;
if (Wire.available() >= 2){
highByte = Wire.read();
lowByte = Wire.read();
}
// in case newer version of IC used the same address to
// store something else, get only the 3 bits