Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions for managing power state #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 61 additions & 3 deletions Adafruit_AMG88xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ bool Adafruit_AMG88xx::begin(uint8_t addr)

_i2c_init();

//enter normal mode
_pctl.PCTL = AMG88xx_NORMAL_MODE;
write8(AMG88xx_PCTL, _pctl.get());
//enter normal mode
setNormalMode();

//software reset
_rst.RST = AMG88xx_INITIAL_RESET;
Expand All @@ -42,6 +41,65 @@ bool Adafruit_AMG88xx::begin(uint8_t addr)
return true;
}

/**************************************************************************/
/*!
@brief Read current power mode
@returns current power mode state
// 0x00 = Normal Mode
// 0x01 = Sleep Mode
// 0x20 = Stand-by mode (60 sec intermittence)
// 0x21 = Stand-by mode (10 sec intermittence))
*/
/**************************************************************************/
uint8_t Adafruit_AMG88xx::getPowerMode()
{
return _pctl.get();
}

/**************************************************************************/
/*!
@brief Set power mode to normal.
*/
/**************************************************************************/
void Adafruit_AMG88xx::setNormalMode()
{
_pctl.PCTL = AMG88xx_NORMAL_MODE;
write8(AMG88xx_PCTL, _pctl.get());
}

/**************************************************************************/
/*!
@brief Set power mode to sleep, temperature register is not updated.
*/
/**************************************************************************/
void Adafruit_AMG88xx::setSleepMode()
{
_pctl.PCTL = AMG88xx_SLEEP_MODE;
write8(AMG88xx_PCTL, _pctl.get());
}

/**************************************************************************/
/*!
@brief Set power mode to standby, temperature register is updated every 60 seconds.
*/
/**************************************************************************/
void Adafruit_AMG88xx::set60sStandbyMode()
{
_pctl.PCTL = AMG88xx_STAND_BY_60;
write8(AMG88xx_PCTL, _pctl.get());
}

/**************************************************************************/
/*!
@brief Set power mode to standby, temperature register is updated every 10 seconds.
*/
/**************************************************************************/
void Adafruit_AMG88xx::set10sStandbyMode()
{
_pctl.PCTL = AMG88xx_STAND_BY_10;
write8(AMG88xx_PCTL, _pctl.get());
}

/**************************************************************************/
/*!
@brief Set the moving average mode.
Expand Down
6 changes: 6 additions & 0 deletions Adafruit_AMG88xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ class Adafruit_AMG88xx {

void readPixels(float *buf, uint8_t size = AMG88xx_PIXEL_ARRAY_SIZE);
float readThermistor();

uint8_t getPowerMode();
void setNormalMode();
void setSleepMode();
void set60sStandbyMode();
void set10sStandbyMode();

void setMovingAverageMode(bool mode);

Expand Down