File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 19
19
20
20
21
21
#include " Arduino_MKRIoTCarrier_Relay.h"
22
+ #include " MKRIoTCarrierDefines.h"
22
23
23
- MKRIoTCarrier_Relay::MKRIoTCarrier_Relay (int pin):_pin{pin }
24
+ MKRIoTCarrier_Relay::MKRIoTCarrier_Relay (int index, getRev_t getRev):_index{index }
24
25
{
26
+ board_revision = getRev;
25
27
}
26
28
void MKRIoTCarrier_Relay::begin (){
29
+
30
+ _revision = board_revision ();
31
+
32
+ if (_revision == BOARD_REVISION_1)
33
+ {
34
+ if (_index == 1 ) {
35
+ _pin = mkr_iot_carrier_rev1::RELAY1;
36
+ }
37
+ else if (_index == 2 ) {
38
+ _pin = mkr_iot_carrier_rev1::RELAY2;
39
+ }
40
+ }
41
+ else {
42
+ /* carrier's revision 2 with pull down on AREF */
43
+ if (_index == 1 ) {
44
+ _pin = mkr_iot_carrier_rev2::RELAY1;
45
+ }
46
+ else if (_index == 2 ) {
47
+ _pin = mkr_iot_carrier_rev2::RELAY2;
48
+ }
49
+ }
27
50
pinMode (_pin ,OUTPUT);
28
51
close ();
29
52
}
@@ -44,7 +67,6 @@ void MKRIoTCarrier_Relay::open(){
44
67
}
45
68
46
69
int MKRIoTCarrier_Relay::getStatus (){
47
- // Serial.println("status");
48
- // Serial.println(_status , BIN);
70
+
49
71
return (int )_status;
50
72
}
Original file line number Diff line number Diff line change 22
22
#define ARDUINO_MKRIoTCarrier_Relay
23
23
24
24
#include " Arduino.h"
25
+ using getRev_t = int (*)();
25
26
26
27
class MKRIoTCarrier_Relay {
27
28
public:
28
- MKRIoTCarrier_Relay (int pin );
29
+ MKRIoTCarrier_Relay (int index, getRev_t getRev );
29
30
void begin ();
30
31
void open ();
31
32
void close ();
32
33
int getPin ();
33
34
int getStatus ();
34
35
35
36
private:
36
- const int _pin;
37
+ int _pin;
37
38
int _status;
39
+ int _index;
40
+ int (*board_revision)(void );
41
+ int _revision;
38
42
};
39
43
40
44
#endif
You can’t perform that action at this time.
0 commit comments