Commit Graph

759 Commits

Author SHA1 Message Date
helgibbons 2aace8cac9 linting examples 2021-12-05 19:57:38 +00:00
helgibbons 1c1cf528f9 Couple of festive examples for Plasma 2040 2021-12-05 19:53:45 +00:00
Phil Howard 580d8cf7a2 Plasma: Add WS2812 W suppot for #220 2021-12-03 10:50:06 +00:00
Chris Blume 9e788f7379 Correct Pico Display 2 baud
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.
2021-12-02 11:42:29 -08:00
Phil Howard 1bb4383074 HUB75 Perf, C++ scrolling text, docs 2021-12-02 12:41:30 +00:00
Phil Howard 4dc3f9b9c4 HUB75 Scrolling wavy text and clock demo 2021-12-01 21:57:40 +00:00
Phil Howard 8ae311e3a5 HUB75 Drop multicore include 2021-11-30 13:04:46 +00:00
Phil Howard c70a9fbb3d HUB75 Optimize performance maybe 2021-11-26 21:36:44 +00:00
Phil Howard 4496c25a8f HUB75: Remove debug from clock, use only flip's implicit delay 2021-11-25 18:14:36 +00:00
Phil Howard 4d33649cd2 HUB75: More rational DMA/PIO setup/teardown, fixes reset bug
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!
2021-11-25 17:52:44 +00:00
Phil Howard c556391be3 HUB75 Clock example, brightness tweak 2021-11-25 16:37:46 +00:00
Phil Howard e09ff78351 HUB75 Strobe invert and larger panel chaining support 2021-11-24 21:36:58 +00:00
Phil Howard 30a455a9d5 HUB75 Less RAM, DMA flip
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.
2021-11-24 19:31:00 +00:00
Phil Howard 069ca38ae7 HUB75 Clear TX FIFOs for MicroPython soft reset glitch 2021-11-23 15:09:03 +00:00
Philip Howard f96012a395
Merge pull request #222 from eddhurst/fix/plasma-set-rgb
Fix documentation examples setting RGB LED
2021-11-23 14:08:32 +00:00
Phil Howard d4bf69324f HUB75 tidyup, examples 2021-11-23 13:58:34 +00:00
Phil Howard c07567f922 HUB75 Panel Types for FM6126A setup, fixes for 32x32 2021-11-23 11:29:41 +00:00
Phil Howard eed7992127 HUB75 Fix intermittent display corruption issue
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.
2021-11-22 16:34:56 +00:00
Phil Howard 66d25d2e9c HUB75 Prevent stuck row on soft reset
TODO:

* Move this into drivers/ for C++ use too.
* Display still goes mighty weird sometimes!
2021-11-22 15:22:37 +00:00
Phil Howard 0e8c1228af HUB75 MicroPython DMA and PIO
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?)
2021-11-22 14:12:18 +00:00
Edd Hurst 47259c55e8
Fix documentation examples setting RGB LED
Update the examples using set_led function and replacing to use set_rgb

Fixes #221
2021-11-21 14:05:12 +00:00
Phil Howard 01f546aaf1 HUB75 MicroPython bindings 2021-11-18 12:51:43 +00:00
Phil Howard d1e8eaa016 Rename GAMMA to avoid conflict with common GAMMA 2021-11-12 12:13:25 +00:00
Phil Howard 48689470aa Vsync flip from front to back buffer 2021-11-12 12:12:02 +00:00
Phil Howard babe8a7760 Pure C++ HUB75 example
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.
2021-11-12 12:12:02 +00:00
Chris Blume 261d2732f0 Improve ST7789 frame rate ~4x
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.
2021-11-11 15:36:13 -08:00
Philip Howard e249113fea
Merge pull request #183 from pimoroni/driver/icp10125
Driver for the ICP10125 pressure & temperature sensor
2021-11-09 17:02:50 +00:00
Philip Howard 0bd8afa272
Merge pull request #215 from pimoroni/patch-bump-mpy-to-v1.17
Bump MicroPython to v1.17
2021-10-11 18:17:45 +01:00
Phil Howard 38fc7de762 Bump MicroPython to v1.17 2021-10-11 12:23:40 +01:00
Philip Howard f04127cd03
Merge pull request #214 from pimoroni/patch-blinka-6141
Bump Blinka to 6.14.1
2021-10-07 12:23:30 +01:00
Phil Howard ba032325d9 Bump Blinka to 6.14.1
Includes a fix for an SPI-related MSB error using Blinka on Pico/MicroPython
2021-10-07 11:38:51 +01:00
Philip Howard e638c8ca58
Merge pull request #211 from Gadgetoid/picosystem
PicoSystem: add helper module to set up PicoSystem
2021-10-06 11:57:36 +01:00
Phil Howard 6170e258f2 PicoSystem: Bat sense scaling 2021-10-06 11:38:10 +01:00
Philip Howard 1a9e2802fe
Merge pull request #206 from pimoroni/driver/pwm3901
C++ and MP drivers and examples for Optical Flow sensors
2021-10-06 11:19:29 +01:00
Philip Howard ff9dcca91b
Merge pull request #205 from pimoroni/patch-plasma-gamma
plasma: add gamma correction
2021-10-06 11:17:38 +01:00
Philip Howard 0c4be0dbb9
Merge pull request #209 from helgibbons/main
add Pico Explorer weather station examples
2021-10-06 11:13:28 +01:00
Philip Howard 3c57cbcdef
Merge pull request #208 from pimoroni/picowireless-ppwhttp
PicoWireless: move HTTP code to ppwhttp library
2021-10-06 11:12:13 +01:00
Phil Howard 321b9ad4af PicoSystem: Move LED after screen init
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.
2021-10-06 11:07:56 +01:00
Philip Howard 2d465da3fa
Merge pull request #170 from pimoroni/driver/320x240lcd
320x240 LCD library + tweaks to ST7789 driver
2021-10-06 10:51:04 +01:00
Phil Howard 44b45e8f00 PicoSystem: add buzzer support 2021-10-04 18:19:26 +01:00
Phil Howard 113cc7c96e PicoSystem: add helper module to set up PicoSystem
Sets up:
* Buttons
* RGB LED
* VBus detect
* Charge detect
* Battery sense
* LCD reset
* Display

TODO: audio
TODO: battery sense settings
2021-10-04 17:52:53 +01:00
Phil Howard 1bb61b2c52 PicoWireless: network scan example
Basic example to scan SSID networks and list them.
2021-10-04 16:20:57 +01:00
Phil Howard 71058bca1e PicoWireless: use strnlen for fwver and SSIDs
Avoid going through std::string and instead uses strnlen to get string length.

Prevents extra null chars leaking into the Python string.
2021-10-04 16:16:19 +01:00
helgibbons de05483ca6 linting Pico Explorer weather station examples 2021-09-30 19:05:11 +01:00
helgibbons 67a4490180 add Pico Explorer tiny weather station examples 2021-09-30 18:37:53 +01:00
Phil Howard 7772959450 PicoWireless: add TLS support to ppwhttp
* 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
2021-09-30 10:47:30 +01:00
Phil Howard 78d50c2986 PicoWireless: ppwhttp add wildcard routes
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.
2021-09-29 16:27:02 +01:00
Phil Howard b92d77a2f9 PicoWireless: handle encoding/content type better in ppwhttp
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.
2021-09-29 14:09:59 +01:00
Phil Howard eb3c8b0ebc PicoWireless: ppwhttp fix to support JSON content type
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.
2021-09-29 12:47:55 +01:00
Phil Howard 9f07be90da PicoWireless: move HTTP code to ppwhttp library
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.
2021-09-29 12:20:06 +01:00