Skip to content

Commit f08fc8a

Browse files
authored andcommitted
Init
0 parents  commit f08fc8a

21 files changed

+728
-0
lines changed

Alarm.h

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
class Alarm {
2+
public:
3+
Alarm();
4+
5+
void enable();
6+
void disable();
7+
void toggleEnabled();
8+
void enableWeekday(int weekdayToEnable);
9+
void disableWeekday(int weekdayToDisable);
10+
void toggleWeekdayEnabled(int weekdayToToggle);
11+
void setFireAt(int hourToFire, int minuteToFire);
12+
13+
bool isEnabled();
14+
bool firesOnWeekday(int testWeekday);
15+
int hourToFire();
16+
int minuteToFire();
17+
18+
bool firesOn(int testWeekday, int testHour, int testMinute);
19+
20+
private:
21+
bool enabled;
22+
bool weekdaysActive [7];
23+
int fireHour;
24+
int fireMinute;
25+
26+
};
27+
28+
Alarm::Alarm() {
29+
enabled = false;
30+
bool weekdaysActive [7];
31+
fireHour = 7;
32+
fireMinute = 00;
33+
}
34+
35+
void Alarm::enable() {
36+
enabled = true;
37+
}
38+
void Alarm::disable() {
39+
enabled = false;
40+
}
41+
42+
void Alarm::toggleEnabled() {
43+
enabled = !enabled;
44+
}
45+
46+
void Alarm::enableWeekday(int weekdayToEnable) {
47+
weekdaysActive[weekdayToEnable - 1] = true;
48+
}
49+
void Alarm::disableWeekday(int weekdayToDisable) {
50+
weekdaysActive[weekdayToDisable - 1] = false;
51+
}
52+
void Alarm::toggleWeekdayEnabled(int weekdayToToggle) {
53+
weekdaysActive[weekdayToToggle - 1] = !weekdaysActive[weekdayToToggle - 1];
54+
}
55+
56+
57+
void Alarm::setFireAt(int hourToFire, int minuteToFire) {
58+
fireHour = hourToFire;
59+
fireMinute = minuteToFire;
60+
}
61+
62+
bool Alarm::isEnabled() {
63+
return enabled;
64+
}
65+
bool Alarm::firesOnWeekday(int testWeekday) {
66+
Serial.println(weekdaysActive[testWeekday - 1]);
67+
return weekdaysActive[(testWeekday - 1)];
68+
}
69+
int Alarm::hourToFire() {
70+
return fireHour;
71+
}
72+
int Alarm::minuteToFire() {
73+
return fireMinute;
74+
}
75+
76+
bool Alarm::firesOn(int testWeekday, int testHour, int testMinute) {
77+
if (enabled) {
78+
if (weekdaysActive[testWeekday - 1]) {
79+
if (testHour == fireHour) {
80+
if (testMinute == fireMinute) {
81+
return true;
82+
}
83+
}
84+
}
85+
}
86+
return false;
87+
}
88+

Clock sketch/3MNut.ipt

131 KB
Binary file not shown.

Clock sketch/AdjBolt.ipt

111 KB
Binary file not shown.

Clock sketch/IV-6 Clock.dwg

338 KB
Binary file not shown.

Clock sketch/IV-6 Clock.iam

210 KB
Binary file not shown.

Clock sketch/IV-6 Clock.png

69.2 KB
Loading
154 KB
Binary file not shown.
111 KB
Binary file not shown.
281 KB
Binary file not shown.
145 KB
Binary file not shown.
91.5 KB
Binary file not shown.
92 KB
Binary file not shown.
409 KB
Binary file not shown.

Clock sketch/PCB1.ipt

113 KB
Binary file not shown.

Clock sketch/PCB2.ipt

108 KB
Binary file not shown.

Clock sketch/PCB3.ipt

430 KB
Binary file not shown.

Clock sketch/Refplate.ipt

92 KB
Binary file not shown.

0 commit comments

Comments
 (0)