Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Devices
Sensor API
Getting Started
 About the Samples and Tools
About the Samples and Tools

The Windows SDK includes useful code samples and tools to help you understand and use the Windows Sensor and Location platform and related APIs.

Samples

The Windows SDK includes the following Sensor API samples. You can find the Sensor API samples in the folder named \Samples\winui\Sensors, where you installed the Windows SDK. For example, if you installed the Windows SDK on drive C, you would find the samples in the following folder: C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\winui\Sensors.

Sample nameDescription
AmbientLightAware

This MFC sample shows how to use the Sensor API by reading data from ambient light sensors on the computer and changing text size according to the lighting conditions. You can see code that shows how to manage events and how to request user permissions. You can also see an example of how to manage the user interface based on varying lighting conditions. For more information, see Creating Light-Aware User Interfaces.

You must have Visual Studio 2008 installed to build this sample.

 

For more information, see the file named ReadMe.txt that is included with the sample.

You can also download the AmbientLightAware sample from Code Gallery. For more information, see the Ambient Light Aware download page.

Tools

The Windows SDK includes a virtual light sensor that you can use to simulate a hardware-based light sensor device. You can use this tool to provide data to the AmbientLightAware sample to see how the code in the sample works.

The following table describes the files you must use to run the virtual light sensor. You can find these files in the folder named Bin, where you installed the Windows SDK. For example, if you installed the Windows SDK on drive C on a 32-bit computer, you would find the virtual light sensor files in the following folder: C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin. On 64-bit computers, you must use the 64-bit version of the tool. In the Windows SDK, 64-bit tools are located in the subfolder named x64.

File nameDescription
VirtualLightSensor.exeThis program provides a slider control that enables you to change the level of the light data that the virtual sensor reports.
VirtualLightSensorDriver.dllThe logical sensor driver that simulates a light sensor.
VirtualLightSensorDriver.infThe INF file for the virtual light sensor driver.

 

Installing the Virtual Light Sensor

Before you use the virtual light sensor application, you must install the logical sensor driver. Follow these steps:

  1. Open a command window as an administrator.
  2. Change to the Windows SDK Bin folder.
  3. Type pnputil -a VirtualLightSensorDriver.inf.
  4. When prompted, click Install this driver software anyway.
  5. Wait for the command window to report that the driver was successfully installed.

Running the Virtual Light Sensor

To run the virtual light sensor, simply double-click the .exe file. Be sure to enable the sensor, when prompted.

When you run the program, you may notice that there is a delay before the sensor becomes available. The virtual light sensor user interface will display the message "Waiting" in the title bar while the logical sensor manager creates a device node for the logical sensor. After the waiting message goes away, you can use the slider to set the lux output level for the virtual light sensor.

The following image shows the virtual light sensor user interface in its ready state.

Virtual light sensor user interface

Related topics

About Logical Sensors
SENSOR_CATEGORY_LIGHT

 

 

Build date: 3/6/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
has been a "waiting"      hawk_wu ... Thomas Lee   |   Edit   |   Show History
Open the virtual light sensors, but she has been in a "waiting", how to troubleshoot?

[tfl - 20 11 11] Hi - and thanks for your post. Community content is not the appropriate place for technical support queries. Instead, you should visit the Technet Forums at http://forums.microsoft.com/msdn, where such posts are welcomed and where you stand a much better chance of getting your query resolved. Sorry if that's not the answer you wanted to hear.

Tags What's this?: Add a tag
Flag as ContentBug
How to do?      hawk_wu ... Thomas Lee   |   Edit   |   Show History
Now you can slide, but the state is "AccessDenied"

How to do?

I add the SensorManager.RequestPermission, but throw exception

[tfl - 20 11 11] Hi - and thanks for your post. Community content is not the appropriate place for technical support queries. Instead, you should visit the Technet Forums at http://forums.microsoft.com/msdn, where such posts are welcomed and where you stand a much better chance of getting your query resolved. Sorry if that's not the answer you wanted to hear.
Sensor Calls for WinXP?      HeRingsMe   |   Edit   |   Show History
We need to do ambient light manipulations on an XP Tablet platform. Can someone direct me to the Windows calls for handling this in XP?
Thanks.
Tags What's this?: Add a tag
Flag as ContentBug
Re: Sample code      WindowsNT   |   Edit   |   Show History
The 7.0 WDK contains samples (UMDF Drivers).

Tags What's this?: Add a tag
Flag as ContentBug
Sample code for a Logical Sensor?      Greg Bray   |   Edit   |   Show History
What would really be helpful is sample code for a logical sensor. I downloaded the SDK but it only includes the binary files for the Virtual Light Sensor Driver. Any other content or sample code for how to write a driver for a software based sensor?
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker