From 5782ff3c7f400a0dba54c8fa2ac857d5d768674f Mon Sep 17 00:00:00 2001 From: Eunyoung Lee Date: Fri, 21 Jul 2017 17:41:39 +0900 Subject: Changed the method of reading the sensor value from the ultrasonic sensor Change-Id: I2ca69857c66db8c2b3ae3bbd2867cc33734d59c0 --- src/controller.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/controller.c') diff --git a/src/controller.c b/src/controller.c index 886f712..cee20d9 100644 --- a/src/controller.c +++ b/src/controller.c @@ -39,7 +39,7 @@ #define GPIO_ULTRASONIC_ECHO_NUM_1 21 #define GPIO_INFRARED_MOTION_NUM_1 4 #define I2C_ILLUMINANCE_FIRST_PIN_1 3 -#define USE_MULTIPLE_SENSOR 1 +#define USE_MULTIPLE_SENSOR 0 #define MULTIPLE_SENSOR_NUMBER 5 static void _start_internal_function(void); @@ -81,12 +81,16 @@ static Eina_Bool _infrared_motion_getter_timer(void *data) } #if (!USE_MULTIPLE_SENSOR) +static void ultrasonic_sensor_read_cb(double value, void *data) +{ + _I("Distance : %.2fcm", value); +} + static Eina_Bool _ultrasonic_getter_timer(void *data) { double value = 0; - retv_if(resource_read_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL); - _I("Ultra Sonic Distance is [%d cm]", value); + retv_if(resource_read_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1, ultrasonic_sensor_read_cb, NULL) == -1, ECORE_CALLBACK_CANCEL); return ECORE_CALLBACK_RENEW; } -- cgit v1.2.3