Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions libraries/RobotOpen/RobotOpen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -185,15 +186,15 @@ 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) {
onDisable();
firstEnableLoop = true;
}
}
else if (_enabled == true) {
else if (_enabled == true || _enable_lock) {
// ENABLED
if (firstEnableLoop) {
// 'wakes up' the shields so they show enable state
Expand Down Expand Up @@ -505,6 +506,10 @@ boolean RobotOpenClass::enabled() {
return _enabled;
}

void RobotOpenClass::enableLock(boolean lock) {
_enable_lock = lock;
}

int RobotOpenClass::numJoysticks() {
return _total_joysticks;
}
2 changes: 2 additions & 0 deletions libraries/RobotOpen/RobotOpen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down