mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
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:
parent
c0bff584d5
commit
668aa320b9
@ -31,46 +31,44 @@ bool 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]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a dfrph sensor on analog pin A0
|
||||
dfrph_context sensor = dfrph_init(0);
|
||||
// Instantiate a dfrph sensor on analog pin A0
|
||||
dfrph_context sensor = dfrph_init(0);
|
||||
|
||||
if (!sensor)
|
||||
if (!sensor)
|
||||
{
|
||||
printf("dfrph_init() failed.\n");
|
||||
return(1);
|
||||
printf("dfrph_init() failed.\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
// Every half a second, sample the URM37 and output the measured
|
||||
// distance in cm.
|
||||
|
||||
while (shouldRun)
|
||||
// Every half a second, sample the sensor output
|
||||
while (shouldRun)
|
||||
{
|
||||
float volts = 0.0, pH = 0.0;
|
||||
float volts = 0.0, pH = 0.0;
|
||||
|
||||
dfrph_get_raw_volts(sensor, &volts);
|
||||
dfrph_get_ph(sensor, &pH);
|
||||
dfrph_get_raw_volts(sensor, &volts);
|
||||
dfrph_get_ph(sensor, &pH);
|
||||
|
||||
printf("Detected volts: %0.03f\n", volts);
|
||||
printf("pH value: %0.03f\n", pH);
|
||||
printf("Detected volts: %0.03f\n", volts);
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user