Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 18:6fc8104e8548, committed 2020-07-17
- Comitter:
- evgeniik
- Date:
- Fri Jul 17 09:26:07 2020 +0000
- Parent:
- 17:2fe73307cb3c
- Commit message:
- not changed
Changed in this revision
--- a/Adafruit_GFX.h Thu Mar 12 15:37:16 2020 +0000 +++ b/Adafruit_GFX.h Fri Jul 17 09:26:07 2020 +0000 @@ -46,7 +46,7 @@ * hardware based on application control. * */ -class Adafruit_GFX : public Stream +class Adafruit_GFX { public: Adafruit_GFX(int16_t w, int16_t h) @@ -93,36 +93,36 @@ /** Draw a circle * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h */ - void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); - void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); + virtual void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); + virtual void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); /** Draw and fill a circle * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h */ - void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); - void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); + virtual void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); + virtual void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); /** Draw a triangle * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h */ - void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); + virtual void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); /** Draw and fill a triangle * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h */ - void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); + virtual void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); /** Draw a rounded rectangle * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h */ - void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); + virtual void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); /** Draw and fill a rounded rectangle * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h */ - void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); + virtual void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); /** Draw a bitmap * @note GFX_WANT_ABSTRACTS must be defined in Adafruit_GFX_config.h */ - void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); + virtual void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); #endif #if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
--- a/Adafruit_GFX_Config.h Thu Mar 12 15:37:16 2020 +0000 +++ b/Adafruit_GFX_Config.h Fri Jul 17 09:26:07 2020 +0000 @@ -5,7 +5,7 @@ //#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
--- a/Adafruit_SSD1306.cpp Thu Mar 12 15:37:16 2020 +0000 +++ b/Adafruit_SSD1306.cpp Fri Jul 17 09:26:07 2020 +0000 @@ -50,15 +50,12 @@ //////追加 void Adafruit_SSD1306::begin(uint8_t vccstate) { - rst = 1; // VDD (3.3V) goes high at start, lets just chill for a ms wait_ms(1); // bring reset low - rst = 0; // wait 10ms wait_ms(10); // bring out of reset - rst = 1; // turn on VCC (9V?) command(SSD1306_DISPLAYOFF); @@ -156,6 +153,7 @@ void Adafruit_SSD1306::clearDisplay(void) { std::fill(buffer.begin(),buffer.end(),0); + display(); } void Adafruit_SSD1306::splash(void) @@ -231,8 +229,161 @@ std::copy( &adaFruitLogo[0] - , &adaFruitLogo[0] + (_rawHeight == 32 ? sizeof(adaFruitLogo)/2 : sizeof(adaFruitLogo)) + , &adaFruitLogo[0] + (_rawHeight == 34 ? sizeof(adaFruitLogo)/2 : sizeof(adaFruitLogo)) , buffer.begin() ); + display(); #endif } + +void Adafruit_SSD1306::E4_logo(void) +{ + // 'E4-side-round', 128x64px + uint8_t E4logo[64 * 128 / 8] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x40, 0x40, 0x60, 0x60, 0xe0, 0x60, 0x20, 0x60, 0xe0, + 0xe0, 0xe0, 0x20, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0xe0, 0x38, 0x0c, 0x06, 0x03, 0x00, 0x80, 0x80, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0xe0, 0x30, 0x10, 0x11, 0x12, 0x34, 0xd8, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x70, 0x1e, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x07, 0x1c, 0x10, 0x30, 0x30, 0x1c, 0x07, 0x00, 0x00, 0x01, 0x02, 0x04, 0x18, 0x20, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3e, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x8c, 0x7c, 0x1f, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x70, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x1c, 0x38, 0x78, 0xf0, 0xc0, 0x00, 0x00, + 0x00, 0x01, 0x02, 0x0c, 0x10, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xbc, 0x7c, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1f, 0x30, 0xe0, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0xe0, 0xff, 0x1f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0c, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x78, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x80, 0x80, 0xc0, 0x40, 0x40, 0x61, 0x21, 0xa1, 0xa1, 0x91, 0x91, 0xf0, 0xb8, 0x88, 0x08, + 0x08, 0x08, 0x38, 0xb0, 0xa0, 0xc0, 0xc0, 0x60, 0x3c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0e, 0x1f, 0x3f, 0x7f, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xf8, 0xee, 0xc3, 0x67, + 0x75, 0x0d, 0x0d, 0x04, 0x04, 0x06, 0x02, 0x03, 0x01, 0x01, 0x00, 0x01, 0x01, 0x03, 0x07, 0x07, + 0x07, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + std::copy( + &E4logo[0] + , &E4logo[0] + (_rawHeight == 34 ? sizeof(E4logo)/2 : sizeof(E4logo)) + , buffer.begin() + ); +} + +void Adafruit_SSD1306::AI_logo(void) +{ + // 'E4-side-round', 128x64px + uint8_t AIlogo[64 * 128 / 8] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x70, 0xc0, 0x90, 0x30, 0x50, 0xb0, 0x20, 0x60, 0x40, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x40, + 0x40, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x60, 0x30, 0xb8, 0xdc, 0x4e, 0x67, + 0x37, 0x92, 0xec, 0x31, 0x1f, 0x00, 0x00, 0x80, 0x80, 0x40, 0x60, 0x20, 0x30, 0x10, 0x98, 0x88, + 0xc8, 0x4c, 0x24, 0x24, 0x36, 0x12, 0xf2, 0x02, 0x82, 0xe2, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x06, 0x1c, 0x19, 0x33, 0xe6, 0xc8, 0x10, 0x30, 0xe1, 0x01, 0x03, 0x06, + 0x04, 0x0c, 0x09, 0x19, 0x33, 0x26, 0x6c, 0xd8, 0x91, 0x20, 0x6c, 0xf3, 0xc1, 0x80, 0x1c, 0x26, + 0x31, 0x30, 0x18, 0x84, 0x66, 0x23, 0x31, 0x18, 0x08, 0x0c, 0x86, 0x82, 0x82, 0xc1, 0x41, 0x60, + 0x30, 0x10, 0x98, 0xcc, 0x66, 0x13, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x06, 0x0c, 0x08, + 0x08, 0x08, 0x18, 0x18, 0x10, 0x10, 0x10, 0x10, 0x01, 0xf1, 0x1f, 0xc6, 0xa0, 0x1b, 0xb6, 0xe4, + 0x0c, 0xc8, 0x1c, 0xe5, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x05, 0x04, 0x04, 0x04, 0x06, 0x02, + 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x04, 0x0a, 0x09, 0x09, 0x09, + 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x78, 0x0c, 0x3c, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfc, 0x0c, 0x3c, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x38, 0x0c, 0xfc, 0x00, 0x00, 0x00, + 0x00, 0xfc, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0xfc, 0x04, 0x04, 0x04, 0x04, + 0x8c, 0xf8, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0x18, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x00, + 0x00, 0x00, 0x00, 0xfc, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0xfc, 0x1c, 0x38, + 0xe0, 0x80, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0x18, 0x0c, 0x04, 0x04, 0x04, + 0x04, 0x08, 0x00, 0x00, 0x00, 0xfc, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x70, 0x1e, 0x0f, 0x08, 0x08, 0x08, 0x09, 0x0f, 0x7c, 0x60, 0x00, 0x00, + 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, + 0x7f, 0x00, 0x00, 0x01, 0x0f, 0x3c, 0x70, 0x3c, 0x07, 0x01, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0x41, 0x41, 0x41, 0x41, 0x41, 0x40, 0x00, 0x00, 0x00, 0x7f, 0x01, 0x01, 0x01, 0x03, + 0x0e, 0x78, 0x60, 0x00, 0x00, 0x07, 0x1f, 0x30, 0x20, 0x40, 0x41, 0x41, 0x41, 0x41, 0x3f, 0x00, + 0x00, 0x00, 0x00, 0x7f, 0x41, 0x41, 0x41, 0x41, 0x41, 0x40, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, + 0x00, 0x03, 0x0f, 0x3c, 0x70, 0x7f, 0x00, 0x00, 0x00, 0x07, 0x1f, 0x30, 0x60, 0x40, 0x40, 0x40, + 0x40, 0x20, 0x00, 0x00, 0x00, 0x7f, 0x41, 0x41, 0x41, 0x41, 0x41, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + std::copy( + &AIlogo[0] + , &AIlogo[0] + (_rawHeight == 34 ? sizeof(AIlogo)/2 : sizeof(AIlogo)) + , buffer.begin() + ); +}
--- a/Adafruit_SSD1306.h Thu Mar 12 15:37:16 2020 +0000 +++ b/Adafruit_SSD1306.h Fri Jul 17 09:26:07 2020 +0000 @@ -29,16 +29,6 @@ #include <vector> #include <algorithm> -// A DigitalOut sub-class that provides a constructed default state -class DigitalOut2 : public DigitalOut -{ -public: - DigitalOut2(PinName pin, bool active = false) : DigitalOut(pin) { write(active); }; - DigitalOut2& operator= (int value) { write(value); return *this; }; - DigitalOut2& operator= (DigitalOut2& rhs) { write(rhs.read()); return *this; }; - operator int() { return read(); }; -}; - #define SSD1306_EXTERNALVCC 0x1 #define SSD1306_SWITCHCAPVCC 0x2 @@ -50,136 +40,21 @@ class Adafruit_SSD1306 : public Adafruit_GFX { public: - Adafruit_SSD1306(PinName RST, uint8_t rawHeight = 32, uint8_t rawWidth = 128) + #define SSD_I2C_ADDRESS 0x78 + Adafruit_SSD1306(I2C &i2c, uint8_t i2cAddress = SSD_I2C_ADDRESS, uint8_t rawHeight = 64, uint8_t rawWidth = 128) : Adafruit_GFX(rawWidth,rawHeight) - , rst(RST,false) + , mi2c(i2c) + , mi2cAddress(i2cAddress) { buffer.resize(rawHeight * rawWidth / 8); + begin(); + //splash(); + //display(); }; void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC); // These must be implemented in the derived transport driver - 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); - - /// Clear the display buffer - void clearDisplay(void); - virtual void invertDisplay(bool i); - - /// Cause the display to be updated with the buffer content. - void display(); - /// Fill the buffer with the AdaFruit splash screen. - virtual void splash(); - -protected: - virtual void sendDisplayBuffer() = 0; - DigitalOut2 rst; - - // the memory buffer for the LCD - std::vector<uint8_t> buffer; -}; - - -/** This is the SPI SSD1306 display driver transport class - * - */ -class Adafruit_SSD1306_Spi : public Adafruit_SSD1306 -{ -public: - /** Create a SSD1306 SPI transport display driver instance with the specified DC, RST, and CS pins, as well as the display dimentions - * - * Required parameters - * @param spi - a reference to an initialized SPI object - * @param DC (Data/Command) pin name - * @param RST (Reset) pin name - * @param CS (Chip Select) pin name - * - * Optional parameters - * @param rawHeight - the vertical number of pixels for the display, defaults to 32 - * @param rawWidth - the horizonal number of pixels for the display, defaults to 128 - */ - Adafruit_SSD1306_Spi(SPI &spi, PinName DC, PinName RST, PinName CS, uint8_t rawHieght = 32, uint8_t rawWidth = 128) - : Adafruit_SSD1306(RST, rawHieght, rawWidth) - , cs(CS,true) - , dc(DC,false) - , mspi(spi) - { - begin(); - splash(); - display(); - }; - - virtual void command(uint8_t c) - { - cs = 1; - dc = 0; - cs = 0; - mspi.write(c); - cs = 1; - }; - - virtual void data(uint8_t c) - { - cs = 1; - dc = 1; - cs = 0; - mspi.write(c); - cs = 1; - }; - -protected: - virtual void sendDisplayBuffer() - { - cs = 1; - dc = 1; - cs = 0; - - for(uint16_t i=0, q=buffer.size(); i<q; i++) - mspi.write(buffer[i]); - - if(height() == 32) - { - for(uint16_t i=0, q=buffer.size(); i<q; i++) - mspi.write(0); - } - - cs = 1; - }; - - DigitalOut2 cs, dc; - SPI &mspi; -}; - -/** This is the I2C SSD1306 display driver transport class - * - */ -class Adafruit_SSD1306_I2c : public Adafruit_SSD1306 -{ -public: - #define SSD_I2C_ADDRESS 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 - * @param i2c - A reference to an initialized I2C object - * @param RST - The Reset pin name - * - * Optional parameters - * @param i2cAddress - The i2c address of the display - * @param rawHeight - The vertical number of pixels for the display, defaults to 32 - * @param rawWidth - The horizonal number of pixels for the display, defaults to 128 - */ - Adafruit_SSD1306_I2c(I2C &i2c, PinName RST, uint8_t i2cAddress = SSD_I2C_ADDRESS, uint8_t rawHeight = 32, uint8_t rawWidth = 128) - : Adafruit_SSD1306(RST, rawHeight, rawWidth) - , mi2c(i2c) - , mi2cAddress(i2cAddress) - { - begin(); - splash(); - display(); - }; - virtual void command(uint8_t c) { char buff[2]; @@ -195,8 +70,21 @@ buff[1] = c; mi2c.write(mi2cAddress, buff, sizeof(buff)); }; + virtual void drawPixel(int16_t x, int16_t y, uint16_t color); + /// Clear the display buffer + void clearDisplay(void); + virtual void invertDisplay(bool i); + + /// Cause the display to be updated with the buffer content. + void display(); + /// Fill the buffer with the AdaFruit splash screen. + virtual void splash(); + virtual void E4_logo(); + virtual void AI_logo(); + protected: + std::vector<uint8_t> buffer; virtual void sendDisplayBuffer() { char buff[17]; @@ -212,9 +100,12 @@ mi2c.write(mi2cAddress, buff, sizeof(buff)); } }; - + I2C &mi2c; uint8_t mi2cAddress; + + // the memory buffer for the LCD + //std::vector<uint8_t> buffer; }; #endif \ No newline at end of file