-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboard.ino
More file actions
87 lines (78 loc) · 1.6 KB
/
board.ino
File metadata and controls
87 lines (78 loc) · 1.6 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
void displayClock(byte *groupData, int blinkDelay)
{
bool points[] = { 0, blinking(blinkDelay), 0, 0 };
displayLED(groupData, points);
}
void displayLED(byte *groupsData, bool *points)
{
for (int i = 0; i < 4; i++)
{
setIndicators(numbers_masks[groupsData[i]]);
if (points[i])
{
digitalWrite(DP_INDICATOR, HIGH);
}
else digitalWrite(DP_INDICATOR, LOW);
digitalWrite(groups[i], HIGH);
delay(1);
digitalWrite(groups[i], LOW);
}
}
inline void setIndicators(bool *mask)
{
for (int i = 0; i < 7; i++)
{
digitalWrite(indicators[i], mask[i]);
}
}
inline void clear()
{
for (int i = 0; i < 8; i++)
{
digitalWrite(indicators[i], LOW);
}
}
inline double getTemperature()
{
double t = log(10000.0 * ((1023.0 / analogRead(THERMISTOR_PIN) - 1)));
t = 1.0 / (0.001129148 + (0.000234125 + (0.0000000876741 * t * t)) * t);
return t - 273.15;
//double R = 1024 / analogRead(THERMISTOR_PIN);
//return 14.156 * R * R * R - 67.858 * R*R + 114.378 * R - 45.438;
}
bool isButton(byte group)
{
pinMode(groups[group], INPUT);
bool result = digitalRead(groups[group]);
pinMode(groups[group], OUTPUT);
return result;
}
bool isButtonDown(byte group)
{
static bool buttonStates[] = { 0, 0, 0, 0 };
pinMode(groups[group], INPUT);
if (digitalRead(groups[group]))
{
if (!buttonStates[group])
{
buttonStates[group] = true;
return true;
}
}
else buttonStates[group] = false;
pinMode(groups[group], OUTPUT);
return false;
}
bool isAnyButtonDown()
{
bool anyKeyPressed = false;
for (int i = 0; i < 4; i++)
{
if (isButtonDown(i))
{
anyKeyPressed = true;
break;
}
}
return anyKeyPressed;
}