-
Notifications
You must be signed in to change notification settings - Fork 0
/
utilities.h
79 lines (71 loc) · 1.29 KB
/
utilities.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
int short_ch_to_pin(int ch)
{
switch (ch) {
case 15: return 2;
case 14: return 6;
case 13: return 10;
case 12: return 14;
case 11: return 18;
case 10: return 19;
case 9: return 15;
case 8: return 11;
case 7: return 7;
case 6: return 3;
default:
return -1;
}
}
float convert_data_to_V(int data)
{
return (data*5) / 1023.0;
}
int continuity_ch_to_pin(int ch, bool first_mux)
{
if(first_mux)
{
switch (ch) {
case 15: return 2;
case 14: return 6;
case 13: return 10;
case 12: return 14;
case 11: return 18;
case 10: return 19;
case 9: return 15;
case 8: return 11;
case 7: return 7;
case 6: return 3;
case 5: return 4;
case 4: return 8;
case 3: return 12;
case 2: return 16;
case 1: return 20;
case 0: return 17;
default:
return -1;
}
}
else {
switch (ch) {
case 15: return 13;
case 14: return 9;
case 13: return 5;
case 12: return 1;
default:
return -1;
}
}
}
void print_ch_result(int ch, float dataV)
{
Serial.print(ch);
Serial.print(" ");
Serial.print(dataV);
Serial.print("V || ");
}
void blink_led(int milis)
{
digitalWrite(led, HIGH);
delay(milis);
digitalWrite(led, LOW);
delay(milis);
}