├── .github └── workflows │ └── mkdocs.yml ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── docs ├── api_arduino.md ├── api_device.md ├── api_draw.md ├── api_graphics.md ├── api_scroll.md ├── assets │ ├── MicroMod-logo-updated.png │ ├── Qwiic-registered-updated.png │ └── sfe_favicon.png ├── github │ ├── contribute.md │ └── file_issue.md ├── hug_0p91.md ├── hug_1p3.md ├── hug_micro_view.md ├── hug_transparent.md ├── img │ ├── OLEDLibBanner.png │ └── sfe_logo_sm.png ├── index.md ├── introduction.md ├── javascript │ ├── README.md │ └── mathjax.js ├── single_page.md ├── software.md ├── stylesheet │ └── extra.css └── troubleshooting.md ├── examples ├── Example-01_Hello │ └── Example-01_Hello.ino ├── Example-02_Shapes │ └── Example-02_Shapes.ino ├── Example-03_Bitmap │ └── Example-03_Bitmap.ino ├── Example-04_Text │ └── Example-04_Text.ino ├── Example-05_ScrollFlip │ └── Example-05_ScrollFlip.ino ├── Example-06_Clock │ └── Example-06_Clock.ino ├── Example-07_Cube │ └── Example-07_Cube.ino ├── Example-08_Multi │ └── Example-08_Multi.ino ├── Example-09_CustomOLED │ └── Example-09_CustomOLED.ino ├── docs │ ├── ex_01_hello.md │ ├── ex_02_lines.md │ ├── ex_03_bitmaps.md │ ├── ex_04_text.md │ ├── ex_other.md │ └── img │ │ └── ex01_hello.png └── mkdocs.yml ├── img └── Contributing.JPG ├── keywords.txt ├── library.json ├── library.properties ├── mkdocs.yml ├── overrides ├── .icons │ └── sfe-logo.svg ├── README.md ├── main.html └── partials │ ├── nav.html │ ├── tabs.html │ └── toc-backup.html └── src ├── SparkFun_Qwiic_OLED.h ├── qwiic_grbuffer.cpp ├── qwiic_grbuffer.h ├── qwiic_grssd1306.cpp ├── qwiic_grssd1306.h ├── qwiic_i2c.cpp ├── qwiic_i2c.h ├── qwiic_oled_1in3.h ├── qwiic_oled_custom.h ├── qwiic_oledmicro.h ├── qwiic_olednarrow.h ├── qwiic_oledtransp.h └── res ├── _bmp_sparkfun.h ├── _bmp_truck.h ├── _fnt_31x48.h ├── _fnt_5x7.h ├── _fnt_7segment.h ├── _fnt_8x16.h ├── _fnt_largenum.h ├── qw_bmp_sparkfun.h ├── qw_bmp_truck.h ├── qw_fnt_31x48.h ├── qw_fnt_5x7.h ├── qw_fnt_7segment.h ├── qw_fnt_8x16.h ├── qw_fnt_largenum.h ├── qw_pgm_arduino.h └── qwiic_resdef.h /.github/workflows/mkdocs.yml: -------------------------------------------------------------------------------- 1 | name: Run mkdocs 2 | on: 3 | push: 4 | branches: 5 | - main 6 | permissions: 7 | contents: write 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v3 14 | 15 | - name: Set up Python runtime 16 | uses: actions/setup-python@v4 17 | with: 18 | python-version: 3.x 19 | 20 | - name: Install Python dependencies 21 | run: pip install mkdocs-monorepo-plugin mkdocs-redirects mkdocs-with-pdf weasyprint mkdocs-git-authors-plugin mkdocs-git-revision-date-localized-plugin mkdocs-git-committers-plugin-2 setuptools 22 | 23 | - name: Set up build cache 24 | uses: actions/cache@v2 25 | with: 26 | key: ${{ github.ref }} 27 | path: .cache 28 | 29 | - name: Install Insiders build 30 | env: 31 | GH_TOKEN: ${{ secrets.GH_TOKEN }} 32 | run: pip install git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git 33 | - run: mkdocs gh-deploy --force 34 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | Thank you so *much* for offering to help out. We truly appreciate it. 4 | 5 | If you'd like to contribute, start by searching through the [issues](https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library/issues) and [pull requests](https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library/pulls) to see whether someone else has raised a similar idea or question. 6 | Please check the [closed issues](https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library/issues?q=is%3Aissue+is%3Aclosed) 7 | and [closed pull requests](https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library/pulls?q=is%3Apr+is%3Aclosed) too - you may find that your issue or feature has already been discussed. 8 | 9 | If you decide to add a feature to this library, please create a PR and follow these best practices: 10 | 11 | * Change as little as possible. Do not submit a PR that changes 100 lines of whitespace. Break up into multiple PRs if necessary. 12 | * If you've added a new feature document it with a simple example sketch. This serves both as a test of your PR and as a quick way for users to quickly learn how to use your new feature. 13 | * If you add new functions also add them to _keywords.txt_ so that they are properly highlighted in Arduino. [Read more](https://www.arduino.cc/en/Hacking/libraryTutorial). 14 | * **Important:** Please submit your PR using the [release_candidate branch](https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library/tree/release_candidate). That way, we can merge and test your PR quickly without changing the _master_ branch 15 | 16 | ![Contributing.JPG](./img/Contributing.JPG) 17 | 18 | ## Style guide 19 | 20 | Please read and follow the [Arduino API style guide](https://www.arduino.cc/en/Reference/APIStyleGuide). Also read and consider the [Arduino style guide](https://www.arduino.cc/en/Reference/StyleGuide). 21 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | SparkFun License Information 2 | ============================ 3 | 4 | SparkFun uses two different licenses for our files — one for hardware and one for code. 5 | 6 | Hardware 7 | --------- 8 | 9 | **SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).** 10 | 11 | Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode). 12 | 13 | You are free to: 14 | 15 | Share — copy and redistribute the material in any medium or format 16 | Adapt — remix, transform, and build upon the material 17 | for any purpose, even commercially. 18 | The licensor cannot revoke these freedoms as long as you follow the license terms. 19 | Under the following terms: 20 | 21 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 22 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 23 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 24 | Notices: 25 | 26 | You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. 27 | No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material. 28 | 29 | 30 | Code 31 | -------- 32 | 33 | **SparkFun code, firmware, and software is released under the [MIT License](http://opensource.org/licenses/MIT).** 34 | 35 | The MIT License (MIT) 36 | 37 | Copyright (c) 2015 SparkFun Electronics 38 | 39 | Permission is hereby granted, free of charge, to any person obtaining a copy 40 | of this software and associated documentation files (the "Software"), to deal 41 | in the Software without restriction, including without limitation the rights 42 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 43 | copies of the Software, and to permit persons to whom the Software is 44 | furnished to do so, subject to the following conditions: 45 | 46 | The above copyright notice and this permission notice shall be included in all 47 | copies or substantial portions of the Software. 48 | 49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 50 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 51 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 52 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 53 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 54 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 55 | SOFTWARE. 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![SparkFun Qwiic OLED Arduino Library](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/blob/main/docs/img/OLEDLibBanner.png "SparkFun Qwiic OLED Arduino Library") 2 | 3 | # SparkFun Qwiic OLED Arduino Library 4 |

5 | 6 | 7 | 8 | 9 | 10 | follow on Twitter 12 | 13 | 14 |

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
SparkFun Micro OLED Breakout (Qwiic)
[LCD-14532]
SparkFun Qwiic OLED Display (0.91 in, 128x32)
[LCD-24606]
smôl OLED Display (0.91 in, 128x32)
[SPX-18996]
SparkFun Transparent Graphical OLED Breakout (Qwiic)
[LCD-15173]
SparkFun Qwiic OLED - (1.3in., 128x64)
[LCD-23453]
32 | 33 | 34 | The SparkFun Qwiic OLED Arduino Library is a single graphics module that supports all SparkFun OLED boards based on the SSD1306 from Solomon Systech. Prior to this library, three different libraries were used to support our four different OLED boards. 35 | 36 | The SparkFun Qwiic OLED Library delivers a common implementation for all our Qwiic OLED products, delivering a unified, fast, and efficient solution that implements a familiar and easy to understand user experience. 37 | 38 | ## Key Features 39 | * Implements common graphics capabilities: pixel, line, rectangle, filled rectangle, circle, filled circle, bitmap, text and raster operators (i.e. XOR). 40 | * Smart data transfer to the device – only sends _dirty_ regions of the graphics buffer to the OLED device, not the entire buffer. 41 | * High performance – 2x faster than our previous OLED library, often much higher. 42 | * Efficient memory usage. No dynamic memory utilized. Static resources are loaded once, and only on explicit declaration. 43 | * Implements a familiar interface, making migration from older libraries straight forward 44 | 45 | ## Documentation 46 | A full library use overview, API reference guide and key example walk through are available on this repositories github page - [sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library](https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/) 47 | 48 | ## How much faster? 49 | 50 | The SparkFun Qwiic OLED Library is between 40% and 450% faster. The original [Micro OLED library](https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library) had a max output of ~75 frames per second. This library automatically only updates *what changed* we can reach more than 300 frames per second. What does that look like? 51 | 52 | https://user-images.githubusercontent.com/117102/160000377-b2de6d3f-a90f-42da-bd95-2a301c817c80.mp4 53 | 54 | Above, the OLED on the right is running the original Micro OLED library at 75fps. On the left the display is more than 348 frames per second. In real life it's quite smooth; the camera is not able to keep up. This is at 400kHz I2C. 55 | 56 | https://user-images.githubusercontent.com/117102/160000390-47a318ac-4158-4988-8831-44f7b9d32f01.mp4 57 | 58 | Above, the OLED on the right is running the original Micro OLED library at 75fps. On the left the display is more than 107 frames per second because the clock takes up a lot of the display, but not all of it. This is at 400kHz I2C. 59 | 60 | ## Supported Products 61 | 62 | * [LCD-22495](https://www.sparkfun.com/products/22495) - SparkFun Micro OLED Breakout (Qwiic) 63 | * [LCD-14532](https://www.sparkfun.com/products/14532) - SparkFun Micro OLED Breakout (Qwiic) 64 | * [LCD-13003](https://www.sparkfun.com/products/13003) - SparkFun Micro OLED Breakout 65 | * [LCD-24606](https://www.sparkfun.com/products/24606) - SparkFun Qwiic OLED Display (0.91 in, 128x32) 66 | * [LCD-17153](https://www.sparkfun.com/products/17153) - SparkFun Qwiic OLED Display (0.91 in, 128x32) 67 | * [SPX-18996](https://www.sparkfun.com/products/18996) - smôl OLED Display (0.91 in, 128x32) 68 | * [LCD-15173](https://www.sparkfun.com/products/15173) - SparkFun Transparent Graphical OLED Breakout (Qwiic) 69 | * [LCD-23453](https://www.sparkfun.com/products/23453) - SparkFun Qwiic OLED (1.3 in., 128x64) 70 | 71 | ### Supported Microcontrollers - Arduino Environment 72 | 73 | * [Artemis](https://www.sparkfun.com/products/15574) 74 | * [SAMD51](https://www.sparkfun.com/products/14713) 75 | * [ESP32](https://www.sparkfun.com/products/15663) 76 | * [STM32](https://www.sparkfun.com/products/17712) 77 | * [SAMD21](https://www.sparkfun.com/products/14812) 78 | * [nrf5280](https://www.sparkfun.com/products/15025) 79 | * [Teensy](https://www.sparkfun.com/products/16402) 80 | * [ATMega328](https://www.sparkfun.com/products/18158) 81 | -------------------------------------------------------------------------------- /docs/api_arduino.md: -------------------------------------------------------------------------------- 1 | # Arduino Print 2 | 3 | Methods used to support Arduino Print functionality. 4 | 5 | ### setCursor() 6 | 7 | This method is called set the "cursor" position in the device. The library supports the Arduino `Print` interface, enabling the use of a `print()` and `println()` methods. The set cursor position defines where to start text output for this functionality. 8 | 9 | ```c++ 10 | void setCursor(uint8_t x, uint8_t y) 11 | ``` 12 | 13 | | Parameter | Type | Description | 14 | | :--- | :--- | :--- | 15 | | x | `uint8_t` | The X coordinate of the cursor| 16 | | y | `uint8_t` | The Y coordinate of the cursor| 17 | 18 | ### setColor() 19 | 20 | This method is called to set the current color of the system. This is used by the Arduino `Print` interface functionality 21 | 22 | 23 | ```c++ 24 | void setColor(uint8_t clr) 25 | ``` 26 | 27 | | Parameter | Type | Description | 28 | | :--- | :--- | :--- | 29 | | `clr` | `uint8_t` | The color to set. 0 = black, > 0 = white| 30 | 31 | ### getColor() 32 | 33 | This method is called to get the current color of the system. This is used by the Arduino `Print` interface functionality 34 | 35 | 36 | ```c++ 37 | uint8_t getColor(void) 38 | ``` 39 | 40 | | Parameter | Type | Description | 41 | | :--- | :--- | :--- | 42 | | return value| `uint8_t` | The current color| 43 | 44 | 45 | -------------------------------------------------------------------------------- /docs/api_device.md: -------------------------------------------------------------------------------- 1 | # Device Operations 2 | 3 | Methods to setup the device, get device information and change display options. 4 | 5 | ## Initialization 6 | 7 | ### begin() 8 | This method is called to initialize the OLED library and connection to the OLED device. This method must be called before calling any graphics methods. 9 | 10 | ```c++ 11 | bool begin(TwoWire &wirePort, uint8_t address) 12 | ``` 13 | 14 | | Parameter | Type | Description | 15 | | :------------ | :---------- | :---------------------------------------------- | 16 | | `wirePort` | `TwoWire` | **optional**. The Wire port. If not provided, the default port is used| 17 | | `address` | `uint8_t` | **optional**. I2C Address. If not provided, the default address is used.| 18 | | return value | `bool` | ```true``` on success, ```false``` on startup failure | 19 | 20 | ### reset() 21 | When called, this method reset the library state and OLED device to their intial state. Helpful to reset the OLED after waking up a system from a sleep state. 22 | 23 | ```C++ 24 | void reset() 25 | ``` 26 | 27 | | Parameter | Type | Description | 28 | | :------------ | :---------- | :---------------------------------------------- | 29 | | return value | `bool` | ```true``` on success, ```false``` on startup failure | 30 | 31 | 32 | ## Geometry 33 | 34 | ### getWidth() 35 | This method returns the width, in pixels, of the connected OLED device 36 | 37 | ```c++ 38 | uint8_t getWidth(void) 39 | ``` 40 | 41 | | Parameter | Type | Description | 42 | | :--- | :--- | :--- | 43 | | return value | `uint8_t` | The width in pixels of the connected OLED device | 44 | 45 | ### getHeight() 46 | This method returns the height, in pixels, of the connected OLED device 47 | 48 | ```c++ 49 | uint8_t getHeight(void) 50 | ``` 51 | 52 | | Parameter | Type | Description | 53 | | :--- | :--- | :--- | 54 | | return value | `uint8_t` | The height in pixels of the connected OLED device | 55 | 56 | ## Display Modes 57 | 58 | ### invert() 59 | This method inverts the current graphics on the display. This results of this command happen immediatly. 60 | 61 | ```c++ 62 | void invert(bool bInvert) 63 | ``` 64 | 65 | | Parameter | Type | Description | 66 | | :--- | :--- | :--- | 67 | | ```bInvert``` | `bool` | ```true``` - the screen is inverted. ```false``` - the screen is set to normal | 68 | 69 | ### flipVertical() 70 | When called, the screen contents are flipped vertically if the flip parameter is true, or restored to normal display if the flip parameter is false. 71 | 72 | ```c++ 73 | void flipVertical(bool bFlip) 74 | ``` 75 | 76 | | Parameter | Type | Description | 77 | | :--- | :--- | :--- | 78 | | ```bFlip``` | `bool` | ```true``` - the screen is flipped vertically. ```false``` - the screen is set to normal | 79 | 80 | ### flipHorizontal() 81 | When called, the screen contents are flipped horizontally if the flip parameter is true, or restored to normal display if the flip parameter is false. 82 | 83 | ```c++ 84 | void flipHorizontal(bool bFlip) 85 | ``` 86 | 87 | | Parameter | Type | Description | 88 | | :--- | :--- | :--- | 89 | | ```bFlip``` | `bool` | ```true``` - the screen is flipped horizontally. ```false``` - the screen is set to normal | 90 | 91 | ### displayPower() 92 | Used to turn the OLED display on or off. 93 | 94 | ```c++ 95 | void displayPower(bool bEnable) 96 | ``` 97 | 98 | | Parameter | Type | Description | 99 | | :--- | :--- | :--- | 100 | | ```bEnable``` | `bool` | ```true``` - the OLED display is powered on (default). ```false``` - the OLED dsiplay is powered off. | 101 | 102 | -------------------------------------------------------------------------------- /docs/api_draw.md: -------------------------------------------------------------------------------- 1 | # Drawing Settings/State 2 | 3 | Methods for setting the drawing state of the library. 4 | 5 | ### setFont() 6 | 7 | This method is called to set the current font in the library. The current font is used when calling the ```text()``` method on this device. 8 | 9 | The default font for the device is `5x7`. 10 | 11 | ```c++ 12 | void setFont(QwiicFont& theFont) 13 | void setFont(const QwiicFont * theFont) 14 | ``` 15 | 16 | | Parameter | Type | Description | 17 | | :--- | :--- | :--- | 18 | | `theFont` | `QwiicFont` | The font to set as current in the device| 19 | | `theFont` | `QwiicFont*` | Pointer to the font to set as current in the device.| 20 | 21 | For the library, fonts are added to your program by including them via include files which are part of this library. 22 | 23 | The following fonts are included: 24 | 25 | | Font | Include File | Font Variable | Description| 26 | | :--- | :--- | :--- | :--- | 27 | | 5x7 | `` | `QW_FONT_5X7`| A full, 5 x 7 font| 28 | | 31x48 | `` |`QW_FONT_31X48`| A full, 31 x 48 font| 29 | | Seven Segment | `` |`QW_FONT_7SEGMENT`| Numbers only| 30 | | 8x16 | `` | `QW_FONT_8X16`| A full, 8 x 16 font| 31 | | Large Numbers | `` |`QW_FONT_LARGENUM`| Numbers only| 32 | 33 | For each font, the font variables are objects with the following attributes: 34 | 35 | | Attribute | Value | 36 | | :--- | :--- | 37 | | `width` | The font width in pixels| 38 | | `height` | The font height in pixels| 39 | | `start` | The font start character offset| 40 | | `n_chars` | The number of characters| 41 | | `map_width` | The width of the font map| 42 | 43 | Example use of a font object attribute: 44 | ```C++ 45 | #include 46 | 47 | int myFontWidth = QW_FONT_31X48.width; 48 | ``` 49 | 50 | ### getFont() 51 | This method returns the current font for the device. 52 | 53 | ```c++ 54 | QwiicFont * getFont(void) 55 | ``` 56 | 57 | | Parameter | Type | Description | 58 | | :--- | :--- | :--- | 59 | | return value | `QwiicFont*` | A pointer to the current font. See `setFont()` for font object details.| 60 | 61 | ### getFontName() 62 | 63 | This method returns the height in pixels of a provided String based on the current device font. 64 | 65 | ```c++ 66 | String getFontName(void) 67 | ``` 68 | 69 | | Parameter | Type | Description | 70 | | :--- | :--- | :--- | 71 | | return value | String | The name of the current font.| 72 | 73 | ### getStringWidth() 74 | 75 | This method returns the width in pixels of a provided String based on the current device font. 76 | 77 | ```c++ 78 | unsigned int getStringWidth(String text) 79 | ``` 80 | 81 | | Parameter | Type | Description | 82 | | :--- | :--- | :--- | 83 | | text | `String` | The string used to determine width | 84 | | return value | `unsigned int` | The width of the provide string, as determined using the current font.| 85 | 86 | ### getStringHeight() 87 | 88 | This method returns the height in pixels of a provided String based on the current device font. 89 | 90 | ```c++ 91 | unsigned int getStringHeight(String text) 92 | ``` 93 | 94 | | Parameter | Type | Description | 95 | | :--- | :--- | :--- | 96 | | text | `String` | The string used to determine height | 97 | | return value | `unsigned int` | The height of the provide string, as determined using the current font.| 98 | 99 | ### setDrawMode() 100 | This method sets the current draw mode for the library. The draw mode determines how pixels are set on the screen during drawing operations. 101 | 102 | ```c++ 103 | void setDrawMode(grRasterOp_t rop) 104 | ``` 105 | 106 | | Parameter | Type | Description | 107 | | :--- | :--- | :--- | 108 | | rop | `grRasterOp_t` | The raster operation (ROP) to set the graphics system to.| 109 | 110 | Raster operations device how source (pixels to draw) are represented on the destination device. The available Raster Operation (ROP) codes are: 111 | 112 | | ROP Code | Description| 113 | | :--- | :--- | 114 | | grROPCopy | **default** Drawn pixel values are copied to the device screen| 115 | | grROPNotCopy | A not operation is applied to the source value before copying to screen| 116 | | grROPNot | A not operation is applied to the destination (screen) value | 117 | | grROPXOR | A XOR operation is performed between the source and destination values| 118 | | grROPBlack | A value of 0, or black is drawn to the destination | 119 | | grROPWhite | A value of 1, or black is drawn to the destination | 120 | 121 | 122 | ### getDrawMode() 123 | This method returns the current draw mode for the library. The draw mode determines how pixels are set on the screen during drawing operations. 124 | 125 | ```c++ 126 | grRasterOp_t getDrawMode(void) 127 | ``` 128 | 129 | | Parameter | Type | Description | 130 | | :--- | :--- | :--- | 131 | | return value | `grRasterOp_t` | The current aster operation (ROP) of the graphics system.| 132 | -------------------------------------------------------------------------------- /docs/api_graphics.md: -------------------------------------------------------------------------------- 1 | # Graphics Methods 2 | 3 | Methods used to draw and display graphics. 4 | 5 | ### display() 6 | When called, any pending display updates are sent to the connected OLED device. This includes drawn graphics and erase commands. 7 | 8 | ```c++ 9 | void display(void) 10 | ``` 11 | 12 | | Parameter | Type | Description | 13 | | :--- | :--- | :--- | 14 | | NONE| | | 15 | 16 | ### erase() 17 | Erases all graphics on the device, placing the display in a blank state. The erase update isn't sent to the device until the next ```display()``` call on the device. 18 | 19 | ```c++ 20 | void erase(void) 21 | ``` 22 | 23 | | Parameter | Type | Description | 24 | | :--- | :--- | :--- | 25 | | NONE| | | 26 | 27 | ### pixel() 28 | 29 | Set the value of a pixel on the screen. 30 | 31 | ```c++ 32 | void pixel(uint8_t x, uint8_t y, uint8_t clr) 33 | ``` 34 | 35 | | Parameter | Type | Description | 36 | | :--- | :--- | :--- | 37 | | x | `uint8_t` | The X coordinate of the pixel to set| 38 | | y | `uint8_t` | The Y coordinate of the pixel to set| 39 | | clr | `uint8_t` | **optional** The color value to set the pixel. This defaults to white (1).| 40 | 41 | ### line() 42 | 43 | Draw a line on the screen. 44 | 45 | Note: If a line is horizontal (y0 = y1) or vertical (x0 = x1), optimized draw algorithms are used by the library. 46 | 47 | ```c++ 48 | void line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t clr) 49 | ``` 50 | 51 | | Parameter | Type | Description | 52 | | :--- | :--- | :--- | 53 | | x0 | `uint8_t` | The start X coordinate of the line| 54 | | y0 | `uint8_t` | The start Y coordinate of the line| 55 | | x1 | `uint8_t` | The end X coordinate of the line| 56 | | y1 | `uint8_t` | The end Y coordinate of the line| 57 | | clr | `uint8_t` | **optional** The color value to draw the line. This defaults to white (1).| 58 | 59 | ### rectangle() 60 | 61 | Draw a rectangle on the screen. 62 | 63 | ```c++ 64 | void rectangle(uint8_t x0, uint8_t y0, uint8_t width, uint8_t height, uint8_t clr) 65 | ``` 66 | 67 | | Parameter | Type | Description | 68 | | :--- | :--- | :--- | 69 | | x0 | `uint8_t` | The start X coordinate of the rectangle - upper left corner| 70 | | y0 | `uint8_t` | The start Y coordinate of the rectangle - upper left corner| 71 | | width | `uint8_t` | The width of the rectangle| 72 | | height | `uint8_t` | The height of the rectangle| 73 | | clr | `uint8_t` | **optional** The color value to draw the line. This defaults to white (1).| 74 | 75 | ### rectangleFill() 76 | 77 | Draw a filled rectangle on the screen. 78 | 79 | ```c++ 80 | void rectangleFill(uint8_t x0, uint8_t y0, uint8_t width, uint8_t height, uint8_t clr) 81 | ``` 82 | 83 | | Parameter | Type | Description | 84 | | :--- | :--- | :--- | 85 | | x0 | `uint8_t` | The start X coordinate of the rectangle - upper left corner| 86 | | y0 | `uint8_t` | The start Y coordinate of the rectangle - upper left corner| 87 | | width | `uint8_t` | The width of the rectangle| 88 | | height | `uint8_t` | The height of the rectangle| 89 | | clr | `uint8_t` | **optional** The color value to draw the line. This defaults to white (1).| 90 | 91 | ### circle() 92 | 93 | Draw a circle on the screen. 94 | 95 | ```c++ 96 | void circle(uint8_t x0, uint8_t y0, uint8_t radius, uint8_t clr) 97 | ``` 98 | 99 | | Parameter | Type | Description | 100 | | :--- | :--- | :--- | 101 | | x0 | `uint8_t` | The X coordinate of the circle center| 102 | | y0 | `uint8_t` | The Y coordinate of the circle center| 103 | | radius | `uint8_t` | The radius of the circle| 104 | | clr | `uint8_t` | **optional** The color value to draw the circle. This defaults to white (1).| 105 | 106 | ### circleFill() 107 | 108 | Draw a filled circle on the screen. 109 | 110 | ```c++ 111 | void circleFill(uint8_t x0, uint8_t y0, uint8_t radius, uint8_t clr) 112 | ``` 113 | 114 | | Parameter | Type | Description | 115 | | :--- | :--- | :--- | 116 | | x0 | `uint8_t` | The X coordinate of the circle center| 117 | | y0 | `uint8_t` | The Y coordinate of the circle center| 118 | | radius | `uint8_t` | The radius of the circle| 119 | | clr | `uint8_t` | **optional** The color value to draw the circle. This defaults to white (1).| 120 | 121 | ### bitmap() 122 | 123 | Draws a bitmap on the screen. 124 | 125 | The bitmap should be 8 bit encoded - each pixel contains 8 y values. 126 | 127 | ```c++ 128 | void bitmap(uint8_t x0, uint8_t y0, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height ) 129 | ``` 130 | 131 | | Parameter | Type | Description | 132 | | :--- | :--- | :--- | 133 | | x0 | `uint8_t` | The X coordinate to place the bitmap - upper left corner| 134 | | y0 | `uint8_t` | The Y coordinate to place the bitmap - upper left corner| 135 | | pBitmap | `uint8_t *` | A pointer to the bitmap array| 136 | | bmp_width | `uint8_t` | The width of the bitmap| 137 | | bmp_height | `uint8_t` | The height of the bitmap| 138 | 139 | ### bitmap() 140 | 141 | Draws a bitmap on the screen. 142 | 143 | The bitmap should be 8 bit encoded - each pixel contains 8 y values. 144 | 145 | The coordinate [x1,y1] allows for only a portion of bitmap to be drawn. 146 | 147 | ```c++ 148 | void bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, 149 | uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height ) 150 | ``` 151 | 152 | | Parameter | Type | Description | 153 | | :--- | :--- | :--- | 154 | | x0 | `uint8_t` | The X coordinate to place the bitmap - upper left corner| 155 | | y0 | `uint8_t` | The Y coordinate to place the bitmap - upper left corner| 156 | | x1 | `uint8_t` | The end X coordinate of the bitmap - lower right corner| 157 | | y1 | `uint8_t` | The end Y coordinate of the bitmap - lower right corner| 158 | | pBitmap | `uint8_t *` | A pointer to the bitmap array| 159 | | bmp_width | `uint8_t` | The width of the bitmap| 160 | | bmp_height | `uint8_t` | The height of the bitmap| 161 | 162 | ### bitmap() 163 | 164 | Draws a bitmap on the screen using a Bitmap object for the bitmap data. 165 | 166 | ```c++ 167 | void bitmap(uint8_t x0, uint8_t y0, QwiicBitmap& bitmap) 168 | ``` 169 | 170 | | Parameter | Type | Description | 171 | | :--- | :--- | :--- | 172 | | x0 | `uint8_t` | The X coordinate to place the bitmap - upper left corner| 173 | | y0 | `uint8_t` | The Y coordinate to place the bitmap - upper left corner| 174 | | Bitmap | `QwiicBitmap` | A bitmap object| 175 | 176 | ### text() 177 | 178 | Draws a string using the current font on the screen. 179 | 180 | ```c++ 181 | void text(uint8_t x0, uint8_t y0, const char * text, uint8_t clr) 182 | ``` 183 | 184 | | Parameter | Type | Description | 185 | | :--- | :--- | :--- | 186 | | x0 | `uint8_t` | The X coordinate to start drawing the text| 187 | | y0 | `uint8_t` | The Y coordinate to start drawing the text| 188 | | text | `const char*` | The string to draw on the screen | 189 | | text | `String` | The Arduino string to draw on the screen | 190 | | clr | `uint8_t` | **optional** The color value to draw the circle. This defaults to white (1).| 191 | -------------------------------------------------------------------------------- /docs/api_scroll.md: -------------------------------------------------------------------------------- 1 | # Scrolling 2 | 3 | Methods for device scrolling 4 | 5 | ### scrollStop() 6 | If the device is in a scrolling mode, calling this method stops the scroll, and restores the device to normal display operation. This action is performed immediately. 7 | 8 | ```c++ 9 | void scrollStop(void) 10 | ``` 11 | 12 | | Parameter | Type | Description | 13 | | :--- | :--- | :--- | 14 | | NONE| | | 15 | 16 | 17 | 18 | ### scrollRight() 19 | This method is called to start the device scrolling the displayed graphics to the right. This action is performed immediately. 20 | 21 | The screen will scroll until the ```scrollStop()``` method is called. 22 | 23 | ```c++ 24 | void scrollRight(uint8_t start, uint8_t stop, uint8_t interval) 25 | ``` 26 | 27 | | Parameter | Type | Description | 28 | | :--- | :--- | :--- | 29 | | `start` | `uint8_t` | The start page address of the scroll - valid values are 0 thru 7| 30 | | `stop` | `uint8_t` | The stop/end page address of the scroll - valid values are 0 thru 7| 31 | | `interval` | `uint8_t` | The time interval between scroll step - values listed below | 32 | 33 | Defined values for the `interval` parameter: 34 | 35 | | Defined Symbol | Time Interval Between Steps | 36 | | :--- | :---| 37 | |`SCROLL_INTERVAL_2_FRAMES` | 2 | 38 | |`SCROLL_INTERVAL_3_FRAMES` | 3 | 39 | |`SCROLL_INTERVAL_4_FRAMES` | 4 | 40 | |`SCROLL_INTERVAL_5_FRAMES` | 5 | 41 | |`SCROLL_INTERVAL_25_FRAMES` | 25 | 42 | |`SCROLL_INTERVAL_64_FRAMES` | 64 | 43 | |`SCROLL_INTERVAL_128_FRAMES` | 128 | 44 | |`SCROLL_INTERVAL_256_FRAMES` | 256 | 45 | 46 | ### scrollVertRight() 47 | This method is called to start the device scrolling the displayed graphics vertically and to the right. This action is performed immediately. 48 | 49 | The screen will scroll until the ```scrollStop()``` method is called. 50 | 51 | ```c++ 52 | void scrolVertlRight(uint8_t start, uint8_t stop, uint8_t interval) 53 | ``` 54 | 55 | | Parameter | Type | Description | 56 | | :--- | :--- | :--- | 57 | | `start` | `uint8_t` | The start page address of the scroll - valid values are 0 thru 7| 58 | | `stop` | `uint8_t` | The stop/end page address of the scroll - valid values are 0 thru 7| 59 | | `interval` | `uint8_t` | The time interval between scroll step - values listed in ```scrollRight``` | 60 | 61 | ### scrollLeft() 62 | This method is called start to the device scrolling the displayed graphics to the left. This action is performed immediately. 63 | 64 | The screen will scroll until the ```scrollStop()``` method is called. 65 | 66 | ```c++ 67 | void scrollLeft(uint8_t start, uint8_t stop, uint8_t interval) 68 | ``` 69 | 70 | | Parameter | Type | Description | 71 | | :--- | :--- | :--- | 72 | | `start` | `uint8_t` | The start page address of the scroll - valid values are 0 thru 7| 73 | | `stop` | `uint8_t` | The stop/end page address of the scroll - valid values are 0 thru 7| 74 | | `interval` | `uint8_t` | The time interval between scroll step - values listed in ```scrollRight``` | 75 | 76 | ### scrollVertLeft() 77 | This method is called to start the device scrolling the displayed graphics vertically and to the left. This action is performed immediately. 78 | 79 | The screen will scroll until the ```scrollStop()``` method is called. 80 | 81 | ```c++ 82 | void scrolVertlLeft(uint8_t start, uint8_t stop, uint8_t interval) 83 | ``` 84 | 85 | | Parameter | Type | Description | 86 | | :--- | :--- | :--- | 87 | | `start` | `uint8_t` | The start page address of the scroll - valid values are 0 thru 7| 88 | | `stop` | `uint8_t` | The stop/end page address of the scroll - valid values are 0 thru 7| 89 | | `interval` | `uint8_t` | The time interval between scroll step - values listed in ```scrollRight``` | 90 | -------------------------------------------------------------------------------- /docs/assets/MicroMod-logo-updated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/b8bdcf5ef2fd8d49e49b2a9d0f44d809ea078951/docs/assets/MicroMod-logo-updated.png -------------------------------------------------------------------------------- /docs/assets/Qwiic-registered-updated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/b8bdcf5ef2fd8d49e49b2a9d0f44d809ea078951/docs/assets/Qwiic-registered-updated.png -------------------------------------------------------------------------------- /docs/assets/sfe_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/b8bdcf5ef2fd8d49e49b2a9d0f44d809ea078951/docs/assets/sfe_favicon.png -------------------------------------------------------------------------------- /docs/github/contribute.md: -------------------------------------------------------------------------------- 1 | # Contribute: Help Fix our Mistake! 2 | Spot something wrong? Feel free to contribute our open-source design and documentation. 3 | 4 | ## Improve our Documentation 5 | All of this documentation can be modified by you! Please help us make it better. 6 | 7 | * These pages are contained in the [`docs` folder of the SparkFun Qwiic OLED Arduino Library repository](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/tree/main/docs). 8 | 9 | ### Submit a Correction 10 | 1. Fork this repo 11 | 2. Add your corrections or improvements to the markdown file 12 | 3. File a pull request with your changes, and enjoy making the ~~words~~ ~~worlds~~ world a better place. 13 | * Once received, the documentation specialist will automatically be notified. 14 | * We will review your suggested improvements to make sure they are correct and fit within our documentation standards. 15 | 16 | ## Improve our Hardware Design 17 | All of our designs are open-source! Please help us make it better. 18 | 19 | * Our board design files are contained in the `Hardware` folder of their respective repositories: 20 | 21 | * [SparkFun Micro OLED Breakout (Qwiic)](https://github.com/sparkfun/Qwiic_Micro_OLED/tree/main/Hardware) 22 | * [SparkFun Qwiic OLED Display (0.91 in, 128x32)](https://github.com/sparkfun/SparkFun_Qwiic_OLED-0.91/tree/main/Hardware) 23 | * [SparkFun Transparent Graphical OLED Breakout (Qwiic)](https://github.com/sparkfun/Qwiic_Transparent_Graphical_OLED/tree/main/Hardware) 24 | * [SparkFun Qwiic OLED - (1.3in., 128x64)](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/tree/main/Hardware) 25 | 26 | ### Submit a Design Improvement 27 | 1. Fork this repo 28 | 2. Add your design improvements 29 | 3. File a pull request with your changes, and enjoy making the ~~words~~ ~~worlds~~ world a better place. 30 | * Once received, the engineer in charge of the original design will automatically be notified. 31 | * We will review your suggested improvements, if they are within our board design standards and meet our product design requirements, we will flag these changes for our next board revision. *(Please note, that even if your suggestion is accepted, these changes may not be immediate. We may have to cycle through our current product inventory first.)* 32 | 33 | ## Contributors 34 | Let's provided some recognition to the contributors for this project! 35 | 36 | ![GitHub Contributors Image](https://contrib.rocks/image?repo=sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/) 37 |
38 | 39 | -------------------------------------------------------------------------------- /docs/github/file_issue.md: -------------------------------------------------------------------------------- 1 | # Did we make a mistake? 2 | 3 | Spot something wrong? Please let us know. 4 | 5 | !!! attention 6 | This is not where customers should seek assistance on a product. If you require technical assistance or have questions about a product that is not working as expected, please head over to the [SparkFun Technical Assistance](https://www.sparkfun.com/technical_assistance) page for some initial troubleshooting. 7 |
8 | [SparkFun Technical Assistance Page](https://www.sparkfun.com/technical_assistance){ .md-button .md-button--primary } 9 |
10 | 11 | If you can't find what you need there, you'll need a [Forum Account](https://forum.sparkfun.com/ucp.php?mode=register) to search product forums and post questions. 12 | 13 | ## Discrepancies in the Documentation 14 | 15 | All of this documentation can be modified by you! Please help us make it better. 16 | 17 | * The documentation files for these pages are contained in the [`docs` folder of the SparkFun Qwiic OLED Arduino Library repository](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/tree/main/docs). 18 | 19 | ### Spot something wrong? 20 | If a section of the documentation is incorrect, please [open an issue](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/issues) and let us know. 21 | 22 | ### Do you have a suggested correction? 23 | 1. With a GitHub account, fork this repo 24 | 2. Add your correction(s) or improvement(s) to the markdown file(s) 25 | 3. File a pull request with your changes, and enjoy making the ~~words~~ ~~worlds~~ world a better place. 26 | * Once received, the documentation specialist will automatically be notified. 27 | * We will review your suggested improvement(s) to make sure they are correct and fit within our documentation standards. 28 | 29 | ## Problems in the Hardware Design 30 | 31 | All of our designs are open-source! Please help us make it better. 32 | 33 | Our board design files are contained in the `Hardware` folder of their respective repositories: 34 | 35 | * [SparkFun Micro OLED Breakout (Qwiic)](https://github.com/sparkfun/Qwiic_Micro_OLED/tree/main/Hardware) 36 | * [SparkFun Qwiic OLED Display (0.91 in, 128x32)](https://github.com/sparkfun/SparkFun_Qwiic_OLED-0.91/tree/main/Hardware) 37 | * [SparkFun Transparent Graphical OLED Breakout (Qwiic)](https://github.com/sparkfun/Qwiic_Transparent_Graphical_OLED/tree/main/Hardware) 38 | * [SparkFun Qwiic OLED - (1.3in., 128x64)](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/tree/main/Hardware) 39 | 40 | ### Does something not make sense? 41 | If part of the design is confusing, please [open an issue](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/issues) and let us know. 42 | 43 | ### Did we forget to include an important function of the board? 44 | * Please keep in mind that we may intentionally exclude certain functions of the board to meet our product design requirements. *(For example, our Qwiic Micro boards are intended to fit on a small board layout and only use I2C communication; therefore, we may not have the SPI and interrupt pins available for users.)* 45 | * If part of the board's functionality is missing, please [open an issue](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/issues) and file a feature request. 46 | 47 | ### Do you wish to contribute directly to improving the board design? 48 | 1. With a GitHub account, Fork this repo 49 | 2. Add your design improvement(s) 50 | 3. File a pull request with your changes, and enjoy making the ~~words~~ ~~worlds~~ world a better place. 51 | * Once received, the engineer in charge of the original design will automatically be notified. 52 | * We will review your suggested improvement(s), if they are within our board design standards and meet our product design requirements, we will flag these changes for our next board revision. *(Please note, that even if your suggestion is accepted, these changes may not be immediate. We may have to cycle through our current product inventory first.)* 53 | -------------------------------------------------------------------------------- /docs/hug_1p3.md: -------------------------------------------------------------------------------- 1 | The Qwiic OLED 1.3in has its own [hook-up guide](https://docs.sparkfun.com/SparkFun_Qwiic_OLED_1.3in/). 2 | -------------------------------------------------------------------------------- /docs/img/OLEDLibBanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/b8bdcf5ef2fd8d49e49b2a9d0f44d809ea078951/docs/img/OLEDLibBanner.png -------------------------------------------------------------------------------- /docs/img/sfe_logo_sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/b8bdcf5ef2fd8d49e49b2a9d0f44d809ea078951/docs/img/sfe_logo_sm.png -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | Placeholder file for index redirect functionality. 2 | -------------------------------------------------------------------------------- /docs/javascript/README.md: -------------------------------------------------------------------------------- 1 | javascript directory 2 | ==================== 3 | This folder should contain the files for the custom javascript that is enabled in the product documentation -------------------------------------------------------------------------------- /docs/javascript/mathjax.js: -------------------------------------------------------------------------------- 1 | window.MathJax = { 2 | tex: { 3 | inlineMath: [["\\(", "\\)"]], 4 | displayMath: [["\\[", "\\]"]], 5 | processEscapes: true, 6 | processEnvironments: true, 7 | // No Equation Numbering 8 | tags: 'none' 9 | }, 10 | options: { 11 | ignoreHtmlClass: ".*|", 12 | processHtmlClass: "arithmatex" 13 | } 14 | }; 15 | 16 | document$.subscribe(() => { 17 | MathJax.typesetPromise() 18 | }) 19 | -------------------------------------------------------------------------------- /docs/single_page.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide: 3 | - navigation 4 | - toc 5 | icon: fontawesome/solid/scroll 6 | --- 7 | 8 | # Getting Started 9 | 10 | ## Introduction 11 | --8<-- "./docs/introduction.md" 12 | 13 | ## Qwiic Micro OLED (0.66", 64x48) 14 | --8<-- "./docs/hug_micro_view.md" 15 | 16 | ## Qwiic Transparent Graphical OLED (1.51", 128x56) 17 | --8<-- "./docs/hug_transparent.md" 18 | 19 | ## Qwiic OLED (0.91", 128x32) 20 | --8<-- "./docs/hug_0p91.md" 21 | 22 | ## Qwiic OLED (1.3", 128x64) 23 | --8<-- "./docs/hug_1p3.md" 24 | 25 | # Software Setup 26 | --8<-- "./docs/software.md" 27 | 28 | # API Reference 29 | 30 | ## Device 31 | --8<-- "./docs/api_device.md" 32 | 33 | ## Scrolling 34 | --8<-- "./docs/api_scroll.md" 35 | 36 | ## Drawing State 37 | --8<-- "./docs/api_draw.md" 38 | 39 | ## Graphics 40 | --8<-- "./docs/api_graphics.md" 41 | 42 | ## Arduino Print 43 | --8<-- "./docs/api_arduino.md" 44 | 45 | # Arduino Examples 46 | 47 | ## Example 1 - Hello 48 | --8<-- "./docs/ex_01_hello.md 49 | 50 | ## Example 2 - Shapes 51 | --8<-- "./docs/ex_02_lines.md 52 | 53 | ## Example 3 - Bitmaps 54 | --8<-- "./docs/ex_03_bitmaps.md 55 | 56 | ## Example 4 - Text 57 | --8<-- "./docs/ex_04_text.md 58 | 59 | ## Other Examples 60 | --8<-- "./docs/ex_other.md 61 | 62 | # Troubleshooting 63 | --8<-- "./docs/troubleshooting.md" 64 | -------------------------------------------------------------------------------- /docs/software.md: -------------------------------------------------------------------------------- 1 | # Software Setup 2 | 3 | 4 | ## Installation 5 | 6 | !!! arduino 7 | This guide assumes you are using the latest version of the Arduino IDE on your desktop. The following resources available at [SparkFun](https://www.sparkfun.com) provide the details on setting up and configuring Arduino to use this library. 8 | 9 | - [Installing the Arduino IDE](https://learn.sparkfun.com/tutorials/installing-arduino-ide) 10 | - [Installing Board Definitions in the Arduino IDE](https://learn.sparkfun.com/tutorials/installing-board-definitions-in-the-arduino-ide) 11 | - [Installing an Arduino Library](https://learn.sparkfun.com/tutorials/installing-an-arduino-library) 12 | 13 | The SparkFun Qwiic OLED Arduino Library is available within in the Arduino library manager, which is launched via the **Sketch** > **Include Libraries** > **Manage Libraries …** menu option in the Arduino IDE. Just search for ***SparkFun Qwiic OLED Library***. 14 | 15 | 16 | !!! note 17 | If you've never connected a USB-to-serial converter to your computer before, you may need to install drivers. The drivers will depend on what is populated on your Arduino development board. Check out the following tutorials for help with the installation. 18 | 19 | * [How to Install CH340 Drivers](https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers) 20 | * [How to Install FTDI Drivers](https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers) 21 | * [How to Install CP2104 Drivers](https://learn.sparkfun.com/tutorials/esp32-thing-plus-hookup-guide#CP2104) 22 | 23 | 24 | ## General Use Pattern 25 | 26 | After installing this library in your local Arduino environment, begin with a standard Arduino sketch, and include the header file for this library. 27 | 28 | ```C++ 29 | // Include the SparkFun qwiic OLED Library 30 | #include 31 | ``` 32 | 33 | 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. 34 | 35 | The user selects from one of the following classes: 36 | 37 | | Class | Qwiic OLED Device | 38 | | :--- | :--- | 39 | | `QwiicMicroOLED` | [SparkFun Qwiic Micro OLED ]( https://www.sparkfun.com/products/14532)| 40 | | `QwiicNarrowOLED` | [SparkFun Qwiic OLED Display (128x32) ]( https://www.sparkfun.com/products/17153)| 41 | | `QwiicTransparentOLED` | [SparkFun Transparent Graphical OLED]( https://www.sparkfun.com/products/15173)| 42 | | `Qwiic1in3OLED` | [SparkFun Qwiic OLED 1.3" Display (128x32) ]( https://www.sparkfun.com/products/23453)| 43 | 44 | For this example, the Qwiic Micro OLED is used. 45 | 46 | ```C++ 47 | QwiicMicroOLED myOLED; 48 | ``` 49 | 50 | 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. 51 | 52 | ```C++ 53 | int width, height; // global variables for use in the sketch 54 | void setup() 55 | { 56 | Serial.begin(115200); 57 | if(!myOLED.begin()){ 58 | Serial.println("Device failed to initialize"); 59 | while(1); // halt execution 60 | } 61 | Serial.println("Device is initialized"); 62 | 63 | } 64 | ``` 65 | 66 | Now that the library is initialized, the desired graphics are drawn. Here we erase the screen and draw simple series of lines that originate at the screen origin and fan out across the height of the display. 67 | 68 | !!! note 69 | Graphics are not send to the OLED device when drawn. Updates are only sent to the device when the `display()` method is called. This minimizes data transfers to the OLED device, delivering a responsive display response. 70 | 71 | ```C++ 72 | 73 | myOLED.erase(); // Erase the screen 74 | myOLED.display(); // Send erase to device 75 | 76 | delay(1000); // Slight pause 77 | 78 | // Draw our lines from point (0,0) to (i, screen height) 79 | 80 | for(int i=0; i < width; i+= 6){ 81 | myOLED.line(0, 0, i, height-1); // draw the line 82 | myOLED.display(); // Send the new line to the device for display 83 | } 84 | ``` 85 | 86 | 87 | 88 | ## Library Provided Examples 89 | 90 | The SparkFun Qwiic OLED Arduino Library, includes a wide variety of examples. These are available from the Examples menu of the Arduino IDE, and in the [`examples`](https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/blob/main/examples)folder of this repository. 91 | 92 | For a detailed description of the examples, see the Examples section of the documentation. 93 | -------------------------------------------------------------------------------- /docs/troubleshooting.md: -------------------------------------------------------------------------------- 1 | ### General Troubleshooting Help 2 | 3 | !!! note 4 | 5 | Not working as expected and need help?

6 | 7 | If you need technical assistance and more information on a product that is not working as you expected, we recommend heading on over to the SparkFun Technical Assistance page for some initial troubleshooting.

8 | 9 | 10 | 11 | If you don't find what you need there, the SparkFun Forums are a great place to find and ask for help. If this is your first visit, you'll need to create a Forum Account to search product forums and post questions.

12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/Example-01_Hello/Example-01_Hello.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Example-01_Hello.ino 4 | 5 | This demo shows the basic setup of the OLED library, generating simple graphics and displaying 6 | the results on the target device. 7 | 8 | Micro OLED https://www.sparkfun.com/products/14532 9 | Transparent OLED https://www.sparkfun.com/products/15173 10 | "Narrow" OLED https://www.sparkfun.com/products/24606 11 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 12 | 13 | Written by Kirk Benell @ SparkFun Electronics, March 2022 14 | 15 | Repository: 16 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 17 | 18 | Documentation: 19 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 20 | 21 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 22 | */ 23 | 24 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 25 | 26 | // The Library supports four different types of SparkFun boards. The demo uses the following 27 | // defines to determine which device is being used. Uncomment the device being used for this demo. 28 | 29 | QwiicMicroOLED myOLED; 30 | //QwiicTransparentOLED myOLED; 31 | //QwiicNarrowOLED myOLED; 32 | //Qwiic1in3OLED myOLED; 33 | 34 | 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | Serial.println("Running OLED example"); 39 | 40 | Wire.begin(); 41 | 42 | // Initalize the OLED device and related graphics system 43 | if (myOLED.begin() == false) 44 | { 45 | Serial.println("Device begin failed. Freezing..."); 46 | while (true) 47 | ; 48 | } 49 | Serial.println("Begin success"); 50 | 51 | // Do a simple test - fill a rectangle on the screen and then print hello! 52 | 53 | // Fill a rectangle on the screen that has a 4 pixel board 54 | myOLED.rectangleFill(4, 4, myOLED.getWidth() - 8, myOLED.getHeight() - 8); 55 | 56 | String hello = "hello"; // our message 57 | 58 | // Center our message on the screen. Get the screen size of the "hello" string, 59 | // calling the getStringWidth() and getStringHeight() methods on the oled 60 | 61 | // starting x position - screen width minus string width / 2 62 | int x0 = (myOLED.getWidth() - myOLED.getStringWidth(hello)) / 2; 63 | 64 | // starting y position - screen height minus string height / 2 65 | int y0 = (myOLED.getHeight() - myOLED.getStringHeight(hello)) / 2; 66 | 67 | // Draw the text - color of black (0) 68 | myOLED.text(x0, y0, hello, 0); 69 | 70 | // There's nothing on the screen yet - Now send the graphics to the device 71 | myOLED.display(); 72 | 73 | // That's it - HELLO! 74 | } 75 | 76 | void loop() 77 | { 78 | delay(1000); // Do nothing 79 | } 80 | -------------------------------------------------------------------------------- /examples/Example-02_Shapes/Example-02_Shapes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example-01_Hello.ino 3 | 4 | This demo shows the various methods available for drawing shapes using the OLED library 5 | 6 | This library configures and draws graphics to OLED boards that use the 7 | SSD1306 display hardware. The library only supports I2C. 8 | 9 | SparkFun sells these at its website: www.sparkfun.com 10 | 11 | Do you like this library? Help support SparkFun. Buy a board! 12 | 13 | Micro OLED https://www.sparkfun.com/products/14532 14 | Transparent OLED https://www.sparkfun.com/products/15173 15 | "Narrow" OLED https://www.sparkfun.com/products/24606 16 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 17 | 18 | Written by Kirk Benell @ SparkFun Electronics, March 2022 19 | 20 | Repository: 21 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 22 | 23 | Documentation: 24 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 25 | 26 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | */ 28 | 29 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 30 | 31 | // The Library supports four different types of SparkFun boards. The demo uses the following 32 | // defines to determine which device is being used. Uncomment the device being used for this demo. 33 | 34 | QwiicMicroOLED myOLED; 35 | //QwiicTransparentOLED myOLED; 36 | //QwiicNarrowOLED myOLED; 37 | //Qwiic1in3OLED myOLED; 38 | 39 | // Global variables - used to stash our screen size 40 | 41 | int width; 42 | int height; 43 | 44 | void setup() 45 | { 46 | Serial.begin(115200); 47 | Serial.println("Running OLED example"); 48 | 49 | Wire.begin(); 50 | 51 | // Initalize the OLED device and related graphics system 52 | if (myOLED.begin() == false) 53 | { 54 | Serial.println("Device begin failed. Freezing..."); 55 | while (true) 56 | ; 57 | } 58 | Serial.println("Begin success"); 59 | 60 | // save device dims for the test routines 61 | width = myOLED.getWidth(); 62 | height = myOLED.getHeight(); 63 | } 64 | 65 | void loop() 66 | { 67 | // Loop over our test functions 68 | for (int i = 0; i < 7; i++) 69 | { 70 | myOLED.erase(); 71 | 72 | if (i == 0) 73 | lineTest1(); 74 | else if (i == 1) 75 | lineTest2(); 76 | else if (i == 2) 77 | lineTestVertical(); 78 | else if (i == 3) 79 | rectangleTest(); 80 | else if (i == 4) 81 | rectangleTestMove(); 82 | else if (i == 5) 83 | rectangleFillTest(); 84 | else if (i == 6) 85 | circleTest(); 86 | 87 | myOLED.display(); 88 | 89 | delay(1000); 90 | } 91 | } 92 | 93 | //////////////////////////////////////////////////////////////////////////////// 94 | // lineTest1() 95 | // 96 | // This test draws a horizontal line on the screen, moving it from the 97 | // top of the screen to the bottom. 98 | // 99 | // This sequence repeats multiple times, starting with a small line and 100 | // growing to the width of the screen. 101 | // 102 | // Since the library uses a "dirty range" methodology to minimize the amount of 103 | // data sent to the device, as the lenght of the line increases, the rate 104 | // of the display updates also decreases. A longer line, results in more data being 105 | // sent to the display. 106 | 107 | void lineTest1(void) 108 | { 109 | int x, y, i; 110 | 111 | int mid = width / 2; 112 | int delta = mid / 8; 113 | 114 | for (int j = 1; j < 8; j++) 115 | { 116 | 117 | x = delta * j; 118 | 119 | for (i = 0; i < height * 2; i++) 120 | { 121 | 122 | y = i % height; 123 | myOLED.erase(); 124 | myOLED.line(mid - x, y, mid + x, y); 125 | myOLED.display(); 126 | } 127 | } 128 | } 129 | 130 | //////////////////////////////////////////////////////////////////////////////// 131 | // lineTest2() 132 | // 133 | // This test draws a series of lines bursting out from the corner of the display. 134 | // 135 | // It demostrates the abilty of the library to draw arbitray straight lines. 136 | 137 | void lineTest2(void) 138 | { 139 | for (int i = 0; i < width; i += 6) 140 | { 141 | myOLED.line(0, 0, i, height - 1); 142 | myOLED.display(); 143 | } 144 | delay(200); 145 | myOLED.erase(); 146 | for (int i = width - 1; i >= 0; i -= 6) 147 | { 148 | myOLED.line(width - 1, 0, i, height - 1); 149 | myOLED.display(); 150 | } 151 | } 152 | 153 | //////////////////////////////////////////////////////////////////////////////// 154 | // lineTestVertIterative() 155 | // 156 | // Draws a series of vertical lines, some horz lines and two diag lines. 157 | // 158 | // Internally, this uses the standard line algorithm (diag), fast horz and fast 159 | // vertical lines functions. 160 | // 161 | // Iterator function - called to animate graphic 162 | 163 | void lineTestVerticalIterative(uint8_t y0, uint8_t y1) 164 | { 165 | for (int i = 0; i < width; i += 8) 166 | myOLED.line(i, y0, i, y1); 167 | 168 | // end off the vertical lines 169 | myOLED.line(width - 1, y0, width - 1, y1); 170 | 171 | // End lines and cross lines 172 | myOLED.line(0, y0, width - 1, y0); 173 | myOLED.line(0, y1, width - 1, y1); 174 | myOLED.line(0, y0, width - 1, y1); 175 | myOLED.line(0, y1, width - 1, y0); 176 | } 177 | 178 | // Entry point for test 179 | void lineTestVertical(void) 180 | { 181 | int mid = height / 2; 182 | 183 | for (int i = 0; i < height; i += 4) 184 | { 185 | 186 | myOLED.erase(); 187 | lineTestVerticalIterative(mid - i / 2, mid + i / 2); 188 | myOLED.display(); 189 | delay(10); 190 | } 191 | } 192 | 193 | //////////////////////////////////////////////////////////////////////////////// 194 | // rect_test() 195 | // 196 | // Simple - draw a rectangle test 197 | 198 | void rectangleTest(void) 199 | { 200 | myOLED.rectangle(4, 4, width - 8, height - 8); 201 | } 202 | 203 | //////////////////////////////////////////////////////////////////////////////// 204 | // rectangleTestMove() 205 | // 206 | // Draws a rectangle, then moves it across the screen 207 | // 208 | void rectangleTestMove(void) 209 | { 210 | float steps = height; 211 | float xinc = width / steps; 212 | float yinc = height / steps; 213 | int side = 10; 214 | float x = 0; 215 | float y = 0; 216 | 217 | for (int i = 0; i < steps; i++) 218 | { 219 | // Draw the rectangle and send it to device 220 | myOLED.rectangle(x, y, side, side); 221 | myOLED.display(); // sends erased rect and new rect pixels to device 222 | 223 | // Erase the that rect, increment and loop 224 | myOLED.rectangle(x, y, side, side, 0); 225 | 226 | x += xinc; 227 | y += yinc; 228 | } 229 | } 230 | 231 | //////////////////////////////////////////////////////////////////////////////// 232 | // rectangleFillTest() 233 | // 234 | // Draws two filled rectangles, switches to XOR draw mode and overwrites them 235 | // with another rectangle 236 | 237 | void rectangleFillTest(void) 238 | { 239 | myOLED.rectangleFill(4, 4, width / 2 - 8, height - 8); 240 | 241 | myOLED.rectangleFill(width / 2 + 4, 4, width / 2 - 8, height - 8); 242 | 243 | myOLED.setDrawMode(grROPXOR); // xor 244 | myOLED.rectangleFill(width / 4, 8, width / 2, height - 16); 245 | myOLED.setDrawMode(grROPCopy); // back to copy op (default) 246 | } 247 | 248 | //////////////////////////////////////////////////////////////////////////////// 249 | // circleTest() 250 | // 251 | // Draw a series of circles - filled and not filled 252 | void circleTest(void) 253 | { 254 | // Let's draw some circles that fit on the device 255 | myOLED.circle(width / 4, height / 2, height / 3); 256 | 257 | myOLED.circleFill(width - width / 4, height / 2, height / 3); 258 | 259 | myOLED.circle(4, height / 2, height / 3); 260 | 261 | myOLED.circleFill(width - width / 2, height / 2, height / 4); 262 | } 263 | -------------------------------------------------------------------------------- /examples/Example-03_Bitmap/Example-03_Bitmap.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example-03_Bitmap.ino 3 | 4 | This demo shows how to write a simple bitmap to an OLED screen 5 | 6 | This library configures and draws graphics to OLED boards that use the 7 | SSD1306 display hardware. The library only supports I2C. 8 | 9 | SparkFun sells these at its website: www.sparkfun.com 10 | 11 | Do you like this library? Help support SparkFun. Buy a board! 12 | 13 | Micro OLED https://www.sparkfun.com/products/14532 14 | Transparent OLED https://www.sparkfun.com/products/15173 15 | "Narrow" OLED https://www.sparkfun.com/products/24606 16 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 17 | 18 | Written by Kirk Benell @ SparkFun Electronics, March 2022 19 | 20 | Repository: 21 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 22 | 23 | Documentation: 24 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 25 | 26 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | */ 28 | 29 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 30 | 31 | // The Library supports four different types of SparkFun boards. The demo uses the following 32 | // defines to determine which device is being used. Uncomment the device being used for this demo. 33 | 34 | QwiicMicroOLED myOLED; 35 | //QwiicTransparentOLED myOLED; 36 | //QwiicNarrowOLED myOLED; 37 | //Qwiic1in3OLED myOLED; 38 | 39 | // Let's draw a truck - use our built in bitmap 40 | #include "res/qw_bmp_truck.h" 41 | #include "res/qw_bmp_sparkfun.h" 42 | 43 | int width; 44 | int height; 45 | 46 | // For simple frame rate calculations 47 | long drawTotalTime = 0; 48 | int numberOfDraws = 0; 49 | 50 | int iconX = 8; 51 | int iconXChangeAmount = 1; 52 | int iconY = 8; 53 | int iconYChangeAmount = 1; 54 | 55 | void setup() 56 | { 57 | Serial.begin(115200); 58 | Serial.println("Running OLED example"); 59 | 60 | Wire.begin(); 61 | Wire.setClock(400000); // Optional increase I2C to 400kHz 62 | 63 | // Initalize the OLED device and related graphics system 64 | if (myOLED.begin() == false) 65 | { 66 | Serial.println("Device begin failed. Freezing..."); 67 | while (true) 68 | ; 69 | } 70 | Serial.println("Begin success"); 71 | 72 | // save device dims for the test routines 73 | width = myOLED.getWidth(); 74 | height = myOLED.getHeight(); 75 | 76 | showSplash(); 77 | 78 | drawTotalTime = 0; 79 | numberOfDraws = 0; 80 | 81 | // set a template for our framerate display 82 | Serial.println("- Frame Rate"); 83 | } 84 | 85 | void loop() 86 | { 87 | // Calculate draw time 88 | long startTime = millis(); 89 | 90 | myOLED.bitmap(iconX, iconY, QW_BMP_TRUCK); 91 | myOLED.display(); 92 | 93 | // Move the icon 94 | iconX += iconXChangeAmount; 95 | iconY += iconYChangeAmount; 96 | 97 | if (iconX + QW_BMP_TRUCK.width >= width) 98 | iconXChangeAmount *= -1; // Change direction 99 | 100 | if (iconX == 0) 101 | iconXChangeAmount *= -1; // Change direction 102 | 103 | if (iconY + QW_BMP_TRUCK.height >= height) 104 | iconYChangeAmount *= -1; // Change direction 105 | 106 | if (iconY == 0) 107 | iconYChangeAmount *= -1; // Change direction 108 | 109 | numberOfDraws++; 110 | drawTotalTime += (millis() - startTime); 111 | 112 | // Output framerate once every 120 frames 113 | if (numberOfDraws % 120 == 0) 114 | { 115 | Serial.print(" Frame rate: "); 116 | Serial.println(numberOfDraws / (float)drawTotalTime * 1000.0); 117 | 118 | numberOfDraws = 0; 119 | drawTotalTime = 0; 120 | } 121 | } 122 | 123 | void showSplash() 124 | { 125 | int x0 = (width - QW_BMP_SPARKFUN.width) / 2; 126 | if (x0 < 0) 127 | x0 = 0; 128 | 129 | int y0 = (height - QW_BMP_SPARKFUN.height) / 2; 130 | if (y0 < 0) 131 | y0 = 0; 132 | 133 | myOLED.erase(); 134 | myOLED.bitmap(x0, y0, QW_BMP_SPARKFUN); 135 | myOLED.display(); 136 | delay(2000); 137 | } 138 | -------------------------------------------------------------------------------- /examples/Example-04_Text/Example-04_Text.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example-04_Text.ino 3 | 4 | This demo shows writing text to an OLED screen using various fonts 5 | 6 | This library configures and draws graphics to OLED boards that use the 7 | SSD1306 display hardware. The library only supports I2C. 8 | 9 | SparkFun sells these at its website: www.sparkfun.com 10 | 11 | Do you like this library? Help support SparkFun. Buy a board! 12 | 13 | Micro OLED https://www.sparkfun.com/products/14532 14 | Transparent OLED https://www.sparkfun.com/products/15173 15 | "Narrow" OLED https://www.sparkfun.com/products/24606 16 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 17 | 18 | Written by Kirk Benell @ SparkFun Electronics, March 2022 19 | 20 | Repository: 21 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 22 | 23 | Documentation: 24 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 25 | 26 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | */ 28 | 29 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 30 | 31 | // The Library supports four different types of SparkFun boards. The demo uses the following 32 | // defines to determine which device is being used. Uncomment the device being used for this demo. 33 | 34 | QwiicMicroOLED myOLED; 35 | //QwiicTransparentOLED myOLED; 36 | //QwiicNarrowOLED myOLED; 37 | //Qwiic1in3OLED myOLED; 38 | 39 | // Fonts 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | // An array of fonts to loop over 47 | QwiicFont *demoFonts[] = { 48 | &QW_FONT_5X7, 49 | &QW_FONT_8X16, 50 | &QW_FONT_31X48, 51 | &QW_FONT_LARGENUM, 52 | &QW_FONT_7SEGMENT}; 53 | int nFONTS = sizeof(demoFonts) / sizeof(demoFonts[0]); 54 | int iFont = 0; 55 | 56 | // Some vars for the title. 57 | String strTitle = "<>"; 58 | QwiicFont *pFntTitle = &QW_FONT_5X7; 59 | 60 | void setup() 61 | { 62 | Serial.begin(115200); 63 | Serial.println("Running OLED example"); 64 | 65 | Wire.begin(); 66 | 67 | // Initalize the OLED device and related graphics system 68 | if (myOLED.begin() == false) 69 | { 70 | Serial.println("Device begin failed. Freezing..."); 71 | while (true) 72 | ; 73 | } 74 | Serial.println("Begin success"); 75 | 76 | } 77 | 78 | void loop() 79 | { 80 | // next font for display 81 | iFont = (iFont + 1) % nFONTS; 82 | myOLED.setFont(demoFonts[iFont]); 83 | 84 | // Write font name to screen 85 | writeTitle(); 86 | 87 | delay(1000); 88 | 89 | // Write out the full font char set 90 | writeFontChars(); 91 | 92 | delay(2000); 93 | } 94 | 95 | // For the current font, write out all its characters 96 | void writeFontChars() 97 | { 98 | // get the font 99 | QwiicFont * currFont = myOLED.getFont(); 100 | 101 | // how many chars can a screen handle? (x * y) 102 | uint16_t screenChars = myOLED.getWidth() / (currFont->width + 1); // X 103 | uint8_t nY = myOLED.getHeight() / currFont->height; // Y 104 | 105 | screenChars *= (nY == 0 ? 1 : nY); // need at least 1 row 106 | 107 | // Loop over the characters in the font. 108 | for (int i = 0; i < currFont->n_chars; i++) 109 | { 110 | 111 | if (i % screenChars == 0) 112 | { // next page 113 | delay(400); 114 | myOLED.erase(); 115 | myOLED.setCursor(0, 0); 116 | } 117 | 118 | // if the character is a carriage return, send a blank - otherwise the 119 | // write routine will perform a CR and lead to a confusing display. 120 | myOLED.write((i + currFont->start != '\n') ? i + currFont->start : ' '); 121 | 122 | myOLED.display(); // show the added char 123 | 124 | delay(10); 125 | } 126 | } 127 | 128 | // Simple title for a font 129 | void writeTitle() 130 | { 131 | 132 | // Get the current font name 133 | String strTitle = myOLED.getFontName(); 134 | 135 | // save our current font, then switch to font for title 136 | QwiicFont * currFont = myOLED.getFont(); 137 | 138 | // Set title font font 139 | myOLED.setFont(pFntTitle); 140 | 141 | // Position to use for the time/banner displayed before each font 142 | 143 | // Get the width of the title in screen size 144 | int width = myOLED.getStringWidth(strTitle); 145 | 146 | // if the string is wider than the screen, set x at 0, otherwise center text 147 | 148 | int xTitle = (width >= myOLED.getWidth() ? 0 : (myOLED.getWidth() - width) / 2); 149 | 150 | // starting y position - width minus string height / 2. No need to chech height, 5x7 font fits everything 151 | int yTitle = (myOLED.getHeight() - myOLED.getStringHeight(strTitle)) / 2; 152 | 153 | myOLED.erase(); 154 | 155 | // Draw the text 156 | myOLED.text(xTitle, yTitle, strTitle); 157 | 158 | // There's nothing on the screen yet - Now send the graphics to the device 159 | myOLED.display(); 160 | 161 | myOLED.setFont(currFont); 162 | } 163 | -------------------------------------------------------------------------------- /examples/Example-05_ScrollFlip/Example-05_ScrollFlip.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example-05_ScrollFlip.ino 3 | 4 | This demo shows the various display options - scrolling, flipping, invert. 5 | 6 | NOTE: Scrolling isn't supported on the Transparent OLED 7 | 8 | This library configures and draws graphics to OLED boards that use the 9 | SSD1306 display hardware. The library only supports I2C. 10 | 11 | SparkFun sells these at its website: www.sparkfun.com 12 | 13 | Do you like this library? Help support SparkFun. Buy a board! 14 | 15 | Micro OLED https://www.sparkfun.com/products/14532 16 | Transparent OLED https://www.sparkfun.com/products/15173 17 | "Narrow" OLED https://www.sparkfun.com/products/24606 18 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 19 | 20 | Written by Kirk Benell @ SparkFun Electronics, March 2022 21 | 22 | Repository: 23 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 24 | 25 | Documentation: 26 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 27 | 28 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 29 | */ 30 | 31 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 32 | 33 | // The Library supports four different types of SparkFun boards. The demo uses the following 34 | // defines to determine which device is being used. Uncomment the device being used for this demo. 35 | 36 | QwiicMicroOLED myOLED; 37 | //QwiicTransparentOLED myOLED; 38 | //QwiicNarrowOLED myOLED; 39 | //Qwiic1in3OLED myOLED; 40 | 41 | int yoffset; 42 | 43 | // Our testing functions 44 | void scrollRight(void) 45 | { 46 | myOLED.scrollStop(); 47 | myOLED.scrollRight(0, 7, SCROLL_INTERVAL_2_FRAMES); 48 | } 49 | 50 | void scrollRightVertical(void) 51 | { 52 | myOLED.scrollStop(); 53 | myOLED.scrollVertRight(0, 7, SCROLL_INTERVAL_3_FRAMES); 54 | } 55 | 56 | void scrollLeft(void) 57 | { 58 | myOLED.scrollStop(); 59 | myOLED.scrollLeft(0, 7, SCROLL_INTERVAL_4_FRAMES); 60 | } 61 | 62 | void scrollLeftVertical(void) 63 | { 64 | myOLED.scrollStop(); 65 | myOLED.scrollVertLeft(0, 7, SCROLL_INTERVAL_5_FRAMES); 66 | } 67 | 68 | void scrollStop(void) 69 | { 70 | myOLED.scrollStop(); 71 | } 72 | 73 | void flipHorizontal(void) 74 | { 75 | for (int i = 0; i < 6; i++) 76 | { 77 | myOLED.flipHorizontal(!(i & 0x01)); 78 | delay(800); 79 | } 80 | } 81 | 82 | void flipVertical(void) 83 | { 84 | for (int i = 0; i < 6; i++) 85 | { 86 | myOLED.flipVertical(!(i & 0x01)); 87 | delay(800); 88 | } 89 | } 90 | 91 | void invert(void) 92 | { 93 | for (int i = 0; i < 6; i++) 94 | { 95 | myOLED.invert(!(i & 0x01)); 96 | delay(800); 97 | } 98 | } 99 | 100 | // Use an array of testing functions, with a title, to run the tests 101 | typedef void (*testFn)(void); 102 | typedef struct _testRoutines 103 | { 104 | void (*testFn)(void); 105 | const char *title; 106 | } testRoutine; 107 | 108 | static const testRoutine testFunctions[] = { 109 | {scrollRight, "Right>"}, 110 | {scrollRightVertical, "^Right-Up>"}, 111 | {scrollLeft, ""}, 114 | {flipHorizontal, "-Flip-Horz-"}, 115 | {flipVertical, "|Flip-Vert|"}, 116 | {invert, "**INVERT**"}}; 117 | 118 | void setup() 119 | { 120 | Serial.begin(115200); 121 | Serial.println("Running OLED example"); 122 | 123 | Wire.begin(); 124 | 125 | // Initalize the OLED device and related graphics system 126 | if (myOLED.begin() == false) 127 | { 128 | Serial.println("Device begin failed. Freezing..."); 129 | while (true) 130 | ; 131 | } 132 | Serial.println("Begin success"); 133 | 134 | yoffset = (myOLED.getHeight() - myOLED.getStringHeight("a")) / 2; 135 | 136 | delay(1000); 137 | } 138 | 139 | void loop() 140 | { 141 | // Loop over the test table entries, write title and run test. 142 | for (int i = 0; i < sizeof(testFunctions) / sizeof(testFunctions[0]); i++) 143 | { 144 | if (testFunctions[i].title) 145 | { 146 | myOLED.erase(); 147 | myOLED.text(3, yoffset, testFunctions[i].title); 148 | myOLED.display(); 149 | } 150 | testFunctions[i].testFn(); // run test 151 | 152 | delay(3000); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /examples/Example-06_Clock/Example-06_Clock.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example-06_Clock.ino 3 | 4 | Draws a clock face on the OLED display. This is a port of the demo for the original Micro OLED library. 5 | 6 | This library configures and draws graphics to OLED boards that use the 7 | SSD1306 display hardware. The library only supports I2C. 8 | 9 | SparkFun sells these at its website: www.sparkfun.com 10 | 11 | Do you like this library? Help support SparkFun. Buy a board! 12 | 13 | Micro OLED https://www.sparkfun.com/products/14532 14 | Transparent OLED https://www.sparkfun.com/products/15173 15 | "Narrow" OLED https://www.sparkfun.com/products/24606 16 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 17 | 18 | Written by 19 | Jim Lindblom @ SparkFun Electronics 20 | Original Creation Date: October 27, 2014 21 | 22 | Repository: 23 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 24 | 25 | Documentation: 26 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 27 | 28 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 29 | */ 30 | 31 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 32 | 33 | // The Library supports four different types of SparkFun boards. The demo uses the following 34 | // defines to determine which device is being used. Uncomment the device being used for this demo. 35 | 36 | QwiicMicroOLED myOLED; 37 | //QwiicTransparentOLED myOLED; 38 | //QwiicNarrowOLED myOLED; 39 | //Qwiic1in3OLED myOLED; 40 | 41 | // Use these variables to set the initial time 42 | int hours = 11; 43 | int minutes = 50; 44 | int seconds = 30; 45 | 46 | // How fast do you want the clock to spin? Set this to 1 for fun. 47 | // Set this to 1000 to get _about_ 1 second timing. 48 | const int CLOCK_SPEED = 1000; 49 | 50 | // Global variables to help draw the clock face: 51 | const int MIDDLE_Y = myOLED.getHeight() / 2; 52 | const int MIDDLE_X = myOLED.getWidth() / 2; 53 | 54 | int CLOCK_RADIUS; 55 | int POS_12_X, POS_12_Y; 56 | int POS_3_X, POS_3_Y; 57 | int POS_6_X, POS_6_Y; 58 | int POS_9_X, POS_9_Y; 59 | int S_LENGTH; 60 | int M_LENGTH; 61 | int H_LENGTH; 62 | 63 | unsigned long lastDraw = 0; 64 | 65 | QwiicFont *pFont; 66 | 67 | void setup() 68 | { 69 | Serial.begin(115200); 70 | Serial.println("Running OLED example"); 71 | 72 | Wire.begin(); 73 | 74 | // Initalize the OLED device and related graphics system 75 | if (myOLED.begin() == false) 76 | { 77 | Serial.println("Device begin failed. Freezing..."); 78 | while (true) 79 | ; 80 | } 81 | Serial.println("Begin success"); 82 | 83 | pFont = myOLED.getFont(); 84 | 85 | initClockVariables(); 86 | 87 | drawFace(); 88 | drawArms(hours, minutes, seconds); 89 | myOLED.display(); // display the memory buffer drawn 90 | } 91 | 92 | void loop() 93 | { 94 | // Check if we need to update seconds, minutes, hours: 95 | if (lastDraw + CLOCK_SPEED < millis()) 96 | { 97 | lastDraw += CLOCK_SPEED; 98 | 99 | // Add a second, update minutes/hours if necessary: 100 | updateTime(); 101 | 102 | // Draw the clock: 103 | myOLED.erase(); 104 | 105 | drawFace(); // Draw the face to the buffer 106 | drawArms(hours, minutes, seconds); // Draw arms to the buffer 107 | 108 | myOLED.display(); // Draw the memory buffer 109 | } 110 | } 111 | 112 | void initClockVariables() 113 | { 114 | // Calculate constants for clock face component positions: 115 | 116 | CLOCK_RADIUS = min(MIDDLE_X, MIDDLE_Y) - 1; 117 | POS_12_X = MIDDLE_X - pFont->width; 118 | POS_12_Y = MIDDLE_Y - CLOCK_RADIUS + 2; 119 | POS_3_X = MIDDLE_X + CLOCK_RADIUS - pFont->width - 1; 120 | POS_3_Y = MIDDLE_Y - pFont->height / 2; 121 | POS_6_X = MIDDLE_X - pFont->width / 2; 122 | POS_6_Y = MIDDLE_Y + CLOCK_RADIUS - pFont->height - 1; 123 | POS_9_X = MIDDLE_X - CLOCK_RADIUS + pFont->width - 2; 124 | POS_9_Y = MIDDLE_Y - pFont->height / 2; 125 | 126 | // Calculate clock arm lengths 127 | S_LENGTH = CLOCK_RADIUS - 2; 128 | M_LENGTH = S_LENGTH * 0.7; 129 | H_LENGTH = S_LENGTH * 0.5; 130 | } 131 | 132 | // Simple function to increment seconds and then increment minutes 133 | // and hours if necessary. 134 | void updateTime() 135 | { 136 | seconds++; // Increment seconds 137 | if (seconds >= 60) 138 | { // If seconds overflows (>=60) 139 | 140 | seconds = 0; // Set seconds back to 0 141 | minutes++; // Increment minutes 142 | 143 | if (minutes >= 60) 144 | { // If minutes overflows (>=60) 145 | 146 | minutes = 0; // Set minutes back to 0 147 | hours++; // Increment hours 148 | 149 | if (hours >= 12) // If hours overflows (>=12) 150 | hours = 0; // Set hours back to 0 151 | } 152 | } 153 | } 154 | 155 | // Draw the clock's three arms: seconds, minutes, hours. 156 | void drawArms(int h, int m, int s) 157 | { 158 | double midHours; // this will be used to slightly adjust the hour hand 159 | static int hx, hy, mx, my, sx, sy; 160 | 161 | // Adjust time to shift display 90 degrees ccw 162 | // this will turn the clock the same direction as text: 163 | h -= 3; 164 | m -= 15; 165 | s -= 15; 166 | 167 | if (h <= 0) 168 | h += 12; 169 | 170 | if (m < 0) 171 | m += 60; 172 | 173 | if (s < 0) 174 | s += 60; 175 | 176 | // Calculate and draw new lines: 177 | s = map(s, 0, 60, 0, 360); // map the 0-60, to "360 degrees" 178 | sx = S_LENGTH * cos(PI * ((float)s) / 180); // woo trig! 179 | sy = S_LENGTH * sin(PI * ((float)s) / 180); // woo trig! 180 | 181 | // draw the second hand: 182 | myOLED.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + sx, MIDDLE_Y + sy); 183 | 184 | m = map(m, 0, 60, 0, 360); // map the 0-60, to "360 degrees" 185 | mx = M_LENGTH * cos(PI * ((float)m) / 180); // woo trig! 186 | my = M_LENGTH * sin(PI * ((float)m) / 180); // woo trig! 187 | 188 | // draw the minute hand 189 | myOLED.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + mx, MIDDLE_Y + my); 190 | 191 | midHours = minutes / 12; // midHours is used to set the hours hand to middling levels between whole hours 192 | h *= 5; // Get hours and midhours to the same scale 193 | h += midHours; // add hours and midhours 194 | h = map(h, 0, 60, 0, 360); // map the 0-60, to "360 degrees" 195 | hx = H_LENGTH * cos(PI * ((float)h) / 180); // woo trig! 196 | hy = H_LENGTH * sin(PI * ((float)h) / 180); // woo trig! 197 | 198 | // draw the hour hand: 199 | myOLED.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + hx, MIDDLE_Y + hy); 200 | } 201 | 202 | // Draw an analog clock face 203 | void drawFace() 204 | { 205 | // Draw the clock border 206 | myOLED.circle(MIDDLE_X, MIDDLE_Y, CLOCK_RADIUS); 207 | 208 | // Draw the clock numbers 209 | 210 | myOLED.setCursor(POS_12_X, POS_12_Y); // points cursor to x=27 y=0 211 | myOLED.print(12); 212 | myOLED.setCursor(POS_6_X, POS_6_Y); 213 | myOLED.print(6); 214 | myOLED.setCursor(POS_9_X, POS_9_Y); 215 | myOLED.print(9); 216 | myOLED.setCursor(POS_3_X, POS_3_Y); 217 | myOLED.print(3); 218 | } 219 | -------------------------------------------------------------------------------- /examples/Example-07_Cube/Example-07_Cube.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example-07_Cube.ino 3 | 4 | This demo draws a rotating 3D cube 5 | 6 | This library configures and draws graphics to OLED boards that use the 7 | SSD1306 display hardware. The library only supports I2C. 8 | 9 | SparkFun sells these at its website: www.sparkfun.com 10 | 11 | Do you like this library? Help support SparkFun. Buy a board! 12 | 13 | Micro OLED https://www.sparkfun.com/products/14532 14 | Transparent OLED https://www.sparkfun.com/products/15173 15 | "Narrow" OLED https://www.sparkfun.com/products/24606 16 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 17 | 18 | Written by 19 | Jim Lindblom @ SparkFun Electronics 20 | Original Creation Date: October 27, 2014 21 | 22 | Repository: 23 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 24 | 25 | Documentation: 26 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 27 | 28 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 29 | */ 30 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 31 | 32 | // The Library supports four different types of SparkFun boards. The demo uses the following 33 | // defines to determine which device is being used. Uncomment the device being used for this demo. 34 | 35 | QwiicMicroOLED myOLED; 36 | //QwiicTransparentOLED myOLED; 37 | //QwiicNarrowOLED myOLED; 38 | //Qwiic1in3OLED myOLED; 39 | 40 | int width; 41 | int height; 42 | 43 | // For simple frame rate calculations 44 | long drawTotalTime = 0; 45 | int numberOfDraws = 0; 46 | 47 | float d = 3; 48 | float px[] = {-d, d, d, -d, -d, d, d, -d}; 49 | float py[] = {-d, -d, d, d, -d, -d, d, d}; 50 | float pz[] = {-d, -d, -d, -d, d, d, d, d}; 51 | 52 | float p2x[8] = {0}; 53 | float p2y[8] = {0}; 54 | float r[3] = {0}; 55 | 56 | #define SHAPE_SIZE 400 57 | // Define how fast the cube rotates. Smaller numbers are faster. 58 | // This is the number of ms between draws. 59 | #define ROTATION_SPEED 00 60 | 61 | void setup() 62 | { 63 | Serial.begin(115200); 64 | Serial.println("Running OLED example"); 65 | 66 | Wire.begin(); 67 | // Wire.setClock(400000); //Optionally increase I2C bus speed to 400kHz 68 | 69 | // Initalize the OLED device and related graphics system 70 | if (myOLED.begin() == false) 71 | { 72 | Serial.println("Device begin failed. Freezing..."); 73 | while (true) 74 | ; 75 | } 76 | Serial.println("Begin success"); 77 | 78 | width = myOLED.getWidth(); 79 | height = myOLED.getHeight(); 80 | 81 | // For frame rate calc 82 | drawTotalTime = 0; 83 | numberOfDraws = 0; 84 | 85 | // Set a template for our framerate display 86 | Serial.print("- Frame Rate: 00.00"); 87 | } 88 | 89 | void loop() 90 | { 91 | // Draw the cube - as fast as we can! 92 | drawCube(); 93 | } 94 | 95 | void drawCube() 96 | { 97 | r[0] = r[0] + PI / 180.0; // Add a degree 98 | r[1] = r[1] + PI / 180.0; // Add a degree 99 | r[2] = r[2] + PI / 180.0; // Add a degree 100 | if (r[0] >= 360.0 * PI / 180.0) 101 | r[0] = 0; 102 | if (r[1] >= 360.0 * PI / 180.0) 103 | r[1] = 0; 104 | if (r[2] >= 360.0 * PI / 180.0) 105 | r[2] = 0; 106 | 107 | // This routine gets called often, so just make these statics 108 | static float px2, py2, pz2, px3, py3, pz3, ax, ay, az; 109 | 110 | for (int i = 0; i < 8; i++) 111 | { 112 | px2 = px[i]; 113 | py2 = cos(r[0]) * py[i] - sin(r[0]) * pz[i]; 114 | pz2 = sin(r[0]) * py[i] + cos(r[0]) * pz[i]; 115 | 116 | px3 = cos(r[1]) * px2 + sin(r[1]) * pz2; 117 | py3 = py2; 118 | pz3 = -sin(r[1]) * px2 + cos(r[1]) * pz2; 119 | 120 | ax = cos(r[2]) * px3 - sin(r[2]) * py3; 121 | ay = sin(r[2]) * px3 + cos(r[2]) * py3; 122 | az = pz3 - 150; 123 | 124 | p2x[i] = width / 2 + ax * SHAPE_SIZE / az; 125 | p2y[i] = height / 2 + ay * SHAPE_SIZE / az; 126 | } 127 | 128 | // Calculate draw time 129 | uint32_t startTime = millis(); 130 | 131 | myOLED.erase(); 132 | for (int i = 0; i < 3; i++) 133 | { 134 | myOLED.line(p2x[i], p2y[i], p2x[i + 1], p2y[i + 1]); 135 | myOLED.line(p2x[i + 4], p2y[i + 4], p2x[i + 5], p2y[i + 5]); 136 | myOLED.line(p2x[i], p2y[i], p2x[i + 4], p2y[i + 4]); 137 | } 138 | 139 | myOLED.line(p2x[3], p2y[3], p2x[0], p2y[0]); 140 | myOLED.line(p2x[7], p2y[7], p2x[4], p2y[4]); 141 | myOLED.line(p2x[3], p2y[3], p2x[7], p2y[7]); 142 | myOLED.display(); 143 | 144 | // Write out our frame rate 145 | drawTotalTime += millis() - startTime; 146 | numberOfDraws++; 147 | 148 | // Output framerate once every 120 frames 149 | if (numberOfDraws % 120 == 0) 150 | { 151 | Serial.print(" Frame rate: "); 152 | Serial.println(numberOfDraws / (float)drawTotalTime * 1000.0); 153 | 154 | numberOfDraws = 0; 155 | drawTotalTime = 0; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /examples/Example-08_Multi/Example-08_Multi.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example-08_Multi.ino 3 | 4 | This demo performs multiple examples 5 | 6 | This library configures and draws graphics to OLED boards that use the 7 | SSD1306 display hardware. The library only supports I2C. 8 | 9 | SparkFun sells these at its website: www.sparkfun.com 10 | 11 | Do you like this library? Help support SparkFun. Buy a board! 12 | 13 | Micro OLED https://www.sparkfun.com/products/14532 14 | Transparent OLED https://www.sparkfun.com/products/15173 15 | "Narrow" OLED https://www.sparkfun.com/products/24606 16 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 17 | 18 | Updated from example writtin by Paul Clark @ SparkFun Electronics 19 | Original Creation Date: December 11th, 2020 20 | 21 | Repository: 22 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 23 | 24 | Documentation: 25 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 26 | 27 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 28 | */ 29 | 30 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 31 | 32 | // The Library supports four different types of SparkFun boards. The demo uses the following 33 | // defines to determine which device is being used. Uncomment the device being used for this demo. 34 | 35 | QwiicMicroOLED myOLED; 36 | //QwiicTransparentOLED myOLED; 37 | //QwiicNarrowOLED myOLED; 38 | //Qwiic1in3OLED myOLED; 39 | 40 | int width; 41 | int height; 42 | 43 | void setup() 44 | { 45 | Serial.begin(115200); 46 | Serial.println("Running OLED example"); 47 | 48 | Wire.begin(); 49 | // Wire.setClock(400000); //Optionally increase I2C bus speed to 400kHz 50 | 51 | // Initalize the OLED device and related graphics system 52 | if (myOLED.begin() == false) 53 | { 54 | Serial.println("Device begin failed. Freezing..."); 55 | while (true) 56 | ; 57 | } 58 | Serial.println("Begin success"); 59 | 60 | width = myOLED.getWidth(); 61 | height = myOLED.getHeight(); 62 | 63 | // Not all platforms have A0 64 | #ifdef A0 65 | randomSeed(analogRead(A0)); 66 | #endif 67 | } 68 | 69 | void loop() 70 | { 71 | pixelExample(); 72 | lineExample(); 73 | shapeExample(); 74 | } 75 | 76 | void pixelExample() 77 | { 78 | myOLED.erase(); 79 | for (int i = 0; i < 512; i++) 80 | { 81 | myOLED.pixel(random(width), random(height)); 82 | myOLED.display(); 83 | delay(10); 84 | } 85 | } 86 | 87 | void lineExample() 88 | { 89 | int middleX = width / 2; 90 | int middleY = height / 2; 91 | int xEnd, yEnd; 92 | int lineWidth = min(middleX, middleY); 93 | 94 | myOLED.erase(); 95 | int deg; 96 | 97 | for (int i = 0; i < 3; i++) 98 | { 99 | 100 | for (deg = 0; deg < 360; deg += 15) 101 | { 102 | 103 | xEnd = lineWidth * cos(deg * PI / 180.0); 104 | yEnd = lineWidth * sin(deg * PI / 180.0); 105 | 106 | myOLED.line(middleX, middleY, middleX + xEnd, middleY + yEnd); 107 | myOLED.display(); 108 | delay(10); 109 | } 110 | 111 | for (deg = 0; deg < 360; deg += 15) 112 | { 113 | 114 | xEnd = lineWidth * cos(deg * PI / 180.0); 115 | yEnd = lineWidth * sin(deg * PI / 180.0); 116 | 117 | myOLED.line(middleX, middleY, middleX + xEnd, middleY + yEnd, 0); 118 | myOLED.display(); 119 | delay(10); 120 | } 121 | } 122 | } 123 | 124 | void shapeExample() 125 | { 126 | // Silly pong demo. It takes a lot of work to fake pong... 127 | int paddleW = 3; // Paddle width 128 | int paddleH = 15; // Paddle height 129 | 130 | // Paddle 0 (left) position coordinates 131 | int paddle0_Y = (height / 2) - (paddleH / 2); 132 | int paddle0_X = 2; 133 | 134 | // Paddle 1 (right) position coordinates 135 | int paddle1_Y = (height / 2) - (paddleH / 2); 136 | int paddle1_X = width - 3 - paddleW; 137 | int ball_rad = 4; // Ball radius 138 | 139 | // Ball position coordinates 140 | int ball_X = paddle0_X + paddleW + ball_rad; 141 | int ball_Y = random(1 + ball_rad, height - ball_rad); // paddle0_Y + ball_rad; 142 | int ballVelocityX = 1; // Ball left/right velocity 143 | int ballVelocityY = 1; // Ball up/down velocity 144 | int paddle0Velocity = -1; // Paddle 0 velocity 145 | int paddle1Velocity = 1; // Paddle 1 velocity 146 | 147 | // Draw the Pong Field 148 | myOLED.erase(); 149 | 150 | // Draw an outline of the screen: 151 | myOLED.rectangle(0, 0, width - 1, height); 152 | 153 | // Draw the center line 154 | myOLED.rectangleFill(width / 2 - 1, 0, 2, height); 155 | 156 | bool firstLoop = true; 157 | 158 | while ((ball_X - ball_rad > 1) && (ball_X + ball_rad < width - 2)) 159 | { 160 | 161 | if (!firstLoop) 162 | { 163 | 164 | // Erase the old ball. In XOR mode, so just draw old values again! 165 | // Draw the Paddles: 166 | myOLED.rectangleFill(paddle0_X, paddle0_Y, paddleW, paddleH); 167 | myOLED.rectangleFill(paddle1_X, paddle1_Y, paddleW, paddleH); 168 | // Draw the ball: - use rect - xor and circle fails b/c of circle algorithm overdraws 169 | myOLED.rectangleFill(ball_X, ball_Y, ball_rad, ball_rad); 170 | } 171 | // Increment ball's position 172 | ball_X += ballVelocityX; 173 | ball_Y += ballVelocityY; 174 | 175 | // Check if the ball is colliding with the left paddle 176 | if (ball_X - ball_rad < paddle0_X + paddleW) 177 | { 178 | 179 | // Check if ball is within paddle's height 180 | if ((ball_Y > paddle0_Y) && (ball_Y < paddle0_Y + paddleH)) 181 | { 182 | 183 | ball_X++; // Move ball over one to the right 184 | ballVelocityX = -ballVelocityX; // Change velocity 185 | } 186 | } 187 | 188 | // Check if the ball hit the right paddle 189 | if (ball_X + ball_rad > paddle1_X) 190 | { 191 | 192 | // Check if ball is within paddle's height 193 | if ((ball_Y > paddle1_Y) && (ball_Y < paddle1_Y + paddleH)) 194 | { 195 | 196 | ball_X--; // Move ball over one to the left 197 | ballVelocityX = -ballVelocityX; // change velocity 198 | } 199 | } 200 | 201 | // Check if the ball hit the top or bottom 202 | if ((ball_Y <= 1) || (ball_Y >= (height - ball_rad - 1))) 203 | { 204 | 205 | // Change up/down velocity direction 206 | ballVelocityY = -ballVelocityY; 207 | } 208 | 209 | // Move the paddles up and down 210 | paddle0_Y += paddle0Velocity; 211 | paddle1_Y += paddle1Velocity; 212 | 213 | // Change paddle 0's direction if it hit top/bottom 214 | if ((paddle0_Y <= 1) || (paddle0_Y > height - 2 - paddleH)) 215 | paddle0Velocity = -paddle0Velocity; 216 | 217 | // Change paddle 1's direction if it hit top/bottom 218 | if ((paddle1_Y <= 1) || (paddle1_Y > height - 2 - paddleH)) 219 | paddle1Velocity = -paddle1Velocity; 220 | 221 | // Draw the Paddles: 222 | myOLED.rectangleFill(paddle0_X, paddle0_Y, paddleW, paddleH); 223 | myOLED.rectangleFill(paddle1_X, paddle1_Y, paddleW, paddleH); 224 | 225 | // Draw the ball: 226 | myOLED.rectangleFill(ball_X, ball_Y, ball_rad, ball_rad); 227 | 228 | // Actually draw everything on the screen: 229 | myOLED.display(); 230 | 231 | // Once the first loop is done, switch to XOR mode. So we just update our 232 | // moving parts 233 | if (firstLoop) 234 | { 235 | firstLoop = false; 236 | myOLED.setDrawMode(grROPXOR); 237 | } 238 | 239 | delay(25); // Delay for visibility 240 | } 241 | delay(1000); 242 | myOLED.setDrawMode(grROPCopy); 243 | } 244 | -------------------------------------------------------------------------------- /examples/Example-09_CustomOLED/Example-09_CustomOLED.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Example-09_CustomOLED.ino 4 | 5 | This demo shows the basic setup of the OLED library, generating simple graphics and displaying 6 | the results on the target device. 7 | 8 | Micro OLED https://www.sparkfun.com/products/14532 9 | Transparent OLED https://www.sparkfun.com/products/15173 10 | "Narrow" OLED https://www.sparkfun.com/products/24606 11 | Qwiic OLED 1.3in https://www.sparkfun.com/products/23453 12 | 13 | Written by Kirk Benell @ SparkFun Electronics, March 2022 14 | 15 | Repository: 16 | https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 17 | 18 | Documentation: 19 | https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 20 | 21 | SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 22 | */ 23 | 24 | #include //http://librarymanager/All#SparkFun_Qwiic_OLED 25 | 26 | 27 | // This demo shows how to use the QwiicCustomOLED class, 28 | // allowing the display width, height etc. to be set manually. 29 | 30 | QwiicCustomOLED myOLED; 31 | 32 | void setup() 33 | { 34 | delay(1000); 35 | 36 | Serial.begin(115200); 37 | Serial.println("Running OLED example"); 38 | 39 | Wire.begin(); 40 | 41 | // If desired, we can customize the OLED before we begin it. 42 | // Otherwise it will default to 128x64 (1.3" OLED). 43 | myOLED.setXOffset(0); // Set the active area X offset. For the Micro 64x48, set this to 2 44 | myOLED.setYOffset(0); // Set the active area Y offset 45 | myOLED.setDisplayWidth(128); // Set the active area width. For the Micro 64x48, set this to 64 46 | myOLED.setDisplayHeight(64); // Set the active area height. For the Micro 64x48, set this to 48 47 | myOLED.setPinConfig(0x12); // Set COM Pins Hardware Configuration (DAh) 48 | myOLED.setPreCharge(0xF1); // Set Pre-charge Period (D9h) 49 | myOLED.setVcomDeselect(0x40); // Set VCOMH Deselect Level (DBh) 50 | myOLED.setContrast(0xCF); // Set Contrast Control for BANK0 (81h). For the Micro 64x48, set this to 0x8F 51 | 52 | // Initalize the OLED device and related graphics system 53 | if (myOLED.begin(Wire, 0x3D) == false) // The TwoWire port and I2C address are set here 54 | { 55 | Serial.println("Device begin failed. Freezing..."); 56 | while (true) 57 | ; 58 | } 59 | Serial.println("Begin success"); 60 | 61 | // Do a simple test - fill a rectangle on the screen and then print hello! 62 | 63 | // Fill a rectangle on the screen that has a 4 pixel board 64 | myOLED.rectangleFill(4, 4, myOLED.getWidth() - 8, myOLED.getHeight() - 8); 65 | 66 | String hello = "hello"; // our message 67 | 68 | // Center our message on the screen. Get the screen size of the "hello" string, 69 | // calling the getStringWidth() and getStringHeight() methods on the oled 70 | 71 | // starting x position - screen width minus string width / 2 72 | int x0 = (myOLED.getWidth() - myOLED.getStringWidth(hello)) / 2; 73 | 74 | // starting y position - screen height minus string height / 2 75 | int y0 = (myOLED.getHeight() - myOLED.getStringHeight(hello)) / 2; 76 | 77 | // Draw the text - color of black (0) 78 | myOLED.text(x0, y0, hello, 0); 79 | 80 | // There's nothing on the screen yet - Now send the graphics to the device 81 | myOLED.display(); 82 | 83 | // That's it - HELLO! 84 | } 85 | 86 | void loop() 87 | { 88 | delay(1000); // Do nothing 89 | } 90 | -------------------------------------------------------------------------------- /examples/docs/ex_01_hello.md: -------------------------------------------------------------------------------- 1 | # Example 1 - Hello 2 | 3 | A simple example to show the basic setup and use of the SparkFun Qwiic OLED Library. 4 | 5 | **Key Demo Features** 6 | 7 | * Declaring a Qwiic OLED device object. 8 | * Initializing the Qwiic OLED device 9 | * Drawing a simple graphic - a filled rectangle and a text string 10 | * Using the current font to center text on the screen. 11 | * Displaying the graphics on the screen 12 | 13 | 14 | 15 | ## Setup 16 | 17 | After installing this library in your local Arduino environment, begin with a standard Arduino sketch, and include the header file for this library. 18 | 19 | 20 | ```C++ 21 | // Include the SparkFun Qwiic OLED Library 22 | #include 23 | ``` 24 | 25 | 26 | 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. 27 | 28 | The user selects from one of the following classes: 29 | 30 |
31 | 32 | 33 | 35 | 37 | 38 | 39 | 41 | 43 | 44 | 45 | 47 | 49 | 50 | 51 | 53 | 55 | 56 | 57 | 59 | 61 | 62 |
Class 34 | Qwiic OLED Device 36 |
QwiicMicroOLED 40 | SparkFun Qwiic Micro OLED 42 |
QwiicTransparentOLED 46 | SparkFun Transparent Graphical OLED 48 |
QwiicNarrowOLED 52 | SparkFun Qwiic OLED Display (128x32) 54 |
Qwiic1in3OLED 58 | SparkFun Qwiic OLED 1.3" Display (128x32) 60 |
63 |
64 | 65 | 66 | 67 | The example code supports all of the SparkFun Qwiic OLED boards. By default, the Qwiic Micro OLED is selected. To select a different board being used, add a single line comment (i.e. `//`) in front of "`QwiicMicroOLED myOLED;`" and uncomment the device being used for the demo board. 68 | 69 | 70 | ```C++ 71 | QwiicMicroOLED myOLED; 72 | //QwiicTransparentOLED myOLED; 73 | //QwiicNarrowOLED myOLED; 74 | //Qwiic1in3OLED myOLED; 75 | 76 | ``` 77 | 78 | 79 | !!! note 80 | As of version 1.0.2+, users will need to use the class as explained above instead of using a `#define`. 81 | 82 | ```C++ 83 | #define MICRO 84 | //#define NARROW 85 | //#define TRANSPARENT 86 | ``` 87 | 88 | 89 | ## Initialization 90 | 91 | In the ```setup()``` function of this sketch, like all of the SparkFun Qwiic Arduino libraries, the device is initialized by calling the ```begin()``` method. This method returns a value of ```true``` on success, or ```false``` on failure. 92 | 93 | ```C++ 94 | void setup() 95 | { 96 | 97 | delay(500); //Give display time to power on 98 | 99 | // Serial on! 100 | Serial.begin(115200); 101 | 102 | Serial.println("\n\r-----------------------------------"); 103 | 104 | Serial.print("Running Example 01 on: "); 105 | Serial.println(String(deviceName)); 106 | 107 | // Initalize the OLED device and related graphics system 108 | if(!myOLED.begin()){ 109 | 110 | Serial.println(" - Device Begin Failed"); 111 | while(1); 112 | } 113 | 114 | Serial.println("- Begin Success"); 115 | 116 | // Do a simple test - fill a rectangle on the screen and then print hello!... 117 | 118 | } 119 | ``` 120 | 121 | 122 | 123 | ## Drawing Graphics 124 | 125 | Once the device is enabled, the rest of the `setup()` function is devoted to drawing a simple graphic on the target device. 126 | 127 | 128 | 129 | ### Filled Rectangle 130 | 131 | First, draw a filled rectangle on the screen - leave a 4 pixel boarder at the end of the screen. Note that the `getWidth()` and `getHeight()` method are used to get the devices screen size. 132 | 133 | ```C++ 134 | // Fill a rectangle on the screen that has a 4 pixel board 135 | myOLED.rectangleFill(4, 4, myOLED.getWidth() - 8, myOLED.getHeight() - 8); 136 | ``` 137 | 138 | 139 | 140 | ### Centered Text 141 | 142 | The next part of our graphic is a message centered in the drawn rectangle. To do the centering, the current font is accessed from the device, and the size of a character in the font is used to calculate the text position on the screen. Once the position is determined, the message is drawn on the display in black (0 for a color value). 143 | 144 | ```C++ 145 | String hello = "hello"; // our message 146 | 147 | // Center our message on the screen. Get the screen size of the "hello" string, 148 | // calling the getStringWidth() and getStringHeight() methods on the oled 149 | 150 | // starting x position - screen width minus string width / 2 151 | int x0 = (myOLED.getWidth() - myOLED.getStringWidth(hello)) / 2; 152 | 153 | // starting y position - screen height minus string height / 2 154 | int y0 = (myOLED.getHeight() - myOLED.getStringHeight(hello)) / 2; 155 | 156 | // Draw the text - color of black (0) 157 | myOLED.text(x0, y0, hello, 0); 158 | ``` 159 | 160 | 161 | 162 | ### Displaying the Graphics 163 | 164 | The last step is sending the graphics to the device. This is accomplished by calling the `display()` method. 165 | 166 | ```C++ 167 | // There's nothing on the screen yet - Now send the graphics to the device 168 | myOLED.display(); 169 | ``` 170 | 171 | 172 | ### What You Should See 173 | 174 | And that's it! Select the board and COM port for your development board. Then upload the code! The graphic should display on the OLED device. 175 | 176 | ![Hello!](img/ex01_hello.png "Hello") 177 | -------------------------------------------------------------------------------- /examples/docs/ex_02_lines.md: -------------------------------------------------------------------------------- 1 | # Example 2 - Shapes 2 | 3 | An example that shows drawing simple shapes using the SparkFun Qwiic OLED Library. 4 | 5 | **Key Demo Features** 6 | 7 | * Drawing lines, rectangles and circles 8 | * Demonstrating how graphics size impacts display speed 9 | * Drawing and erasing graphics quickly 10 | * XOR operations using raster operators 11 | 12 | 13 | 14 | ## Setup 15 | 16 | After installing this library in your local Arduino environment, begin with a standard Arduino sketch, and include the header file for this library. 17 | 18 | 19 | ```C++ 20 | // Include the SparkFun Qwiic OLED Library 21 | #include 22 | ``` 23 | 24 | 25 | 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. 26 | 27 | The user selects from one of the following classes: 28 | 29 |
30 | 31 | 32 | 34 | 36 | 37 | 38 | 40 | 42 | 43 | 44 | 46 | 48 | 49 | 50 | 52 | 54 | 55 | 56 | 58 | 60 | 61 |
Class 33 | Qwiic OLED Device 35 |
QwiicMicroOLED 39 | SparkFun Qwiic Micro OLED 41 |
QwiicTransparentOLED 45 | SparkFun Transparent Graphical OLED 47 |
QwiicNarrowOLED 51 | SparkFun Qwiic OLED Display (128x32) 53 |
Qwiic1in3OLED 57 | SparkFun Qwiic OLED 1.3" Display (128x32) 59 |
62 |
63 | 64 | 65 | 66 | The example code supports all of the SparkFun Qwiic OLED boards. By default, the Qwiic Micro OLED is selected. To select a different board being used, add a single line comment (i.e. `//`) in front of "`QwiicMicroOLED myOLED;`" and uncomment the device being used for the demo board. 67 | 68 | 69 | ```C++ 70 | QwiicMicroOLED myOLED; 71 | //QwiicTransparentOLED myOLED; 72 | //QwiicNarrowOLED myOLED; 73 | //Qwiic1in3OLED myOLED; 74 | 75 | ``` 76 | 77 | 78 | !!! note 79 | As of version 1.0.2+, users will need to use the class as explained above instead of using a `#define`. 80 | 81 | ```C++ 82 | #define MICRO 83 | //#define NARROW 84 | //#define TRANSPARENT 85 | ``` 86 | 87 | 88 | 89 | ## Drawing Shapes 90 | 91 | !!! note 92 | As of version 1.0.2+, the modular functions have a slightly different name. Some functions defined in the example code will have the `_` removed or words spelled out. For example, version v1.0.1 and below defined the function to test the line as `line_test_1()` while version v1.0.2+ defined the function as `lineTest1()`. 93 | 94 | The shapes drawn are broken into a set of functions that perform one test, which is part of the overall example. 95 | 96 | 97 | 98 | ###Lines 99 | 100 | This test starts with a short, horizontal line that is animated from the top to bottom of the display. After each iteration, the line size is increased and the animating sequence repeated. 101 | 102 | To animate the line, the display is erased, then the line drawn. Once the line is draw, the updated graphics is sent to the OLED device by calling the `display()` method. 103 | 104 | !!! note 105 | When `display()` is called, only the range of modified pixels is sent to the OLED device, greatly reducing the data transferred for small graphic changes. 106 | 107 | This is demonstrated by this test. When small lines are drawn, the update rate is fast, but as the line length increases, the update rate of the device is noticeably slower. A longer line requires more data to be sent to the device. 108 | 109 | ```C++ 110 | void lineTest1(void) 111 | { 112 | int x, y, i; 113 | 114 | int mid = width / 2; 115 | int delta = mid / 8; 116 | 117 | for (int j = 1; j < 8; j++) 118 | { 119 | 120 | x = delta * j; 121 | 122 | for (i = 0; i < height * 2; i++) 123 | { 124 | 125 | y = i % height; 126 | myOLED.erase(); 127 | myOLED.line(mid - x, y, mid + x, y); 128 | myOLED.display(); 129 | } 130 | } 131 | } 132 | ``` 133 | 134 | 135 | 136 | This test is followed up with a series of lines that span from a single point to the bottom of the screen, showing the flexibility of the line to raster algorithm used by the library. 137 | 138 | ```C++ 139 | void lineTest2(void) 140 | { 141 | for (int i = 0; i < width; i += 6) 142 | { 143 | myOLED.line(0, 0, i, height - 1); 144 | myOLED.display(); 145 | } 146 | delay(200); 147 | myOLED.erase(); 148 | for (int i = width - 1; i >= 0; i -= 6) 149 | { 150 | myOLED.line(width - 1, 0, i, height - 1); 151 | myOLED.display(); 152 | } 153 | } 154 | ``` 155 | 156 | 157 | 158 | And the last line test draws a series of lines to test all three internal line drawing algorithms. Specifically: 159 | 160 | * Angled lines drawn by the general purpose line algorithm 161 | * Vertical lines drawn by an optimized line routine 162 | * Horizontal lines draw by an optimized line routine 163 | 164 | The test animates to show a growing box, giving an idea of the speed and flexibility of the system. 165 | 166 | ```C++ 167 | void lineTestVerticalIterative(uint8_t y0, uint8_t y1) 168 | { 169 | for (int i = 0; i < width; i += 8) 170 | myOLED.line(i, y0, i, y1); 171 | 172 | // end off the vertical lines 173 | myOLED.line(width - 1, y0, width - 1, y1); 174 | 175 | // End lines and cross lines 176 | myOLED.line(0, y0, width - 1, y0); 177 | myOLED.line(0, y1, width - 1, y1); 178 | myOLED.line(0, y0, width - 1, y1); 179 | myOLED.line(0, y1, width - 1, y0); 180 | } 181 | 182 | // Entry point for test 183 | void lineTestVertical(void) 184 | { 185 | int mid = height / 2; 186 | 187 | for (int i = 0; i < height; i += 4) 188 | { 189 | 190 | myOLED.erase(); 191 | lineTestVerticalIterative(mid - i / 2, mid + i / 2); 192 | myOLED.display(); 193 | delay(10); 194 | } 195 | } 196 | ``` 197 | 198 | 199 | 200 | ### Rectangles 201 | 202 | Several rectangle routines are shown in this example. A key test is a fast drawing routine which animates a small rectangle being drawn diagonally across the screen. 203 | 204 | In this test, the rectangle is drawn, sent to the device via using `display()`, then the rectangle is drawn again, but this time in black. This effectively erases the rectangle. The position is incremented and the process loops, causing the rectangle to appear to fly across the screen. 205 | 206 | The animation is quick, since only the portions of the screen that need updated are actually updated. 207 | 208 | The animation algorithm is listed in the `rectangleTestMove() function. 209 | 210 | ```C++ 211 | void rectangleTestMove(void) 212 | { 213 | float steps = height; 214 | float xinc = width / steps; 215 | float yinc = height / steps; 216 | int side = 10; 217 | float x = 0; 218 | float y = 0; 219 | 220 | for (int i = 0; i < steps; i++) 221 | { 222 | // Draw the rectangle and send it to device 223 | myOLED.rectangle(x, y, side, side); 224 | myOLED.display(); // sends erased rect and new rect pixels to device 225 | 226 | // Erase the that rect, increment and loop 227 | myOLED.rectangle(x, y, side, side, 0); 228 | 229 | x += xinc; 230 | y += yinc; 231 | } 232 | } 233 | ``` 234 | 235 | 236 | 237 | The next rectangle test draws a series of filled rectangles on the screen. The unique aspect of this test is that is uses the XOR functionally to overlay a rectangle on the device, presenting a alternating color pattern. 238 | 239 | The XOR raster operation is set by calling the `setDrawMode()` method on the OLED device, and providing the `grROPXOR` code. This switch the device into a XOR drawing mode. Graphic operations are restored to normal by calling `setDrawMode()` and providing the `grROPCopy` code, which copies the new pixel value to the destination. 240 | 241 | Filled rectangles and XOR operations: 242 | 243 | ```C++ 244 | void rectangleFillTest(void) 245 | { 246 | myOLED.rectangleFill(4, 4, width / 2 - 8, height - 8); 247 | 248 | myOLED.rectangleFill(width / 2 + 4, 4, width / 2 - 8, height - 8); 249 | 250 | myOLED.setDrawMode(grROPXOR); // xor 251 | myOLED.rectangleFill(width / 4, 8, width / 2, height - 16); 252 | myOLED.setDrawMode(grROPCopy); // back to copy op (default) 253 | } 254 | ``` 255 | 256 | 257 | 258 | ### Circles 259 | 260 | The final shape drawn by this example is a series of circles and filled circles. Using the geometry of the screen, a set of circles are drawn and displayed. 261 | 262 | ```C++ 263 | void circleTest(void) 264 | { 265 | // Let's draw some circles that fit on the device 266 | myOLED.circle(width / 4, height / 2, height / 3); 267 | 268 | myOLED.circleFill(width - width / 4, height / 2, height / 3); 269 | 270 | myOLED.circle(4, height / 2, height / 3); 271 | 272 | myOLED.circleFill(width - width / 2, height / 2, height / 4); 273 | } 274 | ``` 275 | -------------------------------------------------------------------------------- /examples/docs/ex_03_bitmaps.md: -------------------------------------------------------------------------------- 1 | # Example 3 - Bitmaps 2 | 3 | An example that shows drawing bitmaps using the SparkFun Qwiic OLED Library. 4 | 5 | **Key Demo Features** 6 | 7 | * Understanding bitmap structure 8 | * Bitmap objects 9 | * Drawing Bitmap 10 | 11 | 12 | ## Setup 13 | 14 | After installing this library in your local Arduino environment, begin with a standard Arduino sketch, and include the header file for this library. 15 | ```C++ 16 | // Include the SparkFun qwiic OLED Library 17 | #include 18 | ``` 19 | 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. 20 | 21 | The user selects from one of the following classes: 22 | 23 | | Class | Qwiic OLED Device | 24 | | :--- | :--- | 25 | | `QwiicMicroOLED` | [SparkFun Qwiic Micro OLED ]( https://www.sparkfun.com/products/14532)| 26 | | `QwiicNarrowOLED` | [SparkFun Qwiic OLED Display (128x32) ]( https://www.sparkfun.com/products/17153)| 27 | | `QwiicTransparentOLED` | [SparkFun Transparent Graphical OLED]( https://www.sparkfun.com/products/15173)| 28 | | `Qwiic1in3OLED` | [SparkFun Qwiic OLED 1.3" Display (128x32) ]( https://www.sparkfun.com/products/23453)| 29 | 30 | The Example code supports all of the SparkFun Qwiic OLED boards. To select the board being used, uncomment the `#define` for the demo board. 31 | 32 | For this example, the Qwiic Micro OLED is used. 33 | 34 | ```C++ 35 | #define MICRO 36 | //#define NARROW 37 | //#define TRANSPARENT 38 | ``` 39 | Which results in myOLED being declared as: 40 | 41 | ```C++ 42 | QwiicMicroOLED myOLED; 43 | ``` 44 | ## Initialization 45 | 46 | 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. 47 | 48 | ```C++ 49 | void setup() 50 | { 51 | 52 | delay(500); //Give display time to power on 53 | 54 | // Serial on! 55 | Serial.begin(115200); 56 | 57 | Serial.println("\n\r-----------------------------------"); 58 | 59 | Serial.print("Running Example 01 on: "); 60 | Serial.println(String(deviceName)); 61 | 62 | // Initalize the OLED device and related graphics system 63 | if(!myOLED.begin()){ 64 | 65 | Serial.println(" - Device Begin Failed"); 66 | while(1); 67 | } 68 | 69 | Serial.println("- Begin Success"); 70 | 71 | ``` 72 | ## Drawing Bitmaps 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /examples/docs/ex_04_text.md: -------------------------------------------------------------------------------- 1 | # Example 4 - Text 2 | 3 | An example that shows drawing bitmaps using the SparkFun Qwiic OLED Library. 4 | 5 | **Key Demo Features** 6 | 7 | * Understanding font structure and use 8 | * Drawing text 9 | * Using the Arduino `Print` functionality 10 | 11 | 12 | ## Setup 13 | 14 | After installing this library in your local Arduino environment, begin with a standard Arduino sketch, and include the header file for this library. 15 | ```C++ 16 | // Include the SparkFun qwiic OLED Library 17 | #include 18 | ``` 19 | 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. 20 | 21 | The user selects from one of the following classes: 22 | 23 | | Class | Qwiic OLED Device | 24 | | :--- | :--- | 25 | | `QwiicMicroOLED` | [SparkFun Qwiic Micro OLED ]( https://www.sparkfun.com/products/14532)| 26 | | `QwiicNarrowOLED` | [SparkFun Qwiic OLED Display (128x32) ]( https://www.sparkfun.com/products/17153)| 27 | | `QwiicTransparentOLED` | [SparkFun Transparent Graphical OLED]( https://www.sparkfun.com/products/15173)| 28 | | `Qwiic1in3OLED` | [SparkFun Qwiic OLED 1.3" Display (128x32) ]( https://www.sparkfun.com/products/23453)| 29 | 30 | The Example code supports all of the SparkFun Qwiic OLED boards. To select the board being used, uncomment the `#define` for the demo board. 31 | 32 | For this example, the Qwiic Micro OLED is used. 33 | 34 | ```C++ 35 | #define MICRO 36 | //#define NARROW 37 | //#define TRANSPARENT 38 | ``` 39 | Which results in myOLED being declared as: 40 | 41 | ```C++ 42 | QwiicMicroOLED myOLED; 43 | ``` 44 | ## Initialization 45 | 46 | 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. 47 | 48 | ```C++ 49 | void setup() 50 | { 51 | 52 | delay(500); //Give display time to power on 53 | 54 | // Serial on! 55 | Serial.begin(115200); 56 | 57 | Serial.println("\n\r-----------------------------------"); 58 | 59 | Serial.print("Running Example 01 on: "); 60 | Serial.println(String(deviceName)); 61 | 62 | // Initalize the OLED device and related graphics system 63 | if(!myOLED.begin()){ 64 | 65 | Serial.println(" - Device Begin Failed"); 66 | while(1); 67 | } 68 | 69 | Serial.println("- Begin Success"); 70 | 71 | ``` 72 | ## Drawing Text 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /examples/docs/ex_other.md: -------------------------------------------------------------------------------- 1 | # Other Examples 2 | 3 | Descriptions of the other demos that are provided as part of the SparkFun Qwiic OLED Library. 4 | 5 | ## Scroll-Flip 6 | 7 | 8 | 9 | ## Clock 10 | 11 | 12 | ## Cube 13 | 14 | 15 | ## Multi 16 | 17 | -------------------------------------------------------------------------------- /examples/docs/img/ex01_hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/b8bdcf5ef2fd8d49e49b2a9d0f44d809ea078951/examples/docs/img/ex01_hello.png -------------------------------------------------------------------------------- /examples/mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: SparkFun Qwiic OLED Arduino Library - Examples 2 | 3 | nav: 4 | - Example 1 - Hello: "ex_01_hello.md" 5 | - Example 2 - Shapes: "ex_02_lines.md" 6 | - Example 3 - Bitmaps: "ex_03_bitmaps.md" 7 | - Example 4 - Text: "ex_04_text.md" 8 | - Other Examples: "ex_other.md" -------------------------------------------------------------------------------- /img/Contributing.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library/b8bdcf5ef2fd8d49e49b2a9d0f44d809ea078951/img/Contributing.JPG -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map Quick OLED Library 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | QwiicTransparentOLED KEYWORD1 10 | QwiicNarrowOLED KEYWORD1 11 | QwiicMicroOLED KEYWORD1 12 | Qwiic1in3OLED KEYWORD1 13 | QwiicCustomOLED KEYWORD1 14 | QwiicFont KEYWORD1 15 | grRasterOp_t KEYWORD1 16 | 17 | 18 | ####################################### 19 | # Methods and Functions (KEYWORD2) 20 | ####################################### 21 | 22 | begin KEYWORD2 23 | reset KEYWORD2 24 | getWidth KEYWORD2 25 | getHeight KEYWORD2 26 | display KEYWORD2 27 | displayPower KEYWORD2 28 | erase KEYWORD2 29 | invert KEYWORD2 30 | scrollRight KEYWORD2 31 | scrollLeft KEYWORD2 32 | scrollVertRight KEYWORD2 33 | scrollVertLeft KEYWORD2 34 | scrollStop KEYWORD2 35 | flipVertical KEYWORD2 36 | flipHorizontal KEYWORD2 37 | setFont KEYWORD2 38 | getFont KEYWORD2 39 | setDrawMode KEYWORD2 40 | getDrawMode KEYWORD2 41 | pixel KEYWORD2 42 | line KEYWORD2 43 | rectangle KEYWORD2 44 | rectangleFill KEYWORD2 45 | circle KEYWORD2 46 | circleFill KEYWORD2 47 | bitmap KEYWORD2 48 | text KEYWORD2 49 | setCursor KEYWORD2 50 | setColor KEYWORD2 51 | getColor KEYWORD2 52 | write KEYWORD2 53 | 54 | ####################################### 55 | # Constants (LITERAL1) 56 | ####################################### 57 | 58 | grROPCopy LITERAL1 59 | grROPNotCopy LITERAL1 60 | grROPNot LITERAL1 61 | grROPXOR LITERAL1 62 | grROPBlack LITERAL1 63 | grROPWhite LITERAL1 64 | 65 | SCROLL_INTERVAL_5_FRAMES LITERAL1 66 | SCROLL_INTERVAL_64_FRAMES LITERAL1 67 | SCROLL_INTERVAL_128_FRAMES LITERAL1 68 | SCROLL_INTERVAL_256_FRAMES LITERAL1 69 | SCROLL_INTERVAL_3_FRAMES LITERAL1 70 | SCROLL_INTERVAL_4_FRAMES LITERAL1 71 | SCROLL_INTERVAL_25_FRAMES LITERAL1 72 | SCROLL_INTERVAL_2_FRAMES LITERAL1 73 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SparkFun Qwiic OLED Arduino Library", 3 | "version": "1.0", 4 | "keywords": "display oled graphics", 5 | "description": "Library for all SparkFun Qwiic OLED boards", 6 | "repository": 7 | { 8 | "type": "git", 9 | "url": "https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library.git" 10 | }, 11 | "frameworks": "arduino", 12 | "platforms": "*" 13 | } 14 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=SparkFun Qwiic OLED Arduino Library 2 | version=1.0.13 3 | author=SparkFun Electronics 4 | maintainer=SparkFun Electronics 5 | sentence=Library for SparkFun SSD1306 based OLED display products. 6 | paragraph=A very fast and efficient Arduino library for the SSD1306 driver IC. Transfer rates are up to 400% faster than alternative libraries; only dirty regions of the graphics buffer are sent to the display. Efficient memory usage. No dynamic memory utilized. Static resources are loaded once, and only on explicit declaration. This library supports the SparkFun Qwiic Micro OLED, 0.91in OLED, Transparent Graphical OLED, smôl OLED Display, and any other board using the SSD1306 IC. 7 | category=Display 8 | url=https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | # Documentation page information 2 | site_name: SparkFun Qwiic OLED Arduino Library - Hookup Guide 3 | site_description: SparkFun Arduino Library for Qwiic OLED Boards 4 | site_url: https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library 5 | site_author: SparkFun Electronics 6 | 7 | repo_url: https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 8 | repo_name: sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 9 | 10 | copyright: 11 | Copyright 2023 - SparkFun Electronics®
12 |
6333 Dry Creek Parkway, Niwot, Colorado 80503 13 | 14 | # Default edit/view actions to "main" branch, instead of "master" 15 | edit_uri: blob/main/docs/ 16 | 17 | #logo: img/sfe_logo_sm.png 18 | 19 | # Configuration for webpage theme 20 | theme: 21 | # Theme: https://squidfunk.github.io/mkdocs-material/ 22 | name: material 23 | 24 | # Icon in Browser Tab (must be square img - i.e. 32x32 pixels) 25 | favicon: assets/sfe_favicon.png 26 | 27 | # Page Font 28 | font: 29 | text: Roboto 30 | code: Roboto Mono 31 | 32 | # Features to Include (ref. theme documentation) 33 | features: 34 | 35 | # Enable copy button on code blocks 36 | - content.code.copy 37 | 38 | # Enable annotations in code blocks 39 | - content.code.annotate 40 | 41 | # Enable "view source" and "edit this page" buttons 42 | - content.action.edit 43 | # - content.action.view 44 | 45 | # Enable Navigation buttons in the footer (i.e. previous/next) 46 | - navigation.footer 47 | 48 | # Enables anchor tracking (updates page url with the section user is on) 49 | # i.e. https://docs.sparkfun.com//# 50 | - navigation.tracking 51 | - navigation.tabs.sticky 52 | 53 | # Enables tabs for navigating the website 54 | - navigation.tabs 55 | # Keeps tabs visible in the header when scrolling 56 | - navigation.tabs.sticky 57 | 58 | # Adds pop-up button just below the header (when the user starts to scroll up) 59 | # Allows users to easily jump to the beginning of the page 60 | - navigation.top 61 | 62 | # Renders path for page navigation at top of the page (makes page navigation more mobile friendly) 63 | - navigation.path 64 | 65 | 66 | # Adds light/dark theme to the webpage 67 | palette: 68 | # Palette toggle for automatic mode 69 | - media: "(prefers-color-scheme)" 70 | primary: grey 71 | accent: red 72 | toggle: 73 | icon: material/brightness-auto 74 | name: Switch to dark mode 75 | 76 | # Palette toggle for light mode 77 | - media: "(prefers-color-scheme: light)" 78 | primary: grey 79 | accent: red 80 | scheme: default 81 | toggle: 82 | icon: material/brightness-7 83 | name: Switch to system preference 84 | 85 | # Palette toggle for dark mode 86 | - media: "(prefers-color-scheme: dark)" 87 | primary: grey 88 | accent: red 89 | scheme: slate 90 | toggle: 91 | icon: material/weather-night 92 | name: Switch to light mode 93 | 94 | # Configures icons 95 | icon: 96 | # Sets homepage icon 97 | logo: sfe-logo 98 | 99 | # Sets repo icon to GitHub icon 100 | repo: fontawesome/brands/github 101 | 102 | # Sets icons for "view source" (commented out) and "edit this page" buttons 103 | edit: material/file-document-edit-outline 104 | # view: material/file-code-outline 105 | 106 | # Admonition Icons (callout boxes) 107 | admonition: 108 | note: octicons/tag-16 109 | abstract: octicons/checklist-16 110 | info: octicons/info-16 111 | tip: simple/sparkfun 112 | success: octicons/check-16 113 | question: octicons/question-16 114 | warning: octicons/alert-16 115 | failure: octicons/x-circle-16 116 | danger: octicons/zap-16 117 | bug: octicons/bug-16 118 | example: octicons/beaker-16 119 | quote: octicons/quote-16 120 | # Add custom admonitions 121 | github: simple/github 122 | arduino: simple/arduino 123 | python: simple/python 124 | code: fontawesome/regular/file-code 125 | terminal: octicons/terminal-16 126 | serial: fontawesome/solid/display 127 | hot: material/fire-alert 128 | # Permalink icon 129 | link: octicons/link-16 130 | 131 | # Adds overrides for stylesheets, html, etc. 132 | custom_dir: overrides 133 | 134 | 135 | # Included MkDocs plugins 136 | # Add the installation of any new plugins to the ./github/workflows/mkdocs.yml file also 137 | plugins: 138 | - search 139 | - typeset 140 | - redirects: 141 | redirect_maps: 142 | 'index.md': 'introduction.md' 143 | # Add revision date 144 | - git-revision-date-localized: 145 | enable_creation_date: true 146 | type: timeago 147 | # Add git committers at bottom of the page 148 | - git-committers: 149 | repository: sparkfun/SparkFun_Qwiic_Buzzer 150 | branch: main 151 | # Add git authors at bottom of the page 152 | - git-authors 153 | # Enables use of Git submodules and larger code base 154 | - monorepo 155 | # For PDF rendering 156 | # - with-pdf: 157 | # author: SparkFun Electronics® 158 | # copyright: Copyright 2023 - SparkFun Electronics® 159 | # cover_subtitle: none 160 | # cover_logo: img/sfe_logo_sm.png 161 | # exclude_pages: [ "hard_copy", "single_page", "file_issue", "contribute" ] 162 | # render_js: true 163 | # headless_chrome_path: headless-chromium 164 | # output_path: board_files/hookup_guide.pdf 165 | 166 | 167 | # Included Markdown extensions 168 | markdown_extensions: 169 | - pymdownx.highlight: 170 | anchor_linenums: true 171 | - pymdownx.inlinehilite 172 | - pymdownx.snippets: 173 | # base_path: ['./docs'] 174 | url_download: true 175 | url_max_size: 0 176 | url_timeout: 0 177 | url_request_headers: {} 178 | - pymdownx.superfences 179 | - pymdownx.details 180 | - pymdownx.tabbed: 181 | alternate_style: true 182 | - pymdownx.betterem: 183 | smart_enable: all 184 | - pymdownx.mark 185 | - pymdownx.caret 186 | - pymdownx.tilde 187 | - pymdownx.keys 188 | - tables 189 | - admonition 190 | - md_in_html 191 | - attr_list 192 | - pymdownx.emoji: 193 | emoji_index: !!python/name:materialx.emoji.twemoji 194 | emoji_generator: !!python/name:materialx.emoji.to_svg 195 | options: 196 | custom_icons: 197 | - overrides/.icons 198 | - pymdownx.arithmatex: 199 | generic: true 200 | - toc: 201 | permalink: '' 202 | # Link: 🔗 🔗 203 | # Chain: ⛓ ⛓ 204 | 205 | 206 | 207 | extra: 208 | # Configures the hyperlink for the logo in the header 209 | homepage: https://www.sparkfun.com/ 210 | 211 | # Configures social icons in the footer 212 | social: 213 | - icon: sfe-logo 214 | link: https://www.sparkfun.com/ 215 | - icon: fontawesome/brands/youtube 216 | link: https://www.youtube.com/sparkfun 217 | - icon: fontawesome/brands/instagram 218 | link: https://www.instagram.com/sparkfun 219 | - icon: fontawesome/brands/github 220 | link: https://www.github.com/sparkfun 221 | - icon: fontawesome/brands/facebook 222 | link: https://www.facebook.com/SparkFun 223 | - icon: fontawesome/brands/x-twitter 224 | link: https://twitter.com/sparkfun 225 | - icon: fontawesome/solid/cookie-bite 226 | link: ./#__consent 227 | name: Change cookie settings 228 | 229 | # Configures Google Analytics 230 | analytics: 231 | provider: google 232 | property: G-7Y7EYCZVC1 233 | 234 | consent: 235 | cookies: 236 | analytics: 237 | name: Google Analytics 238 | checked: true 239 | title: Cookie consent 240 | description: 241 | We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better. 242 | actions: 243 | - accept 244 | - manage 245 | - reject 246 | 247 | # Configures styling for PDF rendering and webpage layout 248 | extra_css: 249 | - stylesheet/extra.css 250 | 251 | # Enables support for rendering block and inline block equations through MathJax 252 | extra_javascript: 253 | # # Enables support for rendering block and inline block equations through MathJax 254 | - javascript/mathjax.js 255 | - https://polyfill.io/v3/polyfill.min.js?features=es6 256 | - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js 257 | 258 | # Configures webpage navigation 259 | nav: 260 | - Getting Started: 261 | - Introduction: introduction.md 262 | - Qwiic Micro OLED (0.66", 64x48): hug_micro_view.md 263 | - Qwiic OLED (0.91", 128x32): hug_0p91.md 264 | - Qwiic Transparent Graphical OLED (1.51", 128x56): hug_transparent.md 265 | - Qwiic OLED (1.3", 128x64): hug_1p3.md 266 | - Software Setup: software.md 267 | - API Reference: 268 | - Device: api_device.md 269 | - Scrolling: api_scroll.md 270 | - Drawing State: api_draw.md 271 | - Graphics: api_graphics.md 272 | - Arduino Print: api_arduino.md 273 | - Examples: '!include ./examples/mkdocs.yml' 274 | - Support: 275 | - Troubleshooting: troubleshooting.md 276 | - Submit Issues: github/file_issue.md 277 | - Contribute: github/contribute.md 278 | -------------------------------------------------------------------------------- /overrides/.icons/sfe-logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /overrides/README.md: -------------------------------------------------------------------------------- 1 | overrides directory 2 | ==================== 3 | This folder should contain the files used for the webpage customizations of the product documentation 4 | -------------------------------------------------------------------------------- /overrides/main.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 | 5 | 6 | {% if "single_page.md" %} 7 | 8 | {% include ".icons/material/file-eye-outline.svg" %} 9 | 10 | 11 | {% endif %} 12 | 13 | 14 | {{ super() }} 15 | {% endblock content %} 16 | -------------------------------------------------------------------------------- /overrides/partials/nav.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | {% import "partials/nav-item.html" as item with context %} 24 | 25 | 26 | {% set class = "md-nav md-nav--primary" %} 27 | {% if "navigation.tabs" in features %} 28 | {% set class = class ~ " md-nav--lifted" %} 29 | {% endif %} 30 | {% if "toc.integrate" in features %} 31 | {% set class = class ~ " md-nav--integrated" %} 32 | {% endif %} 33 | 34 | 35 | 80 | -------------------------------------------------------------------------------- /overrides/partials/tabs.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | {% import "partials/tabs-item.html" as item with context %} 24 | 25 | 26 | 52 | -------------------------------------------------------------------------------- /overrides/partials/toc-backup.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | {% set title = lang.t("toc") %} 25 | {% if config.mdx_configs.toc and config.mdx_configs.toc.title %} 26 | {% set title = config.mdx_configs.toc.title %} 27 | {% endif %} 28 | 29 | 30 | 67 | -------------------------------------------------------------------------------- /src/qwiic_i2c.cpp: -------------------------------------------------------------------------------- 1 | // qwiic_i2c.cpp 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | // Class provide an abstract interface to the I2C device 47 | 48 | #include "qwiic_i2c.h" 49 | 50 | 51 | // What is the max buffer size for this platform. 52 | 53 | #if defined(SERIAL_BUFFER_SIZE) 54 | #define kMaxTransferBuffer SERIAL_BUFFER_SIZE 55 | 56 | #elif defined(I2C_BUFFER_LENGTH) 57 | #define kMaxTransferBuffer I2C_BUFFER_LENGTH 58 | 59 | #elif defined(BUFFER_LENGTH) 60 | #define kMaxTransferBuffer BUFFER_LENGTH 61 | 62 | #else // just the standard Arduino value 63 | #define kMaxTransferBuffer 32 64 | 65 | #endif 66 | 67 | // What we use for transfer chunk size 68 | 69 | const static uint16_t kChunkSize = kMaxTransferBuffer - 1; 70 | 71 | ////////////////////////////////////////////////////////////////////////////////////////////////// 72 | // Constructor 73 | 74 | QwI2C::QwI2C(void) 75 | { 76 | m_i2cPort = nullptr; 77 | } 78 | ////////////////////////////////////////////////////////////////////////////////////////////////// 79 | // init() 80 | // 81 | // Methods to init/setup this device. The caller can provide a Wire Port, or this class 82 | // will use the default 83 | 84 | bool QwI2C::init(TwoWire& wirePort) 85 | { 86 | // if we don't have a wire port already 87 | if (!m_i2cPort) 88 | m_i2cPort = &wirePort; 89 | 90 | return true; 91 | } 92 | ////////////////////////////////////////////////////////////////////////////////////////////////// 93 | // 94 | 95 | bool QwI2C::init(void) 96 | { 97 | // do we already have a wire port? 98 | if (!m_i2cPort) 99 | return init(Wire); // no wire, send in Wire 100 | 101 | return true; 102 | } 103 | 104 | ////////////////////////////////////////////////////////////////////////////////////////////////// 105 | // ping() 106 | // 107 | // Is a device connected? 108 | bool QwI2C::ping(uint8_t i2c_address) 109 | { 110 | m_i2cPort->beginTransmission(i2c_address); 111 | return m_i2cPort->endTransmission() == 0; 112 | } 113 | 114 | ////////////////////////////////////////////////////////////////////////////////////////////////// 115 | // writeRegisterByte() 116 | // 117 | // Write a byte to a register 118 | 119 | bool QwI2C::writeRegisterByte(uint8_t i2c_address, uint8_t offset, uint8_t dataToWrite) 120 | { 121 | m_i2cPort->beginTransmission(i2c_address); 122 | m_i2cPort->write(offset); 123 | m_i2cPort->write(dataToWrite); 124 | return m_i2cPort->endTransmission() == 0; 125 | } 126 | ////////////////////////////////////////////////////////////////////////////////////////////////// 127 | // writeRegisterRegion() 128 | // 129 | // Write a block of data to a device. This routine will chunk over the data if needed 130 | 131 | int QwI2C::writeRegisterRegion(uint8_t i2c_address, uint8_t offset, uint8_t* data, uint16_t length) 132 | { 133 | uint16_t nSent; 134 | uint16_t nRemaining = length; 135 | uint16_t nToWrite; 136 | 137 | while (nRemaining > 0) { 138 | 139 | m_i2cPort->beginTransmission(i2c_address); 140 | m_i2cPort->write(offset); 141 | 142 | nToWrite = (nRemaining > kChunkSize ? kChunkSize : nRemaining); 143 | nSent = m_i2cPort->write(data, nToWrite); 144 | 145 | nRemaining -= nToWrite; // Note - use nToWrite, not nSent, or lock on esp32 146 | data += nSent; // move up to remaining data in buffer 147 | 148 | #if defined(ARDUINO_ARCH_ESP32) 149 | // if we are on ESP32, release bus no matter what 150 | if (m_i2cPort->endTransmission()) 151 | #else 152 | // only release bus if we've sent all data 153 | if (m_i2cPort->endTransmission(nRemaining <= 0)) 154 | #endif 155 | return -1; // the client didn't ACK 156 | } 157 | 158 | return length - nRemaining; 159 | } 160 | -------------------------------------------------------------------------------- /src/qwiic_i2c.h: -------------------------------------------------------------------------------- 1 | // qwiic_i2c.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | // Header for I2C driver object 47 | 48 | #pragma once 49 | 50 | // Simple object to encapsulate basic I2C operations. 51 | // 52 | // This is following a pattern for future implementations 53 | // 54 | // This class is focused on Aurduino.. 55 | 56 | #include 57 | #include 58 | 59 | class QwI2C { 60 | 61 | public: 62 | QwI2C(void); 63 | 64 | bool init(void); 65 | bool init(TwoWire& wirePort); 66 | 67 | // see if a device exists 68 | bool ping(uint8_t address); 69 | 70 | bool writeRegisterByte(uint8_t address, uint8_t offset, uint8_t data); 71 | 72 | // Write a block of bytes to the device -- 73 | int writeRegisterRegion(uint8_t address, uint8_t offset, uint8_t* data, uint16_t length); 74 | 75 | private: 76 | TwoWire* m_i2cPort; 77 | }; -------------------------------------------------------------------------------- /src/qwiic_oled_1in3.h: -------------------------------------------------------------------------------- 1 | // qwiic_oled_1in3.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 1.3" OLED https://www.sparkfun.com/products/23453 13 | // 14 | // 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: 21 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 22 | // 23 | // Documentation: 24 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 25 | // 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 | // The MIT License (MIT) 32 | // 33 | // Copyright (c) 2022 SparkFun Electronics 34 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 35 | // associated documentation files (the "Software"), to deal in the Software without restriction, 36 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 37 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 38 | // do so, subject to the following conditions: 39 | // The above copyright notice and this permission notice shall be included in all copies or substantial 40 | // portions of the Software. 41 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 42 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 43 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 44 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 45 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 46 | 47 | // Implementation for the 1.3" OLED device 48 | 49 | #pragma once 50 | 51 | #include "qwiic_grssd1306.h" 52 | 53 | ////////////////////////////////////////////////////////////////// 54 | // Set the defaults for the SparkFun Qwiic MicroOLED 55 | 56 | #define kOLED1in3Width 128 57 | #define kOLED1in3Height 64 58 | 59 | #define kOLED1in3XOffset 0 60 | #define kOLED1in3YOffset 0 61 | 62 | // Parameters for this device 63 | #define kOLED1in3PinConfig 0x12 64 | #define kOLED1in3PreCharge 0xF1 65 | #define kOLED1in3VCOM 0x40 66 | #define kOLED1in3Contrast 0xCF 67 | 68 | #define kOLED1in3DefaultAddress 0x3D 69 | #define kOLED1in3AltAddress 0x3C 70 | 71 | class QwOLED1in3 : public QwGrSSD1306 { 72 | 73 | public: 74 | // Constructor - setup the viewport and default address for this device. 75 | QwOLED1in3() 76 | : QwGrSSD1306(kOLED1in3XOffset, kOLED1in3YOffset, kOLED1in3Width, kOLED1in3Height) 77 | { 78 | default_address = kOLED1in3DefaultAddress; 79 | }; 80 | 81 | // set up the specific device settings 82 | bool init(void) 83 | { 84 | 85 | setBuffer(m_graphicsBuffer); // The buffer to use 86 | 87 | setCommPins(kOLED1in3PinConfig); 88 | setPreCharge(kOLED1in3PreCharge); 89 | setVcomDeselect(kOLED1in3VCOM); 90 | setContrast(kOLED1in3Contrast); 91 | 92 | // Call the super class to do all the work 93 | return this->QwGrSSD1306::init(); 94 | }; 95 | 96 | private: 97 | // Graphics buffer for this device. 98 | uint8_t m_graphicsBuffer[kOLED1in3Width * kOLED1in3Height / 8]; 99 | }; -------------------------------------------------------------------------------- /src/qwiic_oled_custom.h: -------------------------------------------------------------------------------- 1 | // qwiic_oled_custom.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 1.3" OLED https://www.sparkfun.com/products/23453 13 | // 14 | // 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: 21 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 22 | // 23 | // Documentation: 24 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 25 | // 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 | // The MIT License (MIT) 32 | // 33 | // Copyright (c) 2022 SparkFun Electronics 34 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 35 | // associated documentation files (the "Software"), to deal in the Software without restriction, 36 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 37 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 38 | // do so, subject to the following conditions: 39 | // The above copyright notice and this permission notice shall be included in all copies or substantial 40 | // portions of the Software. 41 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 42 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 43 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 44 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 45 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 46 | 47 | // Implementation for the 1.3" OLED device 48 | 49 | #pragma once 50 | 51 | #include "qwiic_grssd1306.h" 52 | 53 | ////////////////////////////////////////////////////////////////// 54 | // Set the defaults for the SparkFun Qwiic MicroOLED 55 | 56 | #define kOLEDCustomDefaultWidth 128 57 | #define kOLEDCustomDefaultHeight 64 58 | 59 | #define kOLEDCustomDefaultXOffset 0 60 | #define kOLEDCustomDefaultYOffset 0 61 | 62 | // Parameters for this device 63 | #define kOLEDCustomDefaultPinConfig 0x12 64 | #define kOLEDCustomDefaultPreCharge 0xF1 65 | #define kOLEDCustomDefaultVCOM 0x40 66 | #define kOLEDCustomDefaultContrast 0xCF 67 | 68 | #define kOLEDCustomDefaultDefaultAddress 0x3D 69 | #define kOLEDCustomDefaultAltAddress 0x3C 70 | 71 | class QwOLEDCustom : public QwGrSSD1306 { 72 | 73 | public: 74 | // Constructor - setup the viewport and default address for this device. 75 | QwOLEDCustom() 76 | : QwGrSSD1306(kOLEDCustomDefaultXOffset, kOLEDCustomDefaultYOffset, kOLEDCustomDefaultWidth, kOLEDCustomDefaultHeight) 77 | { 78 | default_address = kOLEDCustomDefaultDefaultAddress; 79 | }; 80 | 81 | ~QwOLEDCustom() 82 | { 83 | if (m_graphicsBuffer != nullptr) 84 | { 85 | delete[] m_graphicsBuffer; 86 | m_graphicsBuffer = nullptr; 87 | } 88 | }; 89 | 90 | // set up the specific device settings 91 | bool init(void) 92 | { 93 | this->QwGrSSD1306::setViewport(m_xOffset, m_yOffset, m_displayWidth, m_displayHeight); 94 | 95 | this->QwGrSSD1306::setCommPins(m_pinConfig); 96 | this->QwGrSSD1306::setPreCharge(m_preCharge); 97 | this->QwGrSSD1306::setVcomDeselect(m_vcomDeselect); 98 | this->QwGrSSD1306::setContrast(m_contrast); 99 | 100 | if (m_graphicsBuffer != nullptr) 101 | delete[] m_graphicsBuffer; 102 | m_graphicsBuffer = new uint8_t[(uint16_t)m_displayWidth * (uint16_t)m_displayHeight / 8]; 103 | this->QwGrSSD1306::setBuffer(m_graphicsBuffer); // The buffer to use 104 | 105 | // Call the super class to do all the work 106 | return this->QwGrSSD1306::init(); 107 | }; 108 | 109 | void setXOffset(uint8_t xOffset){ m_xOffset = xOffset; } 110 | void setYOffset(uint8_t yOffset){ m_yOffset = yOffset; } 111 | void setDisplayWidth(uint8_t displayWidth){ m_displayWidth = displayWidth; } 112 | void setDisplayHeight(uint8_t displayHeight){ m_displayHeight = displayHeight; } 113 | void setPinConfig(uint8_t pinConfig){ m_pinConfig = pinConfig; } 114 | void setPreCharge(uint8_t preCharge){ m_preCharge = preCharge; } 115 | void setVcomDeselect(uint8_t vcomDeselect){ m_vcomDeselect = vcomDeselect; } 116 | void setContrast(uint8_t contrast){ m_contrast = contrast; } 117 | 118 | private: 119 | uint8_t m_xOffset = kOLEDCustomDefaultXOffset; 120 | uint8_t m_yOffset = kOLEDCustomDefaultYOffset; 121 | uint8_t m_displayWidth = kOLEDCustomDefaultWidth; 122 | uint8_t m_displayHeight = kOLEDCustomDefaultHeight; 123 | uint8_t m_pinConfig = kOLEDCustomDefaultPinConfig; 124 | uint8_t m_preCharge = kOLEDCustomDefaultPreCharge; 125 | uint8_t m_vcomDeselect = kOLEDCustomDefaultVCOM; 126 | uint8_t m_contrast = kOLEDCustomDefaultContrast; 127 | 128 | // Graphics buffer for this device. 129 | uint8_t *m_graphicsBuffer = nullptr; 130 | }; -------------------------------------------------------------------------------- /src/qwiic_oledmicro.h: -------------------------------------------------------------------------------- 1 | // qwiic_oledmicro.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | // Implementation for the Qwiic Micro OLED Device 47 | 48 | #pragma once 49 | 50 | #include "qwiic_grssd1306.h" 51 | 52 | ////////////////////////////////////////////////////////////////// 53 | // Set the defaults for the SparkFun Qwiic MicroOLED 54 | 55 | #define kOLEDMicroWidth 64 56 | #define kOLEDMicroHeight 48 57 | 58 | // The viewport x is off by 2 on this device - starts at value 2 59 | #define kOLEDMicroXOffset 2 60 | #define kOLEDMicroYOffset 0 61 | 62 | // Parameters for this device 63 | #define kOLEDMicroPinConfig 0x12 64 | #define kOLEDMicroPreCharge 0xF1 65 | #define kOLEDMicroVCOM 0x40 66 | 67 | #define kOLEDMicroDefaultAddress 0x3D 68 | #define kOLEDMicroAltAddress 0x3C 69 | 70 | class QwOLEDMicro : public QwGrSSD1306 { 71 | 72 | public: 73 | // Constructor - setup the viewport and default address for this device. 74 | QwOLEDMicro() 75 | : QwGrSSD1306(kOLEDMicroXOffset, kOLEDMicroYOffset, kOLEDMicroWidth, kOLEDMicroHeight) 76 | { 77 | default_address = kOLEDMicroDefaultAddress; 78 | }; 79 | 80 | // set up the specific device settings 81 | bool init(void) 82 | { 83 | setBuffer(m_graphicsBuffer); // The buffer to use 84 | 85 | setCommPins(kOLEDMicroPinConfig); 86 | setPreCharge(kOLEDMicroPreCharge); 87 | setVcomDeselect(kOLEDMicroVCOM); 88 | 89 | // Call the super class to do all the work 90 | return this->QwGrSSD1306::init(); 91 | }; 92 | 93 | private: 94 | // Graphics buffer for this device. 95 | uint8_t m_graphicsBuffer[kOLEDMicroWidth * kOLEDMicroHeight / 8]; 96 | }; -------------------------------------------------------------------------------- /src/qwiic_olednarrow.h: -------------------------------------------------------------------------------- 1 | // qwiic_olednarrow.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | // Implementation for the Qwiic Narrow OLED Device (128x32) 47 | 48 | #pragma once 49 | 50 | #include "qwiic_grssd1306.h" 51 | 52 | ////////////////////////////////////////////////////////////////// 53 | // Set the defaults for the SparkFun Qwiic "Narrow" OLED 54 | 55 | #define kOLEDNarrowWidth 128 56 | #define kOLEDNarrowHeight 32 57 | 58 | // Parameters for this device 59 | #define kOLEDNarrowPinConfig 0x02 60 | #define kOLEDNarrowPreCharge 0xF1 61 | #define kOLEDNarrowVCOM 0x40 62 | 63 | #define kOLEDNarrowDefaultAddress 0x3C 64 | 65 | class QwOLEDNarrow : public QwGrSSD1306 { 66 | 67 | public: 68 | // Constructor - setup the viewport and default address for this device. 69 | QwOLEDNarrow() 70 | : QwGrSSD1306(kOLEDNarrowWidth, kOLEDNarrowHeight) 71 | { 72 | default_address = kOLEDNarrowDefaultAddress; 73 | }; 74 | 75 | // set up the specific values 76 | bool init(void) 77 | { 78 | 79 | setBuffer(m_graphicsBuffer); 80 | 81 | setCommPins(kOLEDNarrowPinConfig); 82 | setPreCharge(kOLEDNarrowPreCharge); 83 | setVcomDeselect(kOLEDNarrowVCOM); 84 | 85 | // Call the super class to do all the work 86 | return this->QwGrSSD1306::init(); 87 | }; 88 | 89 | private: 90 | // Graphics buffer for this device. 91 | uint8_t m_graphicsBuffer[kOLEDNarrowWidth * kOLEDNarrowHeight / 8]; 92 | }; -------------------------------------------------------------------------------- /src/qwiic_oledtransp.h: -------------------------------------------------------------------------------- 1 | // qwiic_oledtransp.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | // Implementation for the Transparent OLED device 47 | 48 | #pragma once 49 | 50 | #include "qwiic_grssd1306.h" 51 | 52 | ////////////////////////////////////////////////////////////////// 53 | // Set the defaults for the SparkFun Qwiic MicroOLED 54 | 55 | #define kOLEDTransWidth 128 56 | #define kOLEDTransHeight 64 57 | 58 | // The viewport x is off by 2 on this device - starts at value 2 59 | #define kOLEDTransXOffset 0 60 | #define kOLEDTransYOffset 0 61 | 62 | // Parameters for this device 63 | #define kOLEDTransPinConfig 0x12 64 | #define kOLEDTransPreCharge 0x25 65 | #define kOLEDTransVCOM 0x40 66 | 67 | #define kOLEDTransDefaultAddress 0x3C 68 | 69 | class QwOLEDTransparent : public QwGrSSD1306 { 70 | 71 | public: 72 | // Constructor - setup the viewport and default address for this device. 73 | QwOLEDTransparent() 74 | : QwGrSSD1306(kOLEDTransXOffset, kOLEDTransYOffset, kOLEDTransWidth, kOLEDTransHeight) 75 | { 76 | default_address = kOLEDTransDefaultAddress; 77 | }; 78 | 79 | // set up the specific device settings 80 | bool init(void) 81 | { 82 | 83 | setBuffer(m_graphicsBuffer); // The buffer to use 84 | 85 | setCommPins(kOLEDTransPinConfig); 86 | setPreCharge(kOLEDTransPreCharge); 87 | setVcomDeselect(kOLEDTransVCOM); 88 | 89 | // Call the super class to do all the work 90 | return this->QwGrSSD1306::init(); 91 | }; 92 | 93 | private: 94 | // Graphics buffer for this device. 95 | uint8_t m_graphicsBuffer[kOLEDTransWidth * kOLEDTransHeight / 8]; 96 | }; -------------------------------------------------------------------------------- /src/res/_bmp_sparkfun.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | font5x7.h 3 | Definition for small font 4 | 5 | This file was imported from the MicroView library, written by GeekAmmo 6 | (https://github.com/geekammo/MicroView-Arduino-Library), and released under 7 | the terms of the GNU General Public License as published by the Free Software 8 | Foundation, either version 3 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | 19 | Modified by: 20 | Emil Varughese @ Edwin Robotics Pvt. Ltd. 21 | July 27, 2015 22 | https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/ 23 | 24 | ******************************************************************************/ 25 | #pragma once 26 | 27 | /* 28 | #if defined(ARDUINO_ARCH_MBED) 29 | // ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h / PROGMEM 30 | static const uint8_t bmp_truck[] = { 31 | #elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__) 32 | #include 33 | static const uint8_t bmp_truck[] PROGMEM = { 34 | #else 35 | #include 36 | static const uint8_t bmp_truck[] PROGMEM = { 37 | #endif 38 | */ 39 | 40 | #define BMP_SPARKFUN_WIDTH 64 41 | #define BMP_SPARKFUN_HEIGHT 48 42 | 43 | // SparkFun Electronics LOGO 44 | static const uint8_t bmp_sparkfun_data[] = { 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 47 | 0xFF, 0xFF, 0xFF, 0x0F, 0x07, 0x07, 0x06, 0x06, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x07, 0x0F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 51 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFC, 0xFC, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFC, 0xF8, 0xE0, 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 54 | 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xF0, 0xFD, 0xFF, 55 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 57 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 58 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 59 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x07, 0x01, 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 62 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 63 | 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 66 | 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/res/_bmp_truck.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | font5x7.h 3 | Definition for small font 4 | 5 | This file was imported from the MicroView library, written by GeekAmmo 6 | (https://github.com/geekammo/MicroView-Arduino-Library), and released under 7 | the terms of the GNU General Public License as published by the Free Software 8 | Foundation, either version 3 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | 19 | Modified by: 20 | Emil Varughese @ Edwin Robotics Pvt. Ltd. 21 | July 27, 2015 22 | https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/ 23 | 24 | ******************************************************************************/ 25 | #pragma once 26 | 27 | /* 28 | #if defined(ARDUINO_ARCH_MBED) 29 | // ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h / PROGMEM 30 | static const uint8_t bmp_truck[] = { 31 | #elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__) 32 | #include 33 | static const uint8_t bmp_truck[] PROGMEM = { 34 | #else 35 | #include 36 | static const uint8_t bmp_truck[] PROGMEM = { 37 | #endif 38 | */ 39 | 40 | #define BMP_TRUCK_WIDTH 19 41 | #define BMP_TRUCK_HEIGHT 16 42 | 43 | static const uint8_t bmp_truck_data[] = { 44 | 0xFF, 45 | 0x01, 46 | 0xC1, 47 | 0x41, 48 | 0x41, 49 | 0x41, 50 | 0x71, 51 | 0x11, 52 | 0x11, 53 | 0x11, 54 | 0x11, 55 | 0x11, 56 | 0x71, 57 | 0x41, 58 | 0x41, 59 | 0xC1, 60 | 0x81, 61 | 0x01, 62 | 0xFF, 63 | 0xFF, 64 | 0x80, 65 | 0x83, 66 | 0x82, 67 | 0x86, 68 | 0x8F, 69 | 0x8F, 70 | 0x86, 71 | 0x82, 72 | 0x82, 73 | 0x82, 74 | 0x86, 75 | 0x8F, 76 | 0x8F, 77 | 0x86, 78 | 0x83, 79 | 0x81, 80 | 0x80, 81 | 0xFF, 82 | }; 83 | -------------------------------------------------------------------------------- /src/res/_fnt_7segment.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | 7segment.h 3 | Definition for 7-segment font 4 | 5 | This file was imported from the MicroView library, written by GeekAmmo 6 | (https://github.com/geekammo/MicroView-Arduino-Library), and released under 7 | the terms of the GNU General Public License as published by the Free Software 8 | Foundation, either version 3 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | 19 | Modified by: 20 | Emil Varughese @ Edwin Robotics Pvt. Ltd. 21 | July 27, 2015 22 | https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/ 23 | 24 | ******************************************************************************/ 25 | 26 | #pragma once 27 | 28 | // Define the font attributes 29 | #define FONT_7SEG_WIDTH 10 30 | #define FONT_7SEG_HEIGHT 16 31 | #define FONT_7SEG_START 46 32 | #define FONT_7SEG_NCHAR 13 33 | #define FONT_7SEG_MAP_WIDTH 130 34 | #define FONT_7SEG_NAME "7 Segment" 35 | 36 | #if defined(ARDUINO_ARCH_MBED) 37 | // ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h / PROGMEM 38 | static const uint8_t segment7_data [] = { 39 | #elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__) 40 | static const uint8_t segment7_data [] PROGMEM = { 41 | #else 42 | static const uint8_t segment7_data [] PROGMEM = { 43 | #endif 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x78, 0xFC, 0x02, 0x03, 0x03, 0x03, 0x03, 0x02, 0xFC, 0x78, 0x00, 0x00, 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, 0x00, 0x00, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 47 | 0xFC, 0x78, 0x00, 0x00, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x7E, 0xFF, 0x00, 0x80, 48 | 0x80, 0x80, 0x80, 0x00, 0xFF, 0x7E, 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0x00, 0x00, 49 | 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0x00, 0x00, 0x00, 0x02, 0x03, 0x03, 0x03, 0x03, 50 | 0x03, 0x02, 0xFC, 0x78, 0x78, 0xFC, 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x78, 0xFC, 51 | 0x02, 0x83, 0x83, 0x83, 0x83, 0x02, 0xFC, 0x78, 0x00, 0x00, 0x00, 0X00, 0x18, 0x3C, 0x3C, 0x18, 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xF0, 0xF0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x3F, 0x40, 0xC0, 0xC0, 0xC0, 0xC0, 0x40, 0x3F, 0x1E, 54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, 0x1C, 0x3E, 0x41, 0xC1, 0xC1, 0xC1, 55 | 0xC1, 0x41, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C, 0x00, 0x00, 56 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 0x7E, 0x00, 0x00, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 57 | 0x3E, 0x1C, 0x1C, 0x3E, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C, 0x00, 0x00, 0x00, 0x00, 58 | 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7E, 0x1C, 0x3E, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C, 59 | 0x00, 0x00, 0x41, 0xC1, 0xC1, 0xC1, 0xC1, 0x41, 0x3E, 0x1C, 0x00, 0x00, 0x00, 0X00, 0x18, 0x3C, 60 | 0x3C, 0x18, 0x00, 0x00 61 | 62 | }; 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/res/_fnt_largenum.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | fontlargenumber.h 3 | Definition for large font 4 | 5 | This file was imported from the MicroView library, written by GeekAmmo 6 | (https://github.com/geekammo/MicroView-Arduino-Library), and released under 7 | the terms of the GNU General Public License as published by the Free Software 8 | Foundation, either version 3 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | 19 | Modified by: 20 | Emil Varughese @ Edwin Robotics Pvt. Ltd. 21 | July 27, 2015 22 | https://github.com/emil01/SparkFun_Micro_OLED_Arduino_Library/ 23 | 24 | ******************************************************************************/ 25 | #pragma once 26 | 27 | 28 | // Define the font attributes 29 | #define FONT_LARGENUM_WIDTH 12 30 | #define FONT_LARGENUM_HEIGHT 48 31 | #define FONT_LARGENUM_START 48 32 | #define FONT_LARGENUM_NCHAR 11 33 | #define FONT_LARGENUM_MAP_WIDTH 132 34 | #define FONT_LARGENUM_NAME "Large Number" 35 | 36 | #if defined(ARDUINO_ARCH_MBED) 37 | // ARDUINO_ARCH_MBED (APOLLO3 v2) does not support or require pgmspace.h / PROGMEM 38 | static const uint8_t fontlargenum_data[] = { 39 | #elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__) 40 | static const uint8_t fontlargenum_data[] PROGMEM = { 41 | #else 42 | static const uint8_t fontlargenum_data[] PROGMEM = { 43 | #endif 44 | 0x00, 0xC0, 0xF8, 0x7C, 0x3E, 0x3E, 0xFC, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 45 | 0x78, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7C, 0x3C, 0x3E, 0x3E, 0xFE, 0xFC, 46 | 0xE0, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x3E, 0x3E, 0x3E, 0xFE, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x3E, 48 | 0x3E, 0x3E, 0x3E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFC, 0x3E, 0x3E, 0x3E, 49 | 0xFC, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0xFE, 0xFE, 0x00, 0x00, 50 | 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0x3E, 0x7E, 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 51 | 0x7E, 0x3E, 0xFE, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xC0, 0x00, 52 | 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xF9, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 53 | 0x00, 0x00, 0x07, 0x03, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 54 | 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 56 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x3F, 57 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 58 | 0x7F, 0x03, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 59 | 0x00, 0xFE, 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 | 0x3F, 0x7F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 61 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0x1F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 63 | 0xFC, 0xFF, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFE, 0x3F, 0x03, 0x00, 0xFF, 0xFF, 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x3E, 0x7E, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00, 65 | 0x00, 0xFF, 0xFF, 0x80, 0xF0, 0x7C, 0x7C, 0xF8, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 66 | 0x80, 0xF8, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x9F, 0xFF, 0xF8, 0xFE, 0x1F, 67 | 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xC0, 0xFC, 69 | 0x7F, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xE7, 0xE0, 72 | 0xE0, 0xE0, 0xFF, 0xFF, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 73 | 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x00, 74 | 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFC, 0x3F, 75 | 0x03, 0x03, 0x1F, 0xFF, 0xFC, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x3E, 0x3E, 0x0F, 0x01, 76 | 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 77 | 0x07, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 78 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFE, 0x0F, 0x00, 0x00, 0x00, 0x00, 79 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x7F, 0x00, 0x00, 0x00, 80 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 81 | 0x00, 0x00, 0xC0, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x80, 82 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 83 | 0x00, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 84 | 0x00, 0x00, 0x80, 0xFC, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 85 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x3F, 0x7C, 0x7C, 0x3F, 0x1F, 0x03, 0x00, 0x00, 0x00, 86 | 0x00, 0x00, 0x7C, 0x7C, 0x7C, 0x7F, 0x7F, 0x7C, 0x7C, 0x7C, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7C, 87 | 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x7E, 0x7C, 0x7C, 0x7E, 0x1F, 0x07, 88 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 89 | 0x00, 0x1F, 0x3E, 0x7C, 0x7C, 0x3E, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 90 | 0x7F, 0x7C, 0x7C, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 91 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1F, 0x3F, 0x7E, 0x7C, 0x7E, 0x3F, 0x1F, 0x01, 0x00, 0x00, 92 | 0x00, 0x00, 0x3E, 0x7C, 0x7C, 0x7E, 0x3F, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 93 | 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 94 | }; 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/res/qw_bmp_sparkfun.h: -------------------------------------------------------------------------------- 1 | // qw_bmp_sparkun.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | #pragma once 47 | 48 | #include "qwiic_resdef.h" 49 | 50 | class QwBMPSparkFun final : public bmpSingleton { 51 | 52 | public: 53 | const uint8_t* data(void) 54 | { 55 | 56 | #include "_bmp_sparkfun.h" 57 | 58 | return bmp_sparkfun_data; 59 | } 60 | 61 | QwBMPSparkFun() 62 | : bmpSingleton(BMP_SPARKFUN_WIDTH, BMP_SPARKFUN_HEIGHT) 63 | { 64 | } 65 | }; 66 | 67 | #define QW_BMP_SPARKFUN QwBMPSparkFun::instance() -------------------------------------------------------------------------------- /src/res/qw_bmp_truck.h: -------------------------------------------------------------------------------- 1 | // qw_bmp_truck.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | #pragma once 47 | 48 | #include "qwiic_resdef.h" 49 | 50 | class QwBMPTruck final : public bmpSingleton { 51 | 52 | public: 53 | const uint8_t* data(void) 54 | { 55 | 56 | #include "_bmp_truck.h" 57 | 58 | return bmp_truck_data; 59 | } 60 | 61 | QwBMPTruck() 62 | : bmpSingleton(BMP_TRUCK_WIDTH, BMP_TRUCK_HEIGHT) 63 | { 64 | } 65 | }; 66 | 67 | #define QW_BMP_TRUCK QwBMPTruck::instance() -------------------------------------------------------------------------------- /src/res/qw_fnt_31x48.h: -------------------------------------------------------------------------------- 1 | // qw_fnt_31x48.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | #pragma once 47 | 48 | #include "qwiic_resdef.h" 49 | 50 | class QwFont31x48 final : public fontSingleton { 51 | 52 | public: 53 | const uint8_t* data(void) 54 | { 55 | // include font data (static const), and attribute defines. 56 | // Doing this here makes the data variable a static (aka only one instance ever) 57 | // variable in this method. 58 | #include "_fnt_31x48.h" 59 | 60 | return font31x48_data; 61 | } 62 | 63 | QwFont31x48() 64 | : fontSingleton(FONT_31X48_WIDTH, 65 | FONT_31X48_HEIGHT, 66 | FONT_31X48_START, 67 | FONT_31X48_NCHAR, 68 | FONT_31X48_MAP_WIDTH, 69 | FONT_31X48_NAME) 70 | { 71 | } 72 | }; 73 | 74 | #define QW_FONT_31X48 QwFont31x48::instance() -------------------------------------------------------------------------------- /src/res/qw_fnt_5x7.h: -------------------------------------------------------------------------------- 1 | // qw_fnt_5x7.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | #pragma once 47 | 48 | #include "qwiic_resdef.h" 49 | 50 | class QwFont5x7 final : public fontSingleton { 51 | 52 | public: 53 | const uint8_t* data(void) 54 | { 55 | // include font data (static const), and attribute defines. 56 | // Doing this here makes the data variable a static (aka only one instance ever) 57 | // variable in this method. 58 | #include "_fnt_5x7.h" 59 | 60 | return font5x7_data; 61 | } 62 | 63 | QwFont5x7() 64 | : fontSingleton(FONT_5X7_WIDTH, 65 | FONT_5X7_HEIGHT, 66 | FONT_5X7_START, 67 | FONT_5X7_NCHAR, 68 | FONT_5X7_MAP_WIDTH, 69 | FONT_5X7_NAME) 70 | { 71 | } 72 | }; 73 | 74 | #define QW_FONT_5X7 QwFont5x7::instance() -------------------------------------------------------------------------------- /src/res/qw_fnt_7segment.h: -------------------------------------------------------------------------------- 1 | // qw_fnt_7segment.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | #pragma once 47 | 48 | #include "qwiic_resdef.h" 49 | 50 | class QwFont7Segment final : public fontSingleton { 51 | 52 | public: 53 | const uint8_t* data(void) 54 | { 55 | // include font data (static const), and attribute defines. 56 | // Doing this here makes the data variable a static (aka only one instance ever) 57 | // variable in this method. 58 | #include "_fnt_7segment.h" 59 | 60 | return segment7_data; 61 | } 62 | 63 | QwFont7Segment() 64 | : fontSingleton(FONT_7SEG_WIDTH, 65 | FONT_7SEG_HEIGHT, 66 | FONT_7SEG_START, 67 | FONT_7SEG_NCHAR, 68 | FONT_7SEG_MAP_WIDTH, 69 | FONT_7SEG_NAME) 70 | { 71 | } 72 | }; 73 | 74 | #define QW_FONT_7SEGMENT QwFont7Segment::instance() -------------------------------------------------------------------------------- /src/res/qw_fnt_8x16.h: -------------------------------------------------------------------------------- 1 | // qw_fnt_8x16.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | #pragma once 47 | 48 | #include "qwiic_resdef.h" 49 | 50 | class QwFont8x16 final : public fontSingleton { 51 | 52 | public: 53 | const uint8_t* data(void) 54 | { 55 | // include font data (static const), and attribute defines. 56 | // Doing this here makes the data variable a static (aka only one instance ever) 57 | // variable in this method. 58 | #include "_fnt_8x16.h" 59 | 60 | return font8x16_data; 61 | } 62 | 63 | QwFont8x16() 64 | : fontSingleton(FONT_8X16_WIDTH, 65 | FONT_8X16_HEIGHT, 66 | FONT_8X16_START, 67 | FONT_8X16_NCHAR, 68 | FONT_8X16_MAP_WIDTH, 69 | FONT_8X16_NAME) 70 | { 71 | } 72 | }; 73 | 74 | #define QW_FONT_8X16 QwFont8x16::instance() -------------------------------------------------------------------------------- /src/res/qw_fnt_largenum.h: -------------------------------------------------------------------------------- 1 | // qw_fnt_largenum.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | #pragma once 47 | 48 | #include "qwiic_resdef.h" 49 | 50 | class QwFontLargeNum final : public fontSingleton { 51 | 52 | public: 53 | const uint8_t* data(void) 54 | { 55 | // include font data (static const), and attribute defines. 56 | // Doing this here makes the data variable a static (aka only one instance ever) 57 | // variable in this method. 58 | #include "_fnt_largenum.h" 59 | 60 | return fontlargenum_data; 61 | } 62 | 63 | QwFontLargeNum() 64 | : fontSingleton(FONT_LARGENUM_WIDTH, 65 | FONT_LARGENUM_HEIGHT, 66 | FONT_LARGENUM_START, 67 | FONT_LARGENUM_NCHAR, 68 | FONT_LARGENUM_MAP_WIDTH, 69 | FONT_LARGENUM_NAME) 70 | { 71 | } 72 | }; 73 | 74 | #define QW_FONT_LARGENUM QwFontLargeNum::instance() -------------------------------------------------------------------------------- /src/res/qw_pgm_arduino.h: -------------------------------------------------------------------------------- 1 | 2 | // qw_pgm_arduino.h 3 | // 4 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 5 | // 6 | // SparkFun sells these at its website: www.sparkfun.com 7 | // 8 | // Do you like this library? Help support SparkFun. Buy a board! 9 | // 10 | // Micro OLED https://www.sparkfun.com/products/14532 11 | // Transparent OLED https://www.sparkfun.com/products/15173 12 | // "Narrow" OLED https://www.sparkfun.com/products/17153 13 | // 14 | // 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: 21 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 22 | // 23 | // Documentation: 24 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 25 | // 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 | // The MIT License (MIT) 32 | // 33 | // Copyright (c) 2022 SparkFun Electronics 34 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 35 | // associated documentation files (the "Software"), to deal in the Software without restriction, 36 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 37 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 38 | // do so, subject to the following conditions: 39 | // The above copyright notice and this permission notice shall be included in all copies or substantial 40 | // portions of the Software. 41 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 42 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 43 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 44 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 45 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 46 | 47 | // File to declare pgmspace in a platform abstract (sort of ) way 48 | 49 | #pragma once 50 | 51 | #if defined(TARGET_Apollo3) 52 | // do nothing 53 | #elif defined(__AVR__) || defined(__arm__) || defined(__ARDUINO_ARC__) 54 | #include 55 | 56 | #else 57 | #include 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /src/res/qwiic_resdef.h: -------------------------------------------------------------------------------- 1 | // qwiic_resdef.h 2 | // 3 | // This is a library written for SparkFun Qwiic OLED boards that use the SSD1306. 4 | // 5 | // SparkFun sells these at its website: www.sparkfun.com 6 | // 7 | // Do you like this library? Help support SparkFun. Buy a board! 8 | // 9 | // Micro OLED https://www.sparkfun.com/products/14532 10 | // Transparent OLED https://www.sparkfun.com/products/15173 11 | // "Narrow" OLED https://www.sparkfun.com/products/17153 12 | // 13 | // 14 | // Written by Kirk Benell @ SparkFun Electronics, March 2022 15 | // 16 | // This library configures and draws graphics to OLED boards that use the 17 | // SSD1306 display hardware. The library only supports I2C. 18 | // 19 | // Repository: 20 | // https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library 21 | // 22 | // Documentation: 23 | // https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/ 24 | // 25 | // 26 | // SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). 27 | // 28 | // SPDX-License-Identifier: MIT 29 | // 30 | // The MIT License (MIT) 31 | // 32 | // Copyright (c) 2022 SparkFun Electronics 33 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 34 | // associated documentation files (the "Software"), to deal in the Software without restriction, 35 | // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 36 | // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to 37 | // do so, subject to the following conditions: 38 | // The above copyright notice and this permission notice shall be included in all copies or substantial 39 | // portions of the Software. 40 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 41 | // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 43 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 44 | // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 45 | 46 | // 47 | // Define resource objects/structures to manage fonts and bitmaps 48 | 49 | // 50 | #pragma once 51 | 52 | // NOTE: The way I'm including the font/resource defines, some platforms have 53 | // include file issues 54 | 55 | #include "qw_pgm_arduino.h" 56 | 57 | #include 58 | 59 | //////////////////////////////////////////////////////////////////////// 60 | // Notes Template singletons for managing resources 61 | //////////////////////////////////////////////////////////////////////// 62 | // 63 | // The common use/storage of bitmap and font data is creating a static 64 | // array and placing it in a header file. 65 | // 66 | // This pattern is fine for simple uses, where the bitmap is only included 67 | // in a single file. BUT if the bitmap header is included in multiple files, 68 | // multiple copies of the bitmap are created. 69 | // 70 | // You could just make the bitmap array a const - but then multiple includes 71 | // will lead to symbol collision at link time - confusing the user. 72 | // 73 | // These simple classes help place the bitmap data in a singleton class AND 74 | // only create one copy/instance of the bitmap data no matter how many times a 75 | // resource header file is included. 76 | // 77 | // The Plan: 78 | // - Define a base resource class 79 | // - attributes as public instance vars 80 | // - Define a constructor that init's the instance vars 81 | // - Resource data access via virtual accessor - make it const 82 | // 83 | // - Create a template that subclasses the resource class, and defines a singleton 84 | // - It ensures only once of these classes is ever created. 85 | // 86 | // - In a seperate header file - one for each resource, define the resource 87 | // - For example - for a bitmap - the data array, #defines for width and height 88 | // - The data array is declard as const static 89 | // 90 | // - In another header file - create a subclass of our singleton 91 | // ex: 92 | // class QwBMPTruck final : public bitmapSingleton { 93 | // 94 | // - Override the base class data accessor method 95 | // - In the body of this method, include the resource defined header file 96 | // - This defines the resource data as a static in this method. So only one copy is made 97 | // ex: 98 | // const uint8_t * bitmap(void){ 99 | // #include "bmp_truck.h" 100 | // return bmp_truck_data; 101 | // } 102 | // 103 | // - After this resource access method, define the constructor of this class 104 | // - This is done after so it can use the attribute #defines of the included resource def header 105 | // - Have the constructor call it's superclass constructor, passing in resource attributes 106 | // ex: 107 | // QwBMPTruck(): bitmapSingleton(BMP_TRUCK_WIDTH, BMP_TRUCK_HEIGHT){} 108 | // 109 | // - Lastly, define a macro that makes the syntax of access easy. This macro calls the instance 110 | // method of the singleton, getting access to the object that contains the data of the resource 111 | // ex: 112 | // #define QW_BMP_TRUCK QwBMPTruck::instance() 113 | // 114 | // To the user, they just have a bitmap, referenced as QW_BMP_TRUCK and can do the following 115 | // ex: 116 | // uint8_t width = QW_BMP_TRUCK.width; 117 | // uint8_t height = QW_BMP_TRUCK.height; 118 | // 119 | // And internal methods get the data of this bitmap object using the bitmap() method 120 | // ex: 121 | // const uint8_t * pData = QW_BMP_TRUCK.data(); 122 | // 123 | // It shoulds complicated - it isn't. Just look at examples in ths folder and copy when 124 | // adding new resources. 125 | // 126 | /////////////////////////////////////////////////////////////////////////////////////////////////// 127 | // Simple Bitmap class definition 128 | 129 | class QwBitmap { 130 | 131 | public: 132 | uint8_t width; 133 | uint8_t height; 134 | virtual const uint8_t* data(void) { return nullptr; }; 135 | 136 | protected: 137 | QwBitmap(uint8_t w, uint8_t h) 138 | : width { w } 139 | , height { h } 140 | { 141 | } 142 | }; 143 | 144 | // Template that creates a singleton for bitmaps. 145 | template 146 | class bmpSingleton : public QwBitmap { 147 | public: 148 | static T& instance(void) 149 | { 150 | static T instance; 151 | return instance; 152 | } 153 | 154 | bmpSingleton(const bmpSingleton&) = delete; 155 | bmpSingleton& operator=(const bmpSingleton) = delete; 156 | 157 | protected: 158 | bmpSingleton() { } 159 | using QwBitmap::QwBitmap; // inherit contructor 160 | }; 161 | 162 | /////////////////////////////////////////////////////////////////////////////////////////////////// 163 | // Font things - class to hold font attributes 164 | 165 | class QwFont { 166 | 167 | public: 168 | uint8_t width; 169 | uint8_t height; 170 | uint8_t start; 171 | uint8_t n_chars; 172 | uint16_t map_width; 173 | const char* name; 174 | 175 | virtual const uint8_t* data(void) { return nullptr; }; 176 | 177 | protected: 178 | QwFont(uint8_t w, uint8_t h, uint8_t st_chr, uint8_t n_chr, uint16_t m_w, const char* f_name) 179 | : width { w } 180 | , height { h } 181 | , start { st_chr } 182 | , n_chars { n_chr } 183 | , map_width { m_w } 184 | , name { f_name } 185 | { 186 | } 187 | }; 188 | 189 | // Template that creates a singleton for bitmaps. 190 | template 191 | class fontSingleton : public QwFont { 192 | public: 193 | static T& instance(void) 194 | { 195 | static T instance; 196 | return instance; 197 | } 198 | 199 | fontSingleton(const fontSingleton&) = delete; 200 | fontSingleton& operator=(const fontSingleton) = delete; 201 | 202 | protected: 203 | fontSingleton() { } 204 | using QwFont::QwFont; // inherit constructor 205 | }; 206 | --------------------------------------------------------------------------------