Rename Model as Resource 11/138511/1
authorJin Yoon <jinny.yoon@samsung.com>
Wed, 12 Jul 2017 10:26:03 +0000 (19:26 +0900)
committerJin Yoon <jinny.yoon@samsung.com>
Wed, 12 Jul 2017 10:26:03 +0000 (19:26 +0900)
Change-Id: Ie671b3e2bf00fdc45f230c1335b1edc40510bdd0

30 files changed:
CMakeLists.txt
inc/model.h [deleted file]
inc/model/model_illuminance_sensor.h [deleted file]
inc/model/model_infrared_motion_sensor.h [deleted file]
inc/model/model_infrared_obstacle_avoidance_sensor.h [deleted file]
inc/model/model_touch_sensor.h [deleted file]
inc/model/model_ultrasonic_sensor.h [deleted file]
inc/model_internal.h [deleted file]
inc/resource.h [new file with mode: 0644]
inc/resource/resource_illuminance_sensor.h [new file with mode: 0644]
inc/resource/resource_infrared_motion_sensor.h [new file with mode: 0644]
inc/resource/resource_infrared_obstacle_avoidance_sensor.h [new file with mode: 0644]
inc/resource/resource_touch_sensor.h [new file with mode: 0644]
inc/resource/resource_ultrasonic_sensor.h [new file with mode: 0644]
inc/resource_internal.h [new file with mode: 0644]
org.tizen.position-finder-server.manifest [changed mode: 0755->0644]
src/controller.c
src/main.c [deleted file]
src/model.c [deleted file]
src/model/model_illuminance_sensor.c [deleted file]
src/model/model_infrared_motion_sensor.c [deleted file]
src/model/model_infrared_obstacle_avoidance_sensor.c [deleted file]
src/model/model_touch_sensor.c [deleted file]
src/model/model_ultrasonic_sensor.c [deleted file]
src/resource.c [new file with mode: 0644]
src/resource/resource_illuminance_sensor.c [new file with mode: 0644]
src/resource/resource_infrared_motion_sensor.c [new file with mode: 0644]
src/resource/resource_infrared_obstacle_avoidance_sensor.c [new file with mode: 0644]
src/resource/resource_touch_sensor.c [new file with mode: 0644]
src/resource/resource_ultrasonic_sensor.c [new file with mode: 0644]

index 9953f4a1065639ebf181132f36698ec4ddcd5750..b1952ce12aaf96e930d79f268ab892e76a1ebbaa 100644 (file)
@@ -33,12 +33,12 @@ INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc)
 ADD_EXECUTABLE(${PROJECT_NAME}
        ${PROJECT_ROOT_DIR}/src/controller.c
        ${PROJECT_ROOT_DIR}/src/connectivity.c
-       ${PROJECT_ROOT_DIR}/src/model.c
-       ${PROJECT_ROOT_DIR}/src/model/model_illuminance_sensor.c
-       ${PROJECT_ROOT_DIR}/src/model/model_infrared_motion_sensor.c
-       ${PROJECT_ROOT_DIR}/src/model/model_infrared_obstacle_avoidance_sensor.c
-       ${PROJECT_ROOT_DIR}/src/model/model_touch_sensor.c
-       ${PROJECT_ROOT_DIR}/src/model/model_ultrasonic_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_illuminance_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_motion_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_infrared_obstacle_avoidance_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_touch_sensor.c
+       ${PROJECT_ROOT_DIR}/src/resource/resource_ultrasonic_sensor.c
 )
 #${PROJECT_ROOT_DIR}/src/connectivity.c
 
diff --git a/inc/model.h b/inc/model.h
deleted file mode 100644 (file)
index 6cf1869..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_MODEL_H__
-#define __POSITION_FINDER_MODEL_H__
-
-#include <peripheral_io.h>
-
-#include "model_internal.h"
-#include "model/model_illuminance_sensor.h"
-#include "model/model_infrared_motion_sensor.h"
-#include "model/model_infrared_obstacle_avoidance_sensor.h"
-#include "model/model_touch_sensor.h"
-#include "model/model_ultrasonic_sensor.h"
-
-#endif /* __POSITION_FINDER_MODEL_H__ */
diff --git a/inc/model/model_illuminance_sensor.h b/inc/model/model_illuminance_sensor.h
deleted file mode 100644 (file)
index 19eef2d..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__
-#define __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__
-
-/* You have to use this illuminance sensor ONLY ONE in the pi board */
-extern int model_read_illuminance_sensor(int i2c_bus, int *out_value);
-extern void model_close_illuminance_sensor(void);
-
-#endif /* __POSITION_FINDER_MODEL_ILLUMINANCE_SENSOR_H__ */
-
diff --git a/inc/model/model_infrared_motion_sensor.h b/inc/model/model_infrared_motion_sensor.h
deleted file mode 100644 (file)
index fabd14b..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__
-#define __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__
-
-extern void model_close_infrared_motion_sensor(int sensor_index);
-extern int model_read_infrared_motion_sensor(int pin_num, int *out_value);
-
-#endif /* __POSITION_FINDER_MODEL_INFRARED_MOTION_SENSOR_H__ */
diff --git a/inc/model/model_infrared_obstacle_avoidance_sensor.h b/inc/model/model_infrared_obstacle_avoidance_sensor.h
deleted file mode 100644 (file)
index 348ca90..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
-#define __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
-
-extern void model_close_infrared_obstacle_avoidance_sensor(int pin_num);
-extern int model_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value);
-
-#endif /* __POSITION_FINDER_MODEL_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
diff --git a/inc/model/model_touch_sensor.h b/inc/model/model_touch_sensor.h
deleted file mode 100644 (file)
index d3f9f53..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__
-#define __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__
-
-extern void model_close_touch_sensor(int pin_num);
-extern int model_read_touch_sensor(int pin_num, int *out_value);
-
-#endif /* __POSITION_FINDER_MODEL_TOUCH_SENSOR_H__ */
diff --git a/inc/model/model_ultrasonic_sensor.h b/inc/model/model_ultrasonic_sensor.h
deleted file mode 100644 (file)
index 401f37c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__
-#define __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__
-
-extern void model_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num);
-extern int model_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value);
-
-#endif /* __POSITION_FINDER_MODEL_ULTRASONIC_SENSOR_H__ */
diff --git a/inc/model_internal.h b/inc/model_internal.h
deleted file mode 100644 (file)
index ea73236..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __POSITION_FINDER_MODEL_INTERNAL_H__
-#define __POSITION_FINDER_MODEL_INTERNAL_H__
-
-#include <peripheral_io.h>
-
-#define PIN_MAX 40
-
-struct _model_s {
-       int opened;
-       peripheral_gpio_h sensor_h;
-};
-typedef struct _model_s model_s;
-
-extern model_s *model_get_info(int pin_num);
-
-#endif /* __POSITION_FINDER_MODEL_INTERNAL_H__ */
diff --git a/inc/resource.h b/inc/resource.h
new file mode 100644 (file)
index 0000000..89fc1c8
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_H__
+#define __POSITION_FINDER_RESOURCE_H__
+
+#include <peripheral_io.h>
+
+#include "resource_internal.h"
+#include "resource/resource_illuminance_sensor.h"
+#include "resource/resource_infrared_motion_sensor.h"
+#include "resource/resource_infrared_obstacle_avoidance_sensor.h"
+#include "resource/resource_touch_sensor.h"
+#include "resource/resource_ultrasonic_sensor.h"
+
+#endif /* __POSITION_FINDER_RESOURCE_H__ */
diff --git a/inc/resource/resource_illuminance_sensor.h b/inc/resource/resource_illuminance_sensor.h
new file mode 100644 (file)
index 0000000..e95198b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__
+
+/* You have to use this illuminance sensor ONLY ONE in the pi board */
+extern int resource_read_illuminance_sensor(int i2c_bus, int *out_value);
+extern void resource_close_illuminance_sensor(void);
+
+#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__ */
+
diff --git a/inc/resource/resource_infrared_motion_sensor.h b/inc/resource/resource_infrared_motion_sensor.h
new file mode 100644 (file)
index 0000000..fa99633
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
+
+extern void resource_close_infrared_motion_sensor(int sensor_index);
+extern int resource_read_infrared_motion_sensor(int pin_num, int *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__ */
diff --git a/inc/resource/resource_infrared_obstacle_avoidance_sensor.h b/inc/resource/resource_infrared_obstacle_avoidance_sensor.h
new file mode 100644 (file)
index 0000000..3e6f420
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
+
+extern void resource_close_infrared_obstacle_avoidance_sensor(int pin_num);
+extern int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
diff --git a/inc/resource/resource_touch_sensor.h b/inc/resource/resource_touch_sensor.h
new file mode 100644 (file)
index 0000000..e209a80
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
+
+extern void resource_close_touch_sensor(int pin_num);
+extern int resource_read_touch_sensor(int pin_num, int *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__ */
diff --git a/inc/resource/resource_ultrasonic_sensor.h b/inc/resource/resource_ultrasonic_sensor.h
new file mode 100644 (file)
index 0000000..29fdd00
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
+#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
+
+extern void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num);
+extern int resource_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value);
+
+#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__ */
diff --git a/inc/resource_internal.h b/inc/resource_internal.h
new file mode 100644 (file)
index 0000000..1844db6
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __POSITION_FINDER_RESOURCE_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_INTERNAL_H__
+
+#include <peripheral_io.h>
+
+#define PIN_MAX 40
+
+struct _resource_s {
+       int opened;
+       peripheral_gpio_h sensor_h;
+};
+typedef struct _resource_s resource_s;
+
+extern resource_s *resource_get_info(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_INTERNAL_H__ */
old mode 100755 (executable)
new mode 100644 (file)
index 27c3015bc6644cbe1f17674ac3a64661b0ba12b5..69a040e52e2ded69bad1f1a75a6b0954633c78f8 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "log.h"
 #include "controller.h"
-#include "model.h"
+#include "resource.h"
 
 #define I2C_BUS_1 0x1
 #define GPIO_NOT_USED -1
@@ -45,7 +45,7 @@ static Eina_Bool _infrared_motion_getter_timer(void *data)
 {
        int value = 0;
 
-       retv_if(model_read_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+       retv_if(resource_read_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
        _I("Infrared Motion Value is [%d]", value);
 
        return ECORE_CALLBACK_RENEW;
@@ -55,7 +55,7 @@ static Eina_Bool _ultrasonic_getter_timer(void *data)
 {
        double value = 0;
 
-       retv_if(model_read_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+       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);
 
        return ECORE_CALLBACK_RENEW;
@@ -65,7 +65,7 @@ static Eina_Bool _illuminance_getter_timer(void *data)
 {
        int value = 0;
 
-       retv_if(model_read_illuminance_sensor(I2C_BUS_1, &value) == -1, ECORE_CALLBACK_CANCEL);
+       retv_if(resource_read_illuminance_sensor(I2C_BUS_1, &value) == -1, ECORE_CALLBACK_CANCEL);
        _I("Ultra Sonic Distance is [%d lux]", value);
 
        return ECORE_CALLBACK_RENEW;
@@ -108,9 +108,9 @@ static void service_app_terminate(void *data)
                        ecore_timer_del(ad->getter_timer[i]);
                }
        }
-       model_close_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1);
-       model_close_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1);
-       model_close_illuminance_sensor();
+       resource_close_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1);
+       resource_close_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1);
+       resource_close_illuminance_sensor();
        free(ad);
 }
 
diff --git a/src/main.c b/src/main.c
deleted file mode 100644 (file)
index 1da7c7d..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <tizen.h>
-#include <Ecore.h>
-#include <service_app.h>
-#include <unistd.h>
-#include <glib.h>
-
-#include "log.h"
-#include "model.h"
-
-typedef struct app_data_s {
-       Ecore_Timer *getter_timer;
-       void *event;
-} app_data;
-
-static Eina_Bool _getter_timer(void *data)
-{
-#if 0
-       int value = 0;
-       retv_if(model_read_int_value(&value) == -1, ECORE_CALLBACK_CANCEL);
-       _I("Value is [%d]", value);
-#else
-       double value = 0.0;
-       retv_if(model_read_double_value(&value) == -1, ECORE_CALLBACK_RENEW);
-       _I("Value is [%f]", value);
-#endif
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-static bool service_app_create(void *data)
-{
-       app_data *ad = (app_data *)data;
-
-       retv_if(model_init(SENSOR_TYPE_ULTRASONIC) == -1, false);
-
-       ad->getter_timer = ecore_timer_add(3.0, _getter_timer, NULL);
-       if (!ad->getter_timer) {
-               _D("Failed to add getter timer");
-               return false;
-       }
-
-    return true;
-}
-
-static void service_app_terminate(void *data)
-{
-       app_data *ad = (app_data *)data;
-       ecore_timer_del(ad->getter_timer);
-       model_fini();
-       free(ad);
-}
-
-static void service_app_control(app_control_h app_control, void *data)
-{
-    // Todo: add your code here.
-}
-
-static void service_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LANGUAGE_CHANGED*/
-}
-
-static void service_app_region_changed(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void service_app_low_battery(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void service_app_low_memory(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LOW_MEMORY*/
-}
-
-int main(int argc, char* argv[])
-{
-       app_data *ad = NULL;
-       int ret = 0;
-       service_app_lifecycle_callback_s event_callback;
-       app_event_handler_h handlers[5] = {NULL, };
-
-       ad = (app_data *)calloc(1, sizeof(app_data));
-
-       event_callback.create = service_app_create;
-       event_callback.terminate = service_app_terminate;
-       event_callback.app_control = service_app_control;
-
-       service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
-
-       ret = service_app_main(argc, argv, &event_callback, ad);
-
-       return ret;
-}
diff --git a/src/model.c b/src/model.c
deleted file mode 100644 (file)
index f9298a7..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <peripheral_io.h>
-#include "model.h"
-
-static model_s model_info[PIN_MAX] = { 0, };
-
-model_s *model_get_info(int pin_num)
-{
-       return &model_info[pin_num];
-}
diff --git a/src/model/model_illuminance_sensor.c b/src/model/model_illuminance_sensor.c
deleted file mode 100644 (file)
index 9a0f381..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "model_internal.h"
-
-#define I2C_PIN_MAX 28
-/* I2C */
-#define GY30_ADDR 0x23 /* Address of GY30 light sensor */
-#define GY30_CONT_HIGH_RES_MODE 0x10 /* Start measurement at 11x resolution. Measurement time is approx 120mx */
-#define GY30_CONSTANT_NUM (1.2)
-
-static struct {
-       int opened;
-       peripheral_i2c_h sensor_h;
-} model_sensor_s;
-
-void model_close_illuminance_sensor(void)
-{
-       ret_if(!model_sensor_s.opened);
-
-       _I("Infrared Motion Sensor is finishing...");
-       peripheral_i2c_close(model_sensor_s.sensor_h);
-       model_sensor_s.opened = 0;
-}
-
-/* You have to use this illuminance sensor ONLY ONE in the pi board */
-int model_read_illuminance_sensor(int i2c_bus, int *out_value)
-{
-       int ret = PERIPHERAL_ERROR_NONE;
-       unsigned char buf[10] = { 0, };
-
-       if (!model_sensor_s.opened) {
-               ret = peripheral_i2c_open(i2c_bus, GY30_ADDR, &model_sensor_s.sensor_h);
-               retv_if(!model_sensor_s.sensor_h, -1);
-               model_sensor_s.opened = 1;
-       }
-
-       ret = peripheral_i2c_write_byte(model_sensor_s.sensor_h, GY30_CONT_HIGH_RES_MODE);
-       retv_if(ret < 0, -1);
-
-       ret = peripheral_i2c_read(model_sensor_s.sensor_h, buf, 2);
-       retv_if(ret < 0, -1);
-
-       *out_value = (buf[0] << 8 | buf[1]) / GY30_CONSTANT_NUM; // Just Sum High 8bit and Low 8bit
-
-       _I("Infrared Motion Sensor Value : %d", *out_value);
-
-       return 0;
-}
diff --git a/src/model/model_infrared_motion_sensor.c b/src/model/model_infrared_motion_sensor.c
deleted file mode 100644 (file)
index f606b8a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "model_internal.h"
-
-void model_close_infrared_motion_sensor(int pin_num)
-{
-       ret_if(!model_get_info(pin_num)->opened);
-
-       _I("Infrared Motion Sensor is finishing...");
-       model_get_info(pin_num)->opened = 0;
-}
-
-int model_read_infrared_motion_sensor(int pin_num, int *out_value)
-{
-       int ret = PERIPHERAL_ERROR_NONE;
-
-       if (!model_get_info(pin_num)->opened) {
-               ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
-               retv_if(!model_get_info(pin_num)->sensor_h, -1);
-
-               ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
-               retv_if(ret != 0, -1);
-
-               model_get_info(pin_num)->opened = 1;
-       }
-
-       ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, out_value);
-       retv_if(ret < 0, -1);
-
-       _I("Infrared Motion Sensor Value : %d", *out_value);
-
-       return 0;
-}
diff --git a/src/model/model_infrared_obstacle_avoidance_sensor.c b/src/model/model_infrared_obstacle_avoidance_sensor.c
deleted file mode 100644 (file)
index a63ab6a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "model_internal.h"
-
-void model_close_infrared_obstacle_avoidance_sensor(int pin_num)
-{
-       ret_if(!model_get_info(pin_num)->opened);
-
-       _I("Infrared Obstacle Avoidance Sensor is finishing...");
-       peripheral_gpio_close(model_get_info(pin_num)->sensor_h);
-       model_get_info(pin_num)->opened = 0;
-}
-
-int model_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value)
-{
-       int ret = PERIPHERAL_ERROR_NONE;
-
-       if (!model_get_info(pin_num)->opened) {
-               ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
-               retv_if(!model_get_info(pin_num)->sensor_h, -1);
-
-               ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
-               retv_if(ret != 0, -1);
-
-               model_get_info(pin_num)->opened = 1;
-       }
-
-       ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, out_value);
-       retv_if(ret < 0, -1);
-
-       _I("Infrared Obstacle Avoidance Sensor Value : %d", *out_value);
-
-       return 0;
-}
diff --git a/src/model/model_touch_sensor.c b/src/model/model_touch_sensor.c
deleted file mode 100644 (file)
index ba472c5..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "model_internal.h"
-
-void model_close_touch_sensor(int pin_num)
-{
-       ret_if(!model_get_info(pin_num)->opened);
-
-       _I("Touch Sensor is finishing...");
-       peripheral_gpio_close(model_get_info(pin_num)->sensor_h);
-       model_get_info(pin_num)->opened = 0;
-}
-
-int model_read_touch_sensor(int pin_num, int *out_value)
-{
-       int ret = PERIPHERAL_ERROR_NONE;
-
-       if (!model_get_info(pin_num)->opened) {
-               _I("Touch sensor is initializing...");
-
-               ret = peripheral_gpio_open(pin_num, &model_get_info(pin_num)->sensor_h);
-               retv_if(!model_get_info(pin_num)->sensor_h, -1);
-
-               ret = peripheral_gpio_set_direction(model_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
-               retv_if(ret != 0, -1);
-
-               model_get_info(pin_num)->opened = 1;
-       }
-
-       ret = peripheral_gpio_read(model_get_info(pin_num)->sensor_h, out_value);
-       retv_if(ret < 0, -1);
-
-       _I("Touch Sensor Value : %d", *out_value);
-
-       return 0;
-}
diff --git a/src/model/model_ultrasonic_sensor.c b/src/model/model_ultrasonic_sensor.c
deleted file mode 100644 (file)
index 0d2ae75..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- *          Geunsun Lee <gs86.lee@samsung.com>
- *          Eunyoung Lee <ey928.lee@samsung.com>
- *          Junkyu Han <junkyu.han@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <peripheral_io.h>
-#include <sys/time.h>
-
-#include "log.h"
-#include "model_internal.h"
-
-void model_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num)
-{
-       ret_if(!model_get_info(echo_pin_num)->opened);
-       ret_if(!model_get_info(trig_pin_num)->opened);
-
-       _I("Ultrasonic sensor is finishing...");
-
-       peripheral_gpio_close(model_get_info(echo_pin_num)->sensor_h);
-       peripheral_gpio_close(model_get_info(trig_pin_num)->sensor_h);
-
-       model_get_info(echo_pin_num)->opened = 0;
-       model_get_info(trig_pin_num)->opened = 0;
-}
-
-static int _get_echo_value(int echo_pin_num)
-{
-       int ret = 0;
-       int value = 0;
-
-       ret = peripheral_gpio_read(model_get_info(echo_pin_num)->sensor_h, &value);
-       retv_if(ret < 0, -1);
-
-       return value;
-}
-
-int model_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value)
-{
-       int ret = 0;
-       double duration = 0.0;
-       struct timeval start_time, end_time, temp_start_time, temp_end_time;
-
-       if (!model_get_info(echo_pin_num)->opened) {
-               _I("Ultrasonic sensor is initializing...");
-
-               ret = peripheral_gpio_open(echo_pin_num, &model_get_info(echo_pin_num)->sensor_h);
-               retv_if(!model_get_info(echo_pin_num)->sensor_h, -1);
-
-               ret = peripheral_gpio_set_direction(model_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
-               retv_if(ret != 0, -1);
-
-               model_get_info(echo_pin_num)->opened = 1;
-       }
-
-       if (!model_get_info(trig_pin_num)->opened) {
-               _I("Ultrasonic sensor is initializing...");
-
-               ret = peripheral_gpio_open(trig_pin_num, &model_get_info(trig_pin_num)->sensor_h);
-               retv_if(!model_get_info(trig_pin_num)->sensor_h, -1);
-
-               ret = peripheral_gpio_set_direction(model_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
-               retv_if(ret != 0, -1);
-
-               model_get_info(trig_pin_num)->opened = 1;
-       }
-
-       ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 0);
-       retv_if(ret < 0, -1);
-
-       sleep(1);
-
-       ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 1);
-       retv_if(ret < 0, -1);
-
-       usleep(10);
-
-       ret = peripheral_gpio_write(model_get_info(trig_pin_num)->sensor_h, 0);
-       retv_if(ret < 0, -1);
-
-       _D("Count the distance");
-       gettimeofday(&temp_start_time, NULL);
-
-       while (_get_echo_value(echo_pin_num) == 0) {
-               gettimeofday(&temp_end_time, NULL);
-               duration = (double)temp_end_time.tv_sec + (double)(temp_end_time.tv_usec / 1000000.0)
-                       - (double)temp_start_time.tv_sec - (double)(temp_start_time.tv_usec / 1000000.0);
-               if (duration > 1.0f) {
-                       _E("Cannot get the echo value.");
-                       return -1;
-               }
-       }
-       gettimeofday(&start_time, NULL);
-
-       _D("After checking #1");
-
-       while (_get_echo_value(echo_pin_num) == 1);
-       gettimeofday(&end_time, NULL);
-
-       _D("After checking #2");
-
-       duration = (double)end_time.tv_sec + (double)(end_time.tv_usec / 1000000.0)
-               - (double)start_time.tv_sec - (double)(start_time.tv_usec / 1000000.0);
-       *out_value = duration / 2 * 340.0;
-
-       _I("Ultrasonic Sensor Value : %f", *out_value);
-
-       return 0;
-}
diff --git a/src/resource.c b/src/resource.c
new file mode 100644 (file)
index 0000000..7d49961
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <peripheral_io.h>
+#include "resource.h"
+
+static resource_s resource_info[PIN_MAX] = { 0, };
+
+resource_s *resource_get_info(int pin_num)
+{
+       return &resource_info[pin_num];
+}
diff --git a/src/resource/resource_illuminance_sensor.c b/src/resource/resource_illuminance_sensor.c
new file mode 100644 (file)
index 0000000..e5b5dda
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+#define I2C_PIN_MAX 28
+/* I2C */
+#define GY30_ADDR 0x23 /* Address of GY30 light sensor */
+#define GY30_CONT_HIGH_RES_MODE 0x10 /* Start measurement at 11x resolution. Measurement time is approx 120mx */
+#define GY30_CONSTANT_NUM (1.2)
+
+static struct {
+       int opened;
+       peripheral_i2c_h sensor_h;
+} resource_sensor_s;
+
+void resource_close_illuminance_sensor(void)
+{
+       ret_if(!resource_sensor_s.opened);
+
+       _I("Infrared Motion Sensor is finishing...");
+       peripheral_i2c_close(resource_sensor_s.sensor_h);
+       resource_sensor_s.opened = 0;
+}
+
+/* You have to use this illuminance sensor ONLY ONE in the pi board */
+int resource_read_illuminance_sensor(int i2c_bus, int *out_value)
+{
+       int ret = PERIPHERAL_ERROR_NONE;
+       unsigned char buf[10] = { 0, };
+
+       if (!resource_sensor_s.opened) {
+               ret = peripheral_i2c_open(i2c_bus, GY30_ADDR, &resource_sensor_s.sensor_h);
+               retv_if(!resource_sensor_s.sensor_h, -1);
+               resource_sensor_s.opened = 1;
+       }
+
+       ret = peripheral_i2c_write_byte(resource_sensor_s.sensor_h, GY30_CONT_HIGH_RES_MODE);
+       retv_if(ret < 0, -1);
+
+       ret = peripheral_i2c_read(resource_sensor_s.sensor_h, buf, 2);
+       retv_if(ret < 0, -1);
+
+       *out_value = (buf[0] << 8 | buf[1]) / GY30_CONSTANT_NUM; // Just Sum High 8bit and Low 8bit
+
+       _I("Infrared Motion Sensor Value : %d", *out_value);
+
+       return 0;
+}
diff --git a/src/resource/resource_infrared_motion_sensor.c b/src/resource/resource_infrared_motion_sensor.c
new file mode 100644 (file)
index 0000000..d8e86e3
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_infrared_motion_sensor(int pin_num)
+{
+       ret_if(!resource_get_info(pin_num)->opened);
+
+       _I("Infrared Motion Sensor is finishing...");
+       resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_infrared_motion_sensor(int pin_num, int *out_value)
+{
+       int ret = PERIPHERAL_ERROR_NONE;
+
+       if (!resource_get_info(pin_num)->opened) {
+               ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+               retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+               ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               retv_if(ret != 0, -1);
+
+               resource_get_info(pin_num)->opened = 1;
+       }
+
+       ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+       retv_if(ret < 0, -1);
+
+       _I("Infrared Motion Sensor Value : %d", *out_value);
+
+       return 0;
+}
diff --git a/src/resource/resource_infrared_obstacle_avoidance_sensor.c b/src/resource/resource_infrared_obstacle_avoidance_sensor.c
new file mode 100644 (file)
index 0000000..f95d4ed
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_infrared_obstacle_avoidance_sensor(int pin_num)
+{
+       ret_if(!resource_get_info(pin_num)->opened);
+
+       _I("Infrared Obstacle Avoidance Sensor is finishing...");
+       peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+       resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value)
+{
+       int ret = PERIPHERAL_ERROR_NONE;
+
+       if (!resource_get_info(pin_num)->opened) {
+               ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+               retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+               ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               retv_if(ret != 0, -1);
+
+               resource_get_info(pin_num)->opened = 1;
+       }
+
+       ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+       retv_if(ret < 0, -1);
+
+       _I("Infrared Obstacle Avoidance Sensor Value : %d", *out_value);
+
+       return 0;
+}
diff --git a/src/resource/resource_touch_sensor.c b/src/resource/resource_touch_sensor.c
new file mode 100644 (file)
index 0000000..a8ba4ba
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_touch_sensor(int pin_num)
+{
+       ret_if(!resource_get_info(pin_num)->opened);
+
+       _I("Touch Sensor is finishing...");
+       peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
+       resource_get_info(pin_num)->opened = 0;
+}
+
+int resource_read_touch_sensor(int pin_num, int *out_value)
+{
+       int ret = PERIPHERAL_ERROR_NONE;
+
+       if (!resource_get_info(pin_num)->opened) {
+               _I("Touch sensor is initializing...");
+
+               ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
+               retv_if(!resource_get_info(pin_num)->sensor_h, -1);
+
+               ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               retv_if(ret != 0, -1);
+
+               resource_get_info(pin_num)->opened = 1;
+       }
+
+       ret = peripheral_gpio_read(resource_get_info(pin_num)->sensor_h, out_value);
+       retv_if(ret < 0, -1);
+
+       _I("Touch Sensor Value : %d", *out_value);
+
+       return 0;
+}
diff --git a/src/resource/resource_ultrasonic_sensor.c b/src/resource/resource_ultrasonic_sensor.c
new file mode 100644 (file)
index 0000000..c397920
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Geunsun Lee <gs86.lee@samsung.com>
+ *          Eunyoung Lee <ey928.lee@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <peripheral_io.h>
+#include <sys/time.h>
+
+#include "log.h"
+#include "resource_internal.h"
+
+void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num)
+{
+       ret_if(!resource_get_info(echo_pin_num)->opened);
+       ret_if(!resource_get_info(trig_pin_num)->opened);
+
+       _I("Ultrasonic sensor is finishing...");
+
+       peripheral_gpio_close(resource_get_info(echo_pin_num)->sensor_h);
+       peripheral_gpio_close(resource_get_info(trig_pin_num)->sensor_h);
+
+       resource_get_info(echo_pin_num)->opened = 0;
+       resource_get_info(trig_pin_num)->opened = 0;
+}
+
+static int _get_echo_value(int echo_pin_num)
+{
+       int ret = 0;
+       int value = 0;
+
+       ret = peripheral_gpio_read(resource_get_info(echo_pin_num)->sensor_h, &value);
+       retv_if(ret < 0, -1);
+
+       return value;
+}
+
+int resource_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value)
+{
+       int ret = 0;
+       double duration = 0.0;
+       struct timeval start_time, end_time, temp_start_time, temp_end_time;
+
+       if (!resource_get_info(echo_pin_num)->opened) {
+               _I("Ultrasonic sensor is initializing...");
+
+               ret = peripheral_gpio_open(echo_pin_num, &resource_get_info(echo_pin_num)->sensor_h);
+               retv_if(!resource_get_info(echo_pin_num)->sensor_h, -1);
+
+               ret = peripheral_gpio_set_direction(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               retv_if(ret != 0, -1);
+
+               resource_get_info(echo_pin_num)->opened = 1;
+       }
+
+       if (!resource_get_info(trig_pin_num)->opened) {
+               _I("Ultrasonic sensor is initializing...");
+
+               ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h);
+               retv_if(!resource_get_info(trig_pin_num)->sensor_h, -1);
+
+               ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_IN);
+               retv_if(ret != 0, -1);
+
+               resource_get_info(trig_pin_num)->opened = 1;
+       }
+
+       ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
+       retv_if(ret < 0, -1);
+
+       sleep(1);
+
+       ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 1);
+       retv_if(ret < 0, -1);
+
+       usleep(10);
+
+       ret = peripheral_gpio_write(resource_get_info(trig_pin_num)->sensor_h, 0);
+       retv_if(ret < 0, -1);
+
+       _D("Count the distance");
+       gettimeofday(&temp_start_time, NULL);
+
+       while (_get_echo_value(echo_pin_num) == 0) {
+               gettimeofday(&temp_end_time, NULL);
+               duration = (double)temp_end_time.tv_sec + (double)(temp_end_time.tv_usec / 1000000.0)
+                       - (double)temp_start_time.tv_sec - (double)(temp_start_time.tv_usec / 1000000.0);
+               if (duration > 1.0f) {
+                       _E("Cannot get the echo value.");
+                       return -1;
+               }
+       }
+       gettimeofday(&start_time, NULL);
+
+       _D("After checking #1");
+
+       while (_get_echo_value(echo_pin_num) == 1);
+       gettimeofday(&end_time, NULL);
+
+       _D("After checking #2");
+
+       duration = (double)end_time.tv_sec + (double)(end_time.tv_usec / 1000000.0)
+               - (double)start_time.tv_sec - (double)(start_time.tv_usec / 1000000.0);
+       *out_value = duration / 2 * 340.0;
+
+       _I("Ultrasonic Sensor Value : %f", *out_value);
+
+       return 0;
+}