-
Notifications
You must be signed in to change notification settings - Fork 1
/
Igniter.cpp
59 lines (50 loc) · 1.53 KB
/
Igniter.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
#include "Igniter.h"
#include "ExtendedIO.h"
#include <iostream>
Igniter::Igniter(): id(0), pinPWM(0), pinDigital(0), igniterOn(false) {
ExtendedIO::pinModeExtended(pinDigital, 1, 1);
};
Igniter::Igniter(int id, int pinPWM, int pinDigital)
: id(id), pinPWM(pinPWM), pinDigital(pinDigital), igniterOn(false) {
ExtendedIO::pinModeExtended(pinDigital, 1, 1);
ExtendedIO::digitalWriteExtended(this->pinDigital, 1);
Serial.println("IGNITER IS WORKING!");
}
// Getters
int Igniter::getID() {
return this->id;
}
int Igniter::getPinPWM() {
return this->pinPWM;
}
int Igniter::getPinDigital() {
return this->pinDigital;
}
bool Igniter::getIgniterOn() {
return this->igniterOn;
}
// Setters
bool Igniter::setPinDigital(int newPinDigital) {
this->pinDigital = newPinDigital;
if(this->pinDigital == newPinDigital){
return true;
}
else {return false;}
}
bool Igniter::setIgniterOn(bool isignitionOn){
/*Sets the state of Igniter Objects: True (Open) | False (Close)
Returns true if successful*/
this->igniterOn = isignitionOn;
ExtendedIO::pinModeExtended(this->pinDigital,1,OUTPUT); // Sets Pinmode to GPIO, Data Direction OUTPUT
pinMode(this->pinPWM,OUTPUT);
if(isignitionOn == true){
ExtendedIO::digitalWriteExtended(this->pinDigital,1);
digitalWrite(this->pinPWM,1);
return true;
}
if(isignitionOn == false){
ExtendedIO::digitalWriteExtended(this->pinDigital,0);
digitalWrite(this->pinPWM,0);
return false;
}
}