I always wanted to be able to use regular sleep of the Mac, but some of the issues were holding me back and making me stick to the deep sleep. The main problem was the risk of waking the Mac up at wrong moment. It is quite easy to bump into the controller when putting my stuff into the car. And if the ignition is not on at that moment (which is pretty likely), the P1900 detects high current and kills the mini.
Another issue we had to solve was the connection of the power button for the dock. Carnetix supplies an "Y" cable which allows the power button to be controlled by the P1900. Unfortunately, this connection is very difficult to impossible to incorporate into a dock. We did not want to install additional connectors to the mini's back side. So we had to find another solution. And well, we did find it.
It is well known, that any activity on the USB wakes Mac up if it is in the normal sleep mode. Pressing a button on a keyboard or a mouse, adding or removing a device. We can use this behaviour to both wake the mini up at the right time and prevent it from waking up when not appropriate.
The key is in the way the USB devices are powered. They can be either powered from the bus itself, or they can use an external power supply. Most of the hubs are bus-powered, but also allow connection of external power supply. Some of them use this power supply to completely power the hub, some only use the external power supply to distribute power to the connected devices, while the hub's own logical circuits are always powered from the bus.
If a USB hub can be completely powered by an external power supply (such as P5V or secondary output of P1900), it is possible to cut the power that the hub gets over the USB cable either by cutting the red wire in the cable or by insulating the pin 1 on the USB connector by piece of adhesive tape or similar material. When this is done, the hub's power state can be controlled simply by turning the external power on and off. If the power is on, the hub operates normall. If the power is off, the hub is also off and is not visible on the USB. This is also true for any devices connected to the hub. So if the Mac is asleep and a keyboard is connected to hub, which is turned off, the press of a key on this keyboard will not wake up the Mac.
And it get even better. When the hub is powered up, it becomes visible to the Mac over the USB. If the Mac is sleeping at the time, this will trigger wake-up. Therefore if the power to the hub is supplied by a source, that follows the state of the ignition/acc line, the Mac will never wake up when the ignition is off and will always wake up when the ignition is turned on. This leaves us with the last problem - how to put the computer to sleep?
The solution is again pretty simple. When the ignition is turned off, the USB devices are powered down and become invisible to the computer. The solution is to run a simple application on the Mac, that controls the presence of certain device(s). When the devices are not accessible, it means the hub has been powered down because the ignition is down. So when the application detects the device it watches is missing, it puts the computer to sleep.
The "USB watchdog" module for QCar is just being tested. I will post more details about the wiring and the relevant pieces of code probably over the next weekend. It should be easy to use this principle in other applications as well.