Skip to content

PC can't properly enter the sleep mode when PinOne is connected #1

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

Closed
CrazyCoder opened this issue Sep 17, 2023 · 12 comments
Closed

PC can't properly enter the sleep mode when PinOne is connected #1

CrazyCoder opened this issue Sep 17, 2023 · 12 comments

Comments

@CrazyCoder
Copy link
Contributor

PC immediately wakes up until I disconnect the USB. This happens with Virtual Pinball PinOne Mini Machine.

The firmware needs to handle suspend mode.

Related:

@philipellisis
Copy link
Owner

I would recommend just setting windows to power off the usb device when the computer shuts down or is sleeping. This will also ensure all the LEDs turn off.

And another option -- I do not have this issue on my PC when it is sleeping, but I am wondering if the problem could be related to the accelerometer sending a signal. Can you try setting the "dead zone" a bit higher to see if that resolves the issue?

@CrazyCoder
Copy link
Contributor Author

If you mean the USB selective suspend power option, then it's not a good workaround. I want my other devices to remain working so that I can wake the PC with keyboard, for example.

Many keyboards and other devices support this option. For example, it's available in QMK keyboard firmware, and the keyboards turn off the backlight when the device is in sleep mode and turn it on automatically when the device wakes up.

I still believe there needs to be a proper suspend option in firmware that will turn off the LEDs and disable the accelerometer to prevent accidental wakeup.

I think my dead zone was already set pretty high for the accelerometer and it was not causing the stick movements in Steam controller test UI. I'll double-check again later.

@philipellisis
Copy link
Owner

Another thing to try is in device manager just uncheck the box that allows it to wake the computer from sleep, and also check the box to allow the save power by turning off the device while asleep. That could resolve the issue for you. You can find the device by looking for the Bus Reported device description flag
image

@CrazyCoder
Copy link
Contributor Author

CrazyCoder commented Sep 21, 2023

I double checked that dead zone is not the case, the device still wakes the PC instantly with the following:

C:\Windows\System32>powercfg -lastwake
Wake History Count - 1
Wake History [0]
  Wake Source Count - 1
  Wake Source [0]
    Type: Device
    Instance Path: PCI\VEN_8086&DEV_7A60&SUBSYS_88821043&REV_11\3&11583659&0&A0
    Friendly Name: Intel(R) USB 3.20 eXtensible Host Controller - 1.20 (Microsoft)
    Description: USB xHCI Compliant Host Controller
    Manufacturer: Generic USB xHCI Host Controller

The option to wake the computer from sleep is disabled and unchecked:

image

My PinOne is plugged in into the powered USB hub, maybe that prevents it from turning off?

I hope the proper suspend is implemented in the firmware, otherwise I have to unplug the device every time I suspend the PC.

@philipellisis
Copy link
Owner

Sounds like it could be the USB hub because I don't have any issues on any of the computers I have tested it on and even the wake event is tied to the USB hub and not the PinOne board. In either case I will at least look into implementing some kind of sleep procedure but it is not a high priority at this time and I will need to ensure that it doesn't affect the performance of the device too.

@CrazyCoder
Copy link
Contributor Author

This may be the issue caused by the Joystick library you are using. A similar issue was mentioned here: MHeironimus/ArduinoJoystickLibrary#197.

@CrazyCoder
Copy link
Contributor Author

CrazyCoder commented Sep 21, 2023

It looks like you can fix it by applying this logic: MHeironimus/ArduinoJoystickLibrary#242 (comment). I didn't check your code yet, but maybe you are sending some updates even if the values did not change?

EDIT:

From first look, it might very well be the case:

_joystick->setXAxis(xValue);

This example doesn't send the value if it's the same, but your code doesn't have this check:

https://github.com/MHeironimus/ArduinoJoystickLibrary/blob/12cf2bbdb8910619d32ba3bf4b7d669c8e813b99/examples/FunduinoJoystickShield/FunduinoJoystickShield.ino#L65

@philipellisis
Copy link
Owner

Yes I have thought of this, I can do some checking to determine if the value has changed before sending out to the computer. The problem is the analog outputs for the accelerometer and plunger as you typically want those values sent regardless of position. I will have to have some kind of timer to turn off the sending of events after a period of time of no activity and then be able to quickly start sending events again once activity is seen.

@CrazyCoder
Copy link
Contributor Author

CrazyCoder commented Sep 21, 2023

From what I can see, the values for accelerometer and plunger that are sent via _joystick->set*Axis are already adjusted/filtered/smoothed and remain the same until the plunger is really moved, or the accelerometer values exceed the dead zones. I can confirm it in the Steam controller testing UI. The sticks do not move and the values do not change. So, a simple check for the same value and not sending it every time would likely be enough.

The raw values you send via serial should not be a problem (AFAIK, it's not causing the wake).

@philipellisis
Copy link
Owner

I'll try it that way. the serial commands are only sent when connected to the config tool so those should be fine. I was thinking that the plunger will end up sending something occasionally since it's an analog read and even a difference in one digit will cause it to send a new value, but I'll start by adjusting that value and see if it fixes the issue for you.

@CrazyCoder
Copy link
Contributor Author

Here is a more easy and straightforward fix: #2.

I verified that it works and fixes the issue for me.

@philipellisis
Copy link
Owner

Very nice, I didn't realize that check was available with no additional imports or coding.

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