Add SoftwareSerial::stopListening()

This allows one to explicitly stop a SoftwareSerial instance from
listening, without having to make another one listening.
This commit is contained in:
Matthijs Kooijman 2013-06-04 11:28:30 +02:00
parent 7366268025
commit 3f02bcb49f
2 changed files with 12 additions and 0 deletions

View File

@ -195,6 +195,17 @@ bool SoftwareSerial::listen()
return false;
}
// Stop listening. Returns true if we were actually listening.
bool SoftwareSerial::stopListening()
{
if (active_object == this)
{
active_object = NULL;
return true;
}
return false;
}
//
// The receive routine called by the interrupt handler
//

View File

@ -87,6 +87,7 @@ public:
bool listen();
void end();
bool isListening() { return this == active_object; }
bool stopListening();
bool overflow() { bool ret = _buffer_overflow; _buffer_overflow = false; return ret; }
int peek();