add scroll function
Dependents: I2C_SSD1306_nucleo_l432KCc I2C_SSD1306_nucleo_l432KC
Fork of Adafruit_GFX by
Revision 19:e31b31e3128a, committed 2018-09-21
- Comitter:
- bibi94
- Date:
- Fri Sep 21 08:24:03 2018 +0000
- Parent:
- 18:3112550cc6a3
- Commit message:
- add scroll functions
Changed in this revision
diff -r 3112550cc6a3 -r e31b31e3128a Adafruit_GFX_Config.h --- a/Adafruit_GFX_Config.h Tue Jun 23 09:49:01 2015 +0000 +++ b/Adafruit_GFX_Config.h Fri Sep 21 08:24:03 2018 +0000 @@ -2,10 +2,10 @@ #define _ADAFRUIT_GFX_CONFIG_H_ // Uncomment this to turn off the builtin splash -#define NO_SPLASH_ADAFRUIT +//#define NO_SPLASH_ADAFRUIT // Uncomment this to enable all functionality -//#define GFX_WANT_ABSTRACTS +#define GFX_WANT_ABSTRACTS // Uncomment this to enable only runtime font scaling, without all the rest of the Abstracts //#define GFX_SIZEABLE_TEXT
diff -r 3112550cc6a3 -r e31b31e3128a Adafruit_SSD1306.cpp --- a/Adafruit_SSD1306.cpp Tue Jun 23 09:49:01 2015 +0000 +++ b/Adafruit_SSD1306.cpp Fri Sep 21 08:24:03 2018 +0000 @@ -143,7 +143,72 @@ sendDisplayBuffer(); command(SSD1306_DISPLAYON); } +// startscrollright +// Activate a right handed scroll for rows start through stop +// Hint, the display is 16 rows tall. To scroll the whole display, run: +// display.scrollright(0x00, 0x0F) +void Adafruit_SSD1306::startscrollright(uint8_t start, uint8_t stop){ + command(SSD1306_RIGHT_HORIZONTAL_SCROLL); + command(0X00); + command(start); + command(0X00); + command(stop); + command(0X00); + command(0XFF); + command(SSD1306_ACTIVATE_SCROLL); +} +// startscrollleft +// Activate a right handed scroll for rows start through stop +// Hint, the display is 16 rows tall. To scroll the whole display, run: +// display.scrollright(0x00, 0x0F) +void Adafruit_SSD1306::startscrollleft(uint8_t start, uint8_t stop){ + command(SSD1306_LEFT_HORIZONTAL_SCROLL); + command(0X00); + command(start); + command(0X00); + command(stop); + command(0X00); + command(0XFF); + command(SSD1306_ACTIVATE_SCROLL); +} + +// startscrolldiagright +// Activate a diagonal scroll for rows start through stop +// Hint, the display is 16 rows tall. To scroll the whole display, run: +// display.scrollright(0x00, 0x0F) +void Adafruit_SSD1306::startscrolldiagright(uint8_t start, uint8_t stop){ + command(SSD1306_SET_VERTICAL_SCROLL_AREA); + command(0X00); + command(SSD1306_LCDHEIGHT); + command(SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL); + command(0X00); + command(start); + command(0X00); + command(stop); + command(0X01); + command(SSD1306_ACTIVATE_SCROLL); +} + +// startscrolldiagleft +// Activate a diagonal scroll for rows start through stop +// Hint, the display is 16 rows tall. To scroll the whole display, run: +// display.scrollright(0x00, 0x0F) +void Adafruit_SSD1306::startscrolldiagleft(uint8_t start, uint8_t stop){ + command(SSD1306_SET_VERTICAL_SCROLL_AREA); + command(0X00); + command(SSD1306_LCDHEIGHT); + command(SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL); + command(0X00); + command(start); + command(0X00); + command(stop); + command(0X01); + command(SSD1306_ACTIVATE_SCROLL); +} +void Adafruit_SSD1306::stopscroll(void){ + command(SSD1306_DEACTIVATE_SCROLL); +} // Clear the display buffer. Requires a display() call at some point afterwards void Adafruit_SSD1306::clearDisplay(void) {
diff -r 3112550cc6a3 -r e31b31e3128a Adafruit_SSD1306.h --- a/Adafruit_SSD1306.h Tue Jun 23 09:49:01 2015 +0000 +++ b/Adafruit_SSD1306.h Fri Sep 21 08:24:03 2018 +0000 @@ -38,9 +38,50 @@ DigitalOut2& operator= (DigitalOut2& rhs) { write(rhs.read()); return *this; }; operator int() { return read(); }; }; - +#define SSD1306_LCDWIDTH 128 +#define SSD1306_LCDHEIGHT 64 #define SSD1306_EXTERNALVCC 0x1 #define SSD1306_SWITCHCAPVCC 0x2 +#define SSD1306_ACTIVATE_SCROLL 0x2F +#define SSD1306_DEACTIVATE_SCROLL 0x2E +#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 +#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 +#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 +#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 +#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A +#define SSD1306_SETCONTRAST 0x81 +#define SSD1306_DISPLAYALLON_RESUME 0xA4 +#define SSD1306_DISPLAYALLON 0xA5 +#define SSD1306_NORMALDISPLAY 0xA6 +#define SSD1306_INVERTDISPLAY 0xA7 +#define SSD1306_DISPLAYOFF 0xAE +#define SSD1306_DISPLAYON 0xAF + +#define SSD1306_SETDISPLAYOFFSET 0xD3 +#define SSD1306_SETCOMPINS 0xDA + +#define SSD1306_SETVCOMDETECT 0xDB + +#define SSD1306_SETDISPLAYCLOCKDIV 0xD5 +#define SSD1306_SETPRECHARGE 0xD9 + +#define SSD1306_SETMULTIPLEX 0xA8 + +#define SSD1306_SETLOWCOLUMN 0x00 +#define SSD1306_SETHIGHCOLUMN 0x10 + +#define SSD1306_SETSTARTLINE 0x40 + +#define SSD1306_MEMORYMODE 0x20 +#define SSD1306_COLUMNADDR 0x21 +#define SSD1306_PAGEADDR 0x22 + +#define SSD1306_COMSCANINC 0xC0 +#define SSD1306_COMSCANDEC 0xC8 + +#define SSD1306_SEGREMAP 0xA0 + +#define SSD1306_CHARGEPUMP 0x8D /** The pure base class for the SSD1306 display driver. * @@ -63,6 +104,7 @@ virtual void command(uint8_t c) = 0; virtual void data(uint8_t c) = 0; virtual void drawPixel(int16_t x, int16_t y, uint16_t color); + //virtual void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); /// Clear the display buffer void clearDisplay(void); @@ -70,6 +112,12 @@ /// Cause the display to be updated with the buffer content. void display(); + /// Scroll + virtual void startscrollright(uint8_t start, uint8_t stop); + virtual void startscrollleft(uint8_t start, uint8_t stop); + virtual void startscrolldiagright(uint8_t start, uint8_t stop); + virtual void startscrolldiagleft(uint8_t start, uint8_t stop); + void stopscroll(void); /// Fill the buffer with the AdaFruit splash screen. virtual void splash(); @@ -158,7 +206,7 @@ class Adafruit_SSD1306_I2c : public Adafruit_SSD1306 { public: - #define SSD_I2C_ADDRESS 0x78 + #define SSD_I2C_ADDRESS 0x78//0x78 /** Create a SSD1306 I2C transport display driver instance with the specified RST pin name, the I2C address, as well as the display dimensions * * Required parameters