I am designing a battery powered microcontroller circuit that will spend the vast majority of its life turned off. (In the absence of other recommendations, I'm thinking a few AA batteries in series followed by a linear voltage regulator is what I'm likely to use, but if there are other solutions that are better suited to this application, I'm all ears.)
A physical toggle switch will be used to turn the circuit on. As long as the switch is on, the circuit will 'do stuff.' The physical switch is a non-negotiable part of the design.
When the switch is turned off, the circuit will need another 2-3 seconds to finish its work, then should be powered off. It can then remain powered off for months at a time. I would like to maximize battery life by reducing/eliminating current draw when the circuit is inactive.
What kind of power solution can I use to meet these goals? I imagine that I'll use a GPIO on the microcontroller to signal, 'hey, I still need power,' and will need some kind of 'logical-OR' power control that will power the microcontroller when either the switch or the GPIO pin is active.