/
timing.ino
85 lines (78 loc) · 1.79 KB
/
timing.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
long previousMillis = 0;
uint8_t timerState = 0;
void pollTimer()
{
//Call timer trigger
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > 1000)
{
timerTick();
previousMillis = currentMillis;
}
}
void timerTick()
{
Serial.println(timerState);
switch (timerState)
{
case 0:
{
byte tempAddr[8];
for (uint8_t i = 0; i < 8; i++) {
tempAddr[i] = pgm_read_byte_near(addrTapSensor + i);
}
initSensor(tempAddr);
break;
}
case 1:
{
byte tempAddr[8];
for (uint8_t i = 0; i < 8; i++) {
tempAddr[i] = pgm_read_byte_near(addrTapSensor + i);
}
tapSensorTemp = readSensor(tempAddr);
Serial.println(tapSensorTemp);
break;
}
case 4:
{
byte tempAddr[8];
for (uint8_t i = 0; i < 8; i++) {
tempAddr[i] = pgm_read_byte_near(addrOptTemp1 + i);
}
initSensor(tempAddr);
break;
}
case 5:
{
byte tempAddr[8];
for (uint8_t i = 0; i < 8; i++) {
tempAddr[i] = pgm_read_byte_near(addrOptTemp1 + i);
}
optSensor1Temp = readSensor(tempAddr);
Serial.println(optSensor1Temp);
break;
}
case 8:
{
byte tempAddr[8];
for (uint8_t i = 0; i < 8; i++) {
tempAddr[i] = pgm_read_byte_near(addrOptTemp2 + i);
}
initSensor(tempAddr);
break;
}
case 9:
{
byte tempAddr[8];
for (uint8_t i = 0; i < 8; i++) {
tempAddr[i] = pgm_read_byte_near(addrOptTemp2 + i);
}
optSensor2Temp = readSensor(tempAddr);
Serial.println(optSensor2Temp);
break;
}
}
timerState++;
if(timerState > 11) timerState = 0;
}