ESP - Week 2 Flashcards
Arrays
Arrays are lists indexed from zero
Arrays Syntax
int list[10]; - A list of 10 integers
Records/Structs
Combines 3 integers into a single data structure
Records/Structs Syntax
struct rgb { int red; int blue; int green ; };
struct rgb purple = {255,0,255}, p;
p = purple;
p.green=123;
Strings
Strings are arrays of characters with a zero/null character at the end
Strings Syntax
char name[] = “Hello”;
What is a cast
int(ch) - Changes the type from char to int
What is the final character in a string
A zero which is not printed
String data type
String is also a datatype which is more flexible but takes more memory
What is abstraction
A mechanism for hiding details we don’t need to see in an object
Simple lcd commands
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)
What is the purpose of lcd.readButtons()
Returns bitstring with one bit for each button being 1 for on and 0 for off
Bytes for colour
0 - R
1 - B
2 - G
Generating new characters
byte a[] = {4,14,31,etc.};
lcd. createChar(UPARROW, a);
lcd. write(UPARROW)
How to return number of seconds since powerup
unsigned long millis();