Wake computer from sleep with Neo Trinkey?

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tommydog
 
Posts: 3
Joined: Mon Jul 11, 2022 7:25 pm

Wake computer from sleep with Neo Trinkey?

Post by tommydog »

I have a very simple code example (see below) running on the Neo Trinkey that types the word "Password" when the Capacitive Touch button 2 is pressed. From what I understand, this emulates a USB keyboard and is working fine on my windows 10 computer. The problem is I want this to wake the computer from sleep like a normal usb keyboard. This does not currently work. Is there anyway to get this working? I once saw a tutorial (cant find this now) of someone using an Arduino ATtiny85 to wake a computer from sleep utilizing keyboard emulation, so I know it is possible in theory. I think they ended up editing the usb.config.h file by changing the Vendor ID and Product to ID vid=046d, pid=c52b. I believe vid=046d, pid=c52b is the standard HP keyboard, which loads standard Microsoft keyboard drivers and everything then works. I have looked in the adafruit_hid library folder, which contains the below files, but I can't see how to change this ID there?

mouse.mpy
keycode.mpy
keyboard_layout_us.mpy
keyboard_layout_base.mpy
keyboard.mpy
consumer_control_code.mpy
consumer_control.mpy
__init__.mpy


Is there anyway to wake the computer with the Neo Trinkey?

Code: Select all

"""CircuitPython Capacitive Touch HID Example for Neo Trinkey"""
import time
import board
import touchio
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode

keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)


touch2 = touchio.TouchIn(board.TOUCH2)

while True:
    if touch2.value:  # If touch pad 2 is touched...
        while touch2.value:  # Wait for release...
            time.sleep(0.1)
        keyboard_layout.write("PASSWORD\n")  # Then send string.

User avatar
neradoc
 
Posts: 542
Joined: Wed Apr 27, 2016 2:38 pm

Re: Wake computer from sleep with Neo Trinkey?

Post by neradoc »

Hi, there is a discussion on waking on USB in the Circuitpython repository. It's pretty much "almost there".
It doesn't seem like this would be tied to a specific VIP/PID, but requires a change in the USB descriptor.
https://github.com/adafruit/circuitpython/issues/5380

User avatar
tommydog
 
Posts: 3
Joined: Mon Jul 11, 2022 7:25 pm

Re: Wake computer from sleep with Neo Trinkey?

Post by tommydog »

neradoc wrote:Hi, there is a discussion on waking on USB in the Circuitpython repository. It's pretty much "almost there".
It doesn't seem like this would be tied to a specific VIP/PID, but requires a change in the USB descriptor.
https://github.com/adafruit/circuitpython/issues/5380
From what I understand they have not implemented this yet and are adding it to CircuitPython 8.x? Have to say I am just a beginner and did not really understand what they were talking about on that thread. Is there a way to change my code to get this working now, or change the code of a library?

User avatar
neradoc
 
Posts: 542
Joined: Wed Apr 27, 2016 2:38 pm

Re: Wake computer from sleep with Neo Trinkey?

Post by neradoc »

If I understand correctly, I don't think it's possible right now without changes to the core unfortunately.

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”