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
15 changes: 12 additions & 3 deletions src/i2cEncoderLibV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@
/** Class costructor **/
i2cEncoderLibV2::i2cEncoderLibV2(uint8_t add) {
_add = add;
// ensure defined values
_stat = 0x00;
_stat2 = 0x00;
_gconf = 0x00;
}

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

temp = (uint8_t) conf & 0xff;
writeEncoder(REG_GCONF, temp);

temp = (uint8_t) (conf >> 8) & 0xff;
writeEncoder(REG_GCONF, temp);

writeEncoder(REG_GCONF, (uint8_t) conf & 0xFF);
writeEncoder(REG_GCONF2, (uint8_t)(conf >> 8) & 0xFF);
_gconf = conf;
if ((conf & CLK_STRECH_ENABLE) == 0)
_clockstreach = 0;
Expand Down Expand Up @@ -326,7 +335,7 @@ void i2cEncoderLibV2::writeInterruptConfig(uint8_t interrupt) {

/** Check if there is some attached callback and enable the corresponding interrupt **/
void i2cEncoderLibV2::autoconfigInterrupt(void) {
uint8_t reg;
uint8_t reg = 0;

if (onButtonRelease != NULL)
reg |= PUSHR;
Expand Down
10 changes: 5 additions & 5 deletions src/i2cEncoderLibV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class i2cEncoderLibV2 {
uint8_t bval[4];
};

uint8_t id = 0x00;
uint8_t id; // = 0x00;
typedef void (*Callback)(i2cEncoderLibV2*);

/* Event */
Expand Down Expand Up @@ -294,10 +294,10 @@ class i2cEncoderLibV2 {
private:

uint8_t _clockstreach;
uint8_t _add = 0x00;
uint8_t _stat = 0x00;
uint8_t _stat2 = 0x00;
uint8_t _gconf = 0x00;
uint8_t _add ; // = 0x00;
uint8_t _stat ; // = 0x00;
uint8_t _stat2 ; // = 0x00;
uint8_t _gconf ; // = 0x00;
union Data_v _tem_data;

void eventCaller(Callback *event);
Expand Down