Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adafruit_SSD1306 library add support 64 × 48 pixels OLED Shield #1622

Merged
merged 2 commits into from
Feb 14, 2019
Merged
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
132 changes: 120 additions & 12 deletions Sming/Libraries/.patches/Adafruit_SSD1306.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
diff --git a/Adafruit_SSD1306.cpp b/Adafruit_SSD1306.cpp
index 570a335..40f4784 100644
index 570a335..d2bb269 100644
--- a/Adafruit_SSD1306.cpp
+++ b/Adafruit_SSD1306.cpp
@@ -252,7 +252,7 @@ void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
@@ -38,6 +38,33 @@ All text above, and the splash screen below must be included in any redistributi
// the memory buffer for the LCD

static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {
+
+#if (SSD1306_LCDWIDTH == 64 && SSD1306_LCDHEIGHT == 48)
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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,
+0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFC, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0xFF,
+0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x7E, 0x3F, 0x3F, 0x0F, 0x1F, 0xFF, 0xFF,
+0xFF, 0xFC, 0xF0, 0xE0, 0xF1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0x01, 0x01, 0x01, 0x01,
+0x01, 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, 0x03, 0x03, 0x03, 0x03,
+0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
+0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+#else
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -71,7 +98,7 @@ static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {
0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x03,
0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-#if (SSD1306_LCDHEIGHT == 64)
+#if (SSD1306_LCDWIDTH == 128 && SSD1306_LCDHEIGHT == 64)
0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F,
0x87, 0xC7, 0xF7, 0xFF, 0xFF, 0x1F, 0x1F, 0x3D, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0x7C, 0x7D, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x00, 0x30, 0x30, 0x00, 0x00,
@@ -106,6 +133,7 @@ static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
#endif
#endif
+#endif
};

#define ssd1306_swap(a, b) { int16_t t = a; a = b; b = t; }
@@ -252,7 +280,7 @@ void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
ssd1306_command(0x8F);

Expand All @@ -11,7 +62,23 @@ index 570a335..40f4784 100644
ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
ssd1306_command(0x12);
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
@@ -417,6 +417,28 @@ void Adafruit_SSD1306::dim(boolean dim) {
@@ -270,6 +298,15 @@ void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
else
{ ssd1306_command(0xAF); }

+#elif defined SSD1306_64_48
+ ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
+ ssd1306_command(0x12);
+ ssd1306_command(SSD1306_SETCONTRAST); // 0x81
+ if (vccstate == SSD1306_EXTERNALVCC)
+ { ssd1306_command(0x9F); }
+ else
+ { ssd1306_command(0xCF); }
+
#endif

ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9
@@ -417,21 +454,52 @@ void Adafruit_SSD1306::dim(boolean dim) {
}

void Adafruit_SSD1306::display(void) {
Expand All @@ -38,9 +105,38 @@ index 570a335..40f4784 100644
+ }
+#else
ssd1306_command(SSD1306_COLUMNADDR);
+ #if SSD1306_LCDWIDTH == 64 && SSD1306_LCDHEIGHT == 48
+ ssd1306_command(32);
+ ssd1306_command(32 + SSD1306_LCDWIDTH - 1);
+ #else
ssd1306_command(0); // Column start address (0 = reset)
ssd1306_command(SSD1306_LCDWIDTH-1); // Column end address (127 = reset)
@@ -482,6 +504,7 @@ void Adafruit_SSD1306::display(void) {
+#endif

ssd1306_command(SSD1306_PAGEADDR);
ssd1306_command(0); // Page start address (0 = reset)
- #if SSD1306_LCDHEIGHT == 64
+ ssd1306_command((SSD1306_LCDHEIGHT / 8) - 1); // Page end address
+ /*
+ #if SSD1306_LCDWIDTH == 128 && SSD1306_LCDHEIGHT == 64
ssd1306_command(7); // Page end address
- #endif
- #if SSD1306_LCDHEIGHT == 32
+ #elif SSD1306_LCDWIDTH == 64 && SSD1306_LCDHEIGHT == 48
+ ssd1306_command(5); // Page end address
+ #elif SSD1306_LCDWIDTH == 128 && SSD1306_LCDHEIGHT == 32
ssd1306_command(3); // Page end address
- #endif
- #if SSD1306_LCDHEIGHT == 16
+ #elif SSD1306_LCDWIDTH == 96 && SSD1306_LCDHEIGHT == 16
+
ssd1306_command(1); // Page end address
#endif
+*/

if (sid != -1)
{
@@ -482,6 +550,7 @@ void Adafruit_SSD1306::display(void) {
TWBR = twbrbackup;
#endif
}
Expand All @@ -49,10 +145,10 @@ index 570a335..40f4784 100644

// clear everything
diff --git a/Adafruit_SSD1306.h b/Adafruit_SSD1306.h
index 1162f87..4226f3e 100644
index 1162f87..c3f7050 100644
--- a/Adafruit_SSD1306.h
+++ b/Adafruit_SSD1306.h
@@ -69,20 +69,28 @@ All text above, and the splash screen must be included in any redistribution
@@ -69,20 +69,29 @@ All text above, and the splash screen must be included in any redistribution

SSD1306_96_16

Expand All @@ -61,10 +157,12 @@ index 1162f87..4226f3e 100644
-----------------------------------------------------------------------*/
-// #define SSD1306_128_64
- #define SSD1306_128_32
+// #define SH1106_128_64
+ #define SSD1306_128_64
+// #define SSD1306_128_32
// #define SSD1306_96_16
-// #define SSD1306_96_16
+// #define SH1106_128_64
+ #define SSD1306_128_64
+// #define SSD1306_128_32
+// #define SSD1306_96_16
+// #define SSD1306_64_48
/*=========================================================================*/

+#if defined SSD1306_128_64 && defined SH1106_128_64
Expand All @@ -76,7 +174,7 @@ index 1162f87..4226f3e 100644
#error "Only one SSD1306 display can be specified at once in SSD1306.h"
#endif
-#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16
+#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16 && !defined SH1106_128_64
+#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16 && !defined SSD1306_64_48 && !defined SH1106_128_64
#error "At least one SSD1306 display must be specified in SSD1306.h"
#endif

Expand All @@ -85,7 +183,17 @@ index 1162f87..4226f3e 100644
#define SSD1306_LCDWIDTH 128
#define SSD1306_LCDHEIGHT 64
#endif
@@ -132,6 +140,8 @@ All text above, and the splash screen must be included in any redistribution
@@ -93,6 +102,9 @@ All text above, and the splash screen must be included in any redistribution
#if defined SSD1306_96_16
#define SSD1306_LCDWIDTH 96
#define SSD1306_LCDHEIGHT 16
+#elif defined SSD1306_64_48
+ #define SSD1306_LCDWIDTH 64
+ #define SSD1306_LCDHEIGHT 48
#endif

#define SSD1306_SETCONTRAST 0x81
@@ -132,6 +144,8 @@ All text above, and the splash screen must be included in any redistribution
#define SSD1306_EXTERNALVCC 0x1
#define SSD1306_SWITCHCAPVCC 0x2

Expand Down