2 * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
4 * This file is a modified version of BSD licensed file and
5 * licensed under the Flora License, Version 1.1 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * Please, see the LICENSE file for the original copyright owner and
21 #include <device/haptic.h>
23 #include "smart_notification.h"
25 static haptic_device_h handle;
26 static haptic_effect_h effect_handle;
28 #define RED "\x1B[31m"
29 #define RESET "\033[0m"
32 * @brief Initializer for haptic module
35 void haptic_module_init(void)
39 if(!device_haptic_get_count(&num))
41 DEBUG(RED"Haptic device received!"RESET);
45 ERROR("Cannot receive haptic device count");
49 if(!device_haptic_open(0, &handle))
51 DEBUG(RED"Device connected!"RESET);
55 ERROR("Cannot open haptic device");
60 * @brief Disconnect haptic handle
63 void haptic_module_disconnect(void)
67 ERROR("Haptic handle lost");
70 if(!device_haptic_close(handle))
72 DEBUG("Haptic disconnected");
76 ERROR("Haptic close error");
81 * @brief Start vibrations
84 void haptic_vibrate_start(void)
88 ERROR("Haptic handle lost");
91 if(!device_haptic_vibrate(handle, 1000, 100, &effect_handle))
93 DEBUG(RED"Vibrations started!"RESET);
97 ERROR("Cannot start vibration");
102 * @brief Stop vibrations
105 void haptic_vibrate_stop(void)
109 ERROR("Haptic handle lost");
112 if(!device_haptic_stop(handle, &effect_handle))
114 ERROR("Vibrations stopped!");
118 DEBUG(RED"Cannot stop vibration"RESET);