Interface for Light Sensors
This interface is used to represent light sensors
{
try {
lightSensor =
new upm::SI1132(mraa_get_sub_platform_id(FT4222_I2C_BUS));
return lightSensor;
} catch (std::exception& e) {
std::cerr << "SI1132: " << e.what() << std::endl;
}
try {
return lightSensor;
} catch (std::exception& e) {
std::cerr << "MAX44009: " << e.what() << std::endl;
}
return lightSensor;
}
int main ()
{
if (lightSensor == NULL) {
std::cout << "Light sensor not detected" << std::endl;
return 1;
}
std::cout <<
"Light sensor " << lightSensor->
getModuleName() <<
" detected" << std::endl;
while (true) {
try {
std::cout << "Light level = " << value << " lux" << std::endl;
} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
}
sleep(1);
}
delete lightSensor;
return 0;
}