File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
micropython/examples/tufty2040 Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ from picographics import PicoGraphics , DISPLAY_TUFTY_2040
2
+ import pngdec
3
+
4
+ display = PicoGraphics (display = DISPLAY_TUFTY_2040 )
5
+
6
+ # Create an instance of the PNG Decoder
7
+ png = pngdec .PNG (display )
8
+
9
+ # Create some pens for use later.
10
+ BG = display .create_pen (200 , 200 , 200 )
11
+ TEXT = display .create_pen (0 , 0 , 0 )
12
+
13
+ # Clear the screen
14
+ display .set_pen (BG )
15
+ display .clear ()
16
+
17
+ display .set_pen (TEXT )
18
+ display .text ("PNG Pencil" , 105 , 80 )
19
+
20
+ try :
21
+ # Open our PNG File from flash. In this example we're using an image of a cartoon pencil.
22
+ # You can use Thonny to transfer PNG Images to your Pico.
23
+ png .open_file ("pencil.png" )
24
+
25
+ # Decode our PNG file and set the X and Y
26
+ png .decode (140 , 100 )
27
+
28
+ # Handle the error if the image doesn't exist on the flash.
29
+ except OSError :
30
+ print ("Error: PNG File missing. Copy the PNG file from the example folder to your Pico using Thonny and run the example again." )
31
+
32
+ display .update ()
33
+
34
+ # We're not doing anything else with the display now but we want to keep the program running!
35
+ while True :
36
+ pass
You can’t perform that action at this time.
0 commit comments