English
Language : 

LCD-14048 Datasheet, PDF (19/33 Pages) SparkFun Electronics – TeensyView Hookup Guide
// Demonstrate font 2. 10x16. Only numbers and '.' are defin
ed.
// This font looks like 7­segment displays.
// Lets use this big­ish font to display readings from the
// analog pins.
for (int i = 0; i < 25; i++)
{
oled.clear(PAGE);
// Clear the display
oled.setCursor(0, 0);
// Set cursor to top­left
oled.setFontType(0);
// Smallest font
oled.print("A0: ");
// Print "A0"
oled.setFontType(2);
// 7­segment font
oled.print(analogRead(A0)); // Print a0 reading
oled.setCursor(0, 16);
// Set cursor to top­middle­l
eft
oled.setFontType(0);
// Repeat
oled.print("A1: ");
oled.setFontType(2);
oled.print(analogRead(A1));
oled.setCursor(0, 32);
oled.setFontType(0);
oled.print("A2: ");
oled.setFontType(2);
oled.print(analogRead(A2));
oled.display();
delay(100);
}
}
void loop()
{
pixelExample();
lineExample();
shapeExample();
textExamples();
}
// Run the pixel example function
// Then the line example function
// Then the shape example
// Finally the text example
// Center and print a small title
// This function is quick and dirty. Only works for titles one
// line long.
void printTitle(String title, int font)
{
int middleX = oled.getLCDWidth() / 2;
int middleY = oled.getLCDHeight() / 2;
oled.clear(PAGE);
oled.setFontType(font);
// Try to set the cursor in the middle of the screen
oled.setCursor(middleX ­ (oled.getFontWidth() * (title.lengt
h() / 2)),
middleY ­ (oled.getFontWidth() / 2));
// Print the title:
oled.print(title);
oled.display();
delay(1500);
oled.clear(PAGE);
}
The loop() can be seen near the end of the code. It runs each of the
drawing examples. If you’re wondering how the code does a certain thing
on the screen, examine the routine (such as shapeExample(){} ) and
consult the Library Reference.
Page 19 of 33