1
+ /* !
2
+ * @file WipperSnapper_I2C_Driver_Out_Ssd1306.h
3
+ *
4
+ * Device driver for SSD1306 Monochrome I2C OLED displays
5
+ *
6
+ * Adafruit invests time and resources providing this open source code,
7
+ * please support Adafruit and open-source hardware by purchasing
8
+ * products from Adafruit!
9
+ *
10
+ * Copyright (c) Brent Rubell for Adafruit Industries 2025
11
+ *
12
+ * MIT license, all text here must be included in any redistribution.
13
+ *
14
+ */
15
+
16
+ #ifndef WIPPERSNAPPER_I2C_DRIVER_OUT_SSD1306_H
17
+ #define WIPPERSNAPPER_I2C_DRIVER_OUT_SSD1306_H
18
+
19
+ #include " WipperSnapper_I2C_Driver_Out.h"
20
+ #include < Adafruit_GFX.h>
21
+ #include < Adafruit_SSD1306.h>
22
+
23
+
24
+ /* !
25
+ @brief Class that provides a driver interface for SSD1306 OLED displays
26
+ */
27
+ class WipperSnapper_I2C_Driver_Out_Ssd1306
28
+ : public WipperSnapper_I2C_Driver_Out {
29
+
30
+ public:
31
+ /* ******************************************************************************/
32
+ /* !
33
+ @brief Constructor for an SSD1306 display.
34
+ @param i2c
35
+ The I2C interface.
36
+ @param sensorAddress
37
+ 7-bit device address.
38
+ */
39
+ /* ******************************************************************************/
40
+ WipperSnapper_I2C_Driver_Out_Ssd1306 (TwoWire *i2c,
41
+ uint16_t sensorAddress)
42
+ : WipperSnapper_I2C_Driver_Out(i2c, sensorAddress) {
43
+ _i2c = i2c;
44
+ _sensorAddress = sensorAddress;
45
+ }
46
+
47
+ /* !
48
+ @brief Destructor for an SSD1306 display.
49
+ */
50
+ ~WipperSnapper_I2C_Driver_Out_Ssd1306 () {
51
+ if (_display != nullptr ) {
52
+ delete _display;
53
+ _display = nullptr ;
54
+ }
55
+ }
56
+
57
+ /* !
58
+ @brief Initializes the SSD1306 display and begins I2C.
59
+ @returns True if initialized successfully, False otherwise.
60
+ */
61
+ bool begin () {
62
+ _display = new Adafruit_SSD1306 (_width, _height, _i2c);
63
+ bool did_begin = _display->begin (SSD1306_SWITCHCAPVCC, _sensorAddress);
64
+ return did_begin;
65
+ }
66
+
67
+ /* !
68
+ @brief Writes a message to an SSD1306 display.
69
+ @param message
70
+ The message to be displayed.
71
+ */
72
+ void WriteMessage (const char *message) {
73
+
74
+ }
75
+
76
+ protected:
77
+ Adafruit_SSD1306 *_display =
78
+ nullptr ; // /< ptr to an SSD1306 display object
79
+ int32_t _width; // /< Width of the display in pixels
80
+ int32_t _height; // /< Height of the display in pixels
81
+ };
82
+
83
+ #endif // WIPPERSNAPPER_I2C_DRIVER_OUT_SSD1306_H
0 commit comments