-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.h
48 lines (41 loc) · 1.38 KB
/
display.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <WebSerial.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
class Display
{
public:
// static Display *instance;
TwoWire I2CInterface = TwoWire(0);
Adafruit_SSD1306 *display; // = new Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &I2CInterface, -1);
Display(int sdaPin, int sdcPin, int i2cAddr)
{
// Wire.begin(sdaPin, sdcPin);
WebSerial.println("** [Display] OLED Screen **");
// Serial.begin(115200);
I2CInterface.begin(sdaPin, sdcPin, 100000);
display = new Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT, &I2CInterface, -1);
WebSerial.println("** [Display] DBG #1 **");
if (!display->begin(SSD1306_SWITCHCAPVCC, i2cAddr))
{ // Address 0x3D for 128x64
WebSerial.println(F("[Display] [ERR] SSD1306 allocation failed"));
for (;;)
;
}
}
void testDisplay()
{
WebSerial.println("** [Display] Hello World Test **");
// delay(2000);
display->clearDisplay();
display->setTextSize(1);
display->setTextColor(WHITE);
display->setCursor(0, 0);
// Display static text
display->println("Hello, world!");
display->display();
delay(100);
}
};