-
Notifications
You must be signed in to change notification settings - Fork 0
/
MedIOExCppAddOns.cpp
70 lines (41 loc) · 1.29 KB
/
MedIOExCppAddOns.cpp
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
/* MedIOExCppAddOns.cpp
* In this program, you can compile and run MedIOExCppAddOns.cpp
* Compile gcc -o MedIOExCppAddOns MedIOExCppAddOns.cpp pmedex.c -lbcm2835
* first c++ program on MedIOEx
* pe2a.h provides C++ code development
* please set SW2 as being Buzzer ON when you work on this code
* Copyright (C) 2016 Polly Electronics & Automation
* If you have any troubles on MedIoEx, please do no not hesiate to contact [email protected]
* */
#include <iostream>
#include <bcm2835.h>
#include "pmedex.h"
class SmartHome{
public:
SmartHome(); //initialize GPIO
void set_ON_AlarmBuzzer(); //ON Buzzer!
void set_OFF_AlarmBuzzer(); //OFF Buzzer!
~SmartHome(); //close comm. port
};
SmartHome::SmartHome(){
std::cout<<"First Cpp Program"<<std::endl;
std::cout<<"Smart Home Class is being created"<<std::endl;
pe2a_DO_DI_init();
}
SmartHome::~SmartHome(){
std::cout<<"Smart Home is being deleted "<<std::endl;
pe2a_bcm2835_close();
}
void SmartHome::set_ON_AlarmBuzzer(){
pe2a_DO_setHigh(pe2a_GPIO_J4_1);
}
void SmartHome::set_OFF_AlarmBuzzer(){
pe2a_DO_setLow(pe2a_GPIO_J4_1);
}
int main(){
SmartHome bedRoom;
bedRoom.set_ON_AlarmBuzzer();//ON Buzzer
delay(1000); //1second
bedRoom.set_OFF_AlarmBuzzer(); //OFF Buzzer
return 0;
}