Skip to content

Add Stop Mode to register write. #13

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

Merged
merged 1 commit into from
Nov 4, 2018
Merged
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
8 changes: 8 additions & 0 deletions adafruit_mpr121.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,16 @@ def touched_pins(self):

def _write_register_byte(self, register, value):
# Write a byte value to the specifier register address.
# MPR121 must be put in Stop Mode to write to most registers
stop_required = True
if register == MPR121_ECR or 0x73 <= register <= 0x7A:
stop_required = False
with self._i2c:
if stop_required:
self._i2c.write(bytes([MPR121_ECR, 0x00]))
self._i2c.write(bytes([register, value]))
if stop_required:
self._i2c.write(bytes([MPR121_ECR, 0x8F]))

def _read_register_bytes(self, register, result, length=None):
# Read the specified register address and fill the specified result byte
Expand Down