@@ -53,8 +53,10 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
5353 */
5454 ~WipperSnapper_I2C_Driver_Out_Ssd1306 () {
5555 if (_display != nullptr ) {
56+ WS_DEBUG_PRINTLN (" SSD1306 Destructor called, clearing display buffer." );
5657 _display->clearDisplay ();
5758 _display->display ();
59+ WS_DEBUG_PRINTLN (" SSD1306 display cleared, turning off display." );
5860 _display->ssd1306_command (SSD1306_DISPLAYOFF);
5961 delete _display;
6062 _display = nullptr ;
@@ -70,7 +72,8 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
7072 _display = new Adafruit_SSD1306 (_width, _height, _i2c);
7173 if (!_display->begin (SSD1306_SWITCHCAPVCC, _sensorAddress, false , false ))
7274 return false ;
73- // Configure the text size and color
75+ // Configure the rotation, text size and color
76+ _display->setRotation (_rotation);
7477 _display->setTextSize (_text_sz);
7578 _display->setTextColor (SSD1306_WHITE);
7679 // Use full 256 char 'Code Page 437' font
@@ -90,11 +93,15 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
9093 The height of the display in pixels.
9194 @param text_size
9295 The magnification factor for the text size.
96+ @param rotation
97+ The rotation of the display in degrees, default is 0 (no rotation).
9398 */
94- void ConfigureSSD1306 (uint8_t width, uint8_t height, uint8_t text_size) {
99+ void ConfigureSSD1306 (uint8_t width, uint8_t height, uint8_t text_size,
100+ uint8_t rotation = 0 ) {
95101 _width = width;
96102 _height = height;
97103 _text_sz = text_size;
104+ _rotation = rotation;
98105 WS_DEBUG_PRINT (" SSD1306 text size: " );
99106 WS_DEBUG_PRINTLN (text_size);
100107 }
@@ -153,11 +160,12 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
153160 }
154161
155162protected:
156- Adafruit_SSD1306 *_display =
157- nullptr ; // /< Pointer to the Adafruit_SSD1306 object
158- uint8_t _width; // /< Width of the display in pixels
159- uint8_t _height; // /< Height of the display in pixels
160- uint8_t _text_sz; // /< Text size of the display
163+ Adafruit_SSD1306 *_display =
164+ nullptr ; // /< Pointer to the Adafruit_SSD1306 object
165+ uint8_t _width; // /< Width of the display in pixels
166+ uint8_t _height; // /< Height of the display in pixels
167+ uint8_t _rotation; // /< Rotation of the display in degrees
168+ uint8_t _text_sz; // /< Text size of the display
161169};
162170
163171#endif // WIPPERSNAPPER_I2C_DRIVER_OUT_SSD1306_H
0 commit comments