Commit Graph

185 Commits

Author SHA1 Message Date
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 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
Phil Howard b4c0d78ef7 Fix RTC year argument for #176 2021-07-07 17:11:02 +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
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
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 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
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 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
ZodiusInfuser 3e9d670298 Better solution to keywords and constructors, for SPI breakouts 2021-05-14 18:26:44 +01:00
ZodiusInfuser 1508f650b9 Fix for i2c select 2021-05-14 18:13:47 +01:00
ZodiusInfuser 1ee5101826 Fix for i2c select 2021-05-14 18:00:26 +01:00
ZodiusInfuser f2ee2a4f8d Better solution to keywords and constructors. Just for I2C for now 2021-05-14 17:14:07 +01:00
ZodiusInfuser 09fc7ca4a7 Added MP address printout for supported breakouts 2021-05-14 15:14:47 +01:00
ZodiusInfuser 8cbc290de2 Fix for keyworks not always working in MP class constructors of breakouts (and removed some whitespaces) 2021-05-14 14:30:08 +01:00
ZodiusInfuser 0a804a426b Micropython linting fixes 2021-05-14 13:15:39 +01:00
ZodiusInfuser 7886b8e78d Finished MP bindings for RV3028 and included a simple example 2021-05-14 13:15:39 +01:00
ZodiusInfuser 2be5528ec7 Partial micropython bindings for RV3028 2021-05-14 13:15:38 +01:00
Phil Howard 0c34de23f5 Tidy up include paths 2021-05-14 12:49:48 +01:00
ZodiusInfuser 707aeba5aa MP linting fix 2021-05-14 12:41:46 +01:00
ZodiusInfuser 7eb8197e45 Added micropython examples for IOExpander 2021-05-14 12:41:46 +01:00
ZodiusInfuser 370167f0f4 Renamed MICS demo file to match other breakouts 2021-05-14 12:41:46 +01:00
Phil Howard 7202926fbb Add mics6814 python demo 2021-05-14 12:41:46 +01:00
ZodiusInfuser 4b850b9290 Added micropython examples for Pot and Enc 2021-05-14 12:41:46 +01:00
ZodiusInfuser 1b860840a3 MP path fixes 2021-05-14 12:41:46 +01:00
ZodiusInfuser d4ba1d97d9 Switch C++ to use Direction enum for functions and added Direction contants to MP 2021-05-14 12:41:46 +01:00
ZodiusInfuser 4a206a9b70 Fix for set brightness not working 2021-05-14 12:41:46 +01:00
ZodiusInfuser 42f2bff6c7 Fixed pot read from returning bool to returning a float, and removed read_as_percent for read_raw 2021-05-14 12:41:46 +01:00
ZodiusInfuser d45a92fef3 Micropython bindings for IOExpander breakout 2021-05-14 12:41:46 +01:00
ZodiusInfuser 31edcf8f93 Renamed IOE's set_addr method to set_address 2021-05-14 12:41:46 +01:00
ZodiusInfuser 3b9927fbef Added initialisation check to Enc, Pot and MICS MP bindings 2021-05-14 12:41:46 +01:00
ZodiusInfuser fd38343924 Micropython bindings for MICS breakout 2021-05-14 12:41:45 +01:00
ZodiusInfuser 0ce424275f Removed some whitespaces 2021-05-14 12:41:27 +01:00
ZodiusInfuser f527b25fed Micropython bindings for Encoder and Pot breakouts 2021-05-14 12:41:23 +01:00
Philip Howard e26677f81a
Merge pull request #148 from pimoroni/patch-better-include-paths
Remove relative include paths
2021-05-14 10:36:19 +01:00
ZodiusInfuser ea460f9519 Micropython bindings and example for MSA301 2021-05-14 10:02:56 +01:00
Phil Howard 37cac5940b Remove relative include paths
This change removes file-relative include paths and adds the project root as a global include path.

* Project root added to CMakeLists.txt so that all targets can find includes
* Project root added micropython.cmake so that targets used by the MicroPython build can find includes

Note: pico-boilerplate projects must set this include path
2021-05-13 12:06:01 +01:00
Phil Howard a4b464df12 AS7262 add Pico Explorer bargraph example 2021-05-12 16:05:43 +01:00
Phil Howard ae489873ee AS7262 add set_integration_time 2021-05-12 16:04:50 +01:00
ZodiusInfuser 9cbeb79b43 Micropython linting fixes 2021-05-12 16:04:50 +01:00