From aacbef56c6d3bd0ba61af84fa1536e4a1f6787fc Mon Sep 17 00:00:00 2001 From: helgibbons <50950368+helgibbons@users.noreply.github.com> Date: Tue, 21 Jun 2022 10:40:58 +0100 Subject: [PATCH 1/2] Add boot button to button test, new LED PWM example --- micropython/examples/tufty2040/button_test.py | 14 ++++++++++++-- micropython/examples/tufty2040/led_pwm.py | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 micropython/examples/tufty2040/led_pwm.py diff --git a/micropython/examples/tufty2040/button_test.py b/micropython/examples/tufty2040/button_test.py index e17ef0cc..69d5465a 100644 --- a/micropython/examples/tufty2040/button_test.py +++ b/micropython/examples/tufty2040/button_test.py @@ -14,6 +14,7 @@ button_b = Button(8, invert=False) button_c = Button(9, invert=False) button_up = Button(22, invert=False) button_down = Button(6, invert=False) +button_boot = Button(23, invert=True) WHITE = display.create_pen(255, 255, 255) BLACK = display.create_pen(0, 0, 0) @@ -22,6 +23,7 @@ MAGENTA = display.create_pen(255, 0, 255) YELLOW = display.create_pen(255, 255, 0) RED = display.create_pen(255, 0, 0) GREEN = display.create_pen(0, 255, 0) +BLUE = display.create_pen(0, 0, 255) WIDTH, HEIGHT = display.get_bounds() @@ -54,7 +56,7 @@ while True: display.set_pen(BLACK) display.clear() display.set_pen(YELLOW) - display.text("Button up pressed", 10, 10, WIDTH - 10, 3) + display.text("Button UP pressed", 10, 10, WIDTH - 10, 3) display.update() time.sleep(1) @@ -62,7 +64,15 @@ while True: display.set_pen(BLACK) display.clear() display.set_pen(GREEN) - display.text("Button down pressed", 10, 10, WIDTH - 10, 3) + display.text("Button DOWN pressed", 10, 10, WIDTH - 10, 3) + display.update() + time.sleep(1) + + elif button_boot.is_pressed: + display.set_pen(BLACK) + display.clear() + display.set_pen(BLUE) + display.text("Button BOOT/USR pressed", 10, 10, WIDTH - 10, 3) display.update() time.sleep(1) diff --git a/micropython/examples/tufty2040/led_pwm.py b/micropython/examples/tufty2040/led_pwm.py new file mode 100644 index 00000000..23614bde --- /dev/null +++ b/micropython/examples/tufty2040/led_pwm.py @@ -0,0 +1,17 @@ +# This example shows how you can control the brightness of Tufty's activity LED, using PWM. +# More about PWM / frequency / duty cycle here: https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/7 + +from machine import Pin, PWM +from time import sleep + +pwm = PWM(Pin(25)) + +pwm.freq(1000) + +while True: + for duty in range(65025): + pwm.duty_u16(duty) + sleep(0.0001) + for duty in range(65025, 0, -1): + pwm.duty_u16(duty) + sleep(0.0001) From 6a1b0fdcc65174df30f99ed5b7e3e77277040c8a Mon Sep 17 00:00:00 2001 From: helgibbons <50950368+helgibbons@users.noreply.github.com> Date: Tue, 21 Jun 2022 11:19:20 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 7833e8b7..ee266bb0 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te * Pico Display 2.0 - https://shop.pimoroni.com/products/pico-display-pack-2-0 ## SHIMs + * LiPo SHIM for Pico - https://shop.pimoroni.com/products/pico-lipo-shim * Motor SHIM for Pico - https://shop.pimoroni.com/products/motor-shim-for-pico @@ -79,6 +80,9 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te * Plasma 2040 (LED strip driver) - https://shop.pimoroni.com/products/plasma-2040 * Interstate 75 (HUB75 driver) - https://shop.pimoroni.com/products/interstate-75 * Badger 2040 (E Ink badge) - https://shop.pimoroni.com/products/badger-2040 +* Servo 2040 (18 Channel Servo Controller) - https://shop.pimoroni.com/products/servo-2040 +* Motor 2040 (Quad Motor+Encoder Controller) - https://shop.pimoroni.com/products/motor-2040 +* Tufty 2040 (LCD badge) - https://shop.pimoroni.com/products/tufty-2040 ## Breakouts @@ -109,6 +113,7 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te * PWM3901/PAA5100JE - Near Optical Flow Sensor - https://shop.pimoroni.com/products/paa5100je-optical-tracking-spi-breakout * ICP10125 - High Accuracy Pressure / Altitude / Temperature Sensor - https://shop.pimoroni.com/products/icp10125-air-pressure-breakout * SCD41 CO2 Sensor (Carbon Dioxide / Temperature / Humidity) - https://shop.pimoroni.com/products/scd41-co2-sensor-breakout +* VL53L5CX 8x8 Time of Flight Array Sensor - https://shop.pimoroni.com/products/vl53l5cx-time-of-flight-tof-sensor-breakout # Tutorials & Guides @@ -118,3 +123,6 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te - :link: [Getting Started with Interstate 75](https://learn.pimoroni.com/article/getting-started-with-interstate-75) - :link: [Getting Started with Plasma 2040](https://learn.pimoroni.com/article/plasma-2040) - :link: [Assembling Keybow 2040](https://learn.pimoroni.com/article/assembling-keybow-2040) +- :link: [Getting Started with Badger 2040](https://learn.pimoroni.com/article/getting-started-with-badger-2040) +- :link: [MicroPython and VL53L5CX](https://learn.pimoroni.com/article/micropython-and-vl53l5cx) +- :link: [Getting Started with Tufty 2040](https://learn.pimoroni.com/article/getting-started-with-tufty-2040)