Commit Graph

393 Commits

Author SHA1 Message Date
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
Philip Howard 9e1eb6723d
Merge pull request #186 from pimoroni/pymodules
Add python module for RGBLED and Button
2021-07-28 12:52:31 +01:00
Phil Howard 6a4df04ac6 Add python module for RGBLED and Button
Add a pimoroni.py module which includes Python code equivilents of the RGBLED and Button C++ drivers.

This is simpler than binding these drivers into MicroPython and much easier to maintain/extend.
2021-07-28 12:06:57 +01:00
Philip Howard 5f23794c6c
Merge pull request #179 from pimoroni/patch-buttonled
Add RGBLED and Button libraries
2021-07-28 10:12:35 +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
Philip Howard 27fa43087b
Merge pull request #161 from pimoroni/patch-lcdtext
MP Fix for text scaling on lcd breakouts not working, and non-string vars hard-locking
2021-07-12 17:42:52 +01:00
Phil Howard 9d897276f4 Support both kwarg and positional scale
Relies on the default value of the scale argument to avoid needing to explicitly check if it's been supplied.

Fixes x/y (again) on character.
2021-07-12 17:31:17 +01:00
Phil Howard 91c346a17c Change wr to wordwrap for clarity 2021-07-12 16:07:10 +01:00
Philip Howard 141a9670bd
Merge pull request #177 from pimoroni/patch-rv3028
Fix RTC year argument for #176
2021-07-08 09:00:07 +01:00
Phil Howard b4c0d78ef7 Fix RTC year argument for #176 2021-07-07 17:11:02 +01:00
Philip Howard e277bf14dd
Merge pull request #173 from pimoroni/patch-micropython-1.16
Bump MicroPython to v1.16
2021-07-07 16:45:43 +01:00
Phil Howard 09b570ff66 Bump MicroPython to v1.16
* Bump MicroPython from v1.15 to v1.16
* Bump Blinka from 6.10.1 to 6.10.2
* Bump PlatformDetect from 3.13.3 to 3.14.1
* Revert backport patch/hotfix for lwip submodule
2021-06-23 12:47:53 +01:00
Philip Howard 37d86ee766
Merge pull request #171 from pimoroni/patch-pimoroni-pico-import
Add an external import helper module
2021-06-17 12:04:56 +01:00
Phil Howard adaebc33bd Add an external import helper module
Part of the fix for the Pico Boilerplate breakage mentioned in pimoroni/pico-boilerplate#8

This file is included here for posterity and because it's existence is used to validate PIMORONI_PICO_PATH
2021-06-17 11:57:52 +01:00
Philip Howard 28a0a825a8
Merge pull request #166 from pimoroni/patch-cheerlights-try-try-again
Retry failed HTTP connections in cheerlights.py
2021-06-05 19:49:55 +01:00
Phil Howard ff8917cbe0 Retry failed HTTP connections in cheerlights.py
As discussed on https://forums.pimoroni.com/t/pico-wireless-pack-fetching-data-from-web/17215/ the cheerlights.py example was stalling on the first HTTP request.

I have added a timeout in this case, so the code will stop waiting and retry after the 60second polling wait period. Users report this does the trick!
2021-06-05 19:45:07 +01:00
Philip Howard bd359b7fe1
Merge pull request #167 from pimoroni/patch-bump-blinka-platformdetect
Bump blinka to 6.10.1 and platformdetect to 3.13.3
2021-06-05 19:44:37 +01:00
Phil Howard 9935e0d781 Hotfix lwip submodule to avoid server errors
Pulls down the upstream patch from https://github.com/micropython/micropython/pull/7250 and applies it.

Issue discussed here: https://github.com/micropython/micropython/issues/5356
2021-06-05 19:38:42 +01:00
Phil Howard bffca106f6 Bump blinka to 6.10.1 and platformdetect to 3.13.3
Should include fixes and improvements to RP2040 made in versions 6.9.2 and 6.10.1.
2021-06-05 19:20:57 +01:00
Philip Howard a3b7fe2872
Merge pull request #164 from frankdrn/main
Fix character positioning for 3 breakout LCD's in Micropython
2021-06-05 19:17:41 +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
Philip Howard c98e35ffae
Merge pull request #163 from davll/fix-ioexpander-build
Fix: Build error from ioexpander.cpp
2021-06-05 19:09:58 +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
frankdrn b60e0878dd
Merge pull request #1 from frankdrn/character-fix
Fix character positioning for 3 LCD breakouts in Micropython
2021-06-05 15:13:33 +01:00
frankdrn f65d2d00ed
Fix character positioning for colourlcd160x80 2021-06-05 09:09:20 +01:00
frankdrn a2d2165f81
Fix character positioning for colourlcd240x240 2021-06-05 09:07:08 +01:00
frankdrn 09b443bf2d
Update breakout_roundlcd.cpp 2021-06-05 09:04:34 +01:00
David Lin 1f385d8f30 Fix build error: missing printf declaration 2021-06-04 23:08:26 +08:00
Philip Howard 6d23fb210c
Merge pull request #160 from pimoroni/patch-who-wrote-this-code
Rewrite this code for #158
2021-05-26 13:16:30 +01:00
ZodiusInfuser dbbe71702a Fix for text scaling on lcd breakouts not working, and non-string vars hard-locking 2021-05-25 17:06:52 +01:00
Phil Howard 8015ffdb95 Rewrite this code for #158
Rewrites the cursed Pico RGB Keypad code so that it can't hurt anyone else.

Turns out the whole loop could have been a bitwise operator.

The true lesson was the people we met along the way.
2021-05-24 16:48:15 +01:00
Philip Howard 32277ff8c5
Merge pull request #159 from pimoroni/patch-i2c-micropython-repl
Reset unused I2C pins to default when an instance is initialised
2021-05-21 15:27:13 +01:00
Phil Howard 6a9697145b Reset unused I2C pins to default when an instance is initialised
This change is specifically intended to avoid a pitfall in MicroPython and will likely have no effect in C++.

When using the REPL in MicroPython it's possible to set up an I2C instance on two pins - ie: 20, 21 - and then subsequently realise these are the wrong pins for your board.

Before this change, these pins would be left hanging even if you created a new I2C instance with new pins - ie: 4, 5 - this would lead to communications failures where they really shouldn't happen. Confusing!
2021-05-21 15:01:11 +01:00
Philip Howard 91a3ddd602
Merge pull request #157 from pimoroni/patch-simplify-python-cmake
Append CMAKE_MODULE_PATHs to simplify micropython.cmake, drop .mk files
2021-05-21 13:27:49 +01:00
Phil Howard 225d5e024f Append CMAKE_MODULE_PATHs to simplify micropython.cmake, drop .mk files
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.
2021-05-21 11:34:52 +01:00
Philip Howard c393286133
Merge pull request #156 from Gadgetoid/feature/circuitpython-lib-support
Add a new MicroPython build with PlatformDetect and Blinka as frozen modules
2021-05-20 14:42:48 +01:00
Phil Howard 4f8dfd0ed7 Add PlatformDetect and Blinka as frozen modules
This new workflow will build a separate release of MicroPython that includes Blinka and PlatformDetect for compatibility with Adafruit CircuitPython .py libraries.
2021-05-20 14:25:30 +01:00
Philip Howard cb958a7c8a
Merge pull request #129 from pimoroni/patch-gpio-int-types
Add a common header for pins and settings + common I2C class for managing I2C busses across drivers
2021-05-19 11:56:46 +01:00
Phil Howard 0bda2abd2a Fix AS7262 constructor and example 2021-05-18 11:36:14 +01:00
Phil Howard 66f6983290 Port remaining modules to PimoroniI2C, update examples 2021-05-18 11:18:41 +01:00
Phil Howard edf77ddb76 Add finaliser for Pimoroni I2C
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.
2021-05-18 09:48:41 +01:00
Phil Howard b2056040e8 Port Encoder and Potentiometer to Pimoroni I2C
Wraps just enough of Pimoroni I2C to make it work in MicroPython.

Ports Encoder and Potentiometer to use a PimorniI2C() instance in lieu of sda/scl.
2021-05-17 18:09:39 +01:00
Phil Howard 7fa9e5bdca Enable -Werror -Wall and fix all the things
Since MicroPython builds under stricter conditions, this change should help minimise pitfalls when writing/binding drivers.
2021-05-17 16:20:42 +01:00
Phil Howard 3e56dfb14c Remove unecessary manual conversion to byte arrays 2021-05-17 16:05:09 +01:00
Phil Howard 77839e2a6a Tidy up constructors, drop unused variables, const single addr
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.
2021-05-17 14:50:49 +01:00
Phil Howard 445737088f Switch drivers over to I2C class, tidy up common include
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
2021-05-17 11:46:12 +01:00
Phil Howard 42c7555c96 Add common I2C class
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.
2021-05-14 23:02:38 +01:00
Phil Howard 3dfae2ed5c Add a common header for pins and settings
* 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
2021-05-14 21:55:19 +01:00
Philip Howard 76bdf3fb89
Merge pull request #155 from pimoroni/patch-keyword-initialisers
Fix for keywords not working in MP class constructors, for SPI breakouts
2021-05-14 19:25:21 +01:00