|
| 1 | +/* |
| 2 | + SFE_MicroOLED Library Demo |
| 3 | + Paul Clark @ SparkFun Electronics |
| 4 | + Original Creation Date: December 10th, 2020 |
| 5 | +
|
| 6 | + This sketch uses the MicroOLED library to show all the functionality built into the library - |
| 7 | + specifically the line function. This example is based on Gist by buckle2000 |
| 8 | + https://gist.github.com/buckle2000/68dad3f24613d37625e9c2f590dd3f52 |
| 9 | +
|
| 10 | + Hardware Connections: |
| 11 | + This example assumes you are using Qwiic. See the SPI examples for |
| 12 | + a detailed breakdown of connection info. |
| 13 | +
|
| 14 | + This code is beerware; if you see me (or any other SparkFun employee) at the |
| 15 | + local, and you've found our code helpful, please buy us a round! |
| 16 | + |
| 17 | + Distributed as-is; no warranty is given. |
| 18 | +*/ |
| 19 | + |
| 20 | +#include <Wire.h> |
| 21 | +#include <SFE_MicroOLED.h> //Click here to get the library: http://librarymanager/All#SparkFun_Micro_OLED |
| 22 | + |
| 23 | +#define PIN_RESET 9 |
| 24 | +#define DC_JUMPER 0 |
| 25 | +MicroOLED oled(PIN_RESET, DC_JUMPER); // I2C declaration |
| 26 | + |
| 27 | +void setup() |
| 28 | +{ |
| 29 | + delay(100); |
| 30 | + Wire.begin(); |
| 31 | + |
| 32 | + Serial.begin(115200); |
| 33 | + Serial.println(F("Micro OLED Example")); |
| 34 | + |
| 35 | + oled.enableDebugging(); // Uncomment this line to enable debug messages on Serial |
| 36 | + |
| 37 | + oled.begin(); // Initialize the OLED |
| 38 | + oled.clear(ALL); // Clear the display's internal memory |
| 39 | + oled.display(); // Display what's in the buffer (splashscreen) |
| 40 | + |
| 41 | + int MIDDLE_X = oled.getLCDWidth() / 2; // Find the centre of the display |
| 42 | + int MIDDLE_Y = oled.getLCDHeight() / 2; |
| 43 | + |
| 44 | + oled.clear(PAGE); |
| 45 | + oled.line(MIDDLE_X - 10, MIDDLE_Y - 20, MIDDLE_X + 10, MIDDLE_Y + 20); // Steep x0<x1 |
| 46 | + oled.display(); |
| 47 | + delay(500); |
| 48 | + |
| 49 | + oled.clear(PAGE); |
| 50 | + oled.line(MIDDLE_X - 10, MIDDLE_Y - 10, MIDDLE_X + 10, MIDDLE_Y + 10); // 45-degrees x0<x1 |
| 51 | + oled.display(); |
| 52 | + delay(500); |
| 53 | + |
| 54 | + oled.clear(PAGE); |
| 55 | + oled.line(MIDDLE_X - 10, MIDDLE_Y - 5, MIDDLE_X + 10, MIDDLE_Y + 5); // Shallow x0<x1 |
| 56 | + oled.display(); |
| 57 | + delay(500); |
| 58 | + |
| 59 | + oled.clear(PAGE); |
| 60 | + oled.line(MIDDLE_X - 10, MIDDLE_Y, MIDDLE_X + 10, MIDDLE_Y); // Horizontal x0<x1 |
| 61 | + oled.display(); |
| 62 | + delay(500); |
| 63 | + |
| 64 | + oled.clear(PAGE); |
| 65 | + oled.line(MIDDLE_X, MIDDLE_Y - 10, MIDDLE_X, MIDDLE_Y + 10); // Vertical y0<y1 |
| 66 | + oled.display(); |
| 67 | + delay(500); |
| 68 | + |
| 69 | + oled.clear(PAGE); |
| 70 | + oled.line(MIDDLE_X + 10, MIDDLE_Y - 20, MIDDLE_X - 10, MIDDLE_Y + 20); // Steep x0>x1 |
| 71 | + oled.display(); |
| 72 | + delay(500); |
| 73 | + |
| 74 | + oled.clear(PAGE); |
| 75 | + oled.line(MIDDLE_X + 10, MIDDLE_Y - 10, MIDDLE_X - 10, MIDDLE_Y + 10); // 45-degrees x0>x1 |
| 76 | + oled.display(); |
| 77 | + delay(500); |
| 78 | + |
| 79 | + oled.clear(PAGE); |
| 80 | + oled.line(MIDDLE_X + 10, MIDDLE_Y - 5, MIDDLE_X - 10, MIDDLE_Y + 5); // Shallow x0>x1 |
| 81 | + oled.display(); |
| 82 | + delay(500); |
| 83 | + |
| 84 | + oled.clear(PAGE); |
| 85 | + oled.line(MIDDLE_X + 10, MIDDLE_Y, MIDDLE_X - 10, MIDDLE_Y); // Horizontal x0>x1 |
| 86 | + oled.display(); |
| 87 | + delay(500); |
| 88 | + |
| 89 | + oled.clear(PAGE); |
| 90 | + oled.line(MIDDLE_X, MIDDLE_Y + 10, MIDDLE_X, MIDDLE_Y - 10); // Vertical y0>y1 |
| 91 | + oled.display(); |
| 92 | +} |
| 93 | + |
| 94 | +void loop() |
| 95 | +{ |
| 96 | + // Nothing to do here... |
| 97 | +} |
0 commit comments