mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
apds9930: enable sensor before read out sensor data
Changes in library: - enableProximity() function is to enable or disable proximity sensor - enableIlluminance() function is to enable or disable illuminance sensor - run clang-format Changes in example: - proximity and illuminance kernel IIO-based driver init state is power off, require enable before read out sensor data. Sleep time is needed after enable, the sleep time may vary on different platform. - run clang-format Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
40fe6654eb
commit
e64f192fb7
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -46,6 +46,15 @@ main()
|
||||
// Instantiate a Digital Proximity and Ambient Light sensor on iio device 4
|
||||
upm::APDS9930* light_proximity = new upm::APDS9930(4);
|
||||
|
||||
// Kernel driver implement sleep 5000-5100us after enable illuminance sensor
|
||||
light_proximity->enableIlluminance(true);
|
||||
|
||||
// Kernel driver implement sleep 5000-5100us after enable proximity sensor
|
||||
light_proximity->enableProximity(true);
|
||||
|
||||
// Tested this value works. Please change it on your platform
|
||||
usleep(120000);
|
||||
|
||||
while (shouldRun) {
|
||||
float lux = light_proximity->getAmbient();
|
||||
cout << "Luminance value is " << lux << endl;
|
||||
@ -53,6 +62,8 @@ main()
|
||||
cout << "Proximity value is " << proximity << endl;
|
||||
sleep(1);
|
||||
}
|
||||
light_proximity->enableProximity(false);
|
||||
light_proximity->enableIlluminance(false);
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
|
Reference in New Issue
Block a user