Mixtel90
 Guru
 Joined: 05/10/2019 Location: United KingdomPosts: 7341 |
Posted: 09:14am 22 Jan 2025 |
|
|
|
Hmmm... There's usually a hardware answer. :)
Put a series resistor and capacitor on a GPIO pin. Put a diode from the top of the cap to 3V3, so that it's reverse-biased. Use SETPIN GPn DOUT / PIN(GPn)=1 to charge the capacitor (then SETPIN GPn OFF to isolate it if you want to). Even a small cap will stay charged for some time. When you boot the pin will be set as input by default so just use a%=pin(GPn) to read the status. When the power goes off the cap will discharge through the collapsing 3V3 rail so the flag will reset. |