adafruit / Adafruit_CircuitPython_MPR121

Adafruit CircuitPython module for the MPR121 capacitive touch breakout board.
MIT License
19 stars 19 forks source link

need to put MPR121 in Stop Mode for any register writes #11

Closed caternuson closed 5 years ago

caternuson commented 5 years ago

This currently only affects set_threshold since the constructor manually takes care of this. However, this should be fixed in a general way so that any future register write methods will work as expected.

mpr121_reg_write

Adafruit CircuitPython 3.0.3 on 2018-10-10; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board, busio
>>> import adafruit_mpr121
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> mpr121 = adafruit_mpr121.MPR121(i2c)
>>> buf = bytearray(1)
>>> mpr121._read_register_bytes(0x41, buf)  # read ELE0 Touch Threshold
>>> buf
bytearray(b'\x0c')
>>> mpr121.set_thresholds(0xFF, 0x00)  # try to change it to 0xFF
>>> mpr121._read_register_bytes(0x41, buf)  # read ELE0 Touch Threshold
>>> buf
bytearray(b'\x0c')
>>> mpr121._write_register_byte(0x5E, 0x00)  # manually set Stop Mode
>>> mpr121.set_thresholds(0xFF, 0x00)  # try to change it to 0xFF
>>> mpr121._write_register_byte(0x5E, 0x8F)  # manually set Run Mode
>>> mpr121._read_register_bytes(0x41, buf)  # read ELE0 Touch Threshold
>>> buf
bytearray(b'\xff')
>>>
caternuson commented 5 years ago

Fixed by #13