ppd42ns: C implementation; C++ wraps C

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson
2016-11-02 17:38:44 -06:00
parent 8f6442e9c7
commit 1f954a8cbf
13 changed files with 467 additions and 194 deletions

View File

@ -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;
}