Skip to content

Commit 9709716

Browse files
authored
Merge pull request #25 from sparkfun/feature/ch1120_driver_optimized
Feature/ch1120 driver optimized
2 parents 9b8f060 + 76846d7 commit 9709716

15 files changed

Lines changed: 1545 additions & 61 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Transparent OLED https://www.sparkfun.com/products/15173
1010
"Narrow" OLED https://www.sparkfun.com/products/24606
1111
Qwiic OLED 1.3in https://www.sparkfun.com/products/23453
12+
Qwiic OLED 1.5in https://www.sparkfun.com/products/29530
1213
1314
Written by Kirk Benell @ SparkFun Electronics, March 2022
1415
@@ -30,7 +31,7 @@ QwiicMicroOLED myOLED;
3031
//QwiicTransparentOLED myOLED;
3132
//QwiicNarrowOLED myOLED;
3233
//Qwiic1in3OLED myOLED;
33-
34+
//Qwiic1in5OLED myOLED;
3435

3536
void setup()
3637
{

examples/Example-02_Shapes/Example-02_Shapes.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Transparent OLED https://www.sparkfun.com/products/15173
1515
"Narrow" OLED https://www.sparkfun.com/products/24606
1616
Qwiic OLED 1.3in https://www.sparkfun.com/products/23453
17+
Qwiic OLED 1.5in https://www.sparkfun.com/products/29530
1718
1819
Written by Kirk Benell @ SparkFun Electronics, March 2022
1920
@@ -35,6 +36,7 @@ QwiicMicroOLED myOLED;
3536
//QwiicTransparentOLED myOLED;
3637
//QwiicNarrowOLED myOLED;
3738
//Qwiic1in3OLED myOLED;
39+
//Qwiic1in5OLED myOLED;
3840

3941
// Global variables - used to stash our screen size
4042

examples/Example-03_Bitmap/Example-03_Bitmap.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Transparent OLED https://www.sparkfun.com/products/15173
1515
"Narrow" OLED https://www.sparkfun.com/products/24606
1616
Qwiic OLED 1.3in https://www.sparkfun.com/products/23453
17+
Qwiic OLED 1.5in https://www.sparkfun.com/products/29530
1718
1819
Written by Kirk Benell @ SparkFun Electronics, March 2022
1920
@@ -35,6 +36,7 @@ QwiicMicroOLED myOLED;
3536
//QwiicTransparentOLED myOLED;
3637
//QwiicNarrowOLED myOLED;
3738
//Qwiic1in3OLED myOLED;
39+
//Qwiic1in5OLED myOLED;
3840

3941
// Let's draw a truck - use our built in bitmap
4042
#include "res/qw_bmp_truck.h"

examples/Example-04_Text/Example-04_Text.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Transparent OLED https://www.sparkfun.com/products/15173
1515
"Narrow" OLED https://www.sparkfun.com/products/24606
1616
Qwiic OLED 1.3in https://www.sparkfun.com/products/23453
17+
Qwiic OLED 1.5in https://www.sparkfun.com/products/29530
1718
1819
Written by Kirk Benell @ SparkFun Electronics, March 2022
1920
@@ -35,6 +36,7 @@ QwiicMicroOLED myOLED;
3536
//QwiicTransparentOLED myOLED;
3637
//QwiicNarrowOLED myOLED;
3738
//Qwiic1in3OLED myOLED;
39+
//Qwiic1in5OLED myOLED;
3840

3941
// Fonts
4042
#include <res/qw_fnt_5x7.h>

examples/Example-05_ScrollFlip/Example-05_ScrollFlip.ino

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Transparent OLED https://www.sparkfun.com/products/15173
1717
"Narrow" OLED https://www.sparkfun.com/products/24606
1818
Qwiic OLED 1.3in https://www.sparkfun.com/products/23453
19+
Qwiic OLED 1.5in https://www.sparkfun.com/products/29530
1920
2021
Written by Kirk Benell @ SparkFun Electronics, March 2022
2122
@@ -37,32 +38,38 @@ QwiicMicroOLED myOLED;
3738
//QwiicTransparentOLED myOLED;
3839
//QwiicNarrowOLED myOLED;
3940
//Qwiic1in3OLED myOLED;
41+
//Qwiic1in5OLED myOLED;
42+
43+
// Get the end page based on the type of myOLED. If it is 1.5" OLED with 128 rows (15 pages),
44+
// the end page is 15 otherwise we'll pass 7 (for displays with only 64 rows)
45+
int endPage = 7;
46+
// int endPage = 15; // Only use for 1.5" OLED
4047

4148
int yoffset;
4249

4350
// Our testing functions
4451
void scrollRight(void)
4552
{
4653
myOLED.scrollStop();
47-
myOLED.scrollRight(0, 7, SCROLL_INTERVAL_2_FRAMES);
54+
myOLED.scrollRight(0, endPage, SCROLL_INTERVAL_2_FRAMES);
4855
}
4956

5057
void scrollRightVertical(void)
5158
{
5259
myOLED.scrollStop();
53-
myOLED.scrollVertRight(0, 7, SCROLL_INTERVAL_3_FRAMES);
60+
myOLED.scrollVertRight(0, endPage, SCROLL_INTERVAL_3_FRAMES);
5461
}
5562

5663
void scrollLeft(void)
5764
{
5865
myOLED.scrollStop();
59-
myOLED.scrollLeft(0, 7, SCROLL_INTERVAL_4_FRAMES);
66+
myOLED.scrollLeft(0, endPage, SCROLL_INTERVAL_4_FRAMES);
6067
}
6168

6269
void scrollLeftVertical(void)
6370
{
6471
myOLED.scrollStop();
65-
myOLED.scrollVertLeft(0, 7, SCROLL_INTERVAL_5_FRAMES);
72+
myOLED.scrollVertLeft(0, endPage, SCROLL_INTERVAL_5_FRAMES);
6673
}
6774

6875
void scrollStop(void)
@@ -107,9 +114,9 @@ typedef struct _testRoutines
107114

108115
static const testRoutine testFunctions[] = {
109116
{scrollRight, "Right>"},
110-
{scrollRightVertical, "^Right-Up>"},
117+
{scrollRightVertical, "^Vertical-Mode1>"}, // Right-Up for most displays, Up for 1.5" display
111118
{scrollLeft, "<Left"},
112-
{scrollLeftVertical, "<Left-Up^"},
119+
{scrollLeftVertical, "<Vertical-Mode2^"}, // Left-Up for most displays, Down for 1.5" display
113120
{scrollStop, "<STOP>"},
114121
{flipHorizontal, "-Flip-Horz-"},
115122
{flipVertical, "|Flip-Vert|"},

examples/Example-06_Clock/Example-06_Clock.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Transparent OLED https://www.sparkfun.com/products/15173
1515
"Narrow" OLED https://www.sparkfun.com/products/24606
1616
Qwiic OLED 1.3in https://www.sparkfun.com/products/23453
17+
Qwiic OLED 1.5in https://www.sparkfun.com/products/29530
1718
1819
Written by
1920
Jim Lindblom @ SparkFun Electronics
@@ -37,6 +38,7 @@ QwiicMicroOLED myOLED;
3738
//QwiicTransparentOLED myOLED;
3839
//QwiicNarrowOLED myOLED;
3940
//Qwiic1in3OLED myOLED;
41+
//Qwiic1in5OLED myOLED;
4042

4143
// Use these variables to set the initial time
4244
int hours = 11;

examples/Example-07_Cube/Example-07_Cube.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Transparent OLED https://www.sparkfun.com/products/15173
1515
"Narrow" OLED https://www.sparkfun.com/products/24606
1616
Qwiic OLED 1.3in https://www.sparkfun.com/products/23453
17+
Qwiic OLED 1.5in https://www.sparkfun.com/products/29530
1718
1819
Written by
1920
Jim Lindblom @ SparkFun Electronics
@@ -36,6 +37,7 @@ QwiicMicroOLED myOLED;
3637
//QwiicTransparentOLED myOLED;
3738
//QwiicNarrowOLED myOLED;
3839
//Qwiic1in3OLED myOLED;
40+
//Qwiic1in5OLED myOLED;
3941

4042
int width;
4143
int height;

examples/Example-08_Multi/Example-08_Multi.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Transparent OLED https://www.sparkfun.com/products/15173
1515
"Narrow" OLED https://www.sparkfun.com/products/24606
1616
Qwiic OLED 1.3in https://www.sparkfun.com/products/23453
17+
Qwiic OLED 1.5in https://www.sparkfun.com/products/29530
1718
1819
Updated from example writtin by Paul Clark @ SparkFun Electronics
1920
Original Creation Date: December 11th, 2020
@@ -36,6 +37,7 @@ QwiicMicroOLED myOLED;
3637
//QwiicTransparentOLED myOLED;
3738
//QwiicNarrowOLED myOLED;
3839
//Qwiic1in3OLED myOLED;
40+
//Qwiic1in5OLED myOLED;
3941

4042
int width;
4143
int height;

src/SparkFun_Qwiic_OLED.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
// for the Qwiic OLED driver.
5050

5151
// include the underlying SDK implementation headers for the OLED devices
52+
#include "qwiic_oled_1in5.h"
5253
#include "qwiic_oled_1in3.h"
5354
#include "qwiic_oled_custom.h"
5455
#include "qwiic_oledmicro.h"
@@ -83,11 +84,11 @@ typedef QwBitmap QwiicBitmap;
8384

8485
// Define the template and fill in the interface methods in-line.
8586

86-
template <typename SSD1306DeviceType> class QwiicOLEDBaseClass : public Print // NOTE: implementing Arduino Print
87+
template <typename DeviceType> class QwiicOLEDBaseClass : public Print // NOTE: implementing Arduino Print
8788
{
8889
protected:
8990
// our device driver
90-
SSD1306DeviceType m_device;
91+
DeviceType m_device;
9192

9293
private:
9394
QwI2C m_i2cBus; // our i2c object
@@ -275,8 +276,8 @@ template <typename SSD1306DeviceType> class QwiicOLEDBaseClass : public Print //
275276
//
276277
// Parameter Description
277278
// --------- -----------------------------
278-
// start The start page address of the scroll - valid values are 0 thru 7
279-
// stop The stop/end page address of the scroll - valid values are 0 thru 7
279+
// start The start page address of the scroll - valid values are 0 thru 15 (only 0 thru 7 valid for most small displays w/ SSD1306)
280+
// stop The stop/end page address of the scroll - valid values are 0 thru 15 (only 0 thru 7 valid for most small displays w/ SSD1306)
280281
// interval The time interval between scroll step - values listed below
281282
//
282283
// Defined values for the interval parameter:
@@ -307,8 +308,8 @@ template <typename SSD1306DeviceType> class QwiicOLEDBaseClass : public Print //
307308
//
308309
// Parameter Description
309310
// --------- -----------------------------
310-
// start The start page address of the scroll - valid values are 0 thru 7
311-
// stop The stop/end page address of the scroll - valid values are 0 thru 7
311+
// start The start page address of the scroll - valid values are 0 thru 15 (only 0 thru 7 valid for most small displays w/ SSD1306)
312+
// stop The stop/end page address of the scroll - valid values are 0 thru 15 (only 0 thru 7 valid for most small displays w/ SSD1306)
312313
// interval The time interval between scroll step - values listed in scrollRight()
313314

314315
void scrollVertRight(uint8_t start, uint8_t stop, uint8_t interval)
@@ -326,8 +327,8 @@ template <typename SSD1306DeviceType> class QwiicOLEDBaseClass : public Print //
326327
//
327328
// Parameter Description
328329
// --------- -----------------------------
329-
// start The start page address of the scroll - valid values are 0 thru 7
330-
// stop The stop/end page address of the scroll - valid values are 0 thru 7
330+
// start The start page address of the scroll - valid values are 0 thru 15 (only 0 thru 7 valid for most small displays w/ SSD1306)
331+
// stop The stop/end page address of the scroll - valid values are 0 thru 15 (only 0 thru 7 valid for most small displays w/ SSD1306)
331332
// interval The time interval between scroll step - values listed in scrollRight()
332333

333334
void scrollLeft(uint8_t start, uint8_t stop, uint8_t interval)
@@ -345,8 +346,8 @@ template <typename SSD1306DeviceType> class QwiicOLEDBaseClass : public Print //
345346
//
346347
// Parameter Description
347348
// --------- -----------------------------
348-
// start The start page address of the scroll - valid values are 0 thru 7
349-
// stop The stop/end page address of the scroll - valid values are 0 thru 7
349+
// start The start page address of the scroll - valid values are 0 thru 15 (only 0 thru 7 valid for most small displays w/ SSD1306)
350+
// stop The stop/end page address of the scroll - valid values are 0 thru 15 (only 0 thru 7 valid for most small displays w/ SSD1306)
350351
// interval The time interval between scroll step - values listed in scrollRight()
351352

352353
void scrollVertLeft(uint8_t start, uint8_t stop, uint8_t interval)
@@ -845,6 +846,11 @@ class Qwiic1in3OLED : public QwiicOLEDBaseClass<QwOLED1in3>
845846
// nothing here - see above
846847
};
847848

849+
class Qwiic1in5OLED : public QwiicOLEDBaseClass<QwOLED1in5>
850+
{
851+
// nothing here - see above
852+
};
853+
848854
class QwiicCustomOLED : public QwiicOLEDBaseClass<QwOLEDCustom>
849855
{
850856
public:

0 commit comments

Comments
 (0)