Skip to content
Discussion options

You must be logged in to vote

Sorry, I don't know a suitable book. Perhaps someone else can advise?

I think your read bit manipulation should be

def get_wiper(self):
    t = self.i2c.readfrom_mem(self.address, self._WIPER0, 2)
    value =((t[0] & 1) << 8) | t[1]    # move bits, and then mask for desired bits only 
    return value

because t[0] holds the MSB and t[1] holds B7...B0.

However before performing a read, you need to write a single byte comprising the register address and read command as per fig 7.4. Something like

def read_reg(self, reg):
    reg &= 0xF
    buf = byetarray(2)
    buf[0] = self.address
    buf[1] = (reg << 4) | 0x0C  # Read command 
    self.i2c.write(buf)
    t = self.i2c.readfrom(self.address

Replies: 6 comments 13 replies

Comment options

You must be logged in to vote
4 replies
@Comalco
Comment options

@Comalco
Comment options

@Comalco
Comment options

@Comalco
Comment options

Comment options

You must be logged in to vote
2 replies
@Comalco
Comment options

@Comalco
Comment options

Comment options

You must be logged in to vote
4 replies
@Comalco
Comment options

@peterhinch
Comment options

@Comalco
Comment options

@peterhinch
Comment options

Answer selected by Comalco
Comment options

You must be logged in to vote
1 reply
@peterhinch
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@peterhinch
Comment options

@Comalco
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants