Skip to content

Commit 8c8c5c2

Browse files
committed
Set Rotation for 128x64 OLED featherwing
1 parent 6779646 commit 8c8c5c2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Sh1107.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ class WipperSnapper_I2C_Driver_Out_SH1107
6868
@returns True if initialized successfully, False otherwise.
6969
*/
7070
bool begin() {
71-
// Attempt to create and allocate a SH1107 obj, backwards w/h
72-
_display = new Adafruit_SH1107(_height, _width, _i2c);
71+
uint8_t rotation = 0; // Default rotation
72+
// Attempt to create and allocate a SH1107 obj
73+
if (_width == 128 && _height == 64) { // featherwing
74+
_display = new Adafruit_SH1107(_height, _width, _i2c);
75+
rotation = 1; // Set rotation to 1 for 128x64 OLED featherwing
76+
} else {
77+
_display = new Adafruit_SH1107(_width, _height, _i2c);
78+
}
7379
if (!_display->begin(_sensorAddress, true))
7480
return false;
7581

@@ -82,7 +88,7 @@ class WipperSnapper_I2C_Driver_Out_SH1107
8288
// Clear the buffer.
8389
_display->clearDisplay();
8490
_display->display();
85-
_display->setRotation(1);
91+
_display->setRotation(rotation);
8692

8793
// Configure the text size and color
8894
_display->setTextSize(_text_sz);

0 commit comments

Comments
 (0)