adafruit/Adafruit_AMG88xx

I'd like to suggest an addition to the AMG88xx library...

utacc opened this issue · 1 comments

utacc commented

I noticed this afternoon that the default Adafruit AMG88xx library has the following behavior: in the Adafruit_AMG88xx::begin() method, although the method returns a boolean, at no point does the method seem to actively query the AMG88xx that's been initialized, to see if it's actually there; nor does the method seem to have any option to return false.
I need that functionality for the project I'm working on, to that end, I'd like to propose the following minor changes both to Adafruit_AMG88xx.h and to Adafruit_AMG88xx.cpp:

to Adafruit_AMG88xx.h:

@@ -103,10 +103,11 @@ class Adafruit_AMG88xx {
//this will manually set hysteresis
void setInterruptLevels(float high, float low, float hysteresis);

private:
	uint8_t _i2caddr;
  •   uint8_t _AMG88xx_status;
      
      void      write8(byte reg, byte value);
      void      write16(byte reg, uint16_t value);
       uint8_t   read8(byte reg);
    

to Adafruit_AMG88xx.cpp:

@@ -37,11 +37,15 @@ bool Adafruit_AMG88xx::begin(uint8_t addr)
_fpsc.FPS = AMG88xx_FPS_10;
write8(AMG88xx_FPSC, _fpsc.get());

delay(100);
  • return true;
  • // Read the Status Register (0x04). If it's anything other than 0...bad news bears...sorry...
  • _AMG88xx_status = read8(0x04);
  • if (_AMG88xx_status == 0) return true;
  • return false;
    }

/**************************************************************************/
/*!
@brief Set the moving average mode.

In the current copy of my own library, I've actually set the return value of the ::begin() function in Adafruit_AMG88xx.cpp to return a uint8_t. This is to maintain interface compatibility with the other imaging sensors I'm working with; I can submit a diff for that, although it might not be for everyone.

Hope someone find this useful.

Should be fixed with #22