Skip to content

Commit acd3dfd

Browse files
committed
Update docs to reflect new image/display API
1 parent d589a74 commit acd3dfd

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

docs/microbit_micropython_api.rst

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ The LED display
3838

3939
The LED display is exposed via the `display` object::
4040

41-
display.image # this is a MicroBitImage object - changes to this will directly affect the display
42-
display.set_brightness(int) # sets the brightness of the display (between 0 and 255, inclusive)
43-
display.set_display_mode(mode) # mode=0 means put in B&W mode, mode=1 means put in greyscale mode [WILL CHANGE]
41+
display.get_pixel(x, y) # gets the brightness of the pixel (x,y)
42+
display.set_pixel(x, y, val) # sets the brightness of the pixel (x,y) to val (between 0 and 9, inclusive)
4443
display.clear() # clears the display
4544
display.print(string, delay=400) # prints the string to the display one character at a time
46-
display.print(MicroBitImage, delay=400) # prints the image to the screen.
45+
display.print(image, delay=400) # prints the image to the screen.
4746
display.scroll(string, delay=400) # scrolls a string across the display (more exciting than display.print)
48-
display.scroll(MicroBitImage, delay=400, stride=-1) # scrolls an image bigger than 5x5 across the screen
4947
display.animate(image, delay, stride, start, wait=True, loop=False)
48+
display.animate(iterable, delay, wait=True, loop=False)
5049

5150
Pins
5251
----
@@ -86,22 +85,25 @@ Images API::
8685

8786
# constructor overloads:
8887
image = Image() # creates an empty 5x5 image
89-
image = Image('0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0') # create an image from a string - each character in the string represents an LED - 0 is off and 1 is on.
88+
image = Image('90009\n09090\n00900\n09090\n90009') # create an image from a string - each character in the string represents an LED - 0 (or space) is off and 9 is maximum brightness.
9089
image = Image(width, height) # create an empty image of given size
9190
image = Image(width, height, buffer) # initialises an Image with the specified width and height. The buffer should be an array of length width * height
9291

9392
# methods
94-
image.clear() # clear all pixels
9593
image.width() # returns the image's width (most often 5)
9694
image.height() # returns the image's height (most often 5)
97-
image.set_pixel(x, y, value) # sets the pixel at the specified position (between 0 and 255)
98-
image.get_pixel(x, y) # gets the pixel at the specified position (between 0 and 255)
99-
image.shift_left(n) # shifts the picture left 'n' times.
100-
image.shift_right(n) # shifts the picture right 'n' times.
101-
image.shift_up(n) # shifts the picture up 'n' times.
102-
image.shift_down(n) # shifts the picture down 'n' times.
103-
image.paste(image, x, y, transparent=False) # paste another image to this one at (x,y) [NOT YET IMPLEMENTED]
104-
str(image) # get the string representation of the image
95+
image.set_pixel(x, y, value) # sets the pixel at the specified position (between 0 and 9). May fail for constant images.
96+
image.get_pixel(x, y) # gets the pixel at the specified position (between 0 and 9)
97+
image.shift_left(n) # returns a new image created by shifting the picture left 'n' times.
98+
image.shift_right(n) # returns a new image created by shifting the picture right 'n' times.
99+
image.shift_up(n) # returns a new image created by shifting the picture up 'n' times.
100+
image.shift_down(n) # returns a new image created by shifting the picture down 'n' times.
101+
repr(image) # get a compact string representation of the image
102+
str(image) # get a more readable string representation of the image
103+
104+
#operators
105+
image + image # returns a new image created by superimposing the two images
106+
image * n # returns a new image created by multiplying the brightness of each pixel by n
105107

106108
# constants (currently, just lots of images)
107109
Image.HEART

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy