English
Language : 

DEV-13628 Datasheet, PDF (7/12 Pages) SparkFun Electronics – Photon OLED Shield Hookup Guide
lineExample();
shapeExample();
textExamples();
}
// Then the line example function
// Then the shape example
// Finally the text example
void pixelExample()
{
printTitle("Pixels", 1);
for (int i=0; i<512; i++)
{
oled.pixel(random(oled.getLCDWidth()), random(oled.getLCDH
eight()));
oled.display();
}
}
void lineExample()
{
int middleX = oled.getLCDWidth() / 2;
int middleY = oled.getLCDHeight() / 2;
int xEnd, yEnd;
int lineWidth = min(middleX, middleY);
printTitle("Lines!", 1);
for (int i=0; i<3; i++)
{
for (int deg=0; deg<360; deg+=15)
{
xEnd = lineWidth * cos(deg * M_PI / 180.0);
yEnd = lineWidth * sin(deg * M_PI / 180.0);
oled.line(middleX, middleY, middleX + xEnd, middleY + yE
nd);
oled.display();
delay(10);
}
for (int deg=0; deg<360; deg+=15)
{
xEnd = lineWidth * cos(deg * M_PI / 180.0);
yEnd = lineWidth * sin(deg * M_PI / 180.0);
oled.line(middleX, middleY, middleX + xEnd, middleY + yE
nd, BLACK, NORM);
oled.display();
delay(10);
}
}
}
void shapeExample()
{
printTitle("Shapes!", 0);
// Silly pong demo. It takes a lot of work to fake pong...
int paddleW = 3; // Paddle width
int paddleH = 15; // Paddle height
// Paddle 0 (left) position coordinates
int paddle0_Y = (oled.getLCDHeight() / 2) ­ (paddleH / 2);
int paddle0_X = 2;
// Paddle 1 (right) position coordinates
int paddle1_Y = (oled.getLCDHeight() / 2) ­ (paddleH / 2);
int paddle1_X = oled.getLCDWidth() ­ 3 ­ paddleW;
int ball_rad = 2; // Ball radius
Page 7 of 12