Skip to content

Commit 14f76ab

Browse files
updated OLED library
1 parent 9128938 commit 14f76ab

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/oled/OLEDDisplay.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bool OLEDDisplay::init() {
9090
memset(buffer_back, 1, displayBufferSize);
9191
#endif
9292
display();
93-
93+
screenRotate(ANGLE_0_DEGREE);
9494
return true;
9595
}
9696

@@ -981,15 +981,15 @@ void OLEDDisplay::sendInitCommands(void) {
981981
sendCommand(COMSCANDEC);
982982
sendCommand(SETCOMPINS);
983983

984-
if (geometry == GEOMETRY_128_64) {
984+
if ((geometry == GEOMETRY_128_64) || (geometry == GEOMETRY_64_32)) {
985985
sendCommand(0x12);
986986
} else if (geometry == GEOMETRY_128_32) {
987987
sendCommand(0x02);
988988
}
989989

990990
sendCommand(SETCONTRAST);
991991

992-
if (geometry == GEOMETRY_128_64) {
992+
if ((geometry == GEOMETRY_128_64) || (geometry == GEOMETRY_64_32)) {
993993
sendCommand(0xCF);
994994
} else if (geometry == GEOMETRY_128_32) {
995995
sendCommand(0x8F);

src/oled/SSD1306Wire.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class SSD1306Wire : public OLEDDisplay {
7171
initI2cIfNeccesary();
7272
if(rotate_angle==ANGLE_0_DEGREE||rotate_angle==ANGLE_180_DEGREE)
7373
{
74+
const int x_offset = (128 - this->width()) / 2;
7475
#ifdef OLEDDISPLAY_DOUBLE_BUFFER
7576
uint8_t minBoundY = UINT8_MAX;
7677
uint8_t maxBoundY = 0;
@@ -105,8 +106,8 @@ class SSD1306Wire : public OLEDDisplay {
105106
if (minBoundY == UINT8_MAX) return;
106107

107108
sendCommand(COLUMNADDR);
108-
sendCommand( minBoundX);
109-
sendCommand( maxBoundX);
109+
sendCommand(x_offset+minBoundX);
110+
sendCommand(x_offset+ maxBoundX);
110111

111112
sendCommand(PAGEADDR);
112113
sendCommand(minBoundY);
@@ -140,11 +141,12 @@ class SSD1306Wire : public OLEDDisplay {
140141
#else
141142

142143
sendCommand(COLUMNADDR);
143-
sendCommand(0);
144-
sendCommand((this->width() - 1));
144+
sendCommand(x_offset);
145+
sendCommand(x_offset+(this->width() - 1));
145146

146147
sendCommand(PAGEADDR);
147148
sendCommand(0x0);
149+
sendCommand((this->height() / 8) - 1);
148150

149151
if (geometry == GEOMETRY_128_64)
150152
{
@@ -189,7 +191,7 @@ class SSD1306Wire : public OLEDDisplay {
189191
uint8_t minBoundX = UINT8_MAX;
190192
uint8_t maxBoundX = 0;
191193
uint8_t x, y;
192-
194+
const int x_offset = (128 - this->height()) / 2;
193195
// Calculate the Y bounding box of changes
194196
// and copy buffer[pos] to buffer_back[pos];
195197
for (y = 0; y < (this->width() / 8); y++)
@@ -211,8 +213,8 @@ class SSD1306Wire : public OLEDDisplay {
211213
if (minBoundY == UINT8_MAX) return;
212214

213215
sendCommand(COLUMNADDR);
214-
sendCommand(minBoundX);
215-
sendCommand(maxBoundX);
216+
sendCommand(x_offset+minBoundX);
217+
sendCommand(x_offset+maxBoundX);
216218

217219
sendCommand(PAGEADDR);
218220
sendCommand(minBoundY);
@@ -245,12 +247,12 @@ class SSD1306Wire : public OLEDDisplay {
245247
}
246248
#else
247249
sendCommand(COLUMNADDR);
248-
sendCommand(0);
249-
sendCommand((this->height() - 1));
250+
sendCommand(x_offset);
251+
sendCommand(x_offset+(this->height() - 1));
250252

251253
sendCommand(PAGEADDR);
252254
sendCommand(0x0);
253-
255+
sendCommand((this->width() / 8) - 1);
254256
if (geometry == GEOMETRY_128_64)
255257
{
256258
sendCommand(0x7);

0 commit comments

Comments
 (0)