Skip to content

Commit 553ce4a

Browse files
author
Kirk Benell
authored
Merge branch 'main' into ExampleWorkOver
2 parents 829ea6f + 8a8ca16 commit 553ce4a

File tree

6 files changed

+71
-22
lines changed

6 files changed

+71
-22
lines changed

docs/api_graphics.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ Draws a bitmap on the screen.
124124

125125
The bitmap should be 8 bit encoded - each pixel contains 8 y values.
126126

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+
127147
```c++
128148
void bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
129149
uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height )

examples/Example-01_Hello/Example-01_Hello.ino

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
/*
2+
23
Example-01_Hello.ino
34
45
This demo shows the basic setup of the OLED library, generating simple graphics and displaying
56
the results on the target device.
67
7-
This is a library written for SparkFun Qwiic OLED boards that use the SSD1306.
8-
9-
This library configures and draws graphics to OLED boards that use the
10-
SSD1306 display hardware. The library only supports I2C.
11-
12-
SparkFun sells these at its website: www.sparkfun.com
13-
14-
Do you like this library? Help support SparkFun. Buy a board!
15-
168
Micro OLED https://www.sparkfun.com/products/14532
179
Transparent OLED https://www.sparkfun.com/products/15173
1810
"Narrow" OLED https://www.sparkfun.com/products/17153
@@ -30,13 +22,17 @@
3022

3123
#include <SparkFun_Qwiic_OLED.h> //http://librarymanager/All#SparkFun_Qwiic_Graphic_OLED
3224

25+
// Add in our font descriptor -- so we can center the text on the scren
26+
#include <res/qw_fnt_5x7.h>
27+
3328
// The Library supports three different types of SparkFun boards. The demo uses the following
3429
// defines to determine which device is being used. Uncomment the device being used for this demo.
3530

3631
QwiicMicroOLED myOLED;
3732
// QwiicTransparentOLED myOLED;
3833
// QwiicNarrowOLED myOLED;
3934

35+
4036
void setup()
4137
{
4238
Serial.begin(115200);
@@ -60,14 +56,13 @@ void setup()
6056

6157
String hello = "hello"; // our message
6258

63-
// Let's center our message on the screen. We need the current font.
64-
65-
QwiicFont *pFont = myOLED.getFont();
59+
// Center our message on the screen. Use our Font Descriptor: QW_FONT_5X7, the default
60+
// font of the system.
6661

67-
// Starting x position - width minus string length (font width * number of characters) / 2
68-
int x0 = (myOLED.getWidth() - pFont->width * hello.length()) / 2;
62+
// starting x position - width minus string length (font width * number of characters) / 2
63+
int x0 = (myOLED.getWidth() - QW_FONT_5X7.width * hello.length()) / 2;
6964

70-
int y0 = (myOLED.getHeight() - pFont->height) / 2;
65+
int y0 = (myOLED.getHeight() - QW_FONT_5X7.height) / 2;
7166

7267
// Draw the text - color of black (0)
7368
myOLED.text(x0, y0, hello, 0);

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for SparkFun Qwiic OLED Breakout Baords</a>.
66
paragraph=Library for all SparkFun Qwiic OLED Boards: Micro OLED, Transparent OLED, Qwiic OLED (128x32), smol Display
77
category=Display
8-
url=https://github.com/sparkfun/SparkFun_Qwiic_OLED_Graphics_Library
8+
url=https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library
99
architectures=*

src/SparkFun_Qwiic_OLED.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,10 @@ class QwiicOLEDBaseClass : public Print
563563
// --------- -----------------------------
564564
// x0 The X coordinate to place the bitmap - upper left corner
565565
// y0 The Y coordinate to place the bitmap - upper left corner
566-
// x1 The end X coordinate of the bitmap - lower right corner
567-
// y1 The end Y coordinate of the bitmap - lower right corner
566+
// x1 The end X coordinate of area to draw - lower right corner
567+
// Range will not exceed bitmap width
568+
// y1 The end Y coordinate of area to draw - lower right corner
569+
// Range will not exceed bitmap height
568570
// pBitmap A pointer to the bitmap array
569571
// bmp_width The width of the bitmap
570572
// bmp_height The height of the bitmap
@@ -577,8 +579,25 @@ class QwiicOLEDBaseClass : public Print
577579

578580
///////////////////////////////////////////////////////////////////////
579581
// bitmap()
582+
//
583+
// Draws a bitmap on the screen.
580584
//
581-
// Draws a bitmap object on the screen.
585+
// Parameter Description
586+
// --------- -----------------------------
587+
// x0 The X coordinate to place the bitmap - upper left corner
588+
// y0 The Y coordinate to place the bitmap - upper left corner
589+
// pBitmap A pointer to the bitmap array
590+
// bmp_width The width of the bitmap
591+
// bmp_height The height of the bitmap
592+
593+
void bitmap(uint8_t x0, uint8_t y0, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height ){
594+
595+
_device.bitmap(x0, y0, pBitmap, bmp_width, bmp_height);
596+
}
597+
///////////////////////////////////////////////////////////////////////
598+
// bitmap()
599+
//
600+
// Draws a bitmap object on the screen.
582601
//
583602
// Parameter Description
584603
// --------- -----------------------------

src/qwiic_grbuffer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,20 @@ void QwGrBufferDevice::draw_circle_filled(uint8_t x0, uint8_t y0, uint8_t radius
531531
void QwGrBufferDevice::bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
532532
uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height)
533533
{
534-
535534
(*_idraw.draw_bitmap)(this, x0, y0, x1, y1, pBitmap, bmp_width, bmp_height);
536535
}
537536

537+
////////////////////////////////////////////////////////////////////////////////////////
538+
// bitmap()
539+
//
540+
// Draw a bitmap on the screen
541+
542+
void QwGrBufferDevice::bitmap(uint8_t x0, uint8_t y0, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height )
543+
{
544+
545+
(*_idraw.draw_bitmap)(this, x0, y0, bmp_width, bmp_height, pBitmap, bmp_width, bmp_height);
546+
}
547+
538548
////////////////////////////////////////////////////////////////////////////////////////
539549
// bitmap() - use a bitmap object
540550
//

src/qwiic_grbuffer.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,13 @@ class QwGrBufferDevice : protected _QwIDraw
192192
void rectangle(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t clr = 1);
193193
void rectangle_fill(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t clr = 1);
194194

195-
void bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
196-
uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height);
195+
196+
void bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
197+
uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height );
198+
199+
// draw full bitmap
200+
void bitmap(uint8_t x0, uint8_t y0, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height );
201+
197202
// Bitmap draw - using a bitmap object
198203
void bitmap(uint8_t x0, uint8_t y0, QwBitmap &bitmap);
199204

0 commit comments

Comments
 (0)