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

Updated support for 64x48 displays #188

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

dok-net
Copy link

@dok-net dok-net commented Oct 7, 2020

Merges the support originally added in https://github.com/mcauser/Adafruit_SSD1306.git with the head of adafruit/Adafruit_SSD1306.
The splash screen was adopted to mirror that of the other resolution displays.
Relevant displays are for instance those for the Wemos/LOLIN D1 OLED shield.

@Misiu @ladyada @tablatronix @mcauser @MstrVLT This is the same as #136, that has received your attention before.

@tokra
Copy link

tokra commented Dec 15, 2020

@dok-net I tried your code with my wemos d1 mini + 64x48 oled, and its not working properly:
image

@dok-net
Copy link
Author

dok-net commented Dec 15, 2020

@tokra I can confirm your findings for now. Will have to investigate which the fault occured, I'd like to believe it's some change in adafruit:master :-)

@dok-net dok-net force-pushed the esp8266-64x48 branch 2 times, most recently from 59f6a9a to a2c00a3 Compare December 17, 2020 00:10
Copy link
Contributor

@BillyDonahue BillyDonahue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just found some super old pending comments on this PR. Sending them now.
I hope they're still relevant and helpful.

@@ -146,11 +153,11 @@ class Adafruit_SSD1306 : public Adafruit_GFX {
bool reset = true, bool periphBegin = true);
void display(void);
void clearDisplay(void);
void invertDisplay(bool i);
virtual void invertDisplay(bool i) override;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line didn't need to change in order to support 64x48 displays.

Should just be virtual or override, but both is redundant.
Override means this library now depends on C++11, which I don't think it did before.
Maybe just virtual, or nothing at all, would be safer.

#define splash3_width 64
#define splash3_height 48

const uint8_t PROGMEM splash3_data[] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a few problems with this. ALL the splash data gets linked into ALL the SSD1306 driver object files, so this image is a significant cost even for devices that won't use it. It's already a little bit of a problem to have 2 splashes in the executable, but a third splash makes the problem worse.

The other splashes are generated by a Makefile from a source PNG file. See the scripts/ directory. That directory must to be able to rebuild splash3 the same way it rebuilds splash1 and splash2. Just having an array doesn't allow maintenance of the data inside the array to update the logo or whatever. The next time we run the Makefile splash3 will be lost.

It's hard to tell, but the other bitmaps are meant to be visually presented.
That's why they're using binary literals instead of hex.

It was clear before clang-format munged all the line breaks. The pending PR #177 restores them and make the bitmap arrays clang-format proof. I hope we get them back. The arrays were pretty.

Anyway, when splash3 is generated by the make_splash.py script, all of that stuff will be done automatically.

But it's also graphically a little messed up. Neither of the other splashes try to get this narrow.
Dumping this to ascii @ signs yields this image:

[                                                                ]
[                                                                ]
[                                                                ]
[                                                                ]
[                                                                ]
[                                  @@                            ]
[                                 @@@                            ]
[                                @@@@                            ]
[                                @@@@@                           ]
[                               @@@@@@                           ]
[                       @@@@@   @@@@@@                           ]
[                       @@@@@@@@@@@@@@                           ]
[                        @@@@@@@@@ @@ @@@                        ]
[                         @@@@@@@@ @@@@@@@@@@                    ]
[                         @@@@   @ @@@@@@@@@@@                   ]
[                          @@@@@ @@    @@@@@                     ]
[                             @@@@@@@@@@@@@                      ]
[                            @@@    @@@@@                        ]
[                           @@@  @@ @@@                          ]
[                          @@@@@@@@ @@@                          ]
[                          @@@@@@ @@@@@@                         ]
[                          @@@@@@ @@@@@@                         ]
[                         @@@@@@  @@@@@@                         ]
[                         @@@      @@@@@                         ]
[                                    @@@                         ]
[                                     @@                         ]
[                   @@          @@               @               ]
[                   @@         @@@               @               ]
[                   @@         @@                  @@            ]
[        @@@@@  @@@@@@  @@@@@  @@@ @@ @@ @@   @  @ @@@@          ]
[       @@  @@  @@ @@@  @   @@ @@  @@@@@ @@   @  @ @@            ]
[            @ @@   @@      @@ @@  @@    @@   @  @ @@            ]
[       @@@@@@ @@   @@  @@@@@@ @@  @@    @@   @  @ @@            ]
[       @@   @ @@   @@ @@   @@ @@  @@    @@   @  @ @@            ]
[       @@   @ @@   @@ @@   @@ @@  @@    @@   @  @ @@            ]
[       @@@@@@  @@@@@@ @@@@@@@ @@  @@    @@@@ @  @ @@@@          ]
[                                                                ]
[                                                                ]
[       @@@@@@@@@@@@@@@@@@@@@@@@  @@  @@@ @ @@  @@@ @@@          ]
[       @@@@@@@@@@@@@@@@@@@@@@@@  @@  @@@ @ @@  @@@ @@@          ]
[                                                                ]
[                                                                ]
[                                                                ]
[                                                                ]
[                                                                ]
[                                                                ]

The 'u' in Adafruit is broken off, and the a's don't match. The word "INDUSTRIES" is just a few meaningless vertical gaps. I wonder if such a small display should just not bother, or maybe a simpler logo would be more appropriate. Kind of up to Adafruit's branding I guess :).

But the image is centered by blank margins that should be removed in the interest of saving AVR PROGMEM space. Trust the driver to center the bitmap instead of filling to the edge with zeros.

Would be good to check this in as a PNG like the others for direct review.

I believe the image here is from an attachment to #136 from @mcauser.

https://user-images.githubusercontent.com/1038959/57634498-c46f4600-75e8-11e9-8752-ac339805a7a0.png The better way to go would be to trim it down and check it into the scripts/ dir.

void drawPixel(int16_t x, int16_t y, uint16_t color);
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) override;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unrelated to 64x48 display support (see above), and could be controversial.

@@ -24,10 +24,11 @@
#ifndef _Adafruit_SSD1306_H_
#define _Adafruit_SSD1306_H_

// ONE of the following three lines must be #defined:
// ONE of the following four lines must be #defined:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just remove the number from the sentence so we don't have to return to it?

0, // Page start address
0xFF, // Page end (not really, but works here)
SSD1306_COLUMNADDR, 0}; // Column start address
SSD1306_PAGEADDR,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indent. This matters because it's causing a bigger diff in this case.

case SSD1306_INVERSE:
buffer[x + (y / 8) * WIDTH] ^= (1 << (y & 7));
break;
case SSD1306_WHITE:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indent and inconsistent spaces are causing more diff drama here than necessary.

@@ -706,7 +717,9 @@ void Adafruit_SSD1306::drawFastHLineInternal(int16_t x, int16_t y, int16_t w,
w = (WIDTH - x);
}
if (w > 0) { // Proceed only if width is positive
uint8_t *pBuf = &buffer[(y / 8) * WIDTH + x], mask = 1 << (y & 7);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only s/WIDTH/SSD1306_SEGMENTS/ needed to change on this line.

@@ -792,7 +805,8 @@ void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y,
// this display doesn't need ints for coordinates,
// use local byte registers for faster juggling
uint8_t y = __y, h = __h;
uint8_t *pBuf = &buffer[(y / 8) * WIDTH + x];
if ((WIDTH == 64) && (HEIGHT == 48)) x += 32;
uint8_t *pBuf = &buffer[x + (y / 8) * SSD1306_SEGMENTS];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only s/WIDTH/SSD1306_SEGMENTS/ needed to change on this line.

@tokra
Copy link

tokra commented Dec 17, 2020

@dok-net
i downloaded your latest branch changes and i got this:

/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp: In member function 'bool Adafruit_SSD1306::begin(uint8_t, uint8_t, bool, bool)':
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:544:46: error: expected '}' before ')' token
                                           0x0);                     // no offset
                                              ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:544:46: error: expected ',' or ';' before ')' token
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:553:38: error: expected ')' before '}' token
   ssd1306_command1(SSD1306_CHARGEPUMP}; // 0x8D
                                      ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:553:38: error: expected ';' before '}' token
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp: At global scope:
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:555:19: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_command1((vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0x14);
                   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:561:22: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_commandList(init3, sizeof(init3));
                      ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:564:3: error: 'contrast' does not name a type
   contrast = 0x8F;
   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:566:3: error: expected unqualified-id before 'if'
   if ((WIDTH == 128) && (HEIGHT == 32)) {
   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:569:5: error: expected unqualified-id before 'else'
   } else if ((WIDTH == 128) && (HEIGHT == 64)) {
     ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:572:5: error: expected unqualified-id before 'else'
   } else if ((WIDTH == 96) && (HEIGHT == 16)) {
     ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:575:5: error: expected unqualified-id before 'else'
   } else if ((WIDTH == 64) && ((HEIGHT == 48) || (HEIGHT == 32))) {
     ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:578:5: error: expected unqualified-id before 'else'
   } else {
     ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:582:19: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_command1(SSD1306_SETCOMPINS);
                   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:583:19: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_command1(comPins);
                   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:584:19: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_command1(SSD1306_SETCONTRAST);
                   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:585:19: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_command1(contrast);
                   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:587:19: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_command1(SSD1306_SETPRECHARGE); // 0xd9
                   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:588:19: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_command1((vccstate == SSD1306_EXTERNALVCC) ? 0x22 : 0xF1);
                   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:596:22: error: expected constructor, destructor, or type conversion before '(' token
   ssd1306_commandList(init5, sizeof(init5));
                      ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:127:3: error: expected unqualified-id before 'if'
   if (wire) {                                                                  \
   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:598:3: note: in expansion of macro 'TRANSACTION_END'
   TRANSACTION_END
   ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:129:5: error: expected unqualified-id before 'else'
   } else {                                                                     \
     ^
/Users/tokra/Documents/Arduino/libraries/Adafruit_SSD1306-esp8266-64x48/Adafruit_SSD1306.cpp:598:3: note: in expansion of macro 'TRANSACTION_END'
   TRANSACTION_END
   ^
exit status 1
Error compiling for board LOLIN(WEMOS) D1 R2 & mini.

@tokra
Copy link

tokra commented Dec 17, 2020

@dok-net Tested, works great ! 🥳

mcauser and others added 8 commits April 11, 2021 19:32
I2C connections for ESP8266:
SCL = GPIO5
SDA = GPIO4
RST = GPIO0
…an 128 segments wide.

Bug was visible when scrolling.
TDB: allow drawing outside visible area to exploit full 128 horizontal resolution in hardware scrolling.
…plash3.png and updating Makefile. Not regenerating splash.h yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants