mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
guvas12d: C implementation; FTI; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
@ -33,40 +33,40 @@ bool shouldRun = true;
|
||||
|
||||
// analog voltage, usually 3.3 or 5.0
|
||||
#define GUVAS12D_AREF 5.0
|
||||
#define SAMPLES_PER_QUERY 1024
|
||||
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
if (signo == SIGINT)
|
||||
shouldRun = false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// The was tested with the Grove UV Sensor module.
|
||||
// It has a sensing range from between 200-400nm. It's strongest
|
||||
// response is around 320-360nm.
|
||||
// This was tested with the Grove UV Sensor module.
|
||||
// It has a sensing range from between 240-370nm. It's strongest
|
||||
// response is around 320-360nm.
|
||||
|
||||
// Instantiate a GUVAS12D on analog pin A0
|
||||
upm::GUVAS12D *volts = new upm::GUVAS12D(0);
|
||||
|
||||
// The higher the voltage the more intense the UV radiation.
|
||||
// Instantiate a GUVAS12D on analog pin A0
|
||||
upm::GUVAS12D *volts = new upm::GUVAS12D(0);
|
||||
|
||||
while (shouldRun)
|
||||
// The higher the voltage the more intense the UV radiation.
|
||||
|
||||
while (shouldRun)
|
||||
{
|
||||
cout << "AREF: " << GUVAS12D_AREF
|
||||
<< ", Voltage value (higher means more UV): "
|
||||
<< volts->value(GUVAS12D_AREF, SAMPLES_PER_QUERY) << endl;
|
||||
|
||||
sleep(1);
|
||||
cout << "Volts: " << volts->volts()
|
||||
<< ", Intensity: " << volts->intensity()
|
||||
<< " mW/m^2"
|
||||
<< endl;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
delete volts;
|
||||
return 0;
|
||||
delete volts;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user