Skip to content

Commit 7886a63

Browse files
helmut64marcelstoer
authored andcommitted
Added an GEOMETRY_RAWMODE for other low level displays like the flip dots.
Added setGeometry high/width optional parameters to allow custom bitmaps.
1 parent 7f68ee5 commit 7886a63

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/OLEDDisplay.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ OLEDDisplay::OLEDDisplay() {
4242

4343
displayWidth = 128;
4444
displayHeight = 64;
45-
displayBufferSize = 1024;
45+
displayBufferSize = displayWidth * displayHeight / 8;
4646
color = WHITE;
4747
geometry = GEOMETRY_128_64;
4848
textAlignment = TEXT_ALIGN_LEFT;
@@ -800,19 +800,28 @@ int OLEDDisplay::_putc(int c) {
800800
#endif
801801

802802
// Private functions
803-
void OLEDDisplay::setGeometry(OLEDDISPLAY_GEOMETRY g) {
803+
void OLEDDisplay::setGeometry(OLEDDISPLAY_GEOMETRY g, uint16_t width, uint16_t height) {
804804
this->geometry = g;
805-
if (g == GEOMETRY_128_64) {
806-
this->displayWidth = 128;
807-
this->displayHeight = 64;
808-
} else if (g == GEOMETRY_128_32) {
809-
this->displayWidth = 128;
810-
this->displayHeight = 32;
811-
}
812-
this->displayBufferSize = displayWidth*displayHeight/8;
805+
switch (g) {
806+
case GEOMETRY_128_64:
807+
this->displayWidth = 128;
808+
this->displayHeight = 64;
809+
break;
810+
case GEOMETRY_128_32:
811+
this->displayWidth = 128;
812+
this->displayHeight = 32;
813+
break;
814+
case GEOMETRY_RAWMODE:
815+
this->displayWidth = width > 0 ? width : 128;
816+
this->displayHeight = height > 0 ? height : 64;
817+
break;
818+
}
819+
this->displayBufferSize = displayWidth * displayHeight /8;
813820
}
814821

815822
void OLEDDisplay::sendInitCommands(void) {
823+
if (geometry == GEOMETRY_RAWMODE)
824+
return;
816825
sendCommand(DISPLAYOFF);
817826
sendCommand(SETDISPLAYCLOCKDIV);
818827
sendCommand(0xF0); // Increase speed of the display max ~96Hz

src/OLEDDisplay.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ enum OLEDDISPLAY_TEXT_ALIGNMENT {
137137

138138
enum OLEDDISPLAY_GEOMETRY {
139139
GEOMETRY_128_64 = 0,
140-
GEOMETRY_128_32 = 1
140+
GEOMETRY_128_32,
141+
GEOMETRY_RAWMODE,
141142
};
142143

143144
typedef char (*FontTableLookupFunction)(const char ch);
@@ -321,7 +322,7 @@ class OLEDDisplay : public Stream {
321322
uint16_t displayBufferSize;
322323

323324
// Set the correct height, width and buffer for the geometry
324-
void setGeometry(OLEDDISPLAY_GEOMETRY g);
325+
void setGeometry(OLEDDISPLAY_GEOMETRY g, uint16_t width = 0, uint16_t height = 0);
325326

326327
OLEDDISPLAY_TEXT_ALIGNMENT textAlignment;
327328
OLEDDISPLAY_COLOR color;

0 commit comments

Comments
 (0)