I have a RP Pico connected to my Mac using USB and I am able to use CircuitPython's USB HID to send keystrokes to the Mac. However, in my case I want to _avoid_ waking up the computer if it is asleep. Sending a keystroke to the computer wakes it up, which I do not want to do.
Is there any way to detect whether the computer is asleep via the USB connection so that I could avoid sending keystrokes while the computer is asleep?
Alternatively, is there a way to configure USB HID so that the keyboard does not wake the computer from sleep?
Detect sleeping computer
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- sj_remington
- Posts: 1021
- Joined: Mon Jul 27, 2020 4:51 pm
Re: Detect sleeping computer
If the Mac displays something like the "breathing" power LED indicator while in sleep mode, that could be detected by an optical sensor.
- danhalbert
- Posts: 4688
- Joined: Tue Aug 08, 2017 12:37 pm
Re: Detect sleeping computer
supervisor.runtime.usb_available should be false when usb is suspended, which is what happens when the computer sleeps. See if that works for you.
https://docs.circuitpython.org/en/lates ... _connected
https://docs.circuitpython.org/en/lates ... _connected
Please be positive and constructive with your questions and comments.