-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode2.cpp
More file actions
48 lines (34 loc) · 1.06 KB
/
code2.cpp
File metadata and controls
48 lines (34 loc) · 1.06 KB
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 <DMD2.h>
#include <SPI.h>
// width and height of display i panels
#define DISPLAYS_WIDE 3
#define DISPLAYS_HIGH 1
// Ini library
SPIDMD dmd(DISPLAYS_WIDE, DISPLAYS_HIGH);
SoftDMD canvas(dmd);
void setup() {
dmd.begin(); // Init display
dmd.setBrightness(255);
canvas.selectFont(SystemFont5x7);
dmd.setColor(COLOR_RGB(255, 255, 255));
}
void loop() {
static int offsetX = 0; // X offset for scrolling
const char* text1 = "Oxford ";
const char* text2 = "green ";
const char* text3 = "public school";
canvas.clear();
dmd.setColor(COLOR_RGB(255, 255, 255));
canvas.drawString(offsetX, 0, text1);
int width1 = canvas.stringWidth(text1);
dmd.setColor(COLOR_RGB(0, 0, 255));
canvas.drawString(offsetX + width1, 0, text2);
int width2 = canvas.stringWidth(text2);
dmd.setColor(COLOR_RGB(255, 255, 255));
canvas.drawString(offsetX + width1 + width2, 0, text3);
offsetX--;
if (offsetX < -canvas.stringWidth(text1) - width1 - width2) {
offsetX = dmd.width(); // Reset offset when text scrolls out
}
delay(50);
}