0

I'm trying to use this from git: https://github.com/adafruit/Adafruit_CircuitPython_MPR121/blob/master/adafruit_mpr121.py

Inside the class it defines:

class MPR121_Channel:

def __init__(self, mpr121, channel):
    self._mpr121 = mpr121
    self._channel = channel

When I run an example code, based off: https://github.com/adafruit/Adafruit_CircuitPython_MPR121/blob/master/examples/mpr121_simpletest.py

But add the line

mpr121_channel = adafruit_mpr121.MPR121_Channel(i2c)

so that I can access the variables in that class, it gives the error:

__init__() missing 1 required positional argument: 'channel'

I've edited to be:

mpr121_channel = adafruit_mpr121.MPR121_Channel(i2c, channel)

But now name 'channel' is undefined.

Please could someone help me work out where (and how) to define channel?

Thank you!

1
  • Maybe you made a mistake in creating an object of that class. Could you provide more clarification as to which object are you creating ?
    – Raj
    May 15, 2020 at 9:01

1 Answer 1

0

did you try

mpr121 = adafruit_mpr121.MPR121_Channel(i2c) make channel=None

2
  • I tried "mpr121_channel = adafruit_mpr121.MPR121_Channel(i2c, 1)" which works! I assume it is now only reading channel 1, but that will do for now
    – Tom Fisher
    May 15, 2020 at 9:08
  • Now it's claiming i2c doesn't have the attribute "_read_register_bytes". It reads using the other class just fine! I'm so lost
    – Tom Fisher
    May 15, 2020 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.