forked from casartar/MacherDaachBadgeFirmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
outputShiftString.ino
53 lines (46 loc) · 1.1 KB
/
outputShiftString.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
// helper function for mode-array
void outputShiftString() {
char text[] = TEXT;
outputShiftString(text);
}
//Shifts string through matrix
void outputShiftString(char * text){
char *t;
static int i = 0;
static int xOffset = 0;
static int yOffset = 0;
static bool fistrun = true;
/* iterate over text characters
* loop takes car of two characters a the same time
*/
if (countdown == 0){
//remember last drawn char
t = text;
t = t + i;
// if first character start from left side
if (fistrun){
xOffset=7;
fistrun=false;
}
// draw char
displayCharacterOffset(ASCII[(int)*t],xOffset,yOffset);
// *********second charcter part***********
if (xOffset < 0) {
displayCharacterOffset(ASCII[(int)*(t+1)],xOffset+8,yOffset);
}
countdown = TEXT_SHIFT_SPEED_MS;
//reset if end of string
if(*t == '\0'){
i = 0;
//xOffset=0;
fistrun = true;
}
// if charachter shift completed
if(xOffset <= -8){
xOffset=0;
i++;
}
//set X offset for next cycle
xOffset--;
}
}