in FDC1004.cpp [96:128]
uint8_t FDC1004::setupDifferentialMeasurement(uint8_t measurement, uint8_t sensorA, uint8_t sensorB)
{
uint8_t CHA;
uint8_t CHB;
//check which sensor is smaller. CHA is lower CHB is higher
//if they are equal throw an error
if(sensorB > sensorA)
{
CHA = sensorA;
CHB = sensorB;
}
else if (sensorA > sensorB)
{
CHA = sensorB;
CHB = sensorA;
}
else{
Serial.println("Sensor A and B cannot be the same in differential mode.");
}
uint16_t configuration_data;
configuration_data = (CHA-1) << 13; // set CHA (channels are 1 indexed in the datasheet, binary register values are 0-indexed >:( )
//Serial.println(configuration_data, BIN);
configuration_data |= (CHB-1) << 10; // set CHB, disable CAPDAC
configuration_data &= (0xFC1F); //make sure capdac is 0
//Serial.println(configuration_data, BIN);
writeRegister16(FDC1004_CONF_MEAS1+(measurement-1), configuration_data);
//writeRegister16(0x09, configuration_data);
return 0;
}