11
22// Example-01_Hello.ino
3- //
3+ //
44// This is a library written for SparkFun Qwiic OLED boards that use the SSD1306.
55//
66// SparkFun sells these at its website: www.sparkfun.com
1010// Micro OLED https://www.sparkfun.com/products/14532
1111// Transparent OLED https://www.sparkfun.com/products/15173
1212// "Narrow" OLED https://www.sparkfun.com/products/17153
13- //
14- //
13+ //
14+ //
1515// Written by Kirk Benell @ SparkFun Electronics, March 2022
1616//
17- // This library configures and draws graphics to OLED boards that use the
17+ // This library configures and draws graphics to OLED boards that use the
1818// SSD1306 display hardware. The library only supports I2C.
19- //
19+ //
2020// Repository:
2121// https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library
2222//
4949// >> Overview <<
5050//
5151// This demo shows the basic setup of the OLED library, generating simple graphics and displaying
52- // the results on the target device.
52+ // the results on the target device.
5353//
5454// ////////////////////////////////////////////////////////////////////////////////////////
5555// >>> SELECT THE CONNECTED DEVICE FOR THIS EXAMPLE <<<
7474
7575#if defined(TRANSPARENT)
7676QwiicTransparentOLED myOLED;
77- const char * deviceName = " Transparent OLED" ;
77+ const char *deviceName = " Transparent OLED" ;
7878
7979#elif defined(NARROW)
8080QwiicNarrowOLED myOLED;
81- const char * deviceName = " Narrow OLED" ;
81+ const char *deviceName = " Narrow OLED" ;
8282
8383#else
8484QwiicMicroOLED myOLED;
85- const char * deviceName = " Micro OLED" ;
85+ const char *deviceName = " Micro OLED" ;
8686
8787#endif
8888
89-
9089// //////////////////////////////////////////////////////////////////////////////////////////////
9190// setup()
92- //
93- // Arduino setup() function.
91+ //
92+ // Arduino setup() function.
9493//
9594// Initialize our device and draw a simple graphic. That's all this example does.
9695
9796void setup ()
9897{
99- delay (500 ); // Give display time to power on
98+ delay (500 ); // Give display time to power on
10099
101100 // Serial on!
102101 Serial.begin (115200 );
@@ -107,43 +106,45 @@ void setup()
107106 Serial.println (String (deviceName));
108107
109108 // Initalize the OLED device and related graphics system
110- if (!myOLED.begin ()){
109+ if (!myOLED.begin ())
110+ {
111111
112112 Serial.println (" - Device Begin Failed" );
113- while (1 );
113+ while (1 )
114+ ;
114115 }
115116
116117 Serial.println (" - Begin Success" );
117118
118119 // Do a simple test - fill a rectangle on the screen and then print hello!
119120
120121 // fill a rectangle on the screen that has a 4 pixel board
121- myOLED.rectangleFill (4 , 4 , myOLED.getWidth ()- 8 , myOLED.getHeight ()- 8 );
122+ myOLED.rectangleFill (4 , 4 , myOLED.getWidth () - 8 , myOLED.getHeight () - 8 );
122123
123124 String hello = " hello" ; // our message
124125
125- // Lets center our message on the screen. We need to current font.
126+ // Lets center our message on the screen. We need to current font.
126127
127- QwiicFont * pFont = myOLED.getFont ();
128+ QwiicFont *pFont = myOLED.getFont ();
128129
129130 // starting x position - width minus string length (font width * number of characters) / 2
130- int x0 = (myOLED.getWidth () - pFont->width * hello.length ())/ 2 ;
131+ int x0 = (myOLED.getWidth () - pFont->width * hello.length ()) / 2 ;
131132
132- int y0 = (myOLED.getHeight () - pFont->height )/ 2 ;
133+ int y0 = (myOLED.getHeight () - pFont->height ) / 2 ;
133134
134135 // Draw the text - color of black (0)
135136 myOLED.text (x0, y0, hello, 0 );
136137
137138 // There's nothing on the screen yet - Now send the graphics to the device
138139 myOLED.display ();
139140
140- // That's it - HELLO!
141-
141+ // That's it - HELLO!
142142}
143143
144- // Standard Arduino loop function.
145- void loop (){
144+ // Standard Arduino loop function.
145+ void loop ()
146+ {
146147
147- // All loop does in sleep.
148+ // All loop does in sleep.
148149 delay (1000 );
149150}
0 commit comments