MicroPython has changed MP_REGISTER_MODULE to use only *two* args and now runs the preprocessing stage on files before running makemoduledefs.py.
This change avoids the build exploding, since the new regex matches the last two args as a single argument and generates a malformed module defs include.
The pattern here exploits the fact that 1.18 and below do not preprocess files, so *both* MP_REGISTER_MODULE lines are included in the source, but *only* the three arg version is matched by regex.
In >1.18 the files will be processed and the three arg version removed before makemoduledefs.py processes it.
This is the final piece of the puzzle.
Prior to this rather considerable change, Pimoroni breakouts were not de-init'ing I2C when they failed to init()
This change adds a __del__ method which cleans up the I2C instance attached to a MicroPython object.
Under the hood this calls i2c_deinit() and resets the associated pins to their default state.
This means that I2C is now cleaned up during a *soft* reset, so running a script with the wrong pins, seeing an error,
changing the pins and running it again will not result in subsequent I2C errors. Previously a hard reset was required.
To recreate on Breakout Garden run the following code:
```
from breakout_potentiometer import BreakoutPotentiometer
from pimoroni_i2c import PimoroniI2C
i2c = PimoroniI2C()
pot = BreakoutPotentiometer(i2c)
```
This will fail correctly with "Potentiometer breakout not found when initialising."
(The default pins are configured for Pico Explorer)
Now change that to the following and run again without hard-resetting:
```
from breakout_potentiometer import BreakoutPotentiometer
from pimoroni_i2c import PimoroniI2C
i2c = PimoroniI2C(4, 5)
pot = BreakoutPotentiometer(i2c)
```
This should now work, since the failed I2C instance was cleaned up.
Without this change, the second attempt would result in an inexplicable failure.
Since most? (many?) Pico users do not have a reset button, this trap requiring a hard-reset is pretty nasty and would likely have resulted in a support nightmare.
Whew.
This change adds a common I2C class, gathering various I2C functions into a single point of responsibility.
It's necessary for correctly managing the I2C bus pins and state across multiple devices.