Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

Can't set ALS sensors sensitivity

AndreR
Beginner
259 Views

Hi,

I want to set the sensitivity for my ALS sensor driver. I can set the value via SensorViewer but I have no access via HECI. I'm able to get sensor data via HECI. I use in my app the sensor property SENSOR_PROPERTY_CHANGE_SENSITIVITY. The type of the value is unknown. See Sensor Properties - Windows drivers | Microsoft Learn

Can you share with me an example how to set the value?

I use this code for the moment and I didn't get any error:

 

HRESULT SensorManager::SetSensitivity(ISensor* pSensor, ULONG ulSensitivity)
{
assert(pSensor);
 
HRESULT hr = S_OK;
 
// Configure sensitivity
// Create an IPortableDeviceValues container to hold the <Data Field,
IPortableDeviceValues* pInSensitivityValues;
hr = ::CoCreateInstance(CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pInSensitivityValues));
if (FAILED(hr))
{
//::MessageBox(NULL, _T("Unable to CoCreateInstance() a PortableDeviceValues collection."), _T("HBS C++ Sample"), MB_OK |MB_ICONERROR);
        cout << "Unable to CoCreateInstance() a PortableDeviceValues collection." << endl;
return -1;
}
 
PROPVARIANT pv;
PropVariantInit(&pv);
pv.vt = VT_R8; // COM type for (double)
pv.dblVal = (double)ulSensitivity;
pInSensitivityValues->SetValue(SENSOR_DATA_TYPE_SENSOR_DATA_STATE, &pv);
 
// create an IPortableDeviceValues container for holding the <SENSOR_PROPERTY_CHANGE_SENSITIVITY, pInSensitivityValues> tuple.
IPortableDeviceValues* pInValues;
hr = ::CoCreateInstance(CLSID_PortableDeviceValues, NULL,CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pInValues));
if (FAILED(hr))
{
 
//::MessageBox(NULL, _T("Unable to CoCreateInstance() a PortableDeviceValues collection."), _T("HBS C++ Sample"), MB_OK |MB_ICONERROR);
        cout << "Unable to CoCreateInstance() a PortableDeviceValues collection." << endl;
return -1;
}
// fill it in
pInValues->SetIPortableDeviceValuesValue(SENSOR_PROPERTY_CHANGE_SENSITIVITY, pInSensitivityValues);
// now actually set the sensitivity
IPortableDeviceValues* pOutValues;
hr = pSensor->SetProperties(pInValues, &pOutValues);
if (FAILED(hr))
{
//::MessageBox(NULL, _T("Unable to SetProperties() for Sensitivity."),_T("HBS C++ Sample"), MB_OK | MB_ICONERROR);
        cout << "Unable to set sensitivity" << endl;
return -1;
}
 
PropVariantClear(&pv);
 
 
return hr;
}
0 Kudos
0 Replies
Reply