|
1 |
| -# Example 1 - Hello |
| 1 | +# Example 4 - Text |
2 | 2 |
|
3 |
| -A simple example that demonstrates the basic steps required to draw graphics with the Qwiic OLED Library |
| 3 | +An example that shows drawing bitmaps using the SparkFun Qwiic OLED Library. |
4 | 4 |
|
5 |
| -## Getting Started |
| 5 | +**Key Demo Features** |
| 6 | +* Understanding font structure and use |
| 7 | +* Drawing text |
| 8 | +* Using the Arduino `Print` functionality |
6 | 9 |
|
7 | 10 |
|
8 |
| -Detailed examples are included as part of the library installation process and available in the Arduino IDE `File > Examples >` menu. |
| 11 | +## Setup |
| 12 | + |
| 13 | +After installing this library in your local Arduino environment, begin with a standard Arduino sketch, and include the header file for this library. |
| 14 | +```C++ |
| 15 | +// Include the SparkFun qwiic OLED Library |
| 16 | +#include <SparkFun_Qwiic_OLED.h> |
| 17 | +``` |
| 18 | +The next step is to declare the object for the SparkFun qwiic OLED device used. Like most Arduino sketches, this is done at a global scope (after the include file declaration), not within the ```setup()``` or ```loop()``` functions. |
| 19 | + |
| 20 | +The user selects from one of the following classes: |
| 21 | + |
| 22 | +| Class | Qwiic OLED Device | |
| 23 | +| :--- | :--- | |
| 24 | +| `QwiicMicroOLED` | [SparkFun Qwiic Micro OLED ]( https://www.sparkfun.com/products/14532)| |
| 25 | +| `QwiicNarrowOLED` | [SparkFun Qwiic OLED Display (128x32) ]( https://www.sparkfun.com/products/17153)| |
| 26 | +| `QwiicTransparentOLED` | [SparkFun Transparent Graphical OLED]( https://www.sparkfun.com/products/15173)| |
| 27 | + |
| 28 | +The Example code supports all of the SparkFun Qwiic OLED boards. To select the board being used, uncomment the `#define` for the demo board. |
| 29 | + |
| 30 | +For this example, the Qwiic Micro OLED is used. |
| 31 | + |
| 32 | +```C++ |
| 33 | +#define MICRO |
| 34 | +//#define NARROW |
| 35 | +//#define TRANSPARENT |
| 36 | +``` |
| 37 | +Which results in myOLED being declared as: |
| 38 | + |
| 39 | +```C++ |
| 40 | +QwiicMicroOLED myOLED; |
| 41 | +``` |
| 42 | +## Initialization |
| 43 | + |
| 44 | +In the ```setup()``` function of this sketch, like all of the SparkFun qwiic libraries, the device is initialized by calling the ```begin()``` method. This method returns a value of ```true``` on success, or ```false``` on failure. |
| 45 | + |
| 46 | +```C++ |
| 47 | +void setup() |
| 48 | +{ |
| 49 | + |
| 50 | + delay(500); //Give display time to power on |
| 51 | + |
| 52 | + // Serial on! |
| 53 | + Serial.begin(115200); |
| 54 | + |
| 55 | + Serial.println("\n\r-----------------------------------"); |
| 56 | + |
| 57 | + Serial.print("Running Example 01 on: "); |
| 58 | + Serial.println(String(deviceName)); |
| 59 | + |
| 60 | + // Initalize the OLED device and related graphics system |
| 61 | + if(!myOLED.begin()){ |
| 62 | + |
| 63 | + Serial.println(" - Device Begin Failed"); |
| 64 | + while(1); |
| 65 | + } |
| 66 | + |
| 67 | + Serial.println("- Begin Success"); |
| 68 | + |
| 69 | +``` |
| 70 | +## Drawing Text |
| 71 | +
|
| 72 | + |
9 | 73 |
|
0 commit comments