-
Notifications
You must be signed in to change notification settings - Fork 0
/
Display.ino
108 lines (89 loc) · 2.3 KB
/
Display.ino
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <Adafruit_SSD1306.h> // https://learn.adafruit.com/monochrome-oled-breakouts/wiring-128x32-i2c-display
#include <Adafruit_GFX.h> // https://learn.adafruit.com/adafruit-gfx-graphics-library/overview
#include "Modes.h"
// Display
#define SCREEN_WIDTH 128 // OLED display width, in p ixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define SCREEN_ADDRESS 0x3C // 0x3C for 128x32
#define OLED_RESET -1 // Reset pin #, if not connected use -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, OLED_RESET); // display is connected to second I2C
boolean dirtyDisplay = true;
void setupDisplay()
{
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
}
void refreshDisplay()
{
dirtyDisplay = true;
}
void displayLines(int lineCount, String text[])
{
// Clear the buffer.
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,0);
for(int index = 0; index < lineCount; index++)
{
display.println(text[index]);
}
display.setCursor(0,0);
display.display(); // actually display all of the above
}
void displayLine(String text)
{
display.println(text);
}
void updateDisplay()
{
if (dirtyDisplay)
{
dirtyDisplay = false;
}
else
{
return;
}
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,0);
displayMode(getCurrentMode());
if (isDevModeEnabled())
{
display.println("(DEV)");
String testFile = getCurrentPlayingFileName();
display.println(testFile);
}
else
{
display.println();
display.println();
}
display.display();
}
void testDisplay()
{
// print text
Serial.println(">>> Test display");
display.display();
delay(1000);
// Clear the buffer.
display.clearDisplay();
display.display();
// text display tests
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,0);
display.print ("TEST SSD1306 DISPLAY:");
display.print ("ABCDEFGHIJKLMNOPQRSTU");
display.println("0123456789-0123456789");
display.println(")!@#$%^&*(';:.,[]{}|-");
display.setCursor(0,0);
display.display(); // actually display all of the above
delay(2000);
display.clearDisplay();
display.display();
}