-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.ino
More file actions
173 lines (142 loc) · 2.99 KB
/
Copy pathtest.ino
File metadata and controls
173 lines (142 loc) · 2.99 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include "letters.hpp"
#include <Arduino_LED_Matrix.h>
ArduinoLEDMatrix matrix;
enum Mod
{
Mod_Normal = 0,
Mod_Spinning,
};
void setup() {
// put your setup code here, to run once:
init(false);
matrix.begin();
}
byte clearFrame[8][12] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
byte frame[8][12] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
Mod mod = Mod_Spinning;
void normalShow(String str)
{
for(int i = 0; i <str.length(); i++)
{
if(str[i] >= 97 && str[i] <= 122)
{
matrix.renderBitmap(letters[str[i]-97],8,12);
delay(750);
matrix.renderBitmap(clearFrame,8,12);
}else
delay(750);
}
}
void leftShift()
{
for(int i = 1; i < 12; i++)
{
for(int j = 0; j <8; j++)
{
frame[j][i-1] = frame[j][i];
}
}
}
bool addVerticalLine(uint8_t array[8])
{
bool ret = true;
for(int i = 0; i <8; i++)
{
frame[i][11] = array[i];
if(array[i] != 0)
ret = false;
}
delay(250);
return ret;
}
void printLetter(char ch)
{
int index = ch -97;
uint8_t array[8];
for(int i = 0; i <12; i++)
{
for( int j= 0 ; j <8; j++){
array[j] = letters[index][j][i];
}
bool isFinished = addVerticalLine(array);
matrix.renderBitmap(frame,8,12);
leftShift();
if(isFinished)
{
addVerticalLine(array);
matrix.renderBitmap(frame,8,12);
leftShift();
return;
}
}
}
void spinningShow(String str)
{
matrix.renderBitmap(clearFrame,8,12);
memcpy(frame,clearFrame,sizeof(frame));
for(int i = 0; i <str.length(); i++)
{
if(str[i] >= 97 && str[i] <= 122 )
{
printLetter(str[i]);
}
else if(str[i] == ' ')
{
for(int j = 0; j <3; j++){
uint8_t array[8] = {0,0,0,0,0,0,0,0};
addVerticalLine(array);
matrix.renderBitmap(frame,8,12);
leftShift();
}
}
else
delay(300);
}
for(int i = 0; i < 10; i++)
{
leftShift();
delay(100);
matrix.renderBitmap(frame,8,12);
}
}
void loop() {
// put your main code here, to run repeatedly:
String str = Serial.readString();
str.toLowerCase();
if(str[0] == '0'){
mod = Mod_Normal;
Serial.println("Mod Normal");
return;
}
if(str[0] == '1'){
mod = Mod_Spinning;
Serial.println("Mod Spinning");
return;
}
switch(mod)
{
case Mod_Spinning:
spinningShow(str);
break;
default:
normalShow(str);
}
}