0

Ability to detect/sleep when computer sleeps?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Ability to detect/sleep when computer sleeps?

by ryanpavlik on Mon Aug 02, 2021 11:54 am

I've got my ADABOX 019 MacroPad plugged in and starting to be customized. I do notice, however, that it appears to stay fully alive and glowing brightly even when my computer sleeps. It is plugged into a powered USB hub, so I imagine that's why it stays up, but I have other devices that appear to detect that the computer behind the hub is sleeping and react accordingly. (The most noisy of which is an Android phone, but I think a few other things do it too)

Is there a way to similarly detect the computer disconnect without power loss and sleep in CircuitPython? I don't want to burn out the RGB nor the OLED prematurely.

ryanpavlik
 
Posts: 16
Joined: Wed Jan 01, 2020 6:07 pm

Re: Ability to detect/sleep when computer sleeps?

by adafruit_support_mike on Tue Aug 03, 2021 9:12 pm

The other devices are probably watching the keep-alive packets sent by the computer at 1ms intervals. That’s USB’s way of detecting hardware in the device tree.

The RP2040 can probably do that, but it isn’t a standard part of the USB code. Adding it as a feature would be a mid-level challenge for someone famiiliar with USB in general.

adafruit_support_mike
 
Posts: 63701
Joined: Thu Feb 11, 2010 2:51 pm

Re: Ability to detect/sleep when computer sleeps?

by ryanpavlik on Thu Aug 05, 2021 5:16 pm

Ah, thanks for the info. A solution like the red vs green neopixel in the UF2 bootloader is depending on the receipt of enumeration requests, not continued keep-alive, I bet. I might be able to do the USB work, but I don't really have time now.

Think I'll just have a timeout from "any interaction" for now then. Thanks!

ryanpavlik
 
Posts: 16
Joined: Wed Jan 01, 2020 6:07 pm

Re: Ability to detect/sleep when computer sleeps?

by adafruit_support_mike on Sat Aug 07, 2021 8:13 pm

ryanpavlik wrote:A solution like the red vs green neopixel in the UF2 bootloader is depending on the receipt of enumeration requests, not continued keep-alive, I bet.

I think that’s right, but haven’t read that collection of code.

ryanpavlik wrote:Think I'll just have a timeout from "any interaction" for now then. Thanks!

If you want to have some fun with it, you could add a light sensor or a capacitive proximity sensor as a wake-up signal.

There’s a story about Bob Widlar, one if the great geniuses of early IC design, and his hardware tech: Widlar had designed an automated test circuit for an op amp he was working on, and gave the plans to his tech for assembly. The tech, knowing Widlar’s sense if humor, decided to have some fun with it.

Widlar came in a couple of days later to find the box sitting on his desk with a chip slotted in for testing, but there was no power switch or control button.. just a circle drawn in marker on the faceplate and the words “touch here”.

He touched the circle, and the machine did a full test cycle. He touched it again, and the machine did another test.

The body of the machine was made from copper-clad, and it was common practice to put the copper side in so the outside was just blank PCB substrate. The tech had cut away a small circle of copper foil and glued a photosensor over it. It was invisible from the outside, but enough ambient light filtered through the plastic to know if the sensor was covered or not.

Widlar loved it, and showed it to everyone like a kid with a new toy.

adafruit_support_mike
 
Posts: 63701
Joined: Thu Feb 11, 2010 2:51 pm

Re: Ability to detect/sleep when computer sleeps?

by ryanpavlik on Mon Aug 09, 2021 10:18 pm

That's a great story. I'm no Widlar, but I do have a photodiode hot-glued to the "done" led on my washer to make it IOT. I'll definitely consider that technique for the macro pad since the "no activity" timeout isn't quite as satisfying as I'd hoped.

ryanpavlik
 
Posts: 16
Joined: Wed Jan 01, 2020 6:07 pm

Re: Ability to detect/sleep when computer sleeps?

by adafruit_support_mike on Tue Aug 10, 2021 4:48 pm

The nice thing about personal and one-off projects is that you can devote an unreasonable amount of hardware to doing something cool.

That's a strong advantage Makers have over the commercial industrial sector: they can leverage economies of scale, but we can afford things they'd never consider. For a production line building 100k batches, adding $1 per unit costs $100k. For a one-off project it costs $1, so why not? We can spend an hour matching resistors or transistors and be set for months of precision work. They have to design to 1% or 5% tolerance because they can't afford that kind of additional effort.

That being the case, there's a fairly strong business case for spending a little more time, material, and effort on things that are simply fun.

adafruit_support_mike
 
Posts: 63701
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.