The Pico Display 2 example specifies a baud of 74 * 1000 * 1000.
However, the highest baud the Raspberry Pi Pico can achieve is
62,500,000.
I checked and even when the baud of 74 * 1000 * 1000 is specified,
it ends up using the max that the Raspberry Pi Pico can handle anyway.
This commit removes the incorrect baud parameter, using the default
parameter instead.
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!
Switch from 12-bit to 10-bit gamma to fit RGB into a uint32_t. Simplifies PIO and halves the RAM usage for F/B buffer.
Switch "flip" to *literally* swap the front and back buffers, and then asyncronously DMA the new back buffer into the front ready for the next draw.
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?)
This code is intentionally written in C++ to illustrate the basics of driving HUB75 without being overly complicated to read and understand.
Tested on a 32x32 panel and a 64x64 "FM6126A" panel, for which this code includes a magic pair of register settings.
The ST7789's Tscycw (time between serial write clock cycles) is
16 ns. This can be found on page 44 of the datasheet I'm using:
https://www.waveshare.com/w/upload/a/ae/ST7789_Datasheet.pdf
(I do not know which manufacturer Pimoroni products use and if
their parts might be different. But it seems like this wouldn't
change.)
The existing code sets the SPI baud to 16 * 1000 * 1000. But baud
is Hz, not seconds. That 16 * 1000 * 1000 doesn't represent 16 ns.
It represents 16,000,000 Hz.
16 ns * (1 Hz / s) = 62,500,000 Hz.
This commit changes the baud from 16 * 1000 * 1000 to 62'500'000,
representing ~4x speed improvement in SPI and thus ~4x frame rate
improvement, since the display's frame rate is currently
SPI-limited.
A before & after video can be seen here:
https://www.youtube.com/watch?v=n2y19TCnATo
Note that also on page 44 of that datasheet Tscycr (the read speed)
is only 150 ns, not 16 ns. Right now, the Pimoroni code doesn't read
any values back from the ST7789 so it is safe to operate at the
higher speed.
Also note that the 16 * 1000 * 1000 is the requested baud. The actual
baud is the closest the Pico can get, which is 15,625,000.
The new requested baud of 62'500'000 results in an exact match.
The screen init (C++ bindings) was trouncing the PWM setup (Python) for the RGB LED.
This is because the backlight pin (12) and LED G pin (13) share the same PWM slice.
This does not seem to affect the screen backlight functionality.
* Add a new "connection_mode" argument to http_request. This can be TLS_MODE or TCP_MODE
* Fix a bug where assumptions about json parsing don't hold up
* Check for TCP_STATE_CLOSED and bail early from connect_to_server
This slightly reckless extension to ppwhttp adds support for wildcard routes, eg:
/get_led/<int:index>
Which will serve URLs in the form:
/get_led/10
/get_led/22
etc.
The wildcard includes <type:key>, attempting to match the behaviour of Flask.
Only type "int" is supported currently.
/get_led/<index> - would set data["index"] to a string
/get_led/<int:index> - would attempt to parse the URL part to an int, and would not serve eg: /get_led/hi
See plasma_ws2812_http.py for example usage.
Uses the correct? default Content-Type and encoding for HTTP.
Parses the Content-Type header *before* decoding the content body.
Handles JSON type gracefully.
Decodes the response body accoding to the encoding header.
This is a bit of a fudge, and was only tested against the Cheerlights API.
Detects JSON content type, parses out the content length and truncates the response body to length.
Should probably do this *before* decoding from utf-8.
Updates cheerlights.py API example to support XML, JSON and TEXT endpoints.
Creates a new ppwhttp library to hide the implementation detail of HTTP clients/servers from the examples.
Adds a new example - plasma_ws2812_http.py - showing how to expand rgb_http.py to use a WS2812 pixel strip.
Adds "secrets.py" and moves WIFI connection information there. ppwhttp will throw an error if it's missing.