Skip to content
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
6 changes: 5 additions & 1 deletion src/i2cEncoderLibV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ i2cEncoderLibV2::i2cEncoderLibV2(uint8_t add) {
}

/** Used for initialize the encoder **/
void i2cEncoderLibV2::begin(uint16_t conf) {
bool i2cEncoderLibV2::begin(uint16_t conf) {
uint16_t gconf;

writeEncoder(REG_GCONF, (uint8_t)( conf & 0xFF));
writeEncoder(REG_GCONF2, (uint8_t)((conf >> 8) & 0xFF));
Expand All @@ -31,6 +32,9 @@ void i2cEncoderLibV2::begin(uint16_t conf) {
_clockstreach = 0;
else
_clockstreach = 1;

gconf = (readEncoderByte(REG_GCONF2) << 8) | readEncoderByte(REG_GCONF);
return (conf == gconf);
}

/** Reset the board **/
Expand Down
2 changes: 1 addition & 1 deletion src/i2cEncoderLibV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class i2cEncoderLibV2 {

/** Configuration methods **/
i2cEncoderLibV2(uint8_t add);
void begin(uint16_t conf);
bool begin(uint16_t conf);
void reset(void);
void autoconfigInterrupt(void);

Expand Down
3 changes: 2 additions & 1 deletion src/i2cEncoderMiniLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ i2cEncoderMiniLib::i2cEncoderMiniLib(uint8_t add) {
}

/** Used for initialize the I2C Encoder Mini **/
void i2cEncoderMiniLib::begin(uint8_t conf) {
bool i2cEncoderMiniLib::begin(uint8_t conf) {

writeEncoder(REG_GCONF, (uint8_t) conf);
_gconf = conf;
return (conf == readEncoderByte(REG_GCONF));
}

/** Used for reset the I2C Encoder Mini **/
Expand Down
2 changes: 1 addition & 1 deletion src/i2cEncoderMiniLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class i2cEncoderMiniLib {

/** Configuration methods **/
i2cEncoderMiniLib(uint8_t add);
void begin(uint8_t conf);
bool begin(uint8_t conf);
void reset(void);
void autoconfigInterrupt(void);

Expand Down