@@ -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