Commit Graph

325 Commits

Author SHA1 Message Date
ZodiusInfuser 415a1e559a Setup and partial implementations of C++ examples 2022-04-26 23:15:13 +01:00
ZodiusInfuser 0efe210c4c Added in PH_EN motor driver, and zeropoint support 2022-04-25 16:16:02 +01:00
ZodiusInfuser 7608e3f293 Encoder driver finalising 2022-04-25 12:28:42 +01:00
ZodiusInfuser 2eb6a0cf3e Changed encoder folder and gave it a namespace 2022-04-22 16:23:45 +01:00
ZodiusInfuser ba076ccc7b Renamed Snapshot back to Capture 2022-04-22 16:06:54 +01:00
ZodiusInfuser 652612fc31 Removed old C++ motor implementation 2022-04-22 13:59:40 +01:00
Phil Howard 4b86faaf12 VL53L5CX: Fix memory leak. Add get_resolution. 2022-04-20 19:18:53 +01:00
ZodiusInfuser 8ef0d33f0c Finalised more examples 2022-04-20 18:55:39 +01:00
Phil Howard fcd4914cbb VL53L5CX: MicroPython bindings. 2022-04-20 14:33:00 +01:00
Phil Howard f79b2efa9e VL53L5CX: Fix 32k runtime allocation in platform i2c WrMulti 2022-04-20 14:32:13 +01:00
Phil Howard 637f6d18ca VL53L5CX: Class wrapper 2022-04-19 17:24:06 +01:00
ZodiusInfuser 180df9e085 Merge branch 'motor-pio' into motor-and-encoder 2022-04-19 16:28:12 +01:00
ZodiusInfuser 9472a1f109 Fix for hard lock when taking many snapshots 2022-04-19 15:44:31 +01:00
Phil Howard 6028bc16b6 VL53L5CX: Initial bringup 2022-04-19 13:01:54 +01:00
ZodiusInfuser 0bbd07164d Removed unneeded include 2022-04-17 16:52:16 +01:00
ZodiusInfuser 90fd4b8fb9 Encoder mostly implemented, now with MP support 2022-04-17 16:16:59 +01:00
ZodiusInfuser 70b589d431 Fixed inability to use more than one encode, plus other things 2022-04-13 20:12:44 +01:00
ZodiusInfuser a5572e5e44 Fixes post rebase 2022-04-13 11:29:40 +01:00
ZodiusInfuser 55ee058d3e Created a quadrature encoder reader using the Pico's PIO 2022-04-13 10:46:38 +01:00
ZodiusInfuser 5f6e4a3096 Finalised C++ motor implementation 2022-04-11 13:35:53 +01:00
ZodiusInfuser f3c0a305f2 Improvements to MotorState 2022-04-09 01:41:42 +01:00
ZodiusInfuser ac3edafbf4 Contined motor dev 2022-04-05 16:53:36 +01:00
ZodiusInfuser 9a9c3832a2 Various motor work 2022-04-04 20:00:03 +01:00
ZodiusInfuser e59bdc34c4 Added initial structure of new motor classes 2022-03-30 15:50:12 +01:00
ZodiusInfuser 8a36102c53 Merged in old motor implementation 2022-03-30 15:50:12 +01:00
Phil Howard 732e59b314 Pico Wireless: Driver Rewrite
* Use a single common function prototype for all (but two) commands
* Remove "last param" from every param, in favour of an "end_cmd"
* Rename "send_cmd" to "start_cmd" to better reflect what it does
* Replace hard-coded param counts with macro (sizeof(params) / sizeof(inParam))
* Eliminate common causes of bugs
* Try to document some functions
* Correct some types (wl_enc_type, peek as bool)
* Handle timeouts & sleep states
* Successful command exits sleep
2022-03-30 15:30:11 +01:00
ZodiusInfuser 2e2b2002c3 Fix for CI compiler error 2022-03-30 14:52:53 +01:00
ZodiusInfuser 5f3ac9411b Minor internal function rename, and var assignment 2022-03-30 14:29:02 +01:00
ZodiusInfuser 5192e8bc87 Tidied up some debug code 2022-03-30 14:29:02 +01:00
ZodiusInfuser 8d0ae57f2a Changed type to uint8_t 2022-03-30 14:29:02 +01:00
ZodiusInfuser 1efa75a590 Renamed C++ Servo functions to match MP 2022-03-30 14:29:02 +01:00
ZodiusInfuser c5be5be759 Made calibration C++ better match MP 2022-03-30 14:29:02 +01:00
ZodiusInfuser f9a1979d8d Added AnalogMux to C++ 2022-03-30 14:29:02 +01:00
ZodiusInfuser 1b79e85be7 Added offset parameter to Analog, and fixed it not switching between ADC pins 2022-03-30 14:29:02 +01:00
ZodiusInfuser 00408d3b2b Improved servocluster teardown 2022-03-30 14:29:02 +01:00
ZodiusInfuser 44412365b8 Tidying up of calibration 2022-03-30 14:29:02 +01:00
ZodiusInfuser 09e69ff8d9 Improvements to calibration and a calib example 2022-03-30 14:29:02 +01:00
ZodiusInfuser 6f41834082 Various changes to handle class cleanup 2022-03-30 14:29:02 +01:00
ZodiusInfuser 6c16611e88 Much optimisation of PWM generation code 2022-03-30 14:29:02 +01:00
ZodiusInfuser f83521d3ff Expanded list/tuple support to more functions 2022-03-30 14:29:02 +01:00
ZodiusInfuser e1317f432b Expanded options for enabling and disabling servos, and fixed some off-by-one errors. 2022-03-30 14:29:02 +01:00
ZodiusInfuser c352a795a8 Fix for servo cluster frequency being inaccurate at the upper end 2022-03-30 14:29:02 +01:00
ZodiusInfuser 65268098c6 Fix for pulse width bug when changing from high to low frequencies if there was an overrun 2022-03-30 14:29:02 +01:00
ZodiusInfuser d96db62353 Fix for frequency changes enabling servo PWM 2022-03-30 14:29:02 +01:00
ZodiusInfuser 2819fb0020 Exposed servo value loading 2022-03-30 14:29:02 +01:00
ZodiusInfuser 59014f1e86 MP now supports assigning a new calibration to a servo 2022-03-30 14:29:02 +01:00
ZodiusInfuser 176362a49b Updated MP bindings to support latest servo features 2022-03-30 14:29:02 +01:00
ZodiusInfuser e07e248d9e Big refactor of clusters to reduce memory and improve usability 2022-03-30 14:29:02 +01:00
ZodiusInfuser 72516b2ecc Added support for servo phase adjustment 2022-03-30 14:29:02 +01:00
ZodiusInfuser 7f90d3c529 Fixed a bug in the overrun code when load_pwm() is called multiple times between DMA reads 2022-03-30 14:29:02 +01:00
ZodiusInfuser 0838483d2b Added support for pulses with large offsets that cross the wrap level 2022-03-30 14:29:02 +01:00
ZodiusInfuser c4e39fd426 Added solution for PWMCluster not being able to reach 100% with "loading zone" 2022-03-30 14:29:02 +01:00
ZodiusInfuser 35bd03c02b Improved Servo constructors 2022-03-30 14:29:02 +01:00
ZodiusInfuser ec1f0a5ddc ServoCluster states are now only created for the servos actually assigned 2022-03-30 14:29:02 +01:00
ZodiusInfuser 8fc1270404 Added additional PWM/ServoCluster constructors 2022-03-30 14:29:02 +01:00
ZodiusInfuser d94a7c0718 Added set_frequency support to ServoCluster 2022-03-30 14:29:02 +01:00
ZodiusInfuser aeb9705d15 Moved common PWM and MultiPWM out of servo driver, and renamed to cluster 2022-03-30 14:29:02 +01:00
ZodiusInfuser 06c272916c Fix for incorrect ServoCluster duty 2022-03-30 14:28:17 +01:00
ZodiusInfuser 55cbf23f45 Function rename 2022-03-30 14:28:17 +01:00
ZodiusInfuser 565553b3a1 Added an additional case for out-of-bounds values 2022-03-30 14:28:17 +01:00
ZodiusInfuser 5a5282f099 Improved servo limits logic 2022-03-30 14:28:17 +01:00
ZodiusInfuser d1238e802e Added frequency limits 2022-03-30 14:28:17 +01:00
ZodiusInfuser 334ff4e9f9 Added frequency adjustment to Servo 2022-03-30 14:28:17 +01:00
ZodiusInfuser 93eafc4694 All current servo functionality now micropython bindings 2022-03-30 14:28:17 +01:00
ZodiusInfuser 196a5c6111 Much code refactoring and tidy up 2022-03-30 14:28:17 +01:00
ZodiusInfuser 413ef891ce Partial hardware servo support added to MP 2022-03-30 14:28:17 +01:00
ZodiusInfuser f5836e56df Raised servo functions to a base class, and added ServoCluster which uses the PIO PWM. 2022-03-30 14:28:17 +01:00
ZodiusInfuser d4012a271e Improvements to servo calibration and usage 2022-03-30 14:28:17 +01:00
ZodiusInfuser 2e58841b5e Started a hardware PWM servo class, with calibration support 2022-03-30 14:28:17 +01:00
ZodiusInfuser 5957304a46 Adding more PWM functionality 2022-03-30 14:28:17 +01:00
ZodiusInfuser 24aefc16bf Tidied up PIO implementation + commenting 2022-03-30 14:28:17 +01:00
ZodiusInfuser de3cb52931 More progress on Servo PIO 2022-03-30 14:28:17 +01:00
ZodiusInfuser aca98ca747 current WIP code for PIO based PWM 2022-03-30 14:28:17 +01:00
Mike Bell eb95636bca Better if update_time is an underestimate 2022-03-29 23:16:18 +01:00
Mike Bell d96a584ddd Badger2040: Improve performance of some large frame buffer writes 2022-03-29 23:15:43 +01:00
Phil Howard b1fd8936cf Badger2040: Enforce minimum update blocking time. 2022-03-25 10:57:30 +00:00
Phil Howard 249f54fae4 ST7789: Create generic display driver for #299 2022-03-21 17:02:46 +00:00
Phil Howard 8ca91f8e23 PMW3901: Drop print from init. 2022-03-18 13:35:14 +00:00
Philip Howard 273ca5c56d
Merge pull request #252 from pimoroni/badger2040-support
Support for Badger 2040
2022-02-25 16:25:22 +00:00
Phil Howard f90559ed41 Badger2040: Add support for colour inverted mode 2022-02-25 14:49:28 +00:00
Phil Howard 169e332917 Badger2040: Add Medium speed, drop spicy super turbo 2022-02-25 13:37:35 +00:00
Phil Howard 6ff5c39c1b Badger2040: Bugfixes, danger LUTs, examples 2022-02-25 11:08:32 +00:00
Phil Howard af230b5fd5 Badger2040: Refactor to fix MicroPython issues
Move busy wait logic into MicroPython bindings so that MICROPY_EVENT_POLL_HOOK can be called.
2022-02-25 11:08:32 +00:00
Phil Howard 5b084c1b9a Badger2040: Add Fast/Slow LUTs, bugfix and tinkering helpers 2022-02-25 11:08:32 +00:00
Phil Howard 607320c4b6 Badger2040: Fix broken display on reset
Display configuration wasn't applied properly upon reset. Add additional delay to reset and configure busy_wait pulls.
2022-02-25 11:08:32 +00:00
Phil Howard 46d54072ce Badger2040 MicroPython bindings 2022-02-25 11:08:32 +00:00
Phil Howard 5f52626a4f Add partial update support 2022-02-25 11:08:32 +00:00
Jonathan Williamson f7d61b587a added support for badger2040 2022-02-25 11:08:31 +00:00
ZodiusInfuser 95142ffeb5 Fix for display glitch during screen initialisation 2022-02-14 12:57:34 +00:00
Phil Howard c105d111af ICP10125: Fix block indefinitely on repeated start
Should fix pimoroni/icp10125-python#2
2022-02-10 12:28:57 +00:00
Phil Howard 25bebd888f Use .begin() and .size() as per #213
Correct `I2C::write_bytes` to accept a `const uint8_t*` for the array of bytes.
2022-01-25 18:20:54 +00:00
Phil Howard 0eeada72d7 New driver for SCD4X series CO2 sensors
Submodule Sensirion's embedded-i2c-scd4x driver
Add i2c_hal.cpp to binds it to Pimoroni::I2C
Port (loosely) scd4x_i2c_example_usage.c to Pico
2021-12-16 11:39:11 +00:00
Philip Howard 9f6ddb86ae
Merge pull request #218 from ProgramMax/main
Improve ST7789 frame rate ~4x
2021-12-08 15:50:48 +00:00
Philip Howard c322717eb2
Merge pull request #193 from pimoroni/pure-cpp-i75
Pure C++ HUB75 example
2021-12-08 15:25:53 +00:00
Phil Howard 580d8cf7a2 Plasma: Add WS2812 W suppot for #220 2021-12-03 10:50:06 +00: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 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
Phil Howard d4bf69324f HUB75 tidyup, examples 2021-11-23 13:58:34 +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 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
ZodiusInfuser 27b74e140b Finished drivers bindings and examples for flow sensors. 2021-09-13 21:58:11 +01:00
Phil Howard 7375a208c6 make GAMMA common
Moves the 256 entry GAMMA table into pimoroni_common.

Should probably be added into a library so MicroPython is built with only one instance of the table.
2021-09-13 17:40:51 +01:00
Phil Howard 5a7f375ebf plasma: add gamma correction 2021-09-13 17:35:25 +01:00
Phil Howard 759868e787 Python bindings & docs for ICP10125 2021-09-08 14:10:21 +01:00
Phil Howard 7f486314db Driver for ICP10125 temperature/pressure sensor 2021-09-08 14:09:54 +01:00
Phil Howard 240eab7ccf Tweak 320x240 init to avoid flicker 2021-09-08 13:56:03 +01:00
Phil Howard cfe0f8731e Fix bugs in 320x240 display init 2021-09-08 13:56:03 +01:00
ZodiusInfuser 84a81be9d6 Fixed colour ordering 2021-09-08 13:56:03 +01:00
Phil Howard 9ba3a6cfab 320x240 LCD library + tweaks to ST7789 driver
Add the init required for the 320x240 2.0" LCD.

Add an option to set baudrate, 320x240 needs 74MHz for 60FPS

Add library and example for 320x240 2.0 LCD.
2021-09-08 13:55:57 +01:00
ZodiusInfuser 91dfbfdac5 Added PAA secret sauce 2021-09-07 16:23:32 +01:00
ZodiusInfuser a06fff3cbf Added frame capture support and demo 2021-09-07 16:23:32 +01:00
ZodiusInfuser 77f082a984 Initial setup for PMW/PAA flow sensor 2021-09-07 16:23:32 +01:00
Phil Howard b5c7add90d APA102: Extra clocks to flush pixels
This covers an edge case where pixels are updated intermittently - such as the once that happens when clearing before a Python soft reset.

Under normal circumstances users should `start` the LED strip and allow it to continuously update.
2021-08-26 18:14:39 +01:00
Phil Howard 2cc6514583 Slow set/clr_bit writes a little
We chased a bug with handling/clearing interrupts on Encoder into the depths of madness, finding that a Debug build would magically fix the bug.

Turns out it was probably just us being a little aggressive with the poor little MS51-based Encoder driver.

* Fix delays to be more delayey.
* Replace big 'ol loop and boolean with straight up checks and an early exit- the bit-addressed regs are never going to change
2021-08-26 16:35:05 +01:00
Philip Howard 07f3d65a14
Merge pull request #194 from pimoroni/patch_plasma2040_examples
Extra examples and bug fixes for Plasma2040
2021-08-26 14:36:22 +01:00
Phil Howard e283d460d4 Make ws2812 and apa102 responsibly only for their own buffers
This fixes a bug where delete[] would be called on a bytearray buffer allocated by MicroPython on gc_heap.
2021-08-25 22:00:16 +01:00
Phil Howard 53429e0c6f Do not pio_sm_unclaim for MicroPython
Adds an ifdef guard around `pio_sm_unclaim` that prevents it being called when MicroPython cleans up/finalizes classes.

For some reason this appeared to be causing a hardfault.
2021-08-25 16:06:51 +01:00
Philip Howard 0b7076d751
Merge pull request #188 from pimoroni/patch-sdcard-pio
Add support for SD over PIO SPI
2021-08-24 11:18:02 +01:00
ZodiusInfuser c8f90ea846 Changed default color order to GRB to match our strips 2021-08-23 17:18:34 +01:00
ZodiusInfuser b72e0a1bb9 Added Plasma2040 example that displays data from the BME68x 2021-08-20 18:17:39 +01:00
ZodiusInfuser 681edd255b Changed default ws2812 freq to 800khz 2021-08-19 15:36:25 +01:00
ZodiusInfuser 823729dc24 Move apa and ws PIO into drivers so they can be easily used with more boards 2021-08-19 13:40:46 +01:00
ZodiusInfuser ae09498953 Added analog class for plasma current reading 2021-08-19 12:58:13 +01:00
Phil Howard 1e5e4c2f94 Add support for SD over PIO SPI 2021-08-04 10:16:48 +01:00
Phil Howard 815e784625 Plasma 2040 library & examples
Library:

Includes classes for driving WS2812 and APA102 LEDs and defines for Plasma features.

Encoder Example:

Supports connecting a Rotary Encoder via the Qw'St connector.

Works with APA102 or WS281X pixels.

Pressing A will cycle between:
1. Colour change
2. Brightness change
3. Cycle delay

Pressing B will switch back into auto-cycle mode.

Turning the encoder at any time will switch out of auto cycle mode into parameter adjust mode.

Also includes a bugfix to Rotary Encoder for getting the interrupt correctly.

Rainbow Example:

Basic rainbow cycle, press B to speed up and A to slow down.
2021-08-02 14:36:01 +01:00
Phil Howard be9b1437db Add MicroPython bindings for BME280 and BMP280 2021-08-02 14:20:59 +01:00
Phil Howard f0eff195fe C++ SDK Support for BME280 and BMP280 2021-08-02 14:20:40 +01:00
Phil Howard 746e21c542 BME68X Add Time/Temp config to Gas, document 2021-08-02 14:12:46 +01:00
Phil Howard c402d92e0f Basic MicroPython bindings for BME68X
The BME68X library is *linked* against the MicroPython bindings, rather than compiled directly in.
This saves specifing the list of target files twice.
2021-08-02 14:12:46 +01:00
Phil Howard 22d39faf5f Bringup BME688 and BME680 sensors
This changeset brings the BOSCH BME68X Sensor API library in as a submodule and makes it buildable with CMake.

A thin wrapper- the BME68X driver- provides simple init, configure, read_forced and read_parallel functions.

Two BME688 examples are available for forced-mode and parallel-mode operation.
2021-08-02 14:11:56 +01:00
Philip Howard 73d92023e9
Merge pull request #29 from pimoroni/driver-bh1745
Add BH1745 driver
2021-08-02 09:43:46 +01:00
Philip Howard c81b92ecdc
Merge pull request #180 from Daft-Freak/patch-1
Fix some ST7789 regs
2021-08-02 09:20:25 +01:00
Phil Howard bd648034f5 Fix LTR559 duty cycle 2021-07-30 13:30:42 +01:00
Phil Howard b80b714c4f BH1745 MicroPython bindings & example 2021-07-30 12:41:06 +01:00
Phil Howard ea6acf2207 Porti BH1745 to Pimoroni I2C 2021-07-30 12:41:06 +01:00
Phil Howard 54169f4150 Add BH1745 driver 2021-07-30 12:41:02 +01:00
Phil Howard 32e226bfca Add RGBLED and Button libraries
"RGBLED" PWMs 3 pins as a single RGB LED and exposes methods to set the colour via HSV/RGB.

"Button" handles tracking the state and changed state of a single GPIO button, in addition to supporting auto-repeat for held-down buttons.
2021-07-20 15:34:24 +01:00
Charlie Birks 47a2f7c1c7
Fix some ST7789 regs
Fixes frame rate/porch register confusion and uses PWCTRL1 instead of 0xd0.
2021-07-20 15:22:31 +01:00
Philip Howard 3274069a27
Merge pull request #165 from pimoroni/patch-pico-explorer-spi
Fix Pico Explorer SPI for #162
2021-06-05 19:17:16 +01:00
Phil Howard 6022928517 Fix Pico Explorer SPI for #162
The switch to common I2C and common definitions for SPI had broken an edge case in Pico Explorer where no backlight pin is used.

The backlight pin was inadvertently set to the front Breakout Garden SPI slot default, which is pin 20- this also happens to be the I2C SDA pin for Pico Explorer, breaking I2C comms.

This fix adds a new special case board "PICO_EXPLORER_ONBOARD" so that ST7789 can be initialised without the backlight pin.

This will be useful for anyone using ST7789 without the rest of the Pico Explorer library, although it feels a little contrived.

Also switches ST7735 over to the common defines.
2021-06-05 19:06:11 +01:00
David Lin 1f385d8f30 Fix build error: missing printf declaration 2021-06-04 23:08:26 +08:00