kopia lustrzana https://github.com/pimoroni/pimoroni-pico
commit
ab45fee123
|
@ -102,10 +102,11 @@ We also maintain a C++/CMake boilerplate with GitHub workflows configured for te
|
|||
* Inky Frame 5.7" (7-colour E Ink) - https://shop.pimoroni.com/products/inky-frame-5-7
|
||||
* Automation 2040 W Mini (inputs, outputs and a relay, 6-40V compatible) - https://shop.pimoroni.com/products/automation-2040-w-mini
|
||||
* Plasma Stick 2040 W (bijou LED strip controller) - https://shop.pimoroni.com/products/plasma-stick-2040-w
|
||||
* Galactic Unicorn (dazzling 53 x 11 LED matrix) - https://shop.pimoroni.com/products/galactic-unicorn
|
||||
* Galactic Unicorn (53 x 11 LED matrix) - https://shop.pimoroni.com/products/galactic-unicorn
|
||||
* Interstate 75 W (HUB75 matrix driver) - https://shop.pimoroni.com/products/interstate-75-w
|
||||
* Inky Frame 4.0" (7-colour E Ink) - https://shop.pimoroni.com/products/inky-frame-4
|
||||
* Badger 2040 W (E Ink badge) - https://shop.pimoroni.com/products/badger-2040-w
|
||||
* Cosmic Unicorn (32 x 32 LED matrix) - https://shop.pimoroni.com/products/cosmic-unicorn
|
||||
|
||||
## Breakouts
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# Galactic Unicorn (C/C++)<!-- omit in toc -->
|
||||
# Cosmic Unicorn (C/C++)<!-- omit in toc -->
|
||||
|
||||
Galactic Unicorn offers 53x11 bright RGB LEDs driven by Pico W's PIO in addition to a 1W amplifier + speaker, a collection of system and user buttons, and two Qw/ST connectors for adding external sensors and devices. Woha!
|
||||
Cosmic Unicorn offers 32x32 bright RGB LEDs driven by Pico W's PIO in addition to a 1W amplifier + speaker, a collection of system and user buttons, and two Qw/ST connectors for adding external sensors and devices. Woha!
|
||||
|
||||
You can buy one here: https://shop.pimoroni.com/products/galactic-unicorn
|
||||
You can buy one here: https://shop.pimoroni.com/products/cosmic-unicorn
|
||||
|
||||
## These are not your everyday RGB LEDs!
|
||||
|
||||
Internally Galactic Unicorn applies gamma correction to the supplied image data and updates the display with 14-bit precision resulting in extremely linear visual output - including at the low end.
|
||||
Internally Cosmic Unicorn applies gamma correction to the supplied image data and updates the display with 14-bit precision resulting in extremely linear visual output - including at the low end.
|
||||
|
||||
The display is refreshed around 300 times per second (300fps!) allowing for rock solid stability even when being filmed, no smearing or flickering even when in motion.
|
||||
|
||||
|
@ -14,9 +14,9 @@ No strobing or brightness stepping here folks - it's the perfect backdrop for yo
|
|||
|
||||
## Getting started
|
||||
|
||||
The Galactic Unicorn library provides a collection of methods that allow you to easily access all of the features on the board.
|
||||
The Cosmic Unicorn library provides a collection of methods that allow you to easily access all of the features on the board.
|
||||
|
||||
Drawing is primarily handled via our [PicoGraphics](https://github.com/pimoroni/pimoroni-pico/tree/main/libraries/pico_graphics) library which provides a comprehensive selection of drawing methods - once your drawing work is complete you pass the PicoGraphics object to Galactic Unicorn to have it displayed on the screen.
|
||||
Drawing is primarily handled via our [PicoGraphics](https://github.com/pimoroni/pimoroni-pico/tree/main/libraries/pico_graphics) library which provides a comprehensive selection of drawing methods - once your drawing work is complete you pass the PicoGraphics object to Cosmic Unicorn to have it displayed on the screen.
|
||||
|
||||
- [Example Program](#example-program)
|
||||
- [Interleaved Framebuffer](#interleaved-framebuffer)
|
||||
|
@ -41,7 +41,7 @@ Drawing is primarily handled via our [PicoGraphics](https://github.com/pimoroni/
|
|||
- [`void play_synth()`](#void-play_synth)
|
||||
- [`void stop_playing()`](#void-stop_playing)
|
||||
- [Constants](#constants)
|
||||
- [`WIDTH` & `HEIGHT`](#width--height)
|
||||
- [`WIDTH` \& `HEIGHT`](#width--height)
|
||||
|
||||
# Example Program
|
||||
|
||||
|
@ -52,15 +52,15 @@ The following example shows how to scroll a simple message across the display.
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "libraries/pico_graphics/pico_graphics.hpp"
|
||||
#include "galactic_unicorn.hpp"
|
||||
#include "cosmic_unicorn.hpp"
|
||||
|
||||
using namespace pimoroni;
|
||||
|
||||
// create a PicoGraphics framebuffer to draw into
|
||||
PicoGraphics_PenRGB888 graphics(GalacticUnicorn::WIDTH, GalacticUnicorn::HEIGHT, nullptr);
|
||||
PicoGraphics_PenRGB888 graphics(CosmicUnicorn::WIDTH, CosmicUnicorn::HEIGHT, nullptr);
|
||||
|
||||
// create our GalacticUnicorn object
|
||||
GalacticUnicorn galactic_unicorn;
|
||||
// create our CosmicUnicorn object
|
||||
CosmicUnicorn cosmic_unicorn;
|
||||
|
||||
// message to scroll
|
||||
std::string message = "Pirate. Monkey. Robot. Ninja.";
|
||||
|
@ -69,18 +69,18 @@ int main() {
|
|||
|
||||
stdio_init_all();
|
||||
|
||||
// initialise the GalacticUnicorn object
|
||||
galactic_unicorn.init();
|
||||
// initialise the CosmicUnicorn object
|
||||
cosmic_unicorn.init();
|
||||
|
||||
// start position for scrolling (off the side of the display)
|
||||
float scroll = -(float)GalacticUnicorn::WIDTH;
|
||||
float scroll = -(float)CosmicUnicorn::WIDTH;
|
||||
|
||||
while(true) {
|
||||
// determine the scroll position of the text
|
||||
int width = graphics.measure_text(message, 1);
|
||||
scroll += 0.25f;
|
||||
if(scroll > width) {
|
||||
scroll = -(float)GalacticUnicorn::WIDTH;
|
||||
scroll = -(float)CosmicUnicorn::WIDTH;
|
||||
}
|
||||
|
||||
// clear the graphics object
|
||||
|
@ -92,7 +92,7 @@ int main() {
|
|||
graphics.text(message, Point(0 - scroll, 5), -1, 0.55);
|
||||
|
||||
// update the display
|
||||
galactic_unicorn.update(&graphics);
|
||||
cosmic_unicorn.update(&graphics);
|
||||
|
||||
sleep_ms(10);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ int main() {
|
|||
|
||||
# Interleaved Framebuffer
|
||||
|
||||
Galactic Unicorn takes advantage of the RP2040's PIOs to drive screen updates - this is what gives it the performance it needs to render with 14-bit precision at over 300 frames per second.
|
||||
Cosmic Unicorn takes advantage of the RP2040's PIOs to drive screen updates - this is what gives it the performance it needs to render with 14-bit precision at over 300 frames per second.
|
||||
|
||||
The PIO is a powerful, but limited, tool. It has no way to access memory at random and minimal support for decision making and branching. All it can really do is process a stream of data/instructions in order.
|
||||
|
||||
|
@ -129,7 +129,7 @@ If you're working with our library then you don't need to worry about any of the
|
|||
|
||||
### `void init()`
|
||||
|
||||
Initialise the Galactic Unicorn hardware, interleaved framebuffer, and PIO programs. This function must be called before attempting to do anything else with Galactic Unicorn.
|
||||
Initialise the Cosmic Unicorn hardware, interleaved framebuffer, and PIO programs. This function must be called before attempting to do anything else with Cosmic Unicorn.
|
||||
|
||||
### `void set_brightness(float value)`
|
||||
|
||||
|
@ -146,10 +146,10 @@ Adjust the brightness of the display - `delta` is supplied as a floating point v
|
|||
For example:
|
||||
|
||||
```c++
|
||||
galactic.set_brightness(0.5f);
|
||||
galactic.adjust_brightness(0.1f); // brightness is now 0.6
|
||||
galactic.adjust_brightness(0.7f); // brightness is now 1.0
|
||||
galactic.adjust_brightness(-0.2f); // brightness is now 0.8
|
||||
cosmic.set_brightness(0.5f);
|
||||
cosmic.adjust_brightness(0.1f); // brightness is now 0.6
|
||||
cosmic.adjust_brightness(0.7f); // brightness is now 1.0
|
||||
cosmic.adjust_brightness(-0.2f); // brightness is now 0.8
|
||||
```
|
||||
|
||||
### `void set_volume(float value)`
|
||||
|
@ -167,10 +167,10 @@ Adjust the volume - `delta` is supplied as a floating point value and will be ad
|
|||
For example:
|
||||
|
||||
```c++
|
||||
galactic.set_volume(0.5f);
|
||||
galactic.adjust_volume(0.1f); // volume is now 0.6
|
||||
galactic.adjust_volume(0.7f); // volume is now 1.0
|
||||
galactic.adjust_volume(-0.2f); // volume is now 0.8
|
||||
cosmic.set_volume(0.5f);
|
||||
cosmic.adjust_volume(0.1f); // volume is now 0.6
|
||||
cosmic.adjust_volume(0.7f); // volume is now 1.0
|
||||
cosmic.adjust_volume(-0.2f); // volume is now 0.8
|
||||
```
|
||||
|
||||
### `uint16_t light()`
|
||||
|
@ -181,7 +181,7 @@ Get the current value seen by the onboard light sensor as a value between `0` an
|
|||
|
||||
Returns true if the requested `button` is currently pressed.
|
||||
|
||||
There are a set of constants on the GalacticUnicorn class that represent each of the buttons. The brightness, sleep, and volume buttons are not tied to hardware functions (they are implemented entirely in software) so can also be used for user functions if preferred.
|
||||
There are a set of constants on the CosmicUnicorn class that represent each of the buttons. The brightness, sleep, and volume buttons are not tied to hardware functions (they are implemented entirely in software) so can also be used for user functions if preferred.
|
||||
|
||||
```c++
|
||||
static const uint8_t SWITCH_A = 0;
|
||||
|
@ -198,7 +198,7 @@ static const uint8_t SWITCH_BRIGHTNESS_DOWN = 26;
|
|||
For example:
|
||||
|
||||
```c++
|
||||
while(!galactic.is_pressed(GalacticUnicorn::SWITCH_A)) {
|
||||
while(!cosmic.is_pressed(CosmicUnicorn::SWITCH_A)) {
|
||||
// wait for switch A to be pressed
|
||||
}
|
||||
printf("We did it! We pressed switch A! Heck yeah!");
|
||||
|
@ -208,7 +208,7 @@ printf("We did it! We pressed switch A! Heck yeah!");
|
|||
|
||||
### `void update(PicoGraphics *graphics)`
|
||||
|
||||
**This is our recommended way to update the image on Galactic Unicorn.** The PicoGraphics library provides a collection of powerful drawing methods to make things simple.
|
||||
**This is our recommended way to update the image on Cosmic Unicorn.** The PicoGraphics library provides a collection of powerful drawing methods to make things simple.
|
||||
|
||||
The image on the PicoGraphics object provided is copied to the interleaved framebuffer with gamma correction applied. This lets you have multiple PicoGraphics objects on the go at once and switch between them by changing which gets passed into this function.
|
||||
|
||||
|
@ -216,7 +216,7 @@ If however you'd rather twiddle individual pixels (for example you're producing
|
|||
|
||||
### `void clear()`
|
||||
|
||||
Clear the contents of the interleaved framebuffer. This will make your Galactic Unicorn display turn off when the next frame is displayed.
|
||||
Clear the contents of the interleaved framebuffer. This will make your Cosmic Unicorn display turn off when the next frame is displayed.
|
||||
|
||||
If you're using PicoGraphics to build your image (recommended!) then you won't need to call this method as you'll overwrite the entire display when you call `update()` anyway.
|
||||
|
||||
|
@ -250,10 +250,10 @@ Stops any currently playing audio.
|
|||
|
||||
### `WIDTH` & `HEIGHT`
|
||||
|
||||
The width and height of Galactic Unicorn are available in constants `WIDTH` and `HEIGHT`.
|
||||
The width and height of Cosmic Unicorn are available in constants `WIDTH` and `HEIGHT`.
|
||||
|
||||
For example:
|
||||
|
||||
```c++
|
||||
int num_pixels = GalacticUnicorn::WIDTH * GalacticUnicorn::HEIGHT;
|
||||
int num_pixels = CosmicUnicorn::WIDTH * CosmicUnicorn::HEIGHT;
|
||||
```
|
|
@ -1,7 +1,7 @@
|
|||
# Galactic Unicorn MicroPython Examples <!-- omit in toc -->
|
||||
# Cosmic Unicorn MicroPython Examples <!-- omit in toc -->
|
||||
|
||||
- [About Galactic Unicorn](#about-galactic-unicorn)
|
||||
- [Galactic Unicorn and PicoGraphics](#galactic-unicorn-and-picographics)
|
||||
- [About Cosmic Unicorn](#about-cosmic-unicorn)
|
||||
- [Cosmic Unicorn and PicoGraphics](#cosmic-unicorn-and-picographics)
|
||||
- [Examples](#examples)
|
||||
- [Clock](#clock)
|
||||
- [Eighties Super Computer](#eighties-super-computer)
|
||||
|
@ -12,29 +12,33 @@
|
|||
- [Nostalgia Prompt](#nostalgia-prompt)
|
||||
- [Rainbow](#rainbow)
|
||||
- [Scrolling Text](#scrolling-text)
|
||||
- [Today](#today)
|
||||
- [Wireless Examples](#wireless-examples)
|
||||
- [Cheerlights History](#cheerlights-history)
|
||||
- [Galactic Paint](#galactic-paint)
|
||||
- [Cosmic Paint](#cosmic-paint)
|
||||
- [Exchange Ticker](#exchange-ticker)
|
||||
- [HTTP Text](#http-text)
|
||||
- [Weather](#weather)
|
||||
- [NumPy examples](#numpy-examples)
|
||||
- [Other Examples](#other-examples)
|
||||
- [Launch (Demo Reel)](#launch-demo-reel)
|
||||
- [Other Resources](#other-resources)
|
||||
|
||||
## About Galactic Unicorn
|
||||
## About Cosmic Unicorn
|
||||
|
||||
Galactic Unicorn offers 53x11 bright RGB LEDs driven by Pico W's PIO in addition to a 1W amplifier + speaker, a collection of system and user buttons, and two Qw/ST connectors for adding external sensors and devices. Woha!
|
||||
Cosmic Unicorn offers 32x32 bright RGB LEDs driven by Pico W's PIO in addition to a 1W amplifier + speaker, a collection of system and user buttons, and two Qw/ST connectors for adding external sensors and devices. Woha!
|
||||
|
||||
- :link: [Galactic Unicorn store page](https://shop.pimoroni.com/products/galactic-unicorn)
|
||||
- :link: [Cosmic Unicorn store page](https://shop.pimoroni.com/products/cosmic-unicorn)
|
||||
|
||||
Galactic Unicorn ships with MicroPython firmware pre-loaded, but you can download the most recent version at the link below (you'll want the `galactic-unicorn` image).
|
||||
Cosmic Unicorn ships with MicroPython firmware pre-loaded, but you can download the most recent version at the link below (you'll want the `cosmic-unicorn` image).
|
||||
|
||||
- [MicroPython releases](https://github.com/pimoroni/pimoroni-pico/releases)
|
||||
- [Installing MicroPython](../../../setting-up-micropython.md)
|
||||
|
||||
## Galactic Unicorn and PicoGraphics
|
||||
## Cosmic Unicorn and PicoGraphics
|
||||
|
||||
The easiest way to start displaying cool stuff on Galactic Unicorn is using our Galactic Unicorn module (which contains a bunch of helpful functions for interacting with the buttons, adjusting brightness and suchlike) and our PicoGraphics library, which is chock full of useful functions for drawing on the LED matrix.
|
||||
The easiest way to start displaying cool stuff on Cosmic Unicorn is using our Cosmic Unicorn module (which contains a bunch of helpful functions for interacting with the buttons, adjusting brightness and suchlike) and our PicoGraphics library, which is chock full of useful functions for drawing on the LED matrix.
|
||||
|
||||
- [Galactic Unicorn function reference](../../modules/galactic_unicorn/README.md)
|
||||
- [Cosmic Unicorn function reference](../../modules/cosmic_unicorn/README.md)
|
||||
- [PicoGraphics function reference](../../modules/picographics/README.md)
|
||||
|
||||
## Examples
|
||||
|
@ -98,9 +102,15 @@ Some good old fashioned rainbows! You can adjust the cycling speed with A and B,
|
|||
|
||||
Display scrolling wisdom, quotes or greetz. You can adjust the brightness with LUX + and -.
|
||||
|
||||
### Today
|
||||
|
||||
[today.py](today.py)
|
||||
|
||||
Calendar example with (optional) NTP synchronization. You can adjust the brightness with LUX + and -, and resync the date by pressing C.
|
||||
|
||||
## Wireless Examples
|
||||
|
||||
These examples need `WIFI_CONFIG.py` (from the `common` directory) to be saved to your Pico W. Open up `WIFI_CONFIG.py` in Thonny to add your wifi details (and save it when you're done).
|
||||
These examples need `WIFI_CONFIG.py` and `network_manager.py` (from the `common` directory) to be saved to your Pico W. Open up `WIFI_CONFIG.py` in Thonny to add your wifi details (and save it when you're done).
|
||||
|
||||
- [micropython/examples/common](../../examples/common)
|
||||
|
||||
|
@ -108,19 +118,47 @@ These examples need `WIFI_CONFIG.py` (from the `common` directory) to be saved t
|
|||
|
||||
[cheerlights_history.py](cheerlights_history.py)
|
||||
|
||||
Updates one pixel every five minutes to display the most recent #Cheerlights colour. Discover the most popular colours over time, or use it as an avant garde (but colourful) 53 hour clock! Find out more about the Cheerlights API at https://cheerlights.com/
|
||||
|
||||
Requires `WIFI_CONFIG.py` and `network_manager.py` from the `common` directory.
|
||||
Updates one pixel every two minutes to display the most recent #Cheerlights colour. Discover the most popular colours over time, or use it as an avant garde (but colourful) 32 hour clock! Find out more about the Cheerlights API at https://cheerlights.com/
|
||||
|
||||
You can adjust the brightness with LUX + and -.
|
||||
|
||||
### Galactic Paint
|
||||
### Cosmic Paint
|
||||
|
||||
[galactic_paint](galactic_paint)
|
||||
[cosmic_paint](cosmic_paint)
|
||||
|
||||
Draw on your Galactic Unicorn from another device in real time, over wifi!
|
||||
Draw on your Cosmic Unicorn from another device in real time, over wifi!
|
||||
|
||||
Requires `WIFI_CONFIG.py` from the `common` directory. It also needs the `micropython-phew` and `microdot` libraries (you can install these using Thonny's 'Tools > Manage Packages').
|
||||
This example needs the `micropython-phew` and `microdot` libraries (you can install these using Thonny's 'Tools > Manage Packages').
|
||||
|
||||
### Exchange Ticker
|
||||
|
||||
[exchange_ticker.py](exchange_ticker.py)
|
||||
|
||||
This example uses the Coinbase open API to collect the current exchange rates of various cryptocurrencies.
|
||||
|
||||
Press A to change to a different base exchange currency.
|
||||
|
||||
### HTTP Text
|
||||
|
||||
[http_text](http_text)
|
||||
|
||||
Display scrolling wisdom, quotes or greetz... from another computer or device!
|
||||
|
||||
You can adjust the brightness with LUX + and -.
|
||||
|
||||
Requires `logging.mpy` and `tinyweb` from [micropython/examples/common](../../examples/common) - copy these into the `lib` folder on your Pico W. You'll also need `index.html` to be saved alongside `html_text.py`.
|
||||
|
||||
### Weather
|
||||
|
||||
[weather](weather)
|
||||
|
||||
Display current weather data from the [Open-Meteo](https://open-meteo.com/) weather API.
|
||||
|
||||
## NumPy examples
|
||||
|
||||
[numpy](numpy)
|
||||
|
||||
The examples in the folder use `numpy`-like array functions contained in the `ulab` library for super fast graphical effects.
|
||||
|
||||
## Other Examples
|
||||
|
||||
|
@ -128,15 +166,4 @@ Requires `WIFI_CONFIG.py` from the `common` directory. It also needs the `microp
|
|||
|
||||
[launch](launch)
|
||||
|
||||
If you want to get the demo reel that Galactic Unicorn ships with back, copy the contents of this `launch` folder to your Pico W.
|
||||
|
||||
## Other Resources
|
||||
|
||||
Here are some cool Galactic Unicorn community projects and resources that you might find useful / inspirational! Note that code at the links below has not been tested by us and we're not able to offer support with it.
|
||||
|
||||
- :link: [Galactic Unicorn MQTT scroller (and 3D printed case)](https://github.com/ucl-casa-ce/Galactic-Unicorn-MQTT-Scroller)
|
||||
- :link: [Compiling custom pimoroni-pico MicroPython (with ulab)](https://medium.com/@iestynlloyd/galactic-unicorns-and-custom-pimoroni-pico-firmware-38dd7c5913b8)
|
||||
- :link: [Galactic Unicorn Graphical Workout](https://www.instructables.com/Galactic-Unicorn-Graphical-Workout/)
|
||||
- :link: [Galactic Unicorn Bounce - Simple GFX Demo](https://www.instructables.com/Galactic-Unicorn-Bounce-Simple-GFX-Demo/)
|
||||
- :link: [Cheerlights + Galactic Unicorn + MicroPython (beginner-friendly tutorial)](https://cheerlights.com/cheerlights-raspberry-pi-pico-w-micropython/)
|
||||
- :link: [CheerClock (plus laser-cut templates for a fancy case/diffuser)](https://github.com/seanosteen/CheerClock)
|
||||
If you want to get the demo reel that Cosmic Unicorn ships with back, copy the contents of this `launch` folder to your Pico W.
|
|
@ -1,6 +1,6 @@
|
|||
# This Cosmic Unicorn example updates a pixel every five(ish) minutes
|
||||
# This Cosmic Unicorn example updates a pixel every two(ish) minutes
|
||||
# to display the most recent #cheerlights colour. Discover the most popular
|
||||
# colours over time, or use it as an avant garde (but colourful) 53 hour clock!
|
||||
# colours over time, or use it as an avant garde (but colourful) 32 hour clock!
|
||||
# Find out more about the Cheerlights API at https://cheerlights.com/
|
||||
#
|
||||
# To run this example you'll need WIFI_CONFIG.py and network_manager.py from
|
||||
|
@ -77,17 +77,17 @@ def update_leds():
|
|||
graphics.set_pen(current_colour)
|
||||
graphics.pixel(x, y)
|
||||
i = i + 1
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
print("LEDs updated!")
|
||||
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
height = CosmicUnicorn.HEIGHT
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
# set up the Pico W's onboard LED
|
||||
pico_led = Pin('LED', Pin.OUT)
|
||||
|
@ -114,15 +114,15 @@ timer.init(period=UPDATE_INTERVAL * 1000, mode=Timer.PERIODIC, callback=lambda t
|
|||
while True:
|
||||
# adjust brightness with LUX + and -
|
||||
# LEDs take a couple of secs to update, so adjust in big (10%) steps
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.1)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.1)
|
||||
update_leds()
|
||||
print(f"Brightness set to {gu.get_brightness()}")
|
||||
print(f"Brightness set to {cu.get_brightness()}")
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.1)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.1)
|
||||
update_leds()
|
||||
print(f"Brightness set to {gu.get_brightness()}")
|
||||
print(f"Brightness set to {cu.get_brightness()}")
|
||||
|
||||
# pause for a moment (important or the USB serial device will fail)
|
||||
time.sleep(0.001)
|
||||
|
|
|
@ -37,8 +37,8 @@ MIDDAY_VALUE = 0.8
|
|||
MIDNIGHT_VALUE = 0.3
|
||||
|
||||
|
||||
# create galactic object and graphics surface for drawing
|
||||
gu = CosmicUnicorn()
|
||||
# create cosmic object and graphics surface for drawing
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
# create the rtc object
|
||||
|
@ -131,7 +131,7 @@ def sync_time():
|
|||
time.sleep(0.2)
|
||||
|
||||
redraw_display_if_reqd()
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
if max_wait > 0:
|
||||
print("Connected")
|
||||
|
@ -195,9 +195,6 @@ def redraw_display_if_reqd():
|
|||
|
||||
clock = "{:02}:{:02}:{:02}".format(hour, minute, second)
|
||||
|
||||
# set the font
|
||||
graphics.set_font("bitmap8")
|
||||
|
||||
# calculate text position so that it is centred
|
||||
w = graphics.measure_text(clock, 1)
|
||||
x = int(width / 2 - w / 2 + 1)
|
||||
|
@ -208,23 +205,25 @@ def redraw_display_if_reqd():
|
|||
last_second = second
|
||||
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
# set the font
|
||||
graphics.set_font("bitmap8")
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
sync_time()
|
||||
|
||||
while True:
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
sync_time()
|
||||
|
||||
redraw_display_if_reqd()
|
||||
|
||||
# update the display
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
time.sleep(0.01)
|
||||
|
|
|
@ -10,7 +10,7 @@ super computer doing its work in the eighties.
|
|||
You can adjust the brightness with LUX + and -.
|
||||
'''
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
colour = (230, 150, 0)
|
||||
|
@ -42,7 +42,7 @@ def draw():
|
|||
graphics.set_pen(0)
|
||||
graphics.pixel(x, y)
|
||||
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
@micropython.native # noqa: F821
|
||||
|
@ -58,15 +58,15 @@ def update():
|
|||
|
||||
setup()
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
while True:
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
start = time.ticks_ms()
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ Displays some text, gradients and colours and demonstrates button use.
|
|||
You can adjust the brightness with LUX + and -.
|
||||
'''
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
|
@ -57,18 +57,18 @@ def outline_text(text):
|
|||
graphics.text(text, x, y, -1, 1)
|
||||
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
while True:
|
||||
|
||||
time_ms = time.ticks_ms()
|
||||
test = (time_ms // 1000) % 5
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
graphics.set_pen(graphics.create_pen(0, 0, 0))
|
||||
graphics.clear()
|
||||
|
@ -91,33 +91,33 @@ while True:
|
|||
|
||||
text = ""
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
text = "Button A"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_B):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_B):
|
||||
text = "Button B"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
text = "Button C"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_D):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_D):
|
||||
text = "Button D"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_UP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_UP):
|
||||
text = "Louder!"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_DOWN):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_DOWN):
|
||||
text = "Quieter"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
text = "Brighter!"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
text = "Darker"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_SLEEP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_SLEEP):
|
||||
text = "Zzz... zzz..."
|
||||
|
||||
outline_text(text)
|
||||
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
|
|
@ -18,7 +18,7 @@ Also demonstrates some of the audio / synth features.
|
|||
|
||||
gc.collect()
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
|
@ -56,7 +56,7 @@ bass_notes = (
|
|||
SUB, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, SUB, -1, SUB, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, SUB, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, SUB, -1, SUB, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, SUB, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, SUB, -1, SUB, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, SUB, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, SUB, -1, SUB, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0)
|
||||
|
||||
notes = [melody_notes, rhythm_notes, drum_beats, hi_hat, bass_notes]
|
||||
channels = [gu.synth_channel(i) for i in range(len(notes) + 1)] # Extra channel for tones
|
||||
channels = [cu.synth_channel(i) for i in range(len(notes) + 1)] # Extra channel for tones
|
||||
|
||||
# Configure the synth to play our notes
|
||||
channels[0].configure(waveforms=Channel.TRIANGLE + Channel.SQUARE,
|
||||
|
@ -136,7 +136,7 @@ def outline_text(text):
|
|||
graphics.text(text, x, y, -1, 1)
|
||||
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
# Vars for storing button state
|
||||
was_a_pressed = False
|
||||
|
@ -181,7 +181,7 @@ while True:
|
|||
time_ms = time.ticks_ms()
|
||||
test = (time_ms // 1000) % 5
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
if not was_a_pressed:
|
||||
channels[0].volume(10000 / 65535)
|
||||
channels[1].volume(12000 / 65535)
|
||||
|
@ -195,7 +195,7 @@ while True:
|
|||
beat = 0
|
||||
next_beat()
|
||||
|
||||
gu.play_synth()
|
||||
cu.play_synth()
|
||||
synthing = True
|
||||
timer.init(freq=10, mode=Timer.PERIODIC, callback=tick)
|
||||
|
||||
|
@ -203,7 +203,7 @@ while True:
|
|||
else:
|
||||
was_a_pressed = False
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_B):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_B):
|
||||
if not was_b_pressed:
|
||||
channels[0].volume(0)
|
||||
channels[1].volume(12000 / 65535)
|
||||
|
@ -217,7 +217,7 @@ while True:
|
|||
beat = 0
|
||||
next_beat()
|
||||
|
||||
gu.play_synth()
|
||||
cu.play_synth()
|
||||
synthing = True
|
||||
timer.init(freq=10, mode=Timer.PERIODIC, callback=tick)
|
||||
|
||||
|
@ -225,7 +225,7 @@ while True:
|
|||
else:
|
||||
was_b_pressed = False
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
if not was_c_pressed:
|
||||
# Stop synth (if running) and play Tone A
|
||||
timer.deinit()
|
||||
|
@ -233,14 +233,14 @@ while True:
|
|||
channels[5].play_tone(tone_a, 0.06)
|
||||
channels[5].volume(12000 / 65535)
|
||||
|
||||
gu.play_synth()
|
||||
cu.play_synth()
|
||||
synthing = False
|
||||
|
||||
was_c_pressed = True
|
||||
else:
|
||||
was_c_pressed = False
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_D):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_D):
|
||||
if not was_d_pressed:
|
||||
# Stop synth (if running) and play Tone B
|
||||
timer.deinit()
|
||||
|
@ -249,43 +249,43 @@ while True:
|
|||
channels[5].play_tone(tone_b, 0.06, attack=0.5)
|
||||
channels[5].volume(12000 / 65535)
|
||||
|
||||
gu.play_synth()
|
||||
cu.play_synth()
|
||||
synthing = False
|
||||
|
||||
was_d_pressed = True
|
||||
else:
|
||||
was_d_pressed = False
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
if tone_b > 0: # Zero means tone not playing
|
||||
# Increase Tone B
|
||||
tone_b = min(tone_b + 10, 20000)
|
||||
channels[5].frequency(tone_b)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
if tone_b > 0: # Zero means tone not playing
|
||||
# Decrease Tone B
|
||||
tone_b = max(tone_b - 10, 10)
|
||||
channels[5].frequency(max(tone_b, 10))
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_UP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_UP):
|
||||
if tone_a > 0: # Zero means tone not playing
|
||||
# Increase Tone A
|
||||
tone_a = min(tone_a + 10, 20000)
|
||||
channels[5].frequency(tone_a)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_DOWN):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_DOWN):
|
||||
if tone_a > 0: # Zero means tone not playing
|
||||
# Decrease Tone A
|
||||
tone_a = max(tone_a - 10, 10)
|
||||
channels[5].frequency(tone_a)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_SLEEP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_SLEEP):
|
||||
if not was_z_pressed:
|
||||
# Stop synth and both tones
|
||||
tone_a = 0
|
||||
tone_b = 0
|
||||
gu.stop_playing()
|
||||
cu.stop_playing()
|
||||
timer.deinit()
|
||||
synthing = False
|
||||
|
||||
|
@ -312,36 +312,36 @@ while True:
|
|||
# print("white gradient")
|
||||
gradient(255, 255, 255)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
text = "PlaySyn"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_B):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_B):
|
||||
text = "SoloSyn"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
text = "Tone A"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_D):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_D):
|
||||
text = "Tone B"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_UP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_UP):
|
||||
text = "RaiseA"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_DOWN):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_DOWN):
|
||||
text = "LowerA"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
text = "RaiseB"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
text = "LowerB"
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_SLEEP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_SLEEP):
|
||||
text = "Stop"
|
||||
|
||||
outline_text(text)
|
||||
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
# pause for a moment (important or the USB serial device will fail
|
||||
time.sleep(0.001)
|
||||
|
|
|
@ -9,7 +9,7 @@ A pretty, procedural fire effect.
|
|||
You can adjust the brightness with LUX + and -.
|
||||
'''
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
fire_colours = [graphics.create_pen(0, 0, 0),
|
||||
|
@ -71,7 +71,7 @@ def draw():
|
|||
_set_pen(_fire_colours[4])
|
||||
_pixel(x, y)
|
||||
|
||||
gu.update(_graphics)
|
||||
cu.update(_graphics)
|
||||
|
||||
|
||||
width = CosmicUnicorn.WIDTH + 2
|
||||
|
@ -81,15 +81,15 @@ fire_spawns = 5
|
|||
damping_factor = 0.97
|
||||
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
while True:
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
start = time.ticks_ms()
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ A 70s-tastic, procedural rainbow lava lamp.
|
|||
You can adjust the brightness with LUX + and -.
|
||||
'''
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
blob_count = 10
|
||||
|
@ -121,22 +121,22 @@ def draw_portrait():
|
|||
graphics.set_pen(0)
|
||||
graphics.pixel(y, x)
|
||||
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
setup_portrait()
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
while True:
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
setup_portrait()
|
||||
|
||||
start = time.ticks_ms()
|
||||
|
|
|
@ -9,7 +9,7 @@ pixel by pixel from a pattern of Os and Xs.
|
|||
You can adjust the brightness with LUX + and -.
|
||||
'''
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
prompt_x = 0
|
||||
|
@ -125,21 +125,21 @@ def draw(image, fg, bg, time_ms):
|
|||
|
||||
graphics.pixel(x + prompt_x, y + prompt_y)
|
||||
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
while True:
|
||||
|
||||
time_ms = time.ticks_ms()
|
||||
prompt = (time_ms // 3000) % 3
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
start = time.ticks_ms()
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ Play with the number of spawns, heat, damping factor and colour palette to tweak
|
|||
# MAXIMUM OVERKILL
|
||||
# machine.freq(250_000_000)
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
gu.set_brightness(0.5)
|
||||
cu = CosmicUnicorn()
|
||||
cu.set_brightness(0.5)
|
||||
graphics = PicoGraphics(DISPLAY_COSMIC_UNICORN, pen_type=PEN_P8)
|
||||
|
||||
# Number of random fire spawns
|
||||
|
@ -79,7 +79,7 @@ def draw():
|
|||
# Multiplies it by the number of palette entries (-1) to turn it into a palette index
|
||||
# Converts to uint8_t datatype to match the framebuffer
|
||||
memoryview(graphics)[:] = numpy.ndarray(numpy.clip(heat[0:32, 0:32], 0, 1) * (PALETTE_SIZE - 1), dtype=numpy.uint8).tobytes()
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
|
@ -92,11 +92,11 @@ t_total = 0
|
|||
while True:
|
||||
gc.collect()
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
tstart = time.ticks_ms()
|
||||
gc.collect()
|
||||
|
|
|
@ -13,9 +13,9 @@ A lava lamp effect, created by blurred, moving particles.
|
|||
# MAXIMUM OVERKILL
|
||||
# machine.freq(250_000_000)
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY_COSMIC_UNICORN, pen_type=PEN_P8)
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
height = CosmicUnicorn.HEIGHT
|
||||
|
@ -77,18 +77,18 @@ def draw():
|
|||
# Multiplies by palette entries (-1) to turn it into a palette index
|
||||
# Converts to uint8_t datatype to match the framebuffer
|
||||
memoryview(graphics)[:] = numpy.ndarray(numpy.clip(lava, 0.0, 1.0) * (PAL_COLS - 1), dtype=numpy.uint8).tobytes()
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
t_count = 0
|
||||
t_total = 0
|
||||
|
||||
while True:
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
tstart = time.ticks_ms()
|
||||
gc.collect()
|
||||
|
|
|
@ -12,8 +12,8 @@ HELLO NEO.
|
|||
# MAXIMUM OVERKILL
|
||||
# machine.freq(250_000_000)
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
gu.set_brightness(1.0)
|
||||
cu = CosmicUnicorn()
|
||||
cu.set_brightness(1.0)
|
||||
graphics = PicoGraphics(DISPLAY_COSMIC_UNICORN, pen_type=PEN_P8)
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ def update():
|
|||
def draw():
|
||||
# Copy the effect to the framebuffer
|
||||
memoryview(graphics)[:] = numpy.ndarray(numpy.clip(trippy, 0, 1) * 254, dtype=numpy.uint8).tobytes()
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
|
@ -55,11 +55,11 @@ t_total = 0
|
|||
|
||||
|
||||
while True:
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
tstart = time.ticks_ms()
|
||||
gc.collect()
|
||||
|
|
|
@ -12,8 +12,8 @@ THIS IS FINE!
|
|||
# MAXIMUM OVERKILL
|
||||
# machine.freq(250_000_000)
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
gu.set_brightness(0.5)
|
||||
cu = CosmicUnicorn()
|
||||
cu.set_brightness(0.5)
|
||||
graphics = PicoGraphics(DISPLAY_COSMIC_UNICORN, pen_type=PEN_P8)
|
||||
|
||||
# Number of random fire spawns
|
||||
|
@ -84,7 +84,7 @@ def draw():
|
|||
graphics.text("This", 6, 4, 1, 1)
|
||||
graphics.text("is", 11, 12, 1, 1)
|
||||
graphics.text("fine", 6, 20, 1, 1)
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
|
@ -97,11 +97,11 @@ t_total = 0
|
|||
while True:
|
||||
gc.collect()
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
tstart = time.ticks_ms()
|
||||
gc.collect()
|
||||
|
|
|
@ -13,8 +13,8 @@ Experiment with the damping, number of spawns, intensity and offset to change th
|
|||
# MAXIMUM OVERKILL
|
||||
# machine.freq(250_000_000)
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
gu.set_brightness(0.5)
|
||||
cu = CosmicUnicorn()
|
||||
cu.set_brightness(0.5)
|
||||
graphics = PicoGraphics(DISPLAY_COSMIC_UNICORN, pen_type=PEN_P8)
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ def update():
|
|||
def draw():
|
||||
# Copy the effect to the framebuffer
|
||||
memoryview(graphics)[:] = numpy.ndarray(numpy.clip(trippy, 0, 1) * (PALETTE_ENTRIES - 1), dtype=numpy.uint8).tobytes()
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
|
@ -63,11 +63,11 @@ t_total = 0
|
|||
|
||||
|
||||
while True:
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
tstart = time.ticks_ms()
|
||||
gc.collect()
|
||||
|
|
|
@ -12,7 +12,7 @@ and the brightness with LUX + and -.
|
|||
The sleep button stops the animation (can be started again with A or B).
|
||||
'''
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
width = CosmicUnicorn.WIDTH
|
||||
|
@ -55,7 +55,7 @@ def draw():
|
|||
graphics.set_pen(graphics.create_pen(int(colour[0] * v), int(colour[1] * v), int(colour[2] * v)))
|
||||
graphics.pixel(x, y)
|
||||
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
hue_map = [from_hsv(x / width, 1.0, 1.0) for x in range(width)]
|
||||
|
@ -65,7 +65,7 @@ animate = True
|
|||
stripe_width = 3.0
|
||||
speed = 1.0
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
phase = 0
|
||||
while True:
|
||||
|
@ -73,38 +73,38 @@ while True:
|
|||
if animate:
|
||||
phase += speed
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_UP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_UP):
|
||||
hue_offset += 0.01
|
||||
hue_offset = 1.0 if hue_offset > 1.0 else hue_offset
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_DOWN):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_VOLUME_DOWN):
|
||||
hue_offset -= 0.01
|
||||
hue_offset = 0.0 if hue_offset < 0.0 else hue_offset
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_SLEEP):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_SLEEP):
|
||||
animate = False
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
speed += 0.05
|
||||
speed = 10.0 if speed > 10.0 else speed
|
||||
animate = True
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_B):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_B):
|
||||
speed -= 0.05
|
||||
speed = 0.0 if speed < 0.0 else speed
|
||||
animate = True
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
stripe_width += 0.05
|
||||
stripe_width = 10.0 if stripe_width > 10.0 else stripe_width
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_D):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_D):
|
||||
stripe_width -= 0.05
|
||||
stripe_width = 1.0 if stripe_width < 1.0 else stripe_width
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import time
|
||||
from galactic import GalacticUnicorn
|
||||
from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN as DISPLAY
|
||||
from cosmic import CosmicUnicorn
|
||||
from picographics import PicoGraphics, DISPLAY_COSMIC_UNICORN as DISPLAY
|
||||
|
||||
'''
|
||||
Display scrolling wisdom, quotes or greetz.
|
||||
|
@ -17,12 +17,12 @@ MESSAGE = "\"Space is big. Really big. You just won't believe how vastly hugely
|
|||
HOLD_TIME = 2.0
|
||||
STEP_TIME = 0.075
|
||||
|
||||
# create galactic object and graphics surface for drawing
|
||||
gu = GalacticUnicorn()
|
||||
# create cosmic object and graphics surface for drawing
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
width = GalacticUnicorn.WIDTH
|
||||
height = GalacticUnicorn.HEIGHT
|
||||
width = CosmicUnicorn.WIDTH
|
||||
height = CosmicUnicorn.HEIGHT
|
||||
|
||||
|
||||
# function for drawing outlined text
|
||||
|
@ -41,7 +41,7 @@ def outline_text(text, x, y):
|
|||
graphics.text(text, x, y, -1, 1)
|
||||
|
||||
|
||||
gu.set_brightness(0.5)
|
||||
cu.set_brightness(0.5)
|
||||
|
||||
# state constants
|
||||
STATE_PRE_SCROLL = 0
|
||||
|
@ -62,11 +62,11 @@ last_time = time.ticks_ms()
|
|||
while True:
|
||||
time_ms = time.ticks_ms()
|
||||
|
||||
if gu.is_pressed(GalacticUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(GalacticUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
if state == STATE_PRE_SCROLL and time_ms - last_time > HOLD_TIME * 1000:
|
||||
if msg_width + PADDING * 2 >= width:
|
||||
|
@ -90,7 +90,7 @@ while True:
|
|||
outline_text(MESSAGE, x=PADDING - shift, y=2)
|
||||
|
||||
# update the display
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
# pause for a moment (important or the USB serial device will fail)
|
||||
time.sleep(0.001)
|
||||
|
|
|
@ -6,11 +6,11 @@ import machine
|
|||
from cosmic import CosmicUnicorn
|
||||
from picographics import PicoGraphics, DISPLAY_COSMIC_UNICORN as DISPLAY
|
||||
|
||||
gu = CosmicUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(DISPLAY)
|
||||
|
||||
# Default Brightness
|
||||
gu.set_brightness(0.4)
|
||||
cu.set_brightness(0.4)
|
||||
|
||||
# You will need to create or update the file secrets.py with your network credentials using Thonny
|
||||
# in order for the example to update using the NTP.
|
||||
|
@ -106,7 +106,7 @@ def draw():
|
|||
|
||||
graphics.set_pen(graphics.create_pen(0, 0, 0))
|
||||
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
|
||||
init()
|
||||
|
@ -114,14 +114,14 @@ init()
|
|||
while 1:
|
||||
|
||||
# Adjust Brightness +/-
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
|
||||
# Connect to the network and sync with the NTP server
|
||||
if gu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_C):
|
||||
sync_time()
|
||||
|
||||
draw()
|
||||
|
|
|
@ -195,9 +195,6 @@ def redraw_display_if_reqd():
|
|||
|
||||
clock = "{:02}:{:02}:{:02}".format(hour, minute, second)
|
||||
|
||||
# set the font
|
||||
graphics.set_font("bitmap8")
|
||||
|
||||
# calculate text position so that it is centred
|
||||
w = graphics.measure_text(clock, 1)
|
||||
x = int(width / 2 - w / 2 + 1)
|
||||
|
@ -208,6 +205,8 @@ def redraw_display_if_reqd():
|
|||
last_second = second
|
||||
|
||||
|
||||
# set the font
|
||||
graphics.set_font("bitmap8")
|
||||
gu.set_brightness(0.5)
|
||||
|
||||
sync_time()
|
||||
|
|
|
@ -252,7 +252,7 @@ while True:
|
|||
was_c_pressed = False
|
||||
|
||||
if gu.is_pressed(GalacticUnicorn.SWITCH_D):
|
||||
if not was_c_pressed:
|
||||
if not was_d_pressed:
|
||||
# Stop synth (if running) and play Tone B
|
||||
timer.deinit()
|
||||
tone_b = 600
|
||||
|
@ -291,7 +291,7 @@ while True:
|
|||
channels[0].frequency(tone_a)
|
||||
|
||||
if gu.is_pressed(GalacticUnicorn.SWITCH_SLEEP):
|
||||
if not was_d_pressed:
|
||||
if not was_z_pressed:
|
||||
# Stop synth and both tones
|
||||
tone_a = 0
|
||||
tone_b = 0
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# Galactic Unicorn (MicroPython) <!-- omit in toc -->
|
||||
# Cosmic Unicorn (MicroPython) <!-- omit in toc -->
|
||||
|
||||
Galactic Unicorn offers 53x11 bright RGB LEDs driven by Pico W's PIO in addition to a 1W amplifier + speaker, a collection of system and user buttons, and two Qw/ST connectors for adding external sensors and devices. Woha!
|
||||
Cosmic Unicorn offers 32x32 bright RGB LEDs driven by Pico W's PIO in addition to a 1W amplifier + speaker, a collection of system and user buttons, and two Qw/ST connectors for adding external sensors and devices. Woha!
|
||||
|
||||
You can buy one here: https://shop.pimoroni.com/products/galactic-unicorn
|
||||
You can buy one here: https://shop.pimoroni.com/products/cosmic-unicorn
|
||||
|
||||
## These are not your everyday RGB LEDs!
|
||||
|
||||
Internally Galactic Unicorn applies gamma correction to the supplied image data and updates the display with 14-bit precision resulting in extremely linear visual output - including at the low end.
|
||||
Internally Cosmic Unicorn applies gamma correction to the supplied image data and updates the display with 14-bit precision resulting in extremely linear visual output - including at the low end.
|
||||
|
||||
The display is refreshed around 300 times per second (300fps!) allowing for rock solid stability even when being filmed, no smearing or flickering even when in motion.
|
||||
|
||||
|
@ -14,9 +14,9 @@ No strobing or brightness stepping here folks - it's the perfect backdrop for yo
|
|||
|
||||
## Getting started
|
||||
|
||||
The Galactic Unicorn library provides a collection of methods that allow you to easily access all of the features on the board.
|
||||
The Cosmic Unicorn library provides a collection of methods that allow you to easily access all of the features on the board.
|
||||
|
||||
Drawing is primarily handled via our [PicoGraphics](https://github.com/pimoroni/pimoroni-pico/tree/main/micropython/modules/picographics) library which provides a comprehensive selection of drawing methods - once your drawing work is complete you pass the PicoGraphics object to Galactic Unicorn to have it displayed on the screen.
|
||||
Drawing is primarily handled via our [PicoGraphics](https://github.com/pimoroni/pimoroni-pico/tree/main/micropython/modules/picographics) library which provides a comprehensive selection of drawing methods - once your drawing work is complete you pass the PicoGraphics object to Cosmic Unicorn to have it displayed on the screen.
|
||||
|
||||
- [Example Program](#example-program)
|
||||
- [Interleaved Framebuffer](#interleaved-framebuffer)
|
||||
|
@ -41,7 +41,7 @@ Drawing is primarily handled via our [PicoGraphics](https://github.com/pimoroni/
|
|||
- [`stop_playing()`](#stop_playing)
|
||||
- [Channel Reference](#channel-reference)
|
||||
- [Constants](#constants)
|
||||
- [`WIDTH` & `HEIGHT`](#width--height)
|
||||
- [`WIDTH` \& `HEIGHT`](#width--height)
|
||||
- [Using Breakouts](#using-breakouts)
|
||||
|
||||
# Example Program
|
||||
|
@ -49,18 +49,18 @@ Drawing is primarily handled via our [PicoGraphics](https://github.com/pimoroni/
|
|||
The following example shows how to scroll a simple message across the display.
|
||||
|
||||
```python
|
||||
from galactic import GalacticUnicorn
|
||||
from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN
|
||||
from cosmic import CosmicUnicorn
|
||||
from picographics import PicoGraphics, DISPLAY_COSMIC_UNICORN
|
||||
import time
|
||||
|
||||
# create a PicoGraphics framebuffer to draw into
|
||||
graphics = PicoGraphics(display=DISPLAY_GALACTIC_UNICORN)
|
||||
graphics = PicoGraphics(display=DISPLAY_COSMIC_UNICORN)
|
||||
|
||||
# create our GalacticUnicorn object
|
||||
gu = GalacticUnicorn()
|
||||
# create our CosmicUnicorn object
|
||||
cu = CosmicUnicorn()
|
||||
|
||||
# start position for scrolling (off the side of the display)
|
||||
scroll = float(-GalacticUnicorn.WIDTH)
|
||||
scroll = float(-CosmicUnicorn.WIDTH)
|
||||
|
||||
# message to scroll
|
||||
MESSAGE = "Pirate. Monkey. Robot. Ninja."
|
||||
|
@ -74,7 +74,7 @@ while True:
|
|||
width = graphics.measure_text(MESSAGE, 1)
|
||||
scroll += 0.25
|
||||
if scroll > width:
|
||||
scroll = float(-GalacticUnicorn.WIDTH)
|
||||
scroll = float(-CosmicUnicorn.WIDTH)
|
||||
|
||||
# clear the graphics object
|
||||
graphics.set_pen(BLACK)
|
||||
|
@ -85,14 +85,14 @@ while True:
|
|||
graphics.text(MESSAGE, round(0 - scroll), 2, -1, 0.55);
|
||||
|
||||
# update the display
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
|
||||
time.sleep(0.02)
|
||||
```
|
||||
|
||||
# Interleaved Framebuffer
|
||||
|
||||
Galactic Unicorn takes advantage of the RP2040's PIOs to drive screen updates - this is what gives it the performance it needs to render with 14-bit precision at over 300 frames per second.
|
||||
Cosmic Unicorn takes advantage of the RP2040's PIOs to drive screen updates - this is what gives it the performance it needs to render with 14-bit precision at over 300 frames per second.
|
||||
|
||||
The PIO is a powerful, but limited, tool. It has no way to access memory at random and minimal support for decision making and branching. All it can really do is process a stream of data/instructions in order.
|
||||
|
||||
|
@ -116,22 +116,22 @@ If you're working with our library then you don't need to worry about any of the
|
|||
|
||||
## Imports and Objects
|
||||
|
||||
To access these functions, you'll need to first `import` the relevant libraries and then set up a Galactic Unicorn object:
|
||||
To access these functions, you'll need to first `import` the relevant libraries and then set up a Cosmic Unicorn object:
|
||||
|
||||
```python
|
||||
from galactic import GalacticUnicorn
|
||||
from cosmic import CosmicUnicorn
|
||||
|
||||
gu = GalacticUnicorn()
|
||||
cu = CosmicUnicorn()
|
||||
```
|
||||
|
||||
or (with PicoGraphics):
|
||||
|
||||
```python
|
||||
from galactic import GalacticUnicorn
|
||||
from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN
|
||||
from cosmic import CosmicUnicorn
|
||||
from picographics import PicoGraphics, DISPLAY_COSMIC_UNICORN
|
||||
|
||||
gu = GalacticUnicorn()
|
||||
graphics = PicoGraphics(display=DISPLAY_GALACTIC_UNICORN)
|
||||
cu = CosmicUnicorn()
|
||||
graphics = PicoGraphics(display=DISPLAY_COSMIC_UNICORN)
|
||||
```
|
||||
|
||||
## System State
|
||||
|
@ -151,10 +151,10 @@ Adjust the brightness of the display - `delta` is supplied as a floating point v
|
|||
For example:
|
||||
|
||||
```python
|
||||
gu.set_brightness(0.5)
|
||||
gu.adjust_brightness(0.1) # brightness is now 0.6
|
||||
gu.adjust_brightness(0.7) # brightness is now 1.0
|
||||
gu.adjust_brightness(-0.2) # brightness is now 0.8
|
||||
cu.set_brightness(0.5)
|
||||
cu.adjust_brightness(0.1) # brightness is now 0.6
|
||||
cu.adjust_brightness(0.7) # brightness is now 1.0
|
||||
cu.adjust_brightness(-0.2) # brightness is now 0.8
|
||||
```
|
||||
|
||||
### `set_volume(value)`
|
||||
|
@ -172,10 +172,10 @@ Adjust the volume - `delta` is supplied as a floating point value and will be ad
|
|||
For example:
|
||||
|
||||
```python
|
||||
gu.set_volume(0.5)
|
||||
gu.set_volume(0.1) # volume is now 0.6
|
||||
gu.adjust_volume(0.7) # volume is now 1.0
|
||||
gu.adjust_volume(-0.2) # volume is now 0.8
|
||||
cu.set_volume(0.5)
|
||||
cu.set_volume(0.1) # volume is now 0.6
|
||||
cu.adjust_volume(0.7) # volume is now 1.0
|
||||
cu.adjust_volume(-0.2) # volume is now 0.8
|
||||
```
|
||||
|
||||
### `light()`
|
||||
|
@ -186,7 +186,7 @@ Get the current value seen by the onboard light sensor as a value between `0` an
|
|||
|
||||
Returns true if the requested `button` is currently pressed.
|
||||
|
||||
There are a set of constants in the GalacticUnicorn class that represent each of the buttons. The brightness, sleep, and volume buttons are not tied to hardware functions (they are implemented entirely in software) so can also be used for user functions if preferred. Here's a list of the constants and their associated pin numbers:
|
||||
There are a set of constants in the CosmicUnicorn class that represent each of the buttons. The brightness, sleep, and volume buttons are not tied to hardware functions (they are implemented entirely in software) so can also be used for user functions if preferred. Here's a list of the constants and their associated pin numbers:
|
||||
|
||||
```python
|
||||
SWITCH_A = 0
|
||||
|
@ -203,7 +203,7 @@ SWITCH_BRIGHTNESS_DOWN = 26
|
|||
For example:
|
||||
|
||||
```python
|
||||
while not gu.is_pressed(GalacticUnicorn.SWITCH_A):
|
||||
while not cu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
# wait for switch A to be pressed
|
||||
pass
|
||||
|
||||
|
@ -218,17 +218,17 @@ The PicoGraphics library provides a collection of powerful drawing methods to ma
|
|||
|
||||
The image on the PicoGraphics object provided is copied to the interleaved framebuffer with gamma correction applied.
|
||||
|
||||
For example (assuming you've set up your Galactic Unicorn and PicoGraphics objects up [as we did above](#imports-and-objects)):
|
||||
For example (assuming you've set up your Cosmic Unicorn and PicoGraphics objects up [as we did above](#imports-and-objects)):
|
||||
|
||||
```python
|
||||
gu.update(graphics)
|
||||
cu.update(graphics)
|
||||
```
|
||||
|
||||
⚠️ If you've used PicoGraphics on our other boards note that this `update` function works a little differently. Here it's a Galactic Unicorn function to which you need to pass a PicoGraphics object to.
|
||||
⚠️ If you've used PicoGraphics on our other boards note that this `update` function works a little differently. Here it's a Cosmic Unicorn function to which you need to pass a PicoGraphics object to.
|
||||
|
||||
### `clear()`
|
||||
|
||||
Clear the contents of the interleaved framebuffer. This will make your Galactic Unicorn display turn off. To show an image again, call the `update()` function as described above.
|
||||
Clear the contents of the interleaved framebuffer. This will make your Cosmic Unicorn display turn off. To show an image again, call the `update()` function as described above.
|
||||
|
||||
## Audio
|
||||
|
||||
|
@ -282,22 +282,22 @@ play_tone(frequency, volume=None, attack=None, release=None)
|
|||
|
||||
### `WIDTH` & `HEIGHT`
|
||||
|
||||
The width and height of Galactic Unicorn are available in constants `WIDTH` and `HEIGHT`.
|
||||
The width and height of Cosmic Unicorn are available in constants `WIDTH` and `HEIGHT`.
|
||||
|
||||
For example:
|
||||
|
||||
```python
|
||||
num_pixels = GalacticUnicorn.WIDTH * GalacticUnicorn.HEIGHT
|
||||
num_pixels = CosmicUnicorn.WIDTH * CosmicUnicorn.HEIGHT
|
||||
print(num_pixels)
|
||||
```
|
||||
|
||||
## Using Breakouts
|
||||
|
||||
Galactic Unicorn has two Qw/ST (Qwiic/STEMMA QT) connectors. Breakouts with Qw/ST connectors, can be plugged straight in with a [JST-SH to JST-SH cable](https://shop.pimoroni.com/products/jst-sh-cable-qwiic-stemma-qt-compatible?variant=31910609813587). You can connect I2C Breakout Garden breakouts without Qw/ST connectors using a [JST-SH to JST-SH cable](https://shop.pimoroni.com/products/jst-sh-cable-qwiic-stemma-qt-compatible?variant=31910609813587) and a [Qw/ST to Breakout Garden adaptor](https://shop.pimoroni.com/products/stemma-qt-qwiic-to-breakout-garden-adapter).
|
||||
Cosmic Unicorn has two Qw/ST (Qwiic/STEMMA QT) connectors. Breakouts with Qw/ST connectors, can be plugged straight in with a [JST-SH to JST-SH cable](https://shop.pimoroni.com/products/jst-sh-cable-qwiic-stemma-qt-compatible?variant=31910609813587). You can connect I2C Breakout Garden breakouts without Qw/ST connectors using a [JST-SH to JST-SH cable](https://shop.pimoroni.com/products/jst-sh-cable-qwiic-stemma-qt-compatible?variant=31910609813587) and a [Qw/ST to Breakout Garden adaptor](https://shop.pimoroni.com/products/stemma-qt-qwiic-to-breakout-garden-adapter).
|
||||
|
||||
- [List of breakouts currently supported in our C++/MicroPython build](https://github.com/pimoroni/pimoroni-pico#breakouts)
|
||||
|
||||
Galactic Unicorn uses GP4 and GP5 for its I2C interface. You can use the constants in the shared `pimoroni` module to set up the I2C interface:
|
||||
Cosmic Unicorn uses GP4 and GP5 for its I2C interface. You can use the constants in the shared `pimoroni` module to set up the I2C interface:
|
||||
|
||||
```python
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
|
|
|
@ -63,12 +63,13 @@ Bear in mind that MicroPython has only 192K of RAM available- a 320x240 pixel di
|
|||
* 240x240 Square SPI LCD Breakout - `DISPLAY_LCD_240X240`
|
||||
* 160x80 SPI LCD Breakout - `DISPLAY_LCD_160X80`
|
||||
* 128x128 I2C OLED - `DISPLAY_I2C_OLED_128X128`
|
||||
* Pico Inky Pack - 296x128 mono E ink - `DISPLAY_INKY_PACK`
|
||||
* Pico Inky Pack / Badger 2040 / Badger 2040 W - 296x128 mono E ink - `DISPLAY_INKY_PACK`
|
||||
* Inky Frame 5.7" - 600x448 7-colour E ink - `DISPLAY_INKY_FRAME`
|
||||
* Inky Frame 4.0" - 640x400 7-colour E ink - `DISPLAY_INKY_FRAME_4`
|
||||
* Pico GFX Pack - 128x64 mono LCD Matrix - `DISPLAY_GFX_PACK`
|
||||
* Galactic Unicorn - 53x11 LED Matrix - `DISPLAY_GALACTIC_UNICORN`
|
||||
* Interstate75 and 75W - HUB75 Matrix driver - `DISPLAY_INTERSTATE75_SIZEOFMATRIX` please read below!
|
||||
* Cosmic Unicorn - 32x32 LED Matrix - `DISPLAY_COSMIC_UNICORN`
|
||||
|
||||
#### Interstate75 and Interstate75W Display modes
|
||||
|
||||
|
@ -177,6 +178,12 @@ display.set_pen(my_pen)
|
|||
|
||||
This will be either an RGB332, RGB565 or RGB888 colour, or a palette index.
|
||||
|
||||
As of v1.19.14 you can also specify an HSV pen, which allows a pen to be created from HSV (Hue, Saturation, Value) values, avoiding the need to calculate the RGB result in Python.
|
||||
|
||||
```python
|
||||
display.set_pen_hsv(h, s, v)
|
||||
```
|
||||
|
||||
##### Monochrome Modes
|
||||
|
||||
For 1BIT mode - such as for Inky Pack and the Mono OLED - pens are handled a little differently.
|
||||
|
|
|
@ -28,6 +28,7 @@ On the releases page you'll find a bunch of different .uf2 files for use on diff
|
|||
| Galactic Unicorn | **pimoroni-picow_galactic_unicorn-vx.x.x-micropython.uf2** | |
|
||||
| Inky Frame | **pimoroni-picow_inky_frame-vx.x.x-micropython.uf2** | |
|
||||
| Badger 2040 W | **pimoroni-badger2040w-vx.x.x-micropython.uf2** or **pimoroni-badger2040w-vx.x.x-micropython-with-examples.uf2** | Download **pimoroni-badger2040w-vx.x.x-micropython-with-examples.uf2** for built in examples! |
|
||||
| Cosmic Unicorn | **pimoroni-picow_cosmic_unicorn-vx.x.x-micropython.uf2** | |
|
||||
|
||||
## Entering DFU/bootloader mode
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue