PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

battery usage

I played Snails for an hour (on a fully charged unit) and it dropped my battery meter to 69% while I played Hyperspace Delivery Boy (on a fully charged unit too) and after playing for an hour, it dropped my batt meter to just 44%. I'm using the same device, an h1910. My question is, are there any tips/info I should know in coding my own game, that will require less battery resource? Why are there games that drain the batteries faster than the others? Any info will be greatly appreciated.

Regards,

Erick :)
Any game that uses the processor more will require more battery. Use low quality images and sounds (not COMPRESSED! Compression algorithms take up more processing power), and keep the main function loop as limited as possible. Just be very conservative about how much processing power your program uses. Like in Snails, when the enemy is thinking about their next move the blitting is slowed to 1 frame a second. That saves a little battery life, and speeds up the thinking process. Economy is what it's all about, be a penny pincher.
Call Sleep whenever you have extra CPU cycles for that frame. That allows the OS to reduce CPU power consumption. Basically, the more simplistic a game is (for example a card or board game), the less constant CPU usage it will require. So obviously not all games can spare CPU cycles each frame.

Dan East
Compressing an image wont be a big deal since to actually use the data you usually need to create a bitmap surface which only requires uncompressing once.
Dan East wrote:
Call Sleep whenever you have extra CPU cycles for that frame. That allows the OS to reduce CPU power consumption. Basically, the more simplistic a game is (for example a card or board game), the less constant CPU usage it will require. So obviously not all games can spare CPU cycles each frame.

Dan East


This is also true on desktop machines running Windows in the same way as on Windows CE - very true when you are running on batteries. Basically for any given thread you should either be using GetMesssage (which blocks for most of the time) or Sleep.

Windows may be a preemptive multitasking operating system (as least, that's what they tell me), but by default it runs code as fast as it possibly can until your battery is deaded.
Thanks a lot for the tips guys. :)