diff --git a/libraries/RobotOpen/RobotOpen.cpp b/libraries/RobotOpen/RobotOpen.cpp index bcccb46..d52393d 100755 --- a/libraries/RobotOpen/RobotOpen.cpp +++ b/libraries/RobotOpen/RobotOpen.cpp @@ -45,6 +45,7 @@ static unsigned int _outgoingPacketSize = 1; // Robot specific stuff static boolean _enabled = false; // Tells us if the robot is enabled or disabled +static boolean _enable_lock = false; static unsigned long _lastPacket = 0; // Keeps track of the last time (ms) we received data static unsigned long _lastTimedLoop = 0; // Keeps track of the last time the timed loop ran static unsigned long _lastDSLoop = 0; // Keeps track of the last time we published DS data @@ -185,7 +186,7 @@ void RobotOpenClass::syncDS() { wdt_reset(); // detect disconnect - if ((millis() - _lastPacket) > 200) { // Disable the robot, drop the connection + if ((millis() - _lastPacket) > 200 && !_enable_lock) { // Disable the robot, drop the connection _enabled = false; // NO CONNECTION if (!firstEnableLoop) { @@ -193,7 +194,7 @@ void RobotOpenClass::syncDS() { firstEnableLoop = true; } } - else if (_enabled == true) { + else if (_enabled == true || _enable_lock) { // ENABLED if (firstEnableLoop) { // 'wakes up' the shields so they show enable state @@ -505,6 +506,10 @@ boolean RobotOpenClass::enabled() { return _enabled; } +void RobotOpenClass::enableLock(boolean lock) { + _enable_lock = lock; +} + int RobotOpenClass::numJoysticks() { return _total_joysticks; } \ No newline at end of file diff --git a/libraries/RobotOpen/RobotOpen.h b/libraries/RobotOpen/RobotOpen.h index 7f2af85..0ea5604 100755 --- a/libraries/RobotOpen/RobotOpen.h +++ b/libraries/RobotOpen/RobotOpen.h @@ -54,6 +54,8 @@ class RobotOpenClass { // Tells us if the robot is enabled static boolean enabled(); + static void enableLock(boolean lock); + // How many joysticks are being received static int numJoysticks();