Skip to content

Commit 5e05114

Browse files
authored
Merge pull request #1 from sparkfun/ExampleWorkOver
Example work over
2 parents 8a8ca16 + 553ce4a commit 5e05114

File tree

9 files changed

+485
-1034
lines changed

9 files changed

+485
-1034
lines changed
Lines changed: 20 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,57 @@
11
/*
2-
Example-01_Hello.ino
32
4-
This is a library written for SparkFun Qwiic OLED boards that use the SSD1306.
3+
Example-01_Hello.ino
54
6-
SparkFun sells these at its website: www.sparkfun.com
7-
8-
Do you like this library? Help support SparkFun. Buy a board!
5+
This demo shows the basic setup of the OLED library, generating simple graphics and displaying
6+
the results on the target device.
97
108
Micro OLED https://www.sparkfun.com/products/14532
119
Transparent OLED https://www.sparkfun.com/products/15173
1210
"Narrow" OLED https://www.sparkfun.com/products/17153
1311
12+
Written by Kirk Benell @ SparkFun Electronics, March 2022
1413
15-
Written by Kirk Benell @ SparkFun Electronics, March 2022
16-
17-
This library configures and draws graphics to OLED boards that use the
18-
SSD1306 display hardware. The library only supports I2C.
19-
20-
Repository:
14+
Repository:
2115
https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library
2216
23-
Documentation:
17+
Documentation:
2418
https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/
2519
26-
27-
SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
28-
29-
SPDX-License-Identifier: MIT
30-
31-
Example 01 for the SparkFun Qwiic OLED Arduino Library
32-
33-
>> Overview <<
34-
35-
This demo shows the basic setup of the OLED library, generating simple graphics and displaying
36-
the results on the target device.
20+
SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).
3721
*/
38-
////////////////////////////////////////////////////////////////////////////////////////
39-
// >>> SELECT THE CONNECTED DEVICE FOR THIS EXAMPLE <<<
40-
//
41-
// The Library supports three different types of SparkFun boards. The demo uses the following
42-
// defines to determine which device is being used. Uncomment the device being used for this demo.
43-
44-
// The default is Micro OLED
45-
46-
#define MICRO
47-
//#define NARROW
48-
//#define TRANSPARENT
4922

50-
//////////////////////////////////////////////////////////////////////////////////////////
51-
52-
#include <stdint.h>
53-
54-
// Include the SparkFun qwiic OLED Library
55-
#include <SparkFun_Qwiic_OLED.h>
23+
#include <SparkFun_Qwiic_OLED.h> //http://librarymanager/All#SparkFun_Qwiic_Graphic_OLED
5624

5725
// Add in our font descriptor -- so we can center the text on the scren
5826
#include <res/qw_fnt_5x7.h>
5927

60-
// What device is being used in this demo
61-
62-
#if defined(TRANSPARENT)
63-
QwiicTransparentOLED myOLED;
64-
const char *deviceName = "Transparent OLED";
65-
66-
#elif defined(NARROW)
67-
QwiicNarrowOLED myOLED;
68-
const char *deviceName = "Narrow OLED";
28+
// The Library supports three different types of SparkFun boards. The demo uses the following
29+
// defines to determine which device is being used. Uncomment the device being used for this demo.
6930

70-
#else
7131
QwiicMicroOLED myOLED;
72-
const char *deviceName = "Micro OLED";
32+
// QwiicTransparentOLED myOLED;
33+
// QwiicNarrowOLED myOLED;
7334

74-
#endif
75-
76-
////////////////////////////////////////////////////////////////////////////////////////////////
77-
// setup()
7835

7936
void setup()
8037
{
81-
delay(500); // Give display time to power on
82-
83-
// Serial on!
8438
Serial.begin(115200);
39+
Serial.println("Running OLED example");
8540

86-
Serial.println("\n\r-----------------------------------");
87-
88-
Serial.print("Running Example 01 on: ");
89-
Serial.println(String(deviceName));
41+
Wire.begin();
9042

9143
// Initalize the OLED device and related graphics system
92-
if (!myOLED.begin())
44+
if (myOLED.begin() == false)
9345
{
94-
95-
Serial.println(" - Device Begin Failed");
96-
while (1)
46+
Serial.println("Device begin failed. Freezing...");
47+
while (true)
9748
;
9849
}
99-
100-
Serial.println("- Begin Success");
50+
Serial.println("Begin success");
10151

10252
// Do a simple test - fill a rectangle on the screen and then print hello!
10353

104-
// fill a rectangle on the screen that has a 4 pixel board
54+
// Fill a rectangle on the screen that has a 4 pixel board
10555
myOLED.rectangleFill(4, 4, myOLED.getWidth() - 8, myOLED.getHeight() - 8);
10656

10757
String hello = "hello"; // our message
@@ -123,10 +73,7 @@ void setup()
12373
// That's it - HELLO!
12474
}
12575

126-
// Standard Arduino loop function.
12776
void loop()
12877
{
129-
130-
// All loop does in sleep.
131-
delay(1000);
78+
delay(1000); // Do nothing
13279
}

0 commit comments

Comments
 (0)