Battery + Wireless Gui Controls
by Eric Hartman · 05/07/2007 (11:44 pm) · 6 comments
Download Code File
This resource implements two gui controls that display wireless connectivity and battery levels using the Intel Laptop Gaming TDK. Many of the TDK functions are also exposed to script. By monitoring the battery level of a laptop and throttling game performance accordingly, it is possible to significantly extend battery life.
Add the following files your VC++ (or whatever) project:
--------------------------------------------------------
guiIntelBatteryMeter.cc
guiIntelBatteryMeter.h
guiIntelConnectivityMeter.cc
guiIntelConnectivityMeter.h
laptopConsoleFunctions.cc
IntelLaptopGaming.lib
IntelGamingTDKAPI.h
Place this file in the same folder as your Torque executable
--------------------------------------------------------
IntelLaptopGaming.dll
Other Files:
--------------------------------------------------------
BatterySaving.cs - An example script of how to throttle game performance based on remaining battery life.
The source code for the dll file as well as more information on the Intel Laptop Gaming TDK can be found here: http://softwarecommunity.intel.com/articles/eng/1017.htm
The GuiIntelConnectivityMeter switches between 5 different images depending on wireless signal strength, plus a 6th image for wired mode. The thresholds for each image are configurable through the "wirelessThresholds" field of the gui control.
The GuiIntelBatteryMeter is a bar graph that changes smoothly in size and color depending on the battery level (colors and thresholds for each color are configurable). One of two images overlayed on top of the bar depending on if you are using ac power or the battery. When you are on ac power the battery level is still displayed, but it is always displayed in the top color threshold (green in this example)
The following console functions are implemented:
--------------------------------------------------------
IsLaptop()
IsWirelessAdapterConnected()
IsWirelessAdapterEnabled()
GetConnectedAdapter()
GetNumCoresPerProcessor()
GetCurrentCPUUtilization()
GetCurrentCPUFrequency()
GetMaxCPUFrequency()
GetSecBatteryLifeTimeRemaining()
GetPowerSrc()
Returns one of the following strings:
Battery_Power
AC_Power
Undefined
Error
GetPercentBatteryLife()
Returns a value from 0.0 to 1.0
GetCurrentPowerScheme();
Returns one of the following strings:
Throttle_None
Throttle_Constant
Throttle_Degrade
Throttle_Adaptive
Throttle_Undefined
Error
SetCurrentPowerScheme();
Accepts the following strings and sets the power scheme accordingly
Throttle_None
Throttle_Constant
Throttle_Degrade
Throttle_Adaptive
If an invalid string is specified, an error message is displayed
Get80211SignalStrength();
Returns a value from 0.0 to 1.0
These two functions are provided for testing purposes:
--------------------------------------------------------
SetFakeConnectivityLevel(float);
Accepts a number from 0.0 to 1.0 to use for the fake battery level.
SetFakeBatteryLevel(float);
Accepts a number from 0.0 to 1.0 to use for the fake battery level.
This resource implements two gui controls that display wireless connectivity and battery levels using the Intel Laptop Gaming TDK. Many of the TDK functions are also exposed to script. By monitoring the battery level of a laptop and throttling game performance accordingly, it is possible to significantly extend battery life.
Add the following files your VC++ (or whatever) project:
--------------------------------------------------------
guiIntelBatteryMeter.cc
guiIntelBatteryMeter.h
guiIntelConnectivityMeter.cc
guiIntelConnectivityMeter.h
laptopConsoleFunctions.cc
IntelLaptopGaming.lib
IntelGamingTDKAPI.h
Place this file in the same folder as your Torque executable
--------------------------------------------------------
IntelLaptopGaming.dll
Other Files:
--------------------------------------------------------
BatterySaving.cs - An example script of how to throttle game performance based on remaining battery life.
The source code for the dll file as well as more information on the Intel Laptop Gaming TDK can be found here: http://softwarecommunity.intel.com/articles/eng/1017.htm
The GuiIntelConnectivityMeter switches between 5 different images depending on wireless signal strength, plus a 6th image for wired mode. The thresholds for each image are configurable through the "wirelessThresholds" field of the gui control.
The GuiIntelBatteryMeter is a bar graph that changes smoothly in size and color depending on the battery level (colors and thresholds for each color are configurable). One of two images overlayed on top of the bar depending on if you are using ac power or the battery. When you are on ac power the battery level is still displayed, but it is always displayed in the top color threshold (green in this example)
The following console functions are implemented:
--------------------------------------------------------
IsLaptop()
IsWirelessAdapterConnected()
IsWirelessAdapterEnabled()
GetConnectedAdapter()
GetNumCoresPerProcessor()
GetCurrentCPUUtilization()
GetCurrentCPUFrequency()
GetMaxCPUFrequency()
GetSecBatteryLifeTimeRemaining()
GetPowerSrc()
Returns one of the following strings:
Battery_Power
AC_Power
Undefined
Error
GetPercentBatteryLife()
Returns a value from 0.0 to 1.0
GetCurrentPowerScheme();
Returns one of the following strings:
Throttle_None
Throttle_Constant
Throttle_Degrade
Throttle_Adaptive
Throttle_Undefined
Error
SetCurrentPowerScheme();
Accepts the following strings and sets the power scheme accordingly
Throttle_None
Throttle_Constant
Throttle_Degrade
Throttle_Adaptive
If an invalid string is specified, an error message is displayed
Get80211SignalStrength();
Returns a value from 0.0 to 1.0
These two functions are provided for testing purposes:
--------------------------------------------------------
SetFakeConnectivityLevel(float);
Accepts a number from 0.0 to 1.0 to use for the fake battery level.
SetFakeBatteryLevel(float);
Accepts a number from 0.0 to 1.0 to use for the fake battery level.
About the author
Recent Blogs
• GameDev.net Article #2!• GameDev.net Article!
• Pong in Blockland!
• Blockland > 1,000,000
• Blockland Released...
#2
05/12/2007 (11:25 pm)
Great resource! helped me quite a bit, thanks!
#3
Currently I keep getting:
fatal error C1083: Cannot open include file: 'IntelGamingTDKAPI.h': No such file or directory
05/20/2007 (10:40 pm)
I'm having a problem getting this to compile. Is it necessary to include the IntelLaptopGamingTDK within the TGE project? Currently I keep getting:
fatal error C1083: Cannot open include file: 'IntelGamingTDKAPI.h': No such file or directory
#4
I have updated the zip file.
05/29/2007 (5:56 pm)
Apparently I forgot to include that file in the archive. Which brings up the interesting fact that in VC++ you are able to #include files that are not actually in your project. I have updated the zip file.
#5
fatal error C1083: Cannot open include file: 'ILGdefines.h': No such file or directory
please help with this, i've already link the library to the linker, and place the header files just like the instruction on the readme.txt
thx
01/17/2008 (4:29 am)
Hi, I got a problem when compiling the tdk with the engine, this is the error log:fatal error C1083: Cannot open include file: 'ILGdefines.h': No such file or directory
please help with this, i've already link the library to the linker, and place the header files just like the instruction on the readme.txt
thx
#6
cheers.
07/11/2008 (10:48 am)
ok, I can get the ILGdefines.h and other header from www.intel.com/software/laptopgamingtdk and install it first on my box.cheers.
Torque Owner Martin Schultz