Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isConnected() does not work #18

Open
ElectricRCAircraftGuy opened this issue Jun 12, 2016 · 3 comments
Open

isConnected() does not work #18

ElectricRCAircraftGuy opened this issue Jun 12, 2016 · 3 comments

Comments

@ElectricRCAircraftGuy
Copy link

ElectricRCAircraftGuy commented Jun 12, 2016

isConnected() always seems to return 0, no matter what. This function seems to be broken in both the TrinketKeyboard and the TrinketHidCombo libraries.

This means also that this example sketch is broken, as it gets stuck in the while loop where isConnected() is called: https://github.com/adafruit/Adafruit-Trinket-USB/blob/master/TrinketKeyboard/examples/TrinketKeyboardPrank/TrinketKeyboardPrank.ino

@pixelrebel
Copy link

Thanks for this hint. It was driving me crazy why the prank code wasn't working!

I just commented out the line and put 12345 in my random seed. At least it works now!

@ElectricRCAircraftGuy
Copy link
Author

So I'm wrong about isConnected()....sort of. It actually does work, though its implementation in the example sketch does not.

Replace this:

while (TrinketKeyboard.isConnected() == 0); // wait until connection

with this:

//wait until connected to USB before continuing
//-note that isConnected() will change to true at that point 
while (TrinketHidCombo.isConnected() == false)
{
  TrinketHidCombo.poll(); //The poll function must be called at least once every 10 ms, or you must command a keystroke. Otherwise, the computer may think that the device has stopped working, and give errors.
}

@ElectricRCAircraftGuy
Copy link
Author

The poll() function keeps the USB connection active until isConnected() becomes true. Otherwise it fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants