131 Week 8 - micro:bit display and images Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

MicroBit class

A

Consists of variables and methods that operate as drivers to control commonly used features of the micro:bit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Set up micro:bit in C++

A

include “MicroBit.h” Includes library of key microbit functions

MicroBit uBit; - create object uBit to control micro:bit
uBit.innit(); - called in main(), initialises micro:bit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Display text on microbit

A

uBit.display.scroll(); or uBit.display.print();
arguments:
text to scroll - can be text or num
delay - lower value = shorter delay (optional argument)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Difference between scroll and print

A

display.scroll scrolls text accross the screen pixel by pixel
display.print displays each character in turn

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Changing display modes

A

uBit.display.setDisplayMode(displayMode);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

DISPLAY_MODE_BLACK_AND_WHITE

A

Pixels are either on or off
Brightness of all pixels is changed by uBit.display.setBrightness(int between 1-255);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE

A

Each pixel can be on or off, and the display driver will also sense the ambient brightness from the LEDs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

DISPLAY_MODE_GREYSCALE

A

Each pixel can independently have 256 levels of brightness (0-255)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

setting and getting pixel values

A

uBit.display.Image.setPixelValue(int 0-4, int 0-4, int 0-255)
Arguments: x coord, y coord and brightness of a pixel. black and white display mode will ignore brightness argument.
int i = uBit.display.iamge.getPixelValue(int 0-4, int 0-4);
Arguments: x coord and y coord of pixel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Creating images

A

MicroBitImage imageName(“0,255,0,255,0\n 0,255,0,255,0\n 0,0,0,0,0\n 255,0,0,0,255\n 0,255,255,255,0\n”);
MicroBitImage represents a bitmap picture
CSV of 0-255 for pixel brightness
\n moves to new line of pixels

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

displaying images

A

uBit.display.print(imageName);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

pasting an image

A

Create a blank image (5x5 in this example):
MicroBitImage myimage(5,5)
paste an image at specified coords:
myImage.paste(imageName, xcoord, ycoord)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

creating read only images

A

constant array of unsigned integers can be used to store a read-only picture:
const uint8_t imageName[] = {0,255,0,255,0,0,255,0,255,0,0,0,0,0,0,255,0,0,0,255,0,255,255,255,0};
MicroBitImage class offers a constructor that creates a bitmap representation of a given size (e.g., 5×5 in this example), based on a given buffer (i.e., the array imageName in this example):
MicroBitImage myImage(5,5,imageName);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

displaying read only images

A

uBit.display.print(myImage);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly