mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 01:11:10 +03:00
ppd42ns: C implementation; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
@ -33,31 +33,34 @@ int shouldRun = true;
|
||||
|
||||
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]
|
||||
// Instantiate a dust sensor on GPIO pin D8
|
||||
upm::PPD42NS* dust = new upm::PPD42NS(8);
|
||||
upm::dustData data;
|
||||
cout << "This program will give readings every 30 seconds until you stop it" << endl;
|
||||
while (shouldRun)
|
||||
{
|
||||
data = dust->getData();
|
||||
cout << "Low pulse occupancy: " << data.lowPulseOccupancy << endl;
|
||||
cout << "Ratio: " << data.ratio << endl;
|
||||
cout << "Concentration: " << data.concentration << endl;
|
||||
}
|
||||
// Instantiate a dust sensor on GPIO pin D8
|
||||
upm::PPD42NS* dust = new upm::PPD42NS(8);
|
||||
ppd42ns_dust_data data;
|
||||
cout << "This program will give readings every 30 seconds until "
|
||||
<< "you stop it"
|
||||
<< endl;
|
||||
while (shouldRun)
|
||||
{
|
||||
data = dust->getData();
|
||||
cout << "Low pulse occupancy: " << data.lowPulseOccupancy << endl;
|
||||
cout << "Ratio: " << data.ratio << endl;
|
||||
cout << "Concentration: " << data.concentration << endl;
|
||||
cout << endl;
|
||||
}
|
||||
//! [Interesting]
|
||||
|
||||
cout << "Exiting" << endl;
|
||||
cout << "Exiting" << endl;
|
||||
|
||||
delete dust;
|
||||
return 0;
|
||||
delete dust;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user