What I need is the laptop to come out of sleep when the ignition is on and go to sleep when its off. This was easy enough to do with a PIC and works ok until the ignition is switched on and off quickly (if the car doesn't start first turn for instance) and then because the waking/standby cycle takes about 10 seconds the whole thing can get out of sequence.
How about programming your PIC with a delay time greater than the amount of time it takes your laptop to go into/out of sleep mode. When the ignition is turned on, have the PIC take the laptop out of sleep, but then it will wait at least 10 seconds before attempting to put the laptop back into sleep. Same for ignition off going back to sleep.
Maybe also have a pre-change delay, so that:
1. If you turn ignition on and then off quickly (e.g. to roll up/down your windows without starting the car), the laptop stays asleep.
2. If you turn the car off and on quickly (say you drive a stick and stalled it and need to restart), the laptop stays awake.
3. Once the ignition has been on for 10 seconds, the laptop comes out of sleep. If the ignition is then shut off, the PIC will wait an additional 10 seconds to ensure the laptop is out of sleep before it goes back to sleep.
3. Once the ignition has been off for 10 seconds, the laptop goes into sleep. If the ignition is then switched back on, the PIC will wait an additional 10 seconds to ensure the laptop is asleep before it wakes it back up.
The green power light simply flashes instead of being on steady.
There you go. Wire the power LED to an input on your PIC, or use a photodiode/phototransistor/LDR taped over the LED, and have it sense the laptop's state that way. If the light is on steady, the laptop is awake. If it's flashing, it's on standby. If it's off, it's shut down. Then you can send whatever signal is appropriate to wake it up/put it to sleep/power it up.