Skip to content

Commit c506533

Browse files
committed
Merge pull request arduino#174 from jkandasa/master
Use Tx/Rx pin as IO pin
2 parents 2f1df52 + d7459ae commit c506533

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

libraries/MySensors/MyConfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
// to see what is actually is happening when developing
2727
#define DEBUG
2828

29+
// Disable this line, If you are using TX(1), RX(0) as normal I/O pin
30+
#define ENABLED_SERIAL
31+
2932
// Serial output baud rate (for debug prints and serial gateway)
3033
#define BAUD_RATE 115200
3134

libraries/MySensors/MyHwATMega328.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ void powerDown(period_t period) {
119119

120120
void MyHwATMega328::internalSleep(unsigned long ms) {
121121
// Let serial prints finish (debug, log etc)
122-
Serial.flush();
122+
#ifdef ENABLED_SERIAL
123+
Serial.flush();
124+
#endif
123125
pinIntTrigger = 0;
124126
while (!pinIntTrigger && ms >= 8000) { powerDown(SLEEP_8S); ms -= 8000; }
125127
if (!pinIntTrigger && ms >= 4000) { powerDown(SLEEP_4S); ms -= 4000; }
@@ -148,7 +150,9 @@ bool MyHwATMega328::sleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
148150
pinTriggeredWakeup = false;
149151
}
150152
} else {
151-
Serial.flush();
153+
#ifdef ENABLED_SERIAL
154+
Serial.flush();
155+
#endif
152156
powerDown(SLEEP_FOREVER);
153157
}
154158
detachInterrupt(interrupt);
@@ -166,7 +170,9 @@ inline uint8_t MyHwATMega328::sleep(uint8_t interrupt1, uint8_t mode1, uint8_t i
166170
retVal = -1;
167171
}
168172
} else {
169-
Serial.flush();
173+
#ifdef ENABLED_SERIAL
174+
Serial.flush();
175+
#endif
170176
powerDown(SLEEP_FOREVER);
171177
}
172178
detachInterrupt(interrupt1);

libraries/MySensors/MySensor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ void MySensor::errBlink(uint8_t cnt) {
153153
#endif
154154

155155
void MySensor::begin(void (*_msgCallback)(const MyMessage &), uint8_t _nodeId, boolean _repeaterMode, uint8_t _parentNodeId) {
156-
hw_init();
156+
#ifdef ENABLED_SERIAL
157+
hw_init();
158+
#endif
157159
repeaterMode = _repeaterMode;
158160
msgCallback = _msgCallback;
159161
failedTransmissions = 0;

0 commit comments

Comments
 (0)