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

HID needs to wait until initialized #29

Open
NicoHood opened this issue Apr 18, 2015 · 2 comments
Open

HID needs to wait until initialized #29

NicoHood opened this issue Apr 18, 2015 · 2 comments

Comments

@NicoHood
Copy link
Owner

We need something similar to while(!Serial) just for HID. In this example StartupHID never appears. You need to add a 1-2s delay first.

#include "HID-Project.h"

void setup() {
  while(!HID);
  Keyboard.begin();
  Keyboard.println("StartupHID"); 

  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}
@NicoHood
Copy link
Owner Author

Fixed with 60bd43e
Similar approach:
arduino/Arduino#3624

Still not perfect, but at least a solution. Should we also add this check the the HID send function?

@NicoHood
Copy link
Owner Author

HID_::operator bool() {
    if(USBDevice.configured()){
        delay(10);
        return true;
    }
    else{
        return false;
    }
}

TODO after the update

@NicoHood NicoHood reopened this Oct 10, 2015
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

1 participant