Hey Tiny... Duiners!?
I'm doing a fairly simple virtual pet "game" using TinyScreen+ (Video Player kit). It's mostly short processed videos of our pet in an interactive shell so that it's kind of "alive" and has "needs" (tamagotchi like). Still WIP, I have a strict deadline for a gift to my wife
Would be neat to make it less power hungry. How do you make TinyScreen+ sleep for, say, 300ms (consuming very minimal power)? I think I figured out how to do deep sleep interrupted by press of a button:
```
attachInterrupt(TSP_PIN_BT1, blink, LOW);
attachInterrupt(TSP_PIN_BT2, blink, LOW);
attachInterrupt(TSP_PIN_BT3, blink, LOW);
attachInterrupt(TSP_PIN_BT4, blink, LOW);
display.off();
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI();
detachInterrupt(TSP_PIN_BT1);
detachInterrupt(TSP_PIN_BT2);
detachInterrupt(TSP_PIN_BT3);
detachInterrupt(TSP_PIN_BT4);
delay(500); // Just to ignore the already pressed button for 0.5s
display.on();
```
I'm pretty new at C++ and embedded. Looks as if this works (does it look so to you?), but still measuring the battery life with and without this mode on. What I cannot figure out though, is how to make it wake up by itself, say in 300ms? I know I need to crank up some magic clocks like TC5 and fiddle with some register, but I decided to not read the entire datasheet for SAMD21 just yet and ask if maybe some one has a routine handy for sleeping? And all of that is assuming that the built-in "delay" function is not good. I looked at its source code and it looks like it's just a `while` loop, so must be burning through these mAh pretty quick.
Willing to keep doing my research, but hit a roadblock for now, tough to get oriented in the world of C++ in a couple of weeks (I'm a .NET dev)