Skip to content

Commit

Permalink
return bool
Browse files Browse the repository at this point in the history
  • Loading branch information
caternuson committed Sep 6, 2022
1 parent e1a04a4 commit f643744
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Adafruit_PWMServoDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ Adafruit_PWMServoDriver::Adafruit_PWMServoDriver(const uint8_t addr,
* @param prescale
* Sets External Clock (Optional)
*/
void Adafruit_PWMServoDriver::begin(uint8_t prescale) {
bool Adafruit_PWMServoDriver::begin(uint8_t prescale) {
if (i2c_dev)
delete i2c_dev;
i2c_dev = new Adafruit_I2CDevice(_i2caddr, _i2c);
i2c_dev->begin();
if (!i2c_dev->begin())
return false;
reset();
if (prescale) {
setExtClk(prescale);
Expand All @@ -76,6 +77,8 @@ void Adafruit_PWMServoDriver::begin(uint8_t prescale) {
}
// set the default internal frequency
setOscillatorFrequency(FREQUENCY_OSCILLATOR);

return true;
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion Adafruit_PWMServoDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Adafruit_PWMServoDriver {
Adafruit_PWMServoDriver();
Adafruit_PWMServoDriver(const uint8_t addr);
Adafruit_PWMServoDriver(const uint8_t addr, TwoWire &i2c);
void begin(uint8_t prescale = 0);
bool begin(uint8_t prescale = 0);
void reset();
void sleep();
void wakeup();
Expand Down

0 comments on commit f643744

Please sign in to comment.