-
Notifications
You must be signed in to change notification settings - Fork 0
/
cb_ssd1306_text.h
32 lines (22 loc) · 1.03 KB
/
cb_ssd1306_text.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
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void StartSSD1306VCC() {
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
}
void ScreenPrint(String text,int xpos,int ypos, int fontsize) {
display.setTextSize(fontsize); // Normal 1:1 pixel scale
display.setTextColor( SSD1306_WHITE); // Draw white text
display.setCursor(xpos,ypos); // Start at top-left corner
display.println(text);
}