ESP - Week 2 Flashcards

1
Q

Arrays

A

Arrays are lists indexed from zero

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

Arrays Syntax

A

int list[10]; - A list of 10 integers

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

Records/Structs

A

Combines 3 integers into a single data structure

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

Records/Structs Syntax

A
struct rgb {
int red;
int blue;
int green ;
};

struct rgb purple = {255,0,255}, p;

p = purple;
p.green=123;

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

Strings

A

Strings are arrays of characters with a zero/null character at the end

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

Strings Syntax

A

char name[] = “Hello”;

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

What is a cast

A

int(ch) - Changes the type from char to int

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

What is the final character in a string

A

A zero which is not printed

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

String data type

A

String is also a datatype which is more flexible but takes more memory

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

What is abstraction

A

A mechanism for hiding details we don’t need to see in an object

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

Simple lcd commands

A

lcd. begin(16,2) - Tells library screen is 16x2
lcd. SetCursor(x,y) - Puts cursor at (x,y)
lcd. print(“text”) - Writes text on screen

lcd.setBacklight(x)

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

What is the purpose of lcd.readButtons()

A

Returns bitstring with one bit for each button being 1 for on and 0 for off

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

Bytes for colour

A

0 - R
1 - B
2 - G

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

Generating new characters

A

byte a[] = {4,14,31,etc.};

lcd. createChar(UPARROW, a);
lcd. write(UPARROW)

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

How to return number of seconds since powerup

A

unsigned long millis();

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

Arithmetic with floats

A
Int/Int = Int
Float/Int = Float
(float)Int/Int = Float