GP8403 troubleshooting
This commit is contained in:
parent
4c9469aab5
commit
966cf5f117
1 changed files with 31 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* include/Output/OutputI2C_01_MCP4725.h - sensor header for I2C Output MCP4725 sensor
|
||||
* include/Output/OutputI2C_Output_I2C_02_GP8403.h - sensor header for I2C Output GP8403 (DFR Gravity) sensor
|
||||
*
|
||||
*
|
||||
*
|
||||
|
@ -12,7 +12,14 @@
|
|||
|
||||
const byte Output_I2C_02_GP8403_Addr[] = { 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F };
|
||||
|
||||
DFRobot_GP8403 GP8403[sizeof(Output_I2C_02_GP8403_Addr)];
|
||||
//DFRobot_GP8403 GP8403[sizeof(Output_I2C_02_GP8403_Addr)];
|
||||
|
||||
//for(byte i = 0; i < sizeof(Output_I2C_02_GP8403_Addr); i++) {
|
||||
//GP8403[i] = DFRobot_GP8403(Output_I2C_02_GP8403_Addr[i]);
|
||||
//}
|
||||
|
||||
DFRobot_GP8403 GP8403(0x58);
|
||||
|
||||
|
||||
const byte Output_I2C_02_GP8403_Ports = 2;
|
||||
|
||||
|
@ -24,9 +31,10 @@ void Output_I2C_02_GP8403_Update(const byte AddrId, const byte PortId, const byt
|
|||
|
||||
/* 'Value' , which comes from outputState[], is byte, so 0-255. So we need to map this to the MCPs 0-4095 */
|
||||
//MCP4725[AddrId].setVoltage(map(Value, 0, 255, 0, 4095), false);
|
||||
|
||||
//GP8403[AddrId].setDACOutVoltage(map(Value, 0, 255, 0, 4095), PortId);
|
||||
GP8403.setDACOutVoltage(map(Value, 0, 255, 0, 4095), PortId);
|
||||
#ifndef DEBUG
|
||||
Log.verbose(F("%s 0x%x Port %d, Value %d, GP8403_Value %d" CR), LogLoc, Output_I2C_01_MCP4725_Addr[AddrId], PortId, Value, map(Value, 0, 255, 0, 4095));
|
||||
Log.verbose(F("%s 0x%x Port %d, Value %d, GP8403_Value %d" CR), LogLoc, Output_I2C_02_GP8403_Addr[AddrId], PortId, Value, map(Value, 0, 255, 0, 4095));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -35,13 +43,24 @@ bool Output_I2C_02_GP8403_Init(const byte AddrId, const byte PortId) {
|
|||
/* Initialize I2C Module, return true when successful */
|
||||
const static char LogLoc[] PROGMEM = "[Output:I2C:02_GP8403:Init]";
|
||||
bool returnCode;
|
||||
//if(GP8403[AddrId].begin(Output_I2C_01_MCP4725_Addr[AddrId])) {
|
||||
//Log.notice(F("%s found at addr 0x%x" CR), LogLoc, Output_I2C_02_GP8403_Addr[AddrId]);
|
||||
//Output_I2C_01_MCP4725_Update(AddrId, PortId, 0);
|
||||
//returnCode = true;
|
||||
//} else {
|
||||
//Log.error(F("%s FAILED! Not found at addr 0x%x" CR), LogLoc, Output_I2C_02_GP8403_Addr[AddrId]);
|
||||
//returnCode = false;
|
||||
//}
|
||||
|
||||
|
||||
/* GP8403.begin() does not return a valid result, if connection worked or not, so we check it ourselfs beforehand */
|
||||
//Wire.beginTransmission(Output_I2C_02_GP8403_Addr[AddrId]);
|
||||
//short i2cError = Wire.endTransmission();
|
||||
//GP8403[AddrId] = DFRobot_GP8403(Output_I2C_02_GP8403_Addr[AddrId]);
|
||||
//if(i2cError == 0) {
|
||||
//if(GP8403[AddrId].begin() == 0) {
|
||||
if(GP8403.begin() != 0) {
|
||||
//GP8403[AddrId].begin();
|
||||
//GP8403[AddrId].setDACOutRange(GP8403[AddrId].eOutputRange10V);
|
||||
GP8403.setDACOutRange(GP8403.eOutputRange10V);
|
||||
Log.notice(F("%s found at addr 0x%x" CR), LogLoc, Output_I2C_02_GP8403_Addr[AddrId]);
|
||||
Output_I2C_02_GP8403_Update(AddrId, PortId, 0);
|
||||
returnCode = true;
|
||||
} else {
|
||||
Log.error(F("%s FAILED! Not found at addr 0x%x" CR), LogLoc, Output_I2C_02_GP8403_Addr[AddrId]);
|
||||
returnCode = false;
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue