2014-08-12 16:53:16 +01:00
|
|
|
/*
|
|
|
|
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
2014-12-04 10:40:39 +00:00
|
|
|
* Contributions: Sarah Knepper <sarah.knepper@intel.com>
|
2014-08-12 16:53:16 +01:00
|
|
|
* Copyright (c) 2014 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2014-08-12 16:53:16 +01:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-08-12 16:53:16 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-09-09 14:10:30 -07:00
|
|
|
#include "light.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2014-08-12 16:53:16 +01:00
|
|
|
|
|
|
|
int
|
2017-08-30 15:00:29 -07:00
|
|
|
main(int argc, char** argv)
|
2014-08-12 16:53:16 +01:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
2014-12-04 10:40:39 +00:00
|
|
|
// Create the light sensor object using AIO pin 0
|
2017-08-30 15:00:29 -07:00
|
|
|
upm::Light light(0);
|
2014-08-12 16:53:16 +01:00
|
|
|
|
2017-03-17 16:18:40 -06:00
|
|
|
// Read the input and print both the normalized ADC value and a
|
|
|
|
// rough lux value, waiting one second between readings
|
2017-08-30 15:00:29 -07:00
|
|
|
while (1) {
|
|
|
|
std::cout << light.name() << " normalized value is " << light.getNormalized()
|
|
|
|
<< ", which is roughly " << light.value() << " lux" << std::endl;
|
|
|
|
upm_delay(1);
|
2014-12-04 10:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the light sensor object
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
2014-08-12 16:53:16 +01:00
|
|
|
return 0;
|
|
|
|
}
|