Skip to content

Commit 18289f6

Browse files
committed
Added begin() method to MKRIoTCarrier_Relay class - set _pin as const int
1 parent acff2a7 commit 18289f6

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/Arduino_MKRIoTCarrier.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ int MKRIoTCarrier::begin() {
7171
}
7272
return false;
7373
}
74-
74+
Relay1.begin();
75+
Relay2.begin();
7576
if(!SD.begin(SD_CS)) {
7677
Serial.println("Sd card not detected");
7778
}
79+
7880
return true;
7981
}

src/Arduino_MKRIoTCarrier_Relay.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@
2020

2121
#include "Arduino_MKRIoTCarrier_Relay.h"
2222

23-
MKRIoTCarrier_Relay::MKRIoTCarrier_Relay(int pin){
24-
_pin = pin;
23+
MKRIoTCarrier_Relay::MKRIoTCarrier_Relay(int pin):_pin{pin}
24+
{
25+
}
26+
void MKRIoTCarrier_Relay::begin(){
2527
pinMode(_pin ,OUTPUT);
2628
close();
27-
2829
}
29-
30+
int MKRIoTCarrier_Relay::getPin(){
31+
return _pin;
32+
}
3033
//NC state
3134
void MKRIoTCarrier_Relay::close(){
3235
digitalWrite(_pin , LOW);

src/Arduino_MKRIoTCarrier_Relay.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
class MKRIoTCarrier_Relay{
2727
public:
2828
MKRIoTCarrier_Relay(int pin);
29-
29+
void begin();
3030
void open();
3131
void close();
32-
32+
int getPin();
3333
int getStatus();
3434

3535
private:
36-
int _pin;
36+
const int _pin;
3737
int _status;
3838
};
3939

0 commit comments

Comments
 (0)