mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
grovelight.cxx: improve example code
Signed-off-by: Sarah Knepper <sarah.knepper@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
parent
0ff9c7afcc
commit
a1abab8909
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||||
|
* Contributions: Sarah Knepper <sarah.knepper@intel.com>
|
||||||
* Copyright (c) 2014 Intel Corporation.
|
* Copyright (c) 2014 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -29,11 +30,19 @@
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// This example uses AIO 0
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
// Create the light sensor object using AIO pin 0
|
||||||
upm::GroveLight* light = new upm::GroveLight(0);
|
upm::GroveLight* light = new upm::GroveLight(0);
|
||||||
int lightValue = light->value();
|
|
||||||
|
|
||||||
|
// Read the input and print both the raw value and a rough lux value,
|
||||||
|
// waiting one second between readings
|
||||||
|
while( 1 ) {
|
||||||
|
std::cout << light->name() << " raw value is " << light->raw_value() <<
|
||||||
|
", which is roughly " << light->value() << " lux" << std::endl;
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the light sensor object
|
||||||
delete light;
|
delete light;
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user