Defensively tear down DMA/PIO so it's in a known good state upon (soft)reset.
Issue was a race condition with DMA interrupts firing and not being achknowledged, leaving a stuck raised IRQ.
The blocking wait for DMA transactions also exacerbated this, turning a borken DMA interrupt and blank screen into an unrecoverable hardlock.
...not that the blank screen was recoverable without a soft reset anyway!
The FM6126A register write was causing some weirdness on soft reset where the pin state wasn't predictable.
Have twiddled some pins at startup to ensure everything works as expected.
Add set_hsv and set_all_hsv (since setting individual pixels with hsv is S L O W)
Made "flip()" blocking, it was easy to accidentally get a little tearing.
Switch MicroPython HUB75 driver over to DMA/PIO.
TODO:
* Move this into drivers for C++ use too
* Fix hitting "Stop" in Thonny causing rows to stick on the display (this is bad, and should not happen)
* Fix "Stop -> Start" in Thonny causing weird display issues (it's not memory offets, maybe DMA/PIO issues?)
A bytearray allocated in Python would point to uninitialised bytes, missing the SOF byte and brightness for APA102 pixels.
Add a blunt loop over the MicroPython buffer, calling "brightness" for each RGB element to ensure the SOF byte and brightness are initialized.
Includes "WS2812" and "APA102" modules, wrapping the libraries.
Uses a destructor to clean up the LED strip and resources when MicroPython is stopped/restarted.
The BME68X library is *linked* against the MicroPython bindings, rather than compiled directly in.
This saves specifing the list of target files twice.
This change appends the list dir and project root dir to CMAKE_MODULE_PATH so that it doesn't need prepended to each "include" directive.
All .mk files have been deleted, since these are completely redundant.
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.
Removes i2c_inst_t from constructors since it's ignored, and updated the Python bindings not to supply this argument. Instance is inferred from the supplied pins.
Removes all driver-specific SDA/SCL pin definitions and defaults.
Pin type is "uint" everywhere, but "PIN_UNUSED" is *int*_max for MicroPython compat. That's still a lot of pins!
Adds baudrate to the I2C class, and allows a driver (like Trackball) to check the baudrate is supported
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.
* Add a common/pimoroni.hpp to list default pins for various add-ons
* Move the BG SPI Slot enum here for safe keeping
* Switch all GPIO pin references to "uint" to match Pico SDK and bring back PIN_UNUSED as UINT_MAX
This change removes file-relative include paths and adds the project root as a global include path.
* Project root added to CMakeLists.txt so that all targets can find includes
* Project root added micropython.cmake so that targets used by the MicroPython build can find includes
Note: pico-boilerplate projects must set this include path