tried 2'c complement manual

pull/13/head
alanbjohnston 7 years ago committed by GitHub
parent c2c56d3944
commit 200b33ed85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -120,9 +120,9 @@ struct SensorData read_sensor_data(struct SensorConfig sensor) {
wiringPiI2CWrite(sensor.fd, INA219_REG_CURRENT);
delay(1); // Max 12-bit conversion time is 586us per sample
int16_t valueC = (int16_t)((wiringPiI2CRead(sensor.fd) << 8 ) | wiringPiI2CRead (sensor.fd));
float valuec3 = (float)(valueC);
int valueC = ((wiringPiI2CRead(sensor.fd) << 8 ) | wiringPiI2CRead (sensor.fd));
int twos = twosToInt(valueC, 16);
float valuec3 = (float)(twos);
data.current = valuec3 / (float)sensor.currentDivider;
// uint16_t value3 = (uint16_t)wireReadRegister(sensor.fd, INA219_REG_BUSVOLTAGE);

Loading…
Cancel
Save

Powered by TurnKey Linux.