dfrph_c_example: Fixed small copy/paste error

Removed urm37 string.  Re-aligned source.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2016-09-01 14:54:13 -07:00
parent c0bff584d5
commit 668aa320b9

View File

@ -31,46 +31,44 @@ bool shouldRun = true;
void sig_handler(int signo) void sig_handler(int signo)
{ {
if (signo == SIGINT) if (signo == SIGINT)
shouldRun = false; shouldRun = false;
} }
int main() int main()
{ {
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
//! [Interesting] //! [Interesting]
// Instantiate a dfrph sensor on analog pin A0 // Instantiate a dfrph sensor on analog pin A0
dfrph_context sensor = dfrph_init(0); dfrph_context sensor = dfrph_init(0);
if (!sensor) if (!sensor)
{ {
printf("dfrph_init() failed.\n"); printf("dfrph_init() failed.\n");
return(1); return(1);
} }
// Every half a second, sample the URM37 and output the measured // Every half a second, sample the sensor output
// distance in cm. while (shouldRun)
while (shouldRun)
{ {
float volts = 0.0, pH = 0.0; float volts = 0.0, pH = 0.0;
dfrph_get_raw_volts(sensor, &volts); dfrph_get_raw_volts(sensor, &volts);
dfrph_get_ph(sensor, &pH); dfrph_get_ph(sensor, &pH);
printf("Detected volts: %0.03f\n", volts); printf("Detected volts: %0.03f\n", volts);
printf("pH value: %0.03f\n", pH); printf("pH value: %0.03f\n", pH);
usleep(500000); usleep(500000);
} }
//! [Interesting] //! [Interesting]
printf("Exiting\n"); printf("Exiting\n");
dfrph_close(sensor); dfrph_close(sensor);
return 0; return 0;
} }