-
Notifications
You must be signed in to change notification settings - Fork 987
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
base: master
Are you sure you want to change the base?
Conversation
@dok-net I tried your code with my wemos d1 mini + 64x48 oled, and its not working properly: |
@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 :-) |
59f6a9a
to
a2c00a3
Compare
There was a problem hiding this 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.
Adafruit_SSD1306.h
Outdated
@@ -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; |
There was a problem hiding this comment.
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[] = { |
There was a problem hiding this comment.
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.
Adafruit_SSD1306.h
Outdated
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; |
There was a problem hiding this comment.
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.
Adafruit_SSD1306.h
Outdated
@@ -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: |
There was a problem hiding this comment.
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?
Adafruit_SSD1306.cpp
Outdated
0, // Page start address | ||
0xFF, // Page end (not really, but works here) | ||
SSD1306_COLUMNADDR, 0}; // Column start address | ||
SSD1306_PAGEADDR, |
There was a problem hiding this comment.
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.
Adafruit_SSD1306.cpp
Outdated
case SSD1306_INVERSE: | ||
buffer[x + (y / 8) * WIDTH] ^= (1 << (y & 7)); | ||
break; | ||
case SSD1306_WHITE: |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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.
@dok-net
|
dcc1157
to
ad90ea1
Compare
@dok-net Tested, works great ! 🥳 |
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.
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.