Skip to content

Commit a262454

Browse files
committed
formatter updates
1 parent 4c68a7a commit a262454

File tree

2 files changed

+130
-82
lines changed

2 files changed

+130
-82
lines changed

src/SparkFun_Qwiic_OLED.h

Lines changed: 76 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
// for the Qwiic OLED driver.
5050

5151
// include the underlying SDK implementation headers for the OLED devices
52+
#include "qwiic_oled_1in3.h"
53+
#include "qwiic_oled_custom.h"
5254
#include "qwiic_oledmicro.h"
5355
#include "qwiic_olednarrow.h"
5456
#include "qwiic_oledtransp.h"
55-
#include "qwiic_oled_1in3.h"
56-
#include "qwiic_oled_custom.h"
5757

5858
#include <Arduino.h>
5959
#include <Wire.h>
@@ -83,12 +83,13 @@ typedef QwBitmap QwiicBitmap;
8383

8484
// Define the template and fill in the interface methods in-line.
8585

86-
template <typename SSD1306DeviceType>
87-
class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
88-
protected:
86+
template <typename SSD1306DeviceType> class QwiicOLEDBaseClass : public Print // NOTE: implementing Arduino Print
87+
{
88+
protected:
8989
// our device driver
9090
SSD1306DeviceType m_device;
91-
private:
91+
92+
private:
9293
QwI2C m_i2cBus; // our i2c object
9394

9495
// for the Aruduino print functionaliyt
@@ -97,7 +98,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
9798

9899
uint8_t m_color;
99100

100-
public:
101+
public:
101102
///////////////////////////////////////////////////////////////////////
102103
// begin()
103104
//
@@ -113,7 +114,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
113114
// address optional. I2C Address. If not provided, the default address is used.
114115
// retval true on success, false on startup failure
115116

116-
bool begin(TwoWire& wirePort = Wire, uint8_t address = kNoAddressSet)
117+
bool begin(TwoWire &wirePort = Wire, uint8_t address = kNoAddressSet)
117118
{
118119

119120
// defaults for Arduino Print
@@ -122,17 +123,17 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
122123

123124
m_i2cBus.init(wirePort);
124125

125-
m_device.setCommBus(m_i2cBus,
126-
(address == kNoAddressSet ? m_device.default_address : address));
126+
m_device.setCommBus(m_i2cBus, (address == kNoAddressSet ? m_device.default_address : address));
127127

128128
// call init on the device
129129
bool bStatus = m_device.init();
130130

131131
// Want to start cursor at Y height of the current font, if we have a font.
132132
//
133133
// Get our font height ... a default font is set during init ...
134-
if (bStatus) {
135-
QwiicFont* pFont = m_device.font();
134+
if (bStatus)
135+
{
136+
QwiicFont *pFont = m_device.font();
136137
if (pFont)
137138
m_cursorY = pFont->height;
138139
}
@@ -175,7 +176,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
175176
//
176177
// Parameter Description
177178
// --------- -----------------------------
178-
// clearDisplay true - clear the internal buffers during reset
179+
// clearDisplay true - clear the internal buffers during reset
179180
// retval true on success, false on failure
180181

181182
bool reset(bool clearDisplay)
@@ -411,11 +412,11 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
411412
// int myFontWidth = QW_FONT_31X48.width;
412413
//
413414

414-
void setFont(QwiicFont& theFont)
415+
void setFont(QwiicFont &theFont)
415416
{
416417
m_device.setFont(theFont);
417418
}
418-
void setFont(const QwiicFont* theFont)
419+
void setFont(const QwiicFont *theFont)
419420
{
420421
m_device.setFont(theFont);
421422
}
@@ -429,7 +430,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
429430
// --------- -----------------------------
430431
// retval A pointer to the current font. See setFont() for font object details.
431432

432-
QwiicFont* getFont(void)
433+
QwiicFont *getFont(void)
433434
{
434435
return m_device.font();
435436
}
@@ -441,7 +442,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
441442

442443
String getFontName(void)
443444
{
444-
QwiicFont* pFont = m_device.font();
445+
QwiicFont *pFont = m_device.font();
445446

446447
if (!pFont)
447448
return String("");
@@ -458,12 +459,12 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
458459
// text The string used to determine width
459460
// retval The width of the provide string, as determined using the current font.
460461

461-
unsigned int getStringWidth(String& text)
462+
unsigned int getStringWidth(String &text)
462463
{
463464
return getStringWidth(text.c_str());
464465
}
465466

466-
unsigned int getStringWidth(const char* text)
467+
unsigned int getStringWidth(const char *text)
467468
{
468469

469470
uint16_t height, width;
@@ -481,12 +482,12 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
481482
// text The string used to determine height
482483
// retval The height of the provide string, as determined using the current font.
483484

484-
unsigned int getStringHeight(String& text)
485+
unsigned int getStringHeight(String &text)
485486
{
486487
return getStringHeight(text.c_str());
487488
}
488489

489-
unsigned int getStringHeight(const char* text)
490+
unsigned int getStringHeight(const char *text)
490491
{
491492

492493
uint16_t height, width;
@@ -662,8 +663,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
662663
// bmp_width The width of the bitmap
663664
// bmp_height The height of the bitmap
664665

665-
void bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
666-
uint8_t* pBitmap, uint8_t bmp_width, uint8_t bmp_height)
666+
void bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height)
667667
{
668668
m_device.bitmap(x0, y0, x1, y1, pBitmap, bmp_width, bmp_height);
669669
}
@@ -681,7 +681,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
681681
// bmp_width The width of the bitmap
682682
// bmp_height The height of the bitmap
683683

684-
void bitmap(uint8_t x0, uint8_t y0, uint8_t* pBitmap, uint8_t bmp_width, uint8_t bmp_height)
684+
void bitmap(uint8_t x0, uint8_t y0, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height)
685685
{
686686

687687
m_device.bitmap(x0, y0, pBitmap, bmp_width, bmp_height);
@@ -697,7 +697,7 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
697697
// y0 The Y coordinate to place the bitmap - upper left corner
698698
// bitmap A bitmap object
699699

700-
void bitmap(uint8_t x0, uint8_t y0, QwiicBitmap& bitmap)
700+
void bitmap(uint8_t x0, uint8_t y0, QwiicBitmap &bitmap)
701701
{
702702
m_device.bitmap(x0, y0, bitmap);
703703
}
@@ -714,12 +714,12 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
714714
// text The string to draw on the screen
715715
// clr optional The color value to draw the text. This defaults to white (1).
716716

717-
void text(uint8_t x0, uint8_t y0, const char* text, uint8_t clr = COLOR_WHITE)
717+
void text(uint8_t x0, uint8_t y0, const char *text, uint8_t clr = COLOR_WHITE)
718718
{
719719
m_device.text(x0, y0, text, clr);
720720
}
721721

722-
void text(uint8_t x0, uint8_t y0, String& text, uint8_t clr = COLOR_WHITE)
722+
void text(uint8_t x0, uint8_t y0, String &text, uint8_t clr = COLOR_WHITE)
723723
{
724724

725725
m_device.text(x0, y0, text.c_str(), clr);
@@ -789,25 +789,27 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
789789

790790
virtual size_t write(uint8_t theChar)
791791
{
792-
QwiicFont* pFont = m_device.font();
792+
QwiicFont *pFont = m_device.font();
793793

794794
if (!pFont) // no Font?! No dice
795795
return 0;
796796

797-
switch (theChar) {
797+
switch (theChar)
798+
{
798799
case '\n': // Carriage return
799800
m_cursorX = 0;
800801
m_cursorY += pFont->height;
801802
case '\r': // Line feed - do nothing
802803
break;
803804
default:
804805

805-
char buffer[2] = { theChar, '\0' }; // text() needs a c string
806+
char buffer[2] = {theChar, '\0'}; // text() needs a c string
806807
m_device.text(m_cursorX, m_cursorY, buffer, m_color);
807808

808809
m_cursorX += pFont->width + 1;
809810

810-
if (m_cursorX > m_device.width() - pFont->width) { // overflow
811+
if (m_cursorX > m_device.width() - pFont->width)
812+
{ // overflow
811813
m_cursorX = 0;
812814
m_cursorY += pFont->height;
813815
}
@@ -823,30 +825,59 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
823825
///////////////////////////////////////////////////////////////////////
824826
// For our actual implementations - just subclass from the above Arduino template
825827

826-
class QwiicMicroOLED : public QwiicOLEDBaseClass<QwOLEDMicro> {
828+
class QwiicMicroOLED : public QwiicOLEDBaseClass<QwOLEDMicro>
829+
{
827830
// nothing here - see above
828831
};
829832

830-
class QwiicNarrowOLED : public QwiicOLEDBaseClass<QwOLEDNarrow> {
833+
class QwiicNarrowOLED : public QwiicOLEDBaseClass<QwOLEDNarrow>
834+
{
831835
// nothing here - see above
832836
};
833837

834-
class QwiicTransparentOLED : public QwiicOLEDBaseClass<QwOLEDTransparent> {
838+
class QwiicTransparentOLED : public QwiicOLEDBaseClass<QwOLEDTransparent>
839+
{
835840
// nothing here - see above
836841
};
837842

838-
class Qwiic1in3OLED : public QwiicOLEDBaseClass<QwOLED1in3> {
843+
class Qwiic1in3OLED : public QwiicOLEDBaseClass<QwOLED1in3>
844+
{
839845
// nothing here - see above
840846
};
841847

842-
class QwiicCustomOLED : public QwiicOLEDBaseClass<QwOLEDCustom> {
843-
public:
844-
void setXOffset(uint8_t xOffset){ m_device.setXOffset(xOffset); }
845-
void setYOffset(uint8_t yOffset){ m_device.setYOffset(yOffset); }
846-
void setDisplayWidth(uint8_t displayWidth){ m_device.setDisplayWidth(displayWidth); }
847-
void setDisplayHeight(uint8_t displayHeight){ m_device.setDisplayHeight(displayHeight); }
848-
void setPinConfig(uint8_t pinConfig){ m_device.setPinConfig(pinConfig); }
849-
void setPreCharge(uint8_t preCharge){ m_device.setPreCharge(preCharge); }
850-
void setVcomDeselect(uint8_t vcomDeselect){ m_device.setVcomDeselect(vcomDeselect); }
851-
void setContrast(uint8_t contrast){ m_device.setContrast(contrast); }
848+
class QwiicCustomOLED : public QwiicOLEDBaseClass<QwOLEDCustom>
849+
{
850+
public:
851+
void setXOffset(uint8_t xOffset)
852+
{
853+
m_device.setXOffset(xOffset);
854+
}
855+
void setYOffset(uint8_t yOffset)
856+
{
857+
m_device.setYOffset(yOffset);
858+
}
859+
void setDisplayWidth(uint8_t displayWidth)
860+
{
861+
m_device.setDisplayWidth(displayWidth);
862+
}
863+
void setDisplayHeight(uint8_t displayHeight)
864+
{
865+
m_device.setDisplayHeight(displayHeight);
866+
}
867+
void setPinConfig(uint8_t pinConfig)
868+
{
869+
m_device.setPinConfig(pinConfig);
870+
}
871+
void setPreCharge(uint8_t preCharge)
872+
{
873+
m_device.setPreCharge(preCharge);
874+
}
875+
void setVcomDeselect(uint8_t vcomDeselect)
876+
{
877+
m_device.setVcomDeselect(vcomDeselect);
878+
}
879+
void setContrast(uint8_t contrast)
880+
{
881+
m_device.setContrast(contrast);
882+
}
852883
};

0 commit comments

Comments
 (0)