-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodes.h
95 lines (90 loc) · 1.99 KB
/
modes.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
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
#include <MatrixGL.h>
#include "State.h"
#include "zDHT.h"
#include "updateClock.h"
void println(MatrixGL &matrix, String str){
char buf[6];
str.toCharArray(buf, 7);
matrix.lock();
matrix.clear();
for(int i = 0; i<6; i++){
if(buf[i]==NULL){
buf[i] = ' ';
}
matrix.drawChar(buf[i],1+(i*5),1);
}
matrix.unlock();
}
void say(MatrixGL matrix, State st){
println(matrix, st.storedText);
}
void drawDHT(MatrixGL matrix, State st){
updateDHT(st);
String DHTString = String(st.lastTemp).substring(0,2) + "C" + String(st.lastHum).substring(0,2) + "H";
println(matrix, DHTString);
}
void demoRandomNoise(MatrixGL &matrix){
// Generate random noise
int X = matrix.lenX();
int Y = matrix.lenY();
matrix.lock();
matrix.clear();
for(int i = 0; i<(X*Y); i++){
matrix.drawPoint(random(X), random(Y));
}
matrix.unlock();
matrix.delayF();
}
void drawClock(MatrixGL &matrix, State &st){
updateClock(st);
// Skip if time has not changed
if(st.localTime[3] != st.lastMin){
matrix.lock();
matrix.clear();
matrix.drawNum(st.localTime[0],5,1);
matrix.drawNum(st.localTime[1],10,1);
matrix.drawChar(':',14,1);
matrix.drawNum(st.localTime[2],18,1);
matrix.drawNum(st.localTime[3],23,1);
matrix.unlock();
}
st.lastMin = st.localTime[3];
}
/*
* RUN CURRENT MODE
*/
void runMode(MatrixGL &matrix, State &st){
if(st.mode == "clock"){
drawClock(matrix, st);
}
else if(st.mode == "demo"){
demoRandomNoise(matrix);
}
else if(st.mode == "say"){
say(matrix, st);
}
else if(st.mode == "dht"){
drawDHT(matrix, st);
}
else{
drawClock(matrix, st);
st.mode="clock";
}
// switch(st.mode){
// case ml.clock:
// drawClock(matrix, st);
// break;
// case 1:
// demoRandomNoise(matrix);
// break;
// case 2:
// say(matrix, st);
// break;
// case 3:
// drawDHT(matrix, st);
// break;
// default:
// drawClock(matrix, st);
// break;
// }
}