From 46a83b7a66310f8765a2cf94c70a3f9e2aaa7f87 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 11 Oct 2024 13:32:02 +0100 Subject: [PATCH 1/9] docs: Docs --- README.md | 52 +++++++++++++++++++++++++++++++++------------- examples/README.md | 0 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 examples/README.md diff --git a/README.md b/README.md index 2a3808e..7757fcb 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,41 @@ -# Pimoroni PGA Boilerplate +# Explorer -This repository is intended to provide a baseline MicroPython build for PGA2040 -and PGA2350, in addition to being a minimal example of how you might set up your -own custom MicroPython flavour to support your PGA-based project. +This repository is home to the Explorer MicroPython fimrware and examples. -Use this repository as a boilerplate to set up your own project, and GitHub actions -should automatically handle building MicroPython for you. +Explorer is a electronic adventure playground for physical computing, built around the RP2350B. Includes a 2.8" LCD screen, a speaker, a mini breadboard, and much more! -## Contents +Grab yours at https://shop.pimoroni.com/products/explorer -* pga2040 - MicroPython and Pico SDK board definitions for PGA2040 -* pga2350 - MicroPython and Pico SDK board definitions for PGA2350, with PSRAM variant -* modules/c/example - An example MicroPython C++ module, demonstrating C class bindings -* modules/py_frozen - Python files intended to be frozen into the firmware -* modules/py_littlefs - Python files intended to be visible/editable in the LittleFS user filesystem -* modules/default.py - The MicroPython manifest file, for specifying frozen libs -* modules/default.txt - The dir2uf2 LittleFS manifest file, for specifying included files -* modules/default.cmake - The MicroPython USER_C_MODULES file, for specifying included C/C++ modules \ No newline at end of file +- [Explorer](#explorer) + - [Download MicroPython for Explorer](#download-micropython-for-explorer) +- [Flashing The Firmware](#flashing-the-firmware) +- [Examples](#examples) +- [Documentation](#documentation) + +## Download MicroPython for Explorer + +Explorer comes pre-flashed with MicroPython, our own custom drivers/libraries and a range of examples to get you started. MicroPython support for the RP2350B is currently a work-in-progress, so you should be prepared to update as we make fixes and improvements! + +To upgrade, grab the latest release from https://github.com/pimoroni/explorer/releases/latest + +There are two choices of firmware: + +* explorer-vX.X.X-micropython-with-filesystem.uf2 :warning: (recommended) - A full update package including examples and the explorer library +* explorer-vX.X.X-micropython.uf2 - a firmware-only update, that will leave your filesystem alone! + +:warning: If you flash the `with-filesystem` version, the contents of your Explorer board will be erased- so make sure to back up your own code first. Alternatively you can flash the firmware-only build and manually copy the files in [examples/lib](examples/libs) + +# Flashing The Firmware + +1. Connect Explorer to your computer with a USB Type-C cable +2. Put your Explorer into bootloader mode by holding down "BOOT", the second button from the left when holding Explorer with the screen facing away from you. Keep holding "BOOT" and press "RESET", the button next to "BOOT". +3. Drag and drop your chosen `.uf2` file onto the `RP2350` drive that appears. +4. Your board should reset and, if you used the `with-filesystemz build, should dipslay a menu of examples. + +# Examples + +We've tried to cover all the bases with some simple examples to get you started. See [examples/README.md](examples/README.md) for more information. + +# Documentation + +To help you get started we've created a function refernece. See [docs/reference.md](docs/reference.md) \ No newline at end of file diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..e69de29 From 8c73dba4bdb9886240b484ed052b51bff654b06d Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 11 Oct 2024 14:13:36 +0100 Subject: [PATCH 2/9] Docs: Fixup README, document examples. --- README.md | 16 +++++---- examples/README.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7757fcb..14d589c 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,23 @@ -# Explorer +# Explorer -This repository is home to the Explorer MicroPython fimrware and examples. +This repository is home to the Explorer MicroPython fimrware and examples. -Explorer is a electronic adventure playground for physical computing, built around the RP2350B. Includes a 2.8" LCD screen, a speaker, a mini breadboard, and much more! +Explorer is a MicroPython-powered electronic adventure playground for physical computing, built around the RP2350B. Grab yours at https://shop.pimoroni.com/products/explorer -- [Explorer](#explorer) - - [Download MicroPython for Explorer](#download-micropython-for-explorer) +- [Introduction](#introduction) +- [Download MicroPython for Explorer](#download-micropython-for-explorer) - [Flashing The Firmware](#flashing-the-firmware) - [Examples](#examples) - [Documentation](#documentation) -## Download MicroPython for Explorer +# Introduction Explorer comes pre-flashed with MicroPython, our own custom drivers/libraries and a range of examples to get you started. MicroPython support for the RP2350B is currently a work-in-progress, so you should be prepared to update as we make fixes and improvements! +# Download MicroPython for Explorer + To upgrade, grab the latest release from https://github.com/pimoroni/explorer/releases/latest There are two choices of firmware: @@ -23,7 +25,7 @@ There are two choices of firmware: * explorer-vX.X.X-micropython-with-filesystem.uf2 :warning: (recommended) - A full update package including examples and the explorer library * explorer-vX.X.X-micropython.uf2 - a firmware-only update, that will leave your filesystem alone! -:warning: If you flash the `with-filesystem` version, the contents of your Explorer board will be erased- so make sure to back up your own code first. Alternatively you can flash the firmware-only build and manually copy the files in [examples/lib](examples/libs) +:warning: If you flash the `with-filesystem` version, the contents of your Explorer board will be erased- so make sure to back up your own code first. Alternatively you can flash the firmware-only build and manually copy the files in [examples/lib](examples/lib) # Flashing The Firmware diff --git a/examples/README.md b/examples/README.md index e69de29..ef04ba2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -0,0 +1,85 @@ +# Examples + +# balls_demo.py + +Our timeless silly bouncing balls demo, shows off drawing in PicoGraphics. + +# button_test.py + +Want to test your buttons? Look no further! + +# clock.py + +We'd be remiss without an example to flex our new PicoVector and PicoGraphics improvements. If you're not using your Explorer for anything else, then here's a handy Analog or Digital desk clock for you. Connect to your computer and use Thonny to automagically set the time. + +# cubes.py + +Seen those spinny wire mesh cube demos and wondered "how do they do that?" well you can continue to wonder, because this code makes me cry. + +# display_jpg.py + +As the name suggests, this example will display a JPEG. Remember, it's "f" as in "Photographic" so technically you should pronounce it "jfeg."" + +# display_png.py + +Bored of jfegs? Display a PNG instead... no, not the sound, but an image. PNG's are great because they can be *paletted* and give you super crisp details for low colour applications. Think icons, icons and, uh, icons! + +# double_tap.py / double_tap_async.py + +A delightful example for the LSM6DS3 accelerometer on our [multi sensor stick](https://shop.pimoroni.com/products/multi-sensor-stick). Knock on your desk, go on! + +The async version uses `asyncio.create_task` to poll for a tap event. Keeps your main loop all nice and clean. + +# explorer_sensor_stick_demo.py + +Another example for our [multi sensor stick](https://shop.pimoroni.com/products/multi-sensor-stick). Uh, sorry. I guess this is a bit of an upsell. But it's three pretty cool sensors in one... and not a bag of virtual gems! + +Displays light, acceleromater and temperature data! + +# external_buttons.py + +Gotta put something on that little breadboard, right! How about more buttons. You can never have enough buttons. The ones they keep taking out of cars must go somewhere!? + +# image_gallery.py + +At a loss for what to do with your Explorer. Clock just not your cup of tea? How about a digital photo frame! Those are still cool, right? + +# marker.py + +If you haven't Google'd "permenant marker font" yet, you really should. It's about the only worthwhile thing Google.com still does. + +# maze.py + +It's a-maze-ing! Use the C, Z, A and B buttons to navigate. + +# multiple_servos.py + +You can't do much with one servo, so how about multiple? You could be well on your way to being the next terrifyingly lifelike robot engineer! + +# potentiometer.py + +While it sounds like something for detecting ghosts or 1920s Soviet silent movies, a potentiometer is actually just a resistor, in a circle, with a knob to change its resistance. This one weird trick gives you a rotary control for your projects... use it to wiggle a servo! + +# rainbow.py + +Cue [appropriate musical accompaniment](https://remix.kwed.org/files/RKOfiles/Lagerfeldt%20-%20Flip%20the%20Flop%20(Rock%20My%20Commodore).mp3) before launching. + +# shake.py + +Another example for our [multi sensor stick](https://shop.pimoroni.com/products/multi-sensor-stick). A truly classic falling sand demo. [Shake it off. Shake it off.](https://www.youtube.com/watch?v=jRMHp7_kPec) + +# simple_menu.py + +How to menu? How to menu! + +# single_servo.py + +Nobody wants one servo... though I guess this does demonstrate all the cool features Chris packed into our servo library. Give it a go! + +# step_counter.py + +Another example for our [multi sensor stick](https://shop.pimoroni.com/products/multi-sensor-stick). Turns out the LSM6DS3 has turnkey step counting built right in... I guess we know how all those sports trackers work now! + +# tone_song.py + +By the grace of alphabetical ordering this wonderful musical example has come last. I think parents will thank us for this. \ No newline at end of file From c9ac38c5347c2a31e9c3d59b5530341f510d6d4f Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 11 Oct 2024 15:19:21 +0100 Subject: [PATCH 3/9] docs: Fix spelling and typos. Start reference. --- README.md | 6 +-- docs/reference.md | 91 ++++++++++++++++++++++++++++++++++++++-------- examples/README.md | 4 +- 3 files changed, 80 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 14d589c..79d8e8c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Explorer -This repository is home to the Explorer MicroPython fimrware and examples. +This repository is home to the Explorer MicroPython firmware and examples. Explorer is a MicroPython-powered electronic adventure playground for physical computing, built around the RP2350B. @@ -32,7 +32,7 @@ There are two choices of firmware: 1. Connect Explorer to your computer with a USB Type-C cable 2. Put your Explorer into bootloader mode by holding down "BOOT", the second button from the left when holding Explorer with the screen facing away from you. Keep holding "BOOT" and press "RESET", the button next to "BOOT". 3. Drag and drop your chosen `.uf2` file onto the `RP2350` drive that appears. -4. Your board should reset and, if you used the `with-filesystemz build, should dipslay a menu of examples. +4. Your board should reset and, if you used the `with-filesystem build, should display a menu of examples. # Examples @@ -40,4 +40,4 @@ We've tried to cover all the bases with some simple examples to get you started. # Documentation -To help you get started we've created a function refernece. See [docs/reference.md](docs/reference.md) \ No newline at end of file +To help you get started we've created a function reference. See [docs/reference.md](docs/reference.md) \ No newline at end of file diff --git a/docs/reference.md b/docs/reference.md index 996763d..8c2e2e0 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -2,23 +2,43 @@ This is the library reference for the [Pimoroni Explorer](https://shop.pimoroni.com/products/explorer), an electronics adventure playground, powered by the Raspberry Pi RP2350. - -## Table of Content -- [Getting Started](#getting-started) -- [Reading the Switches](#reading-the-switches) -- [`explorer` Reference](#explorer-reference) - - [Index Constants](#index-constants) - - [Count Constants](#count-constants) - - [Colour Constants](#colour-constants) - - [Pin Constants](#pin-constants) - - [Audio Constants](#audio-constants) - - [Variables](#variables) - - [Functions](#functions) - +It's split into three main sections for your convenience: + +- [Explorer Library](#explorer-library) + - [Getting Started](#getting-started) + - [Reading the Switches](#reading-the-switches) + - [`explorer` Reference](#explorer-reference) + - [Index Constants](#index-constants) + - [Count Constants](#count-constants) + - [Colour Constants](#colour-constants) + - [Pin Constants](#pin-constants) + - [Audio Constants](#audio-constants) + - [Variables](#variables) + - [Functions](#functions) +- [PicoGraphics](#picographics) + - [Basic Drawing Functions](#basic-drawing-functions) + - [Changing The Display Mode](#changing-the-display-mode) + - [JPEG Decoding](#jpeg-decoding) + - [PNG Decoding](#png-decoding) +- [PicoVector](#picovector) + - [Setup \& Anti-aliasing](#setup--anti-aliasing) + - [Shapes \& Primitives](#shapes--primitives) + - [Fonts \& Text](#fonts--text) + +# Explorer Library + +The [explorer library](examples/lib/explorer.py) is a wrapper around some of Explorer's particulars. It aims to get you set up with a PicoGraphics surface for drawing, and help you find the right pins for the many inputs and outputs. + +It defines a few values that you'll probably use most: + +* `i2c` - A `machine.I2C` compatible I2C instance for I2C devices connected to the Qw/St socket +* `audio_pwm` - A `machine.PWM` instance to drive the piezo for beeps and boops +* `servos` - A list containing four `Servo` instances for driving the four servo connectors +* `display` - A PicoGraphics instance, configured in RGB565 pen mode with two drawing layers ## Getting Started -To start coding your Pimoroni Explorer, you will need to add the following line to the start of your code file. +To start coding your Pimoroni Explorer, you will need to add the following line to the start of your code file: ```python import explorer @@ -26,7 +46,6 @@ import explorer ... - ## Reading the Switches ... @@ -35,6 +54,7 @@ import explorer ## `explorer` Reference ### Index Constants + ```python SERVO_1 = 0 SERVO_2 = 1 @@ -43,6 +63,7 @@ SERVO_4 = 3 ``` ### Count Constants + ```python NUM_GPIOS = 6 NUM_ADCS = 6 @@ -51,6 +72,7 @@ NUM_SWITCHES = 6 ``` ### Colour Constants + ```python WHITE = 65535 BLACK = 0 @@ -63,6 +85,7 @@ BLUE = 7936 ``` ### Pin Constants + ```python SWITCH_A_PIN = 16 SWITCH_B_PIN = 15 @@ -99,12 +122,14 @@ AMP_EN_PIN = 13 ``` ### Audio Constants + ```python AMP_CORRECTION = 4 DEFAULT_VOLUME = 0.2 ``` ### Variables + ```python i2c: PimoroniI2C audio_pwm: PWM @@ -123,10 +148,44 @@ servos: list[Servo] ``` ### Functions + ```python play_tone(frequency: float) -> None play_silence() -> None stop_playing() -> None set_volume(volume: float=None) -> None mute_audio(value: bool=True) -> None -``` \ No newline at end of file +``` + +# PicoGraphics + +Explorer, like all of our display products, uses our in-hour framebuffer graphics library - PicoGraphics. + +PicoGraphics is a wrapper around a big ol' chunk of RAM, which corresponds to the pixels on an attached display. By default, Explorer is configured in RGB565 mode which corresponds to two bytes per pixel, or 5 bits of red, 6 bits of green and 5 bits of blue respectively. It's also known as 65k colour, and does a pretty good job of making pretty pictures at half (rather than 2/3rds) the RAM cost (for awkward technical reasons) of RGB888. + +## Basic Drawing Functions + +Since there are many, many things you can do with PicoGraphics that would be silly to repeat here, I'll send you over to our main MicroPython repository for [a full PicoGraphics function reference.][https://github.com/pimoroni/pimoroni-pico/blob/main/micropython/modules/picographics/README.md#function-reference] + +## Changing The Display Mode + +You can replace `explorer.display` by just creating a PicoGraphics instance as normal, for example switching into RGB332 mode (1 byte per pixel) to save RAM can be done by just replacing `explorer.display`: + +```python +from picographics import PicoGraphics, DISPLAY_EXPLORER, PEN_RGB332 +explorer.display = PicoGraphics(display=DISPLAY_EXPLORER, pen_type=PEN_RGB332, layers=2) +``` + +We use two layers by default, since that extra layer is handy for static backgrounds and other fun drawing tricks. + +## JPEG Decoding + +## PNG Decoding + +# PicoVector + +## Setup & Anti-aliasing + +## Shapes & Primitives + +## Fonts & Text diff --git a/examples/README.md b/examples/README.md index ef04ba2..e064920 100644 --- a/examples/README.md +++ b/examples/README.md @@ -34,7 +34,7 @@ The async version uses `asyncio.create_task` to poll for a tap event. Keeps your Another example for our [multi sensor stick](https://shop.pimoroni.com/products/multi-sensor-stick). Uh, sorry. I guess this is a bit of an upsell. But it's three pretty cool sensors in one... and not a bag of virtual gems! -Displays light, acceleromater and temperature data! +Displays light, accelerometer and temperature data! # external_buttons.py @@ -46,7 +46,7 @@ At a loss for what to do with your Explorer. Clock just not your cup of tea? How # marker.py -If you haven't Google'd "permenant marker font" yet, you really should. It's about the only worthwhile thing Google.com still does. +If you haven't Google'd "permanent marker font" yet, you really should. It's about the only worthwhile thing Google.com still does. # maze.py From 7cbc48fcaae05bbfd71823ad1eb6cacd689b991a Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 11 Oct 2024 15:51:07 +0100 Subject: [PATCH 4/9] docs: Update reference. --- docs/reference.md | 70 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index 8c2e2e0..6d46665 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -29,13 +29,6 @@ It's split into three main sections for your convenience: The [explorer library](examples/lib/explorer.py) is a wrapper around some of Explorer's particulars. It aims to get you set up with a PicoGraphics surface for drawing, and help you find the right pins for the many inputs and outputs. -It defines a few values that you'll probably use most: - -* `i2c` - A `machine.I2C` compatible I2C instance for I2C devices connected to the Qw/St socket -* `audio_pwm` - A `machine.PWM` instance to drive the piezo for beeps and boops -* `servos` - A list containing four `Servo` instances for driving the four servo connectors -* `display` - A PicoGraphics instance, configured in RGB565 pen mode with two drawing layers - ## Getting Started To start coding your Pimoroni Explorer, you will need to add the following line to the start of your code file: @@ -64,6 +57,8 @@ SERVO_4 = 3 ### Count Constants +These handy constants tell you how many of something Explorer has. + ```python NUM_GPIOS = 6 NUM_ADCS = 6 @@ -73,19 +68,53 @@ NUM_SWITCHES = 6 ### Colour Constants +These are RGB565 colours for Explorer's default PicoGraphics instance. + ```python -WHITE = 65535 -BLACK = 0 -CYAN = 65287 -MAGENTA = 8184 -YELLOW = 57599 -GREEN = 57351 -RED = 248 -BLUE = 7936 +WHITE = 65535 # 255, 255, 255 +BLACK = 0 # 0, 0, 0 +CYAN = 65287 # 0, 255, 255 +MAGENTA = 8184 # 255, 0, 255 +YELLOW = 57599 # 255, 255, 0 +GREEN = 57351 # 0, 255, 0 +RED = 248 # 255, 0, 0 +BLUE = 7936 # 0, 0, 255 +``` + +If you're wondering how these baffling numbers are arrived at, we start with three 8-bit values for Red, Green and Blue: + +``` +red = RRRRRRRR +green = GGGGGGGG +blue = BBBBBBBB +``` + +Then we chop them down to 5, 6 and 5 bits respectively: + +``` +red = RRRRR +green = GGGGGG +blue = BBBBBB ``` +And stick them together: + +``` +rgb565 = RRRRRGGGGGGBBBBB +``` + +And byteswap them (swap the lower 8 bits with the upper 8 bits, for reasons): + +``` +rgb565 = GGGBBBBBRRRRRGGG +``` + +And that's why 255 red, or `0b0000000011111000` equals 248. + ### Pin Constants +Constants for all the pins you might need to access on Explorer: + ```python SWITCH_A_PIN = 16 SWITCH_B_PIN = 15 @@ -130,6 +159,15 @@ DEFAULT_VOLUME = 0.2 ### Variables +Defines a few values that you'll probably use most: + +* `i2c` - A `machine.I2C` compatible I2C instance for I2C devices connected to the Qw/St socket +* `audio_pwm` - A `machine.PWM` instance to drive the piezo for beeps and boops +* `servos` - A list containing four `Servo` instances for driving the four servo connectors +* `display` - A PicoGraphics instance, configured in RGB565 pen mode with two drawing layers +* `button_` - A collection of six `machine.Pin` instances for reading the onboard button +* `button_user` - A `machine.Pin` instance for reading the user / boot button + ```python i2c: PimoroniI2C audio_pwm: PWM @@ -159,7 +197,7 @@ mute_audio(value: bool=True) -> None # PicoGraphics -Explorer, like all of our display products, uses our in-hour framebuffer graphics library - PicoGraphics. +Explorer, like all of our display products, uses our in-house framebuffer graphics library - PicoGraphics. PicoGraphics is a wrapper around a big ol' chunk of RAM, which corresponds to the pixels on an attached display. By default, Explorer is configured in RGB565 mode which corresponds to two bytes per pixel, or 5 bits of red, 6 bits of green and 5 bits of blue respectively. It's also known as 65k colour, and does a pretty good job of making pretty pictures at half (rather than 2/3rds) the RAM cost (for awkward technical reasons) of RGB888. From fa0f280f716a2490317dc75cb229c5d3bdbdeb5c Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 11 Oct 2024 15:51:25 +0100 Subject: [PATCH 5/9] examples: Add marker.py. --- examples/marker.af | Bin 0 -> 10871 bytes examples/marker.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 examples/marker.af create mode 100644 examples/marker.py diff --git a/examples/marker.af b/examples/marker.af new file mode 100644 index 0000000000000000000000000000000000000000..b3a5364d4f51e45c75262ec1b55784cfe4a0763b GIT binary patch literal 10871 zcmb7q=XYw|edalb-g^_hOY|yGZ@0I%*q%6!6UT8T6Hg|Y-ZJfv@oPJ;$IBl3UbU-s zuK)omfItOR5C|cOE>NYM*>dL7e41JMfX-U5_t|^@%2W1_|4KOmLC}w&|H1itNCEzX zbP%M3+LABC2&5v4Ep`V2sWH&=S1%AqgX#3XbHb1o3yr)S$APb62i!vlq$i36b}ihO8~r^|}X! zY)EJ9t7iygN6@Y}N*HqBp^4WMFyutx{+InQ(xGPJC!RH`^8L^DQ&=5@aY6cN#xCNfaz>jh5 z{xA9vXcXQl?as4z&oIyg1P#3!fuSb|+V=+h?kS9pzXszx>!7dS zfO(%o(Dz<{1w$`T^x50zF!Zv8K6~Sap;sN~yD!1|U&H8EZ@z?~H!wQ<2F&*sMt}15 zFJb6i2YU7T84P^^qc7gQL7*?Oow2v$2=o%)j;;_{Q-j9jjC3&et zo0v89$Nht*w|AK^xiK$PTuno$E#iq zQ%5v#E%@H&F71$I?8UICUn`jtf0Fn`>w$)-QsHaDzQqfvFf5J$*gQ%z9?vF z0g>8-Ch?k5!B;Q^OpcIYov_lJBz=#ZB*uvm%9>!UYgw`&n^jHe7J7WTur2Ida?kZo z4KIxOhF8beo~%EQyokQse3^K%-M`~W52WSkp0sI4wIe?S|DE)l_FU*ns+z1Jy%FDc zb@(tBp`)~W@*VMpa80NaD#Q}4#4AYiij3k!aLhSk91#xi`+Eax0~Nxf*f#c#P$g6-1y)YF-xHC|OBba}a-S-wURQ2Px5V4L9mXzs zm#~G~#IF%T)KBy!<^pGqH!GMCPK#%x9|fy|Fn@&`WQSO5+_i!7V14kW|IX8Nw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yGfqrg0)WC>|JP#BRUvW?v&M9EP~gtg9D6^6P#%YG~Swe(lAUn+j7 z|Ap}z`!}OMd-;nmzWwrle*N3mzkBlg;rI6UrVoZW;Ecx9aeh*jQs!huAtXhus1*{V z`8iGr+yDWXiPj+?;0i?xzQI;-Me+$bMcZMm@s Date: Fri, 11 Oct 2024 18:23:42 +0100 Subject: [PATCH 6/9] docs: More reference --- docs/reference.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/docs/reference.md b/docs/reference.md index 6d46665..2f3679e 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -24,6 +24,7 @@ It's split into three main sections for your convenience: - [Setup \& Anti-aliasing](#setup--anti-aliasing) - [Shapes \& Primitives](#shapes--primitives) - [Fonts \& Text](#fonts--text) + - [Transforms](#transforms) # Explorer Library @@ -218,12 +219,92 @@ We use two layers by default, since that extra layer is handy for static backgro ## JPEG Decoding +Sometimes it's easy just to grab a JPEG file from somewhere, squash it down and display it on your screen. You can rely on JPEGs lossy compression to help fit more images on your flash storage. + +You can find documentation for the JPEG decoder in our [PicoGraphics reference](https://github.com/pimoroni/pimoroni-pico/tree/main/micropython/modules/picographics#jpeg-files). + ## PNG Decoding +More often than not you want your image to look exactly as you intended it, without ugly compression artifacts and distortion. This is particularly useful for icons and interface elements- for which you should use the PNG format and aim for a palette mode image with as few colours as you can represent your artwork in. + +You can find documentation for PNG decoder in our [PicoGraphics reference]( +https://github.com/pimoroni/pimoroni-pico/tree/main/micropython/modules/picographics#png-files). + # PicoVector +Explorer includes our new and improved PicoVector library, bringing vector graphics and text along with it. + ## Setup & Anti-aliasing +The first step is to create a PicoVector instance: + +```python +from picovector import PicoVector + +vector = PicoVector(explorer.display) +``` + +You should then pick an anti-aliasing method. Anti-aliasing is the technique that turns harsh, pixellated edges into a smooth transition between elements. You probably look at it all day without realising, and on Explorer there's a very real tradeoff between speed and anti-aliasing quality. You can pick one of: + +* `ANTIALIAS_NONE` - Turn off anti-aliasing altogether +* `ANTIALIAS_FAST` - A nice balance between none, and best +* `ANTIALIAS_BEST` - High quality x16 anti-aliasing + +And set it with: + +```python +from picovector import PicoVector, ANTIALIAS_BEST + +vector = PicoVector(explorer.display) +vector.set_antialiasing(ANTIALIAS_BEST) +``` + ## Shapes & Primitives +PicoVector is built around polygons, which is really a collection of arbitrary paths that describe a shape. You create a shape by adding predefined primitives to you "Polygon", these are: + +* `rectangle(x, y, w, h [, (corners), stroke])` - A rectangle, with a optional tuple of four corner radii or a stroke width to convert it into an outline +* `regular(x, y, radius, sides [, stroke])` - A regular polygon. Starts as a triangle and converges to a circle. Providing a stroke with makes it an outline. +* `path((x, y), (x, y), (x, y), ...)` - A closed path consisting of at least three points (two would be an invisible line!) +* `circle(x, y, radius [, stroke])` - A circle, with optional stroke to make it an outline +* `arc(x, y, radius, from, to [, stroke])` - A circular arc between the angles from and to + ## Fonts & Text + +* `set_font(filename)` - Load an `.af` font from flash. +* `set_font_size(size)` - What units are we using here? TODO: Maybe we need to normalise this somehow! +* `set_font_word_spacing(spacing)` - The worst named function ever! Sets the space between words. +* `set_font_letter_spacing(spacing)` - Sets the space between letters. +* `set_font_line_height(spacing)` - Sets the text line-height. +* `set_font_align(spacing)` - Sets the text alignment, for reasons currently only *horizontal* alignment works. Remind me to fix this! + +## Transforms + +Every time you draw something with PicoVector, it's affected by the `transform` you've set. This is how you rotate, scale and translate your shapes to position them on the screen. + +* `transform = Transform()` - Create a new transform +* `transform.rotate(angle degrees, (origin_x, origin_y))` +* `transform.scale(scale_x, scale_y)` +* `transform.translate(translate_x, translate_y)` +* `transform.reset()` + +To create a new transform you should create it, apply it to your vector instance and add some transformations: + +```python +from picovector import PicoVector, Transform + +vector = PicoVector(explorer.display) +transform = Transform() +vector.set_transform(transform) + +transform.rotate(90, (0, 0)) +transform.scale(10) +``` + +For a clean slate, you can reset your transform back to its original state: + +```python +transform.reset() +``` + +Transformations can be a little confusing \ No newline at end of file From e5b76fe695a86085430d21c5d546393d0490fa1c Mon Sep 17 00:00:00 2001 From: thirdr Date: Mon, 14 Oct 2024 10:54:06 +0100 Subject: [PATCH 7/9] Docs: reading the switches --- docs/reference.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/reference.md b/docs/reference.md index 2f3679e..3987dcf 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -42,7 +42,29 @@ import explorer ## Reading the Switches -... +Import the initilised Pin objects from the explorer library. + +```python +from explorer import button_a, button_b, button_c, button_x, button_y, button_z, button_user +``` +You can read the value of the a button using the Pin function `.value()` The buttons are Active Low. So you'll read `0` when the button is being pressed and `1` when it isn't! + +The example below prints out the string `Pressed!` when it detects that Button A has been pressed + +```python +from explorer import button_a +import time + +while True: + + if button_a.value() == 0: + print("Pressed!") + else: + print("Not Pressed") + + time.sleep(1) + +``` ## `explorer` Reference From 8e3073bbd5eba39c2bd2a01c83b46a5ed31c8685 Mon Sep 17 00:00:00 2001 From: thirdr Date: Mon, 14 Oct 2024 10:55:52 +0100 Subject: [PATCH 8/9] Docs: spelling --- docs/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference.md b/docs/reference.md index 3987dcf..f7a7886 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -42,7 +42,7 @@ import explorer ## Reading the Switches -Import the initilised Pin objects from the explorer library. +Import the initialized Pin objects from the explorer library. ```python from explorer import button_a, button_b, button_c, button_x, button_y, button_z, button_user From e6fca7d13282f6ec3f1c910639fdbf077c86ab53 Mon Sep 17 00:00:00 2001 From: thirdr Date: Mon, 14 Oct 2024 11:04:03 +0100 Subject: [PATCH 9/9] Docs: expanded getting started --- docs/reference.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/reference.md b/docs/reference.md index f7a7886..4c43b4b 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -38,7 +38,11 @@ To start coding your Pimoroni Explorer, you will need to add the following line import explorer ``` -... +Alternatively you can import only what you plan to use in your code like so: + +```python +from explorer import display, i2c, button_a +``` ## Reading the Switches