2 Copyright (C) 2007 Peter Mackay and Chris Swindle.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "../quakedef.h"
28 #include "battery.hpp"
34 // The previous battery level.
35 static int lastLevel
= scePowerGetBatteryLifePercent();
36 static bool lastCharging
= scePowerGetBatteryChargingStatus();
41 if (!scePowerIsBatteryExist())
43 // Don't report anything.
47 // Get the new battery status.
48 const int level
= scePowerGetBatteryLifePercent();
49 const bool charging
= scePowerGetBatteryChargingStatus();
51 // Is the level not sensible?
52 if ((level
< 0) || (level
> 100))
54 // Hopefully it will be sensible soon.
58 // Has the battery status changed?
59 if ((level
!= lastLevel
) || (charging
!= lastCharging
))
65 Con_Printf("Battery %d%% (charging)\n",
70 // How much time is left?
71 const int timeLeft
= scePowerGetBatteryLifeTime();
73 // Is the time sensible?
76 // Convert the time to something readable.
77 const int hoursLeft
= timeLeft
/ 60;
78 const int minutesLeft
= timeLeft
% 60;
81 Con_Printf("Battery %d%% (%d hour%s %d minute%s)\n",
84 (hoursLeft
== 1) ? "" : "s", // Handle pluralisation of hour(s).
86 (minutesLeft
== 1) ? "" : "s"); // Handle pluralisation of minute(s).
90 // It's a silly time, just report the battery level.
91 Con_Printf("Battery %d%%\n",
96 // Remember the status for next frame.
98 lastCharging
= charging
;