Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Adafruit_SSD1306.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,3 +1099,28 @@ void Adafruit_SSD1306::dim(boolean dim) {
TRANSACTION_END
}


/**************************************************************************/
/*!
@brief Scroll display up one line, reseting cursor y to print at bottom
*/
/**************************************************************************/
void Adafruit_SSD1306::scrollUp(void) {
/*
* - supporting oled 128x32 pixel display so know width
* -- a row of pixels 128 columns x 8 down is 8 * 16, left to right
*/

// copy 2nd to last line from buffer to top of scroll buffer; (char pixel width with 8 as base size of 1) * (total pixel width / 8 as that is how this display is addressed) * (lines)
int intLineSize = ((textsize * SSD1306_PIXEL_CHUNK) * (WIDTH / SSD1306_PIXEL_CHUNK));
memcpy(buffer, buffer + intLineSize, SSD1306_BUFF_SIZE - intLineSize);

// clear buffer last line; (char pixel width with 8 as base size of 1) * (total pixel width / 8 as that is how this display is addressed) * (font size for height * lines)
int intOffsetLastLine = intLineSize * 3;
memset(buffer + intOffsetLastLine, 0, SSD1306_BUFF_SIZE - intOffsetLastLine);

setCursor(cursor_x, (textsize * SSD1306_PIXEL_CHUNK) * 3);

}


8 changes: 7 additions & 1 deletion Adafruit_SSD1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@
#if defined SSD1306_128_32
#define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_32 defined
#define SSD1306_LCDHEIGHT 32 ///< DEPRECATED: height w/SSD1306_128_32 defined
#define SSD1306_PIXEL_CHUNK 8 ///< for scrollUP(); 8 bit "pages"; see datasheet
#define SSD1306_BUFF_SIZE (128 * ((32 + 7) / 8)) ///< for scrollUP()
#endif
#if defined SSD1306_96_16
#define SSD1306_LCDWIDTH 96 ///< DEPRECATED: width w/SSD1306_96_16 defined
#define SSD1306_LCDHEIGHT 16 ///< DEPRECATED: height w/SSD1306_96_16 defined
#endif

/*!
/*!
@brief Class that stores state and functions for interacting with
SSD1306 OLED displays.
*/
Expand Down Expand Up @@ -149,6 +151,10 @@ class Adafruit_SSD1306 : public Adafruit_GFX {
boolean getPixel(int16_t x, int16_t y);
uint8_t *getBuffer(void);

// adding function to scroll display up a line; for use with println
void scrollUp(void); // scroll display up one line of text


private:
inline void SPIwrite(uint8_t d) __attribute__((always_inline));
void drawFastHLineInternal(int16_t x, int16_t y, int16_t w,
Expand Down