The rp2040 is _very_ marginal for mp3 playback, and currently sometimes triggers a bug that gives garbled audio output. However, it does work for some limited situations.
Also found a race condition between timer_disable and redraw, which
would happen if I debugger-paused inside common_hal_rgbmatrix_timer_disable
or put a delay or print inside it. That's what pausing inside reconstruct
fixes.
So that the "right timer" can be chosen, `timer_allocate` now gets the `self`
pointer. It's guaranteed at this point that the pin information is accurate,
so you can e.g., find a PWM unit related to the pins themselves.
This required touching each port to add the parameter even though it's
unused everywhere but raspberrypi.
The RP2040 is new microcontroller from Raspberry Pi that features
two Cortex M0s and eight PIO state machines that are good for
crunching lots of data. It has 264k RAM and a built in UF2
bootloader too.
Datasheet: https://pico.raspberrypi.org/files/rp2040_datasheet.pdf
uzlib isn't actually used in any firmwares, but is built into the
"unix" port used for testing.
The main benefit of the update is to fix problems encountered on
Windows, as the old ref of uzlib had filenames with embedded colons;
this has been fixed upstream.
uzlib seems to have been reabsed since the version that we took; this
doesn't really matter to us.
This brings in the following, and updates us to the 1.0.4 release tag:
Submodule lib/protomatter 2a1ba8fa4..5f07ec618:
> Bumping version for release
> Merge pull request #21 from makermelissa/master
> Merge pull request #20 from makermelissa/master
> Merge pull request #18 from jepler/fix-cpy-3184
> Merge pull request #14 from hierophect/cpy-timer-allocator
We previously had the _changes_ of jepler/fix-cpy-3184 and
hierophect/cpy-timer-allocator but not their merge commits.
The only other changes in protomatter were one formatting change in the
core, plus several Arduino sketches. So this should make no practical
difference for CPy.
e.g., allocating a 192x32x6bpp matrix would be enough to trigger this
reliably on a Metro M4 Express using the "memory hogging" layout.
Allocating 64x32x6bpp could trigger it, but somewhat unreliably.
There are several things going on here:
* we make the failing call with interrupts off
* we were throwing an exception with interrupts off
* protomatter failed badly in _PM_free when it was partially-initialized
Incorporate the fix from protomatter, switch to a non-throwing malloc
variant, and ensure that interrupts get turned back on.
This decreases the quality of the MemoryError (it cannot report the size
of the failed allocation) but allows CircuitPython to survive, rather
than faulting.
In relatively unusual circumstances, such as entering `l = 17 ** 17777`
at the REPL, you could hit ctrl-c, but not get KeyboardInterrupt.
This can lead to a condition where the display would stop updating (#2689).
Currently when a utf8 character that is bigger than 1 byte is typed in
the repl, it isn't handled how it should be. If you try to move the
cursor in any direction the text gets messed up. This fixes that.
This array was of 32-bit values, but the entries were only ever
in the 0-255 range. Convert to uint8_t.
Testing performed: The result of the sum-of-sin was unchanged
>>> import math; sum(math.sin(2.**i) for i in range(21))
1.42069
This function computes the remainder of a value `x` modulo pi/2, to high
precision.
It does this by dividing the flotaing point values into several ranges
by magnitude, and applies successively slower but more accurate algorithms.
The last two steps, one covering values up to around 2^7 * pi/2
(called "medium size") and a final one covering all possible float values,
require big tables.
By eliminating the "medium size" case, a table and some code are removed
from the binary. This makes some cases take longer, but saves hundreds
of bytes. It does _NOT_ affect the result, only the speed.
```
[desktop python]
>>> sum(math.sin(2.**i) for i in range(21))
1.4206898748939305
[trinket m0, before change to ef_rem_pio2.c]
>>> sum(math.sin(2.**i) for i in range(21))
1.42069
[trinket m0, after change to ef_rem_pio2.c]
>>> sum(math.sin(2.**i) for i in range(21))
1.42069
```