-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples: update for Pico Display 2.8"
- Loading branch information
1 parent
bb51ce5
commit afd652b
Showing
14 changed files
with
290 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
Bitmap font demo! | ||
Bitmap fonts are fast but blocky. They are best used for small text. | ||
""" | ||
|
||
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2 | ||
|
||
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2) | ||
|
||
WIDTH, HEIGHT = display.get_bounds() | ||
|
||
hue = 0.0 | ||
|
||
display.set_font("bitmap8") | ||
|
||
for i in range(7): | ||
# create a pen and set the drawing color | ||
PEN_COLOUR = display.create_pen_hsv(hue, 1.0, 1.0) | ||
display.set_pen(PEN_COLOUR) | ||
# draw text | ||
display.text("Hello World", i * WIDTH // 12, i * HEIGHT // 7 + 6, scale=3) | ||
# increment hue | ||
hue += 1.0 / 7 | ||
|
||
display.update() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
""" | ||
Vector font demo! Vector fonts are slower but smoother. They are best used for large text. | ||
You will need to copy the .af font files to your Pico. | ||
Spicy Soup font originally from https://www.dafont.com/spicy-soup.font | ||
Next Sunday font originally from https://www.dafont.com/next-sunday.font | ||
Coolvetica font originally from https://www.dafont.com/coolvetica.font | ||
Find out how to convert your own fonts to .af here: https://github.com/lowfatcode/alright-fonts | ||
""" | ||
|
||
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2, PEN_RGB565 | ||
from picovector import PicoVector, ANTIALIAS_X16 | ||
import time | ||
|
||
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, pen_type=PEN_RGB565) | ||
vector = PicoVector(display) | ||
|
||
display.set_backlight(1.0) | ||
|
||
WIDTH, HEIGHT = display.get_bounds() | ||
BLACK = display.create_pen(0, 0, 0) | ||
|
||
hue = 0.0 | ||
|
||
# antialiasing draws the vector multiple times for a smoother look | ||
vector.set_antialiasing(ANTIALIAS_X16) | ||
|
||
TEXT = "Hello World" | ||
|
||
while True: | ||
# reset the hue | ||
hue = 0.0 | ||
|
||
# clear to black | ||
display.set_pen(BLACK) | ||
display.clear() | ||
# set the vector font and size | ||
vector.set_font("spicy_soup.af", 36) | ||
# draw the text seven times | ||
for i in range(7): | ||
# create a HSV (hue, value, saturation) pen and set the drawing color | ||
PEN_COLOUR = display.create_pen_hsv(hue, 1.0, 1.0) | ||
display.set_pen(PEN_COLOUR) | ||
# draw text | ||
vector.text(TEXT, i * WIDTH // 20, i * HEIGHT // 7 - 5) | ||
# increment hue | ||
hue += 1.0 / 7 | ||
display.update() | ||
time.sleep(5) | ||
|
||
display.set_pen(BLACK) | ||
display.clear() | ||
vector.set_font("next_sunday.af", 30) | ||
# draw the text ten times, sideways | ||
for i in range(10): | ||
PEN_COLOUR = display.create_pen_hsv(hue, 1.0, 1.0) | ||
display.set_pen(PEN_COLOUR) | ||
vector.text(TEXT, i * WIDTH // 10, HEIGHT, 270) | ||
hue += 1.0 / 10 | ||
display.update() | ||
time.sleep(5) | ||
|
||
display.set_pen(BLACK) | ||
display.clear() | ||
vector.set_font("coolvetica_rg.af", 44) | ||
# draw the text many times | ||
for i in range(30): | ||
PEN_COLOUR = display.create_pen_hsv(hue, 1.0, 1.0) | ||
display.set_pen(PEN_COLOUR) | ||
vector.text(TEXT, WIDTH // 2, HEIGHT // 2, i * 12) | ||
hue += 1.0 / 30 | ||
display.update() | ||
time.sleep(5) | ||
|
||
display.set_pen(BLACK) | ||
display.clear() | ||
vector.set_font("coolvetica_rg.af", 72) | ||
# draw the text many times | ||
for i in range(36): | ||
PEN_COLOUR = display.create_pen_hsv(hue, 1.0, 1.0) | ||
display.set_pen(PEN_COLOUR) | ||
vector.text(TEXT, 10, i * HEIGHT // 44 - 25) | ||
hue += 1.0 / 18 | ||
display.update() | ||
time.sleep(5) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# A spinny rainbow wheel. Change up some of the constants below to see what happens. | ||
|
||
import math | ||
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2 | ||
|
||
# Constants for drawing | ||
INNER_RADIUS = 40 | ||
OUTER_RADIUS = 120 | ||
NUMBER_OF_LINES = 24 | ||
HUE_SHIFT = 0.02 | ||
ROTATION_SPEED = 2 | ||
LINE_THICKNESS = 2 | ||
|
||
# Set up the display | ||
graphics = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2) | ||
|
||
WIDTH, HEIGHT = graphics.get_bounds() | ||
|
||
BLACK = graphics.create_pen(0, 0, 0) | ||
|
||
# Variables to keep track of rotation and hue positions | ||
r = 0 | ||
t = 0 | ||
|
||
while True: | ||
graphics.set_pen(BLACK) | ||
graphics.clear() | ||
for i in range(0, 360, 360 // NUMBER_OF_LINES): | ||
graphics.set_pen(graphics.create_pen_hsv((i / 360) + t, 1.0, 1.0)) | ||
# Draw some lines, offset by the rotation variable | ||
graphics.line(int(WIDTH / 2 + math.cos(math.radians(i + r)) * INNER_RADIUS), | ||
int(HEIGHT / 2 + math.sin(math.radians(i + r)) * INNER_RADIUS), | ||
int(WIDTH / 2 + math.cos(math.radians(i + 90 + r)) * OUTER_RADIUS), | ||
int(HEIGHT / 2 + math.sin(math.radians(i + 90 + r)) * OUTER_RADIUS), | ||
LINE_THICKNESS) | ||
graphics.update() | ||
r += ROTATION_SPEED | ||
t += HUE_SHIFT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.