From 190651ebc55b5b544dbb988d6d42967f05e5324a Mon Sep 17 00:00:00 2001 From: psionprime Date: Sat, 12 Jan 2019 17:37:00 -0500 Subject: [PATCH 1/3] - initial fork and push -- add function scrollUp() for use in Adafruit_GFX write() for println() - only supporting standard font for ssd1306 OLED 128x32 --- Adafruit_SSD1306.cpp | 25 +++++++++++++++++++++++++ Adafruit_SSD1306.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/Adafruit_SSD1306.cpp b/Adafruit_SSD1306.cpp index 46218d7d..3136098b 100644 --- a/Adafruit_SSD1306.cpp +++ b/Adafruit_SSD1306.cpp @@ -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); + +} + + diff --git a/Adafruit_SSD1306.h b/Adafruit_SSD1306.h index 2933cb0b..dd4c8785 100644 --- a/Adafruit_SSD1306.h +++ b/Adafruit_SSD1306.h @@ -102,6 +102,8 @@ #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() + #define SSD1306_BUFF_SIZE (SSD1306_LCDWIDTH * ((SSD1306_LCDHEIGHT + 7) / 8)) // for scrollUP() #endif #if defined SSD1306_96_16 #define SSD1306_LCDWIDTH 96 ///< DEPRECATED: width w/SSD1306_96_16 defined @@ -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, From b964f2eec31bf007cebaee9d921448a5deed7910 Mon Sep 17 00:00:00 2001 From: psionprime Date: Mon, 21 Jan 2019 07:52:35 -0500 Subject: [PATCH 2/3] - modified comments due to build fail "not documented" - SSD1306_BUFF_SIZE definition set to use number instead of depricated #defines --- Adafruit_SSD1306.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Adafruit_SSD1306.h b/Adafruit_SSD1306.h index dd4c8785..c403648b 100644 --- a/Adafruit_SSD1306.h +++ b/Adafruit_SSD1306.h @@ -102,15 +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() - #define SSD1306_BUFF_SIZE (SSD1306_LCDWIDTH * ((SSD1306_LCDHEIGHT + 7) / 8)) // for scrollUP() + #define SSD1306_PIXEL_CHUNK 8 ///< for scrollUP() + #define SSD1306_BUFF_SIZE (128 * ((32 + 7) / SSD1306_PIXEL_CHUNK)) ///< 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. */ From e1120f2a2e1cdf01f3a40868f606137d0334a056 Mon Sep 17 00:00:00 2001 From: psionprime Date: Mon, 21 Jan 2019 08:06:27 -0500 Subject: [PATCH 3/3] - build failing due to documentaion issues -- macro inside macro is out of scope for doxygen --- Adafruit_SSD1306.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adafruit_SSD1306.h b/Adafruit_SSD1306.h index c403648b..18b0a853 100644 --- a/Adafruit_SSD1306.h +++ b/Adafruit_SSD1306.h @@ -102,8 +102,8 @@ #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() - #define SSD1306_BUFF_SIZE (128 * ((32 + 7) / SSD1306_PIXEL_CHUNK)) ///< for scrollUP() + #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