11/*
2+
23 Example-01_Hello.ino
34
45 This demo shows the basic setup of the OLED library, generating simple graphics and displaying
56 the results on the target device.
67
7- This is a library written for SparkFun Qwiic OLED boards that use the SSD1306.
8-
9- This library configures and draws graphics to OLED boards that use the
10- SSD1306 display hardware. The library only supports I2C.
11-
12- SparkFun sells these at its website: www.sparkfun.com
13-
14- Do you like this library? Help support SparkFun. Buy a board!
15-
168 Micro OLED https://www.sparkfun.com/products/14532
179 Transparent OLED https://www.sparkfun.com/products/15173
1810 "Narrow" OLED https://www.sparkfun.com/products/17153
3022
3123#include < SparkFun_Qwiic_OLED.h> // http://librarymanager/All#SparkFun_Qwiic_Graphic_OLED
3224
25+ // Add in our font descriptor -- so we can center the text on the scren
26+ #include < res/qw_fnt_5x7.h>
27+
3328// The Library supports three different types of SparkFun boards. The demo uses the following
3429// defines to determine which device is being used. Uncomment the device being used for this demo.
3530
3631QwiicMicroOLED myOLED;
3732// QwiicTransparentOLED myOLED;
3833// QwiicNarrowOLED myOLED;
3934
35+
4036void setup ()
4137{
4238 Serial.begin (115200 );
@@ -60,14 +56,13 @@ void setup()
6056
6157 String hello = " hello" ; // our message
6258
63- // Let's center our message on the screen. We need the current font.
64-
65- QwiicFont *pFont = myOLED.getFont ();
59+ // Center our message on the screen. Use our Font Descriptor: QW_FONT_5X7, the default
60+ // font of the system.
6661
67- // Starting x position - width minus string length (font width * number of characters) / 2
68- int x0 = (myOLED.getWidth () - pFont-> width * hello.length ()) / 2 ;
62+ // starting x position - width minus string length (font width * number of characters) / 2
63+ int x0 = (myOLED.getWidth () - QW_FONT_5X7. width * hello.length ()) / 2 ;
6964
70- int y0 = (myOLED.getHeight () - pFont-> height ) / 2 ;
65+ int y0 = (myOLED.getHeight () - QW_FONT_5X7. height ) / 2 ;
7166
7267 // Draw the text - color of black (0)
7368 myOLED.text (x0, y0, hello, 0 );
0 commit comments