Skip to content

Commit 04207b6

Browse files
authored
Merge pull request adafruit#222 from bmoniey/protected
Protected
2 parents 35ad544 + b4bb6bc commit 04207b6

File tree

2 files changed

+88
-15
lines changed

2 files changed

+88
-15
lines changed

Adafruit_SSD1306.cpp

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ Adafruit_SSD1306::~Adafruit_SSD1306(void) {
345345

346346
// Issue single byte out SPI, either soft or hardware as appropriate.
347347
// SPI transaction/selection must be performed in calling function.
348+
/*!
349+
@brief Write a single byte to the SPI port.
350+
351+
@param d
352+
Data byte to be written.
353+
354+
@return void
355+
@note See HAVE_PORTREG which defines if the method uses a port or bit-bang
356+
method
357+
*/
348358
inline void Adafruit_SSD1306::SPIwrite(uint8_t d) {
349359
if (spi) {
350360
(void)spi->transfer(d);
@@ -366,10 +376,18 @@ inline void Adafruit_SSD1306::SPIwrite(uint8_t d) {
366376
}
367377
}
368378

369-
// Issue single command to SSD1306, using I2C or hard/soft SPI as needed.
370-
// Because command calls are often grouped, SPI transaction and selection
371-
// must be started/ended in calling function for efficiency.
372-
// This is a private function, not exposed (see ssd1306_command() instead).
379+
/*!
380+
@brief Issue single command to SSD1306, using I2C or hard/soft SPI as
381+
needed. Because command calls are often grouped, SPI transaction and
382+
selection must be started/ended in calling function for efficiency. This is a
383+
protected function, not exposed (see ssd1306_command() instead).
384+
385+
@param c
386+
the command character to send to the display.
387+
Refer to ssd1306 data sheet for commands
388+
@return None (void).
389+
@note
390+
*/
373391
void Adafruit_SSD1306::ssd1306_command1(uint8_t c) {
374392
if (wire) { // I2C
375393
wire->beginTransmission(i2caddr);
@@ -382,8 +400,18 @@ void Adafruit_SSD1306::ssd1306_command1(uint8_t c) {
382400
}
383401
}
384402

385-
// Issue list of commands to SSD1306, same rules as above re: transactions.
386-
// This is a private function, not exposed.
403+
/*!
404+
@brief Issue list of commands to SSD1306, same rules as above re:
405+
transactions. This is a protected function, not exposed.
406+
@param c
407+
pointer to list of commands
408+
409+
@param n
410+
number of commands in the list
411+
412+
@return None (void).
413+
@note
414+
*/
387415
void Adafruit_SSD1306::ssd1306_commandList(const uint8_t *c, uint8_t n) {
388416
if (wire) { // I2C
389417
wire->beginTransmission(i2caddr);
@@ -695,6 +723,23 @@ void Adafruit_SSD1306::drawFastHLine(int16_t x, int16_t y, int16_t w,
695723
drawFastHLineInternal(x, y, w, color);
696724
}
697725

726+
/*!
727+
@brief Draw a horizontal line with a width and color. Used by public
728+
methods drawFastHLine,drawFastVLine
729+
@param x
730+
Leftmost column -- 0 at left to (screen width - 1) at right.
731+
@param y
732+
Row of display -- 0 at top to (screen height -1) at bottom.
733+
@param w
734+
Width of line, in pixels.
735+
@param color
736+
Line color, one of: SSD1306_BLACK, SSD1306_WHITE or
737+
SSD1306_INVERT.
738+
@return None (void).
739+
@note Changes buffer contents only, no immediate effect on display.
740+
Follow up with a call to display(), or with other graphics
741+
commands as needed by one's own application.
742+
*/
698743
void Adafruit_SSD1306::drawFastHLineInternal(int16_t x, int16_t y, int16_t w,
699744
uint16_t color) {
700745

@@ -778,6 +823,22 @@ void Adafruit_SSD1306::drawFastVLine(int16_t x, int16_t y, int16_t h,
778823
drawFastVLineInternal(x, y, h, color);
779824
}
780825

826+
/*!
827+
@brief Draw a vertical line with a width and color. Used by public method
828+
drawFastHLine,drawFastVLine
829+
@param x
830+
Leftmost column -- 0 at left to (screen width - 1) at right.
831+
@param __y
832+
Row of display -- 0 at top to (screen height -1) at bottom.
833+
@param __h height of the line in pixels
834+
@param color
835+
Line color, one of: SSD1306_BLACK, SSD1306_WHITE or
836+
SSD1306_INVERT.
837+
@return None (void).
838+
@note Changes buffer contents only, no immediate effect on display.
839+
Follow up with a call to display(), or with other graphics
840+
commands as needed by one's own application.
841+
*/
781842
void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y,
782843
int16_t __h, uint16_t color) {
783844

Adafruit_SSD1306.h

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,27 +160,39 @@ class Adafruit_SSD1306 : public Adafruit_GFX {
160160
bool getPixel(int16_t x, int16_t y);
161161
uint8_t *getBuffer(void);
162162

163-
private:
163+
protected:
164164
inline void SPIwrite(uint8_t d) __attribute__((always_inline));
165165
void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color);
166166
void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color);
167167
void ssd1306_command1(uint8_t c);
168168
void ssd1306_commandList(const uint8_t *c, uint8_t n);
169169

170-
SPIClass *spi;
171-
TwoWire *wire;
172-
uint8_t *buffer;
173-
int8_t i2caddr, vccstate, page_end;
174-
int8_t mosiPin, clkPin, dcPin, csPin, rstPin;
170+
SPIClass *spi; ///< Initialized during construction when using SPI. See
171+
///< SPI.cpp, SPI.h
172+
TwoWire *wire; ///< Initialized during construction when using I2C. See
173+
///< Wire.cpp, Wire.h
174+
uint8_t *buffer; ///< Buffer data used for display buffer. Allocated when
175+
///< begin method is called.
176+
int8_t i2caddr; ///< I2C address initialized when begin method is called.
177+
int8_t vccstate; ///< VCC selection, set by begin method.
178+
int8_t page_end; ///< not used
179+
int8_t mosiPin; ///< (Master Out Slave In) set when using SPI set during
180+
///< construction.
181+
int8_t clkPin; ///< (Clock Pin) set when using SPI set during construction.
182+
int8_t dcPin; ///< (Data Pin) set when using SPI set during construction.
183+
int8_t
184+
csPin; ///< (Chip Select Pin) set when using SPI set during construction.
185+
int8_t rstPin; ///< Display reset pin assignment. Set during construction.
186+
175187
#ifdef HAVE_PORTREG
176188
PortReg *mosiPort, *clkPort, *dcPort, *csPort;
177189
PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask;
178190
#endif
179191
#if ARDUINO >= 157
180-
uint32_t wireClk; // Wire speed for SSD1306 transfers
181-
uint32_t restoreClk; // Wire speed following SSD1306 transfers
192+
uint32_t wireClk; ///< Wire speed for SSD1306 transfers
193+
uint32_t restoreClk; ///< Wire speed following SSD1306 transfers
182194
#endif
183-
uint8_t contrast; // normal contrast setting for this device
195+
uint8_t contrast; ///< normal contrast setting for this device
184196
#if defined(SPI_HAS_TRANSACTION)
185197
protected:
186198
// Allow sub-class to change

0 commit comments

Comments
 (0)